Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions create-lx-image
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ IUUID=${IMAGE_NAME}-$BUILD_DATE
filetype=$({ LC_ALL=C file $TARBALL | awk '{print $2}' ; } 2>/dev/null)

if [[ "$filetype" = "gzip" ]]; then
gtaropts="-xz"
gtaropts="z"
elif [[ "$filetype" = "bzip2" ]]; then
gtaropts="-xj"
gtaropts="j"
elif [[ "$filetype" = "compressed" ]]; then
gtaropts="-xZ"
gtaropts="Z"
elif [[ "$filetype" = "USTAR" ]]; then
gtaropts="-x"
gtaropts=""
else
printf "==> ERROR: must be a gzip, bzip2, .Z or uncompressed tar archive"
exit 1
Expand Down Expand Up @@ -164,8 +164,7 @@ create_dataset() {

install_tar() {
echo "==> Installing the tar archive, this will take a few minutes..."
( cd "$zroot" && gtar --strip-components=2 "$gtaropts" "$TARBALL" )
if [[ "$?" -ne "0" ]] ; then
if ! ( cd "$zroot" && gtar --strip-components="$(tar tzf $TARBALL | grep '/root/' | awk -F"/" '{print NF-2}')" "-x$gtaropts" "$TARBALL" ); then
echo "==> Error: extraction from tar archive failed."
zfs destroy -r zones/$IUUID
fi
Expand Down
8 changes: 6 additions & 2 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ ln -s ../bin/busybox init
popd

echo "==> Making /usr/bin/su symlink relative"
rm $INSTALL_DIR/usr/bin/su
[ -e $INSTALL_DIR/usr/bin/su ] && rm $INSTALL_DIR/usr/bin/su
pushd $PWD
cd $INSTALL_DIR/usr/bin/
ln -s ../../bin/bbsuid ./su
Expand Down Expand Up @@ -286,7 +286,11 @@ echo "====> Running ./install.sh -i $INSTALL_DIR"
)

echo "==> Saving installation as $TARGET. This may take a few minutes."
tar czf $TARGET --exclude-from=exclude.txt $INSTALL_DIR/
umount $INSTALL_DIR/proc
umount $INSTALL_DIR/sys
ESCAPED_INSTALL_DIR="$(echo "$INSTALL_DIR/" | sed -e 's/\//\\\//g')"
EXCLUDE="$(sed -e s/^/--exclude=$ESCAPED_INSTALL_DIR/g exclude.txt | sed -e 's/exclude=\//exclude=/g' | tr '\n' ' '))"
tar czf $TARGET $EXCLUDE $INSTALL_DIR/

echo "==> Installation complete!"
echo "==> $TARGET"
Expand Down