Browse Source

mkplatformfs.sh: add option to disable compression

Urs Schulz 7 năm trước cách đây
mục cha
commit
d3505ba860
1 tập tin đã thay đổi với 24 bổ sung15 xóa
  1. 24 15
      mkplatformfs.sh.in

+ 24 - 15
mkplatformfs.sh.in

@@ -61,6 +61,7 @@ Options
     -C <file>   Full path to the XBPS configuration file
     -r <repo>   Set XBPS repository (may be set multiple times)
     -x <num>    Use <num> threads to compress the image (dynamic if unset)
+    -n          Do not compress the image, instead print out the rootfs directory
     -h          Show this help
     -V          Show version
 _EOF
@@ -71,8 +72,9 @@ _EOF
 # ########################################
 
 BASEPKG=base-system
+COMPRESSION="y"
 
-while getopts "b:p:k:c:C:r:x:hV" opt; do
+while getopts "b:p:k:c:C:r:x:nhV" opt; do
     case $opt in
         b) BASEPKG="$OPTARG" ;;
         p) EXTRA_PKGS="$OPTARG" ;;
@@ -81,6 +83,7 @@ while getopts "b:p:k:c:C:r:x:hV" opt; do
         C) XBPS_CONFFILE="-C $OPTARG" ;;
         r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG" ;;
         x) COMPRESSOR_THREADS="$OPTARG" ;;
+        n) COMPRESSION="n" ;;
         h) usage; exit 0 ;;
         V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;;
     esac
@@ -207,17 +210,23 @@ cleanup_chroot
 # only for it to be out of date, we remove it now.
 rm -rf "$ROOTFS/var/cache/*" 2>/dev/null
 
-# Finally we can compress the tarball, the name will include the
-# platform and the date on which the tarball was built.
-tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz
-run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball "
-
-# Now that we have the tarball we don't need the rootfs anymore, so we
-# can get rid of it.
-rm -rf "$ROOTFS"
-
-# Last thing to do before closing out is to let the user know that
-# this succeeded.  This also ensures that there's something visible
-# that the user can look for at the end of the script, which can make
-# it easier to see what's going on if something above failed.
-info_msg "Successfully created $tarball ($PLATFORM)"
+# Compress the tarball or just print out the path?
+if [ "$COMPRESSION" = "y" ]; then
+    # Finally we can compress the tarball, the name will include the
+    # platform and the date on which the tarball was built.
+    tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz
+    run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball "
+
+    # Now that we have the tarball we don't need the rootfs anymore, so we
+    # can get rid of it.
+    rm -rf "$ROOTFS"
+
+    # Last thing to do before closing out is to let the user know that
+    # this succeeded.  This also ensures that there's something visible
+    # that the user can look for at the end of the script, which can make
+    # it easier to see what's going on if something above failed.
+    info_msg "Successfully created $tarball ($PLATFORM)"
+else
+    # User requested just printing out the path to the rootfs, here it comes.
+    info_msg "Successfully created rootfs under $ROOTFS"
+fi