All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 02/16] Get rid of unneeded dirname calls.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-08-14 19:23   ` Victor Lowther
       [not found]     ` <0e55145f49bde182dc7efec5fa8965f31dc5234e.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2010-08-14 19:23   ` [PATCH 05/16] Shorten permission checking to ensure we can actually write our initramfs Victor Lowther
                     ` (15 subsequent siblings)
  16 siblings, 1 reply; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Use parameter expansion instead.

---
 dracut |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dracut b/dracut
index a50e14a..541bfc0 100755
--- a/dracut
+++ b/dracut
@@ -127,7 +127,7 @@ export PATH
 
 [[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
 
-[[ $allowlocal && -f "$(readlink -f $(dirname $0))/dracut-functions" ]] && dracutbasedir="$(dirname $0)" 
+[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && dracutbasedir="${0%/*}" 
 
 # if we were not passed a config file, try the default one
 if [[ ! -f $conffile ]]; then
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 04/16] Bashify the code that actually sources out config files.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 03/16] Clean up some conditional checking when trying to find our config files Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 08/16] Add support for bzip2 and xz compressed initramfs images Victor Lowther
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Just some trivial bashification.

---
 dracut |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dracut b/dracut
index a653981..33d802a 100755
--- a/dracut
+++ b/dracut
@@ -144,9 +144,9 @@ fi
 [[ -f $conffile ]] && . "$conffile"
 
 # source our config dir
-if [ "$confdir" ] && [  -d "$confdir" ]; then
+if [[ $confdir && -d $confdir ]]; then
     for f in "$confdir"/*.conf; do 
-	[ -e "$f" ] && . "$f"
+	[[ -e $f ]] && . "$f"
     done
 fi
 
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 03/16] Clean up some conditional checking when trying to find our config files.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2010-08-14 19:23   ` [PATCH 02/16] Get rid of unneeded dirname calls Victor Lowther
  2010-08-14 19:23   ` [PATCH 05/16] Shorten permission checking to ensure we can actually write our initramfs Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
       [not found]     ` <ef5afb56d5b0073885e92a7fbe0bd79dfe84fb77.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2010-08-14 19:23   ` [PATCH 04/16] Bashify the code that actually sources out " Victor Lowther
                     ` (13 subsequent siblings)
  16 siblings, 1 reply; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

No point in checking the same condition twice when compound commands will do.

---
 dracut |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dracut b/dracut
index 541bfc0..a653981 100755
--- a/dracut
+++ b/dracut
@@ -131,13 +131,13 @@ export PATH
 
 # if we were not passed a config file, try the default one
 if [[ ! -f $conffile ]]; then
-    [[ $allowlocal ]] || conffile="/etc/dracut.conf"
-    [[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf"
+    [[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf" || \
+        conffile="/etc/dracut.conf"
 fi
 
 if [[ ! -d $confdir ]]; then
-    [[ $allowlocal ]] || confdir="/etc/dracut.conf.d"
-    [[ $allowlocal ]] && confdir="$dracutbasedir/dracut.conf.d"
+    [[ $allowlocal ]] && confdir="$dracutbasedir/dracut.conf.d" \
+        confdir="/etc/dracut.conf.d"
 fi
 
 # source our config file
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 01/16] Trivial cleanups in dracut-functions
@ 2010-08-14 19:23 Victor Lowther
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

This is a patch series I have been playing with for awhile.

It cleans up some of the dracut code and adds a PKGBUILD file to make
it easier to use in Arch Linux.

---
 dracut-functions |   57 +++++++++++++++++++----------------------------------
 1 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index 56ebd88..f2b7ffb 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -168,7 +168,7 @@ check_block_and_slaves() {
     [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
     "$1" $2 && return
     check_vol_slaves "$@" && return 0
-    if [[ -f "/sys/dev/block/$2/../dev" ]]; then
+    if [[ -f /sys/dev/block/$2/../dev ]]; then
 	check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") &&  return 0
     fi
     [[ -d /sys/dev/block/$2/slaves ]] || return 1
@@ -214,22 +214,22 @@ check_vol_slaves() {
 # and a symlink ${initdir}/lib -> lib64.
 inst_dir() {
     local dir="$1"
-    [[ -e "${initdir}$dir" ]] && return 0
+    [[ -e ${initdir}$dir ]] && return 0
 
     # iterate over parent directories
     local file=""
     local IFS="/"
     for part in $dir; do
-        [ -z "$part" ] && continue
+        [[ $part ]] || continue
         file="$file/$part"
-        [[ -e "${initdir}$file" ]] && continue
+        [[ -e ${initdir}$file ]] && continue
 
-        if [ -L "$file" ]; then
+        if [[ -L $file ]]; then
             # create link as the original
             local target=$(readlink "$file")
             ln -sfn "$target" "${initdir}$file" || return 1
             # resolve relative path and recursively install destionation
-            [[ "$target" = "${target##*/}" ]] && target="${file%/*}/$target"
+            [[ $target = ${target##*/} ]] && target="${file%/*}/$target"
             inst_dir "$target"
         else
             # create directory
@@ -408,18 +408,12 @@ inst_rules() {
 inst() {
     case $# in
         1) ;;
-        2)
-            [[ -z $initdir ]] && [[ -d $2 ]] && export initdir=$2
-            [[ $initdir = $2 ]] && set $1
-            ;;
-        3)
-	    [[ -z $initdir ]] && export initdir=$2 
-            set $1 $3
-            ;;
-        *)
-            derror "inst only takes 1 or 2 or 3 arguments"
-            exit 1
-            ;;
+        2) [[ ! $initdir && -d $2 ]] && export initdir=$2
+           [[ $initdir = $2 ]] && set $1;;
+        3) [[ -z $initdir ]] && export initdir=$2 
+           set $1 $3;;
+        *) derror "inst only takes 1 or 2 or 3 arguments"
+           exit 1;;
     esac
     for x in inst_symlink inst_script inst_binary inst_simple; do
        $x "$@" && return 0
@@ -537,7 +531,7 @@ should_source_module() {
         [[ -x $1/installkernel ]] && return 0
         return 1
     fi
-    [[ -x $1/install ]] || [[ -x $1/installkernel ]] || return 1
+    [[ -x $1/install || -x $1/installkernel ]] || return 1
     [[ -x $1/check ]] || return 0
     "$1/check" $hostonly || continue
     for dep in $("$1/check" -d); do
@@ -642,14 +636,10 @@ filter_kernel_modules () (
     fi
     for modname in $(eval $filtercmd); do
         case $modname in
-            *.ko)
-                "$1" "$modname" && echo "$modname"
-                ;;
-            *.ko.gz)
-                gzip -dc "$modname" > $initdir/$$.ko
-                $1 $initdir/$$.ko && echo "$modname"
-                rm -f $initdir/$$.ko
-                ;;
+            *.ko) "$1" "$modname" && echo "$modname";;
+            *.ko.gz) gzip -dc "$modname" > $initdir/$$.ko
+                     $1 $initdir/$$.ko && echo "$modname"
+                     rm -f $initdir/$$.ko;;
         esac
     done
 )
@@ -671,15 +661,10 @@ instmods() {
 		    instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*")
 		fi
 		;;
-	    --*) 
-	        mod=${mod##*/}
-                mpargs+=" $mod";;
-            i2o_scsi)
-                    # Must never run this diagnostic-only module
-                    shift; continue;
-                ;;
-	    *)  
-	        mod=${mod##*/}
+	    --*) mod=${mod##*/}
+                 mpargs+=" $mod";;
+            i2o_scsi) shift; continue;; # Do not load this diagnostic-only module
+	    *)  mod=${mod##*/}
                 # if we are already installed, skip this module and go on
 	        # to the next one.
 	        [[ -f $initdir/$1 ]] && { shift; continue; }
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 05/16] Shorten permission checking to ensure we can actually write our initramfs.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2010-08-14 19:23   ` [PATCH 02/16] Get rid of unneeded dirname calls Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
       [not found]     ` <f25afda727e1ff3ddebccc987268b5fdc2d1332b.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2010-08-14 19:23   ` [PATCH 03/16] Clean up some conditional checking when trying to find our config files Victor Lowther
                     ` (14 subsequent siblings)
  16 siblings, 1 reply; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

These tests can be combined into an if... elif... elif... statement, and
that makes it clear they are all part of the same test.

---
 dracut |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/dracut b/dracut
index 33d802a..184b0c1 100755
--- a/dracut
+++ b/dracut
@@ -210,18 +210,14 @@ if [[ -f $outfile && ! $force ]]; then
     exit 1
 fi
 
-outdir=$(dirname "$outfile")
-if ! [[ -d "$outdir" ]]; then
+outdir=${outfile%/*}
+if [[ ! -d "$outdir" ]]; then
     echo "Can't write $outfile: Directory $outdir does not exist."
     exit 1
-fi
-
-if ! [[ -w "$outdir" ]]; then
+elif [[ ! -w "$outdir" ]]; then
     echo "No permission to write $outdir."
     exit 1
-fi
-
-if [[ -f "$outfile" ]] &&  ! [[ -w "$outfile" ]]; then
+elif [[ ! -w "$outfile" ]]; then
     echo "No permission to write $outfile."
     exit 1
 fi
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 06/16] Flatten our check to ensure that depmod works.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 10/16] Bashify error() and usage() in mkinitrd-dracut.sh Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 09/16] Just test the status of the cpio-and-compress pipe directly Victor Lowther
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

No need for a nested if here.

---
 dracut |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/dracut b/dracut
index 184b0c1..bfef92c 100755
--- a/dracut
+++ b/dracut
@@ -270,11 +270,10 @@ unset moddir
 ## final stuff that has to happen
 
 # generate module dependencies for the initrd
-if [[ -d $initdir/lib/modules/$kernel ]]; then
-    if ! depmod -a -b "$initdir" $kernel; then
-        derror "\"depmod -a $kernel\" failed."
-        exit 1
-    fi
+if [[ -d $initdir/lib/modules/$kernel ]] && \
+    ! depmod -a -b "$initdir" $kernel; then
+    derror "\"depmod -a $kernel\" failed."
+    exit 1
 fi
 
 if [[ $include_src && $include_target ]]; then
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 07/16] We have $UID, use it instead of $(id -u)
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (7 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 09/16] Just test the status of the cpio-and-compress pipe directly Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 13/16] Trivial bashification and minor code rearrangement for initramfs compression Victor Lowther
                     ` (7 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

No point in spawning a command and parsing its output when the UID
is already in the environment.

---
 dracut |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dracut b/dracut
index bfef92c..a2bc312 100755
--- a/dracut
+++ b/dracut
@@ -288,7 +288,7 @@ unset item
 
 # make sure that library links are correct and up to date
 cp -ar /etc/ld.so.conf* "$initdir"/etc
-ldconfig -r "$initdir" || [[ $(id -u) != "0" ]] && dinfo "ldconfig might need uid=0 (root) for chroot()"
+ldconfig -r "$initdir" || [[ $UID != "0" ]] && dinfo "ldconfig might need uid=0 (root) for chroot()"
 
 [[ $beverbose = yes ]] && (du -c "$initdir" | sort -n)
 
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 08/16] Add support for bzip2 and xz compressed initramfs images.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 04/16] Bashify the code that actually sources out " Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
       [not found]     ` <d23e6d8e5281904090c6a05cecf1576ee7f098f6.1281812506.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2010-08-14 19:23   ` [PATCH 10/16] Bashify error() and usage() in mkinitrd-dracut.sh Victor Lowther
                     ` (11 subsequent siblings)
  16 siblings, 1 reply; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Current kernels know how to uncompress bzip2 and xz, so use them for compressing
the initramfs if asked.  The more compression the merrier.

Also add support for generating uncompressed images, although they
are usually not what you want.

---
 dracut             |   21 ++++++++++++++++++---
 mkinitrd-dracut.sh |    2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dracut b/dracut
index a2bc312..5c1c4b4 100755
--- a/dracut
+++ b/dracut
@@ -75,6 +75,17 @@ Creates initial ramdisk images for preloading modules
                          Target directory in the final initramfs.
   -I, --install [LIST]  Install the space separated list of files into the
                          initramfs.
+  --gzip                Compress the generated initramfs using gzip.
+                        This will be done by default, unless another
+                        compression option or --no-compress is passed.
+  --bzip2               Compress the generated initramfs using bzip2.
+                        Make sure your kernel has bzip2 decompression support
+                        compiled in, otherwise you will not be able to boot.
+  --xz                  Compress the generated initramfs using xz.
+                        Make sure your kernel has xz support compiled in, 
+                        otherwise you will not be able to boot.
+  --no-compress         Do not compress the generated initramfs.  This will
+                        override any other compression options.
 "
 }
 
@@ -111,6 +122,10 @@ while (($# > 0)); do
 	--fstab) use_fstab_l="yes" ;;
 	-i|--include) include_src="$2"; include_target="$3"; shift 2;;
 	-I|--install) install_items="$2"; shift;;
+        --gzip) [[ $compress != cat ]] && compress="gzip -9";;
+        --bzip2) [[$compress != cat ]] && compress="bzip2 -9";;
+        --xz) [[ $compress != cat ]] && compress="xz -9";;
+        --no-compress) compress="cat";;
 	-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
 	*) break ;;
     esac
@@ -174,6 +189,7 @@ fw_dir=${fw_dir//:/ }
 
 [[ $hostonly = yes ]] && hostonly="-h"
 [[ $hostonly != "-h" ]] && unset hostonly
+[[ $compress ]] || compress="gzip -9"
 
 if [[ -f $dracutbasedir/dracut-functions ]]; then
    . $dracutbasedir/dracut-functions
@@ -323,8 +339,8 @@ type hardlink &>/dev/null && {
 	hardlink "$initdir" 2>&1
 }
 
-type pigz &>/dev/null && gzip=pigz || gzip=gzip
-( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |$gzip -9 > "$outfile"; ) 
+[[ $compress = gzip* ]] && type pigz > /dev/null 2>&1 && compress="pigz -9"
+( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |$compress > "$outfile"; ) 
 if [ $? -ne 0 ]; then
     derror "dracut: creation of $outfile failed"
     exit 1
@@ -333,4 +349,3 @@ fi
 [[ $beverbose = yes ]] && ls -lh "$outfile"
 
 exit 0
-
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
index 64b3069..59333a7 100644
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -96,7 +96,7 @@ while [ $# -gt 0 ]; do
         --without*) ;;
         --without-usb) ;;
         --fstab*) ;;
-        --nocompress) ;;
+        --nocompress) dracut_args="$dracut_args --no-compress";;
         --ifneeded) ;;
         --omit-scsi-modules) ;;
         --omit-ide-modules) ;;
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 10/16] Bashify error() and usage() in mkinitrd-dracut.sh
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 08/16] Add support for bzip2 and xz compressed initramfs images Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 06/16] Flatten our check to ensure that depmod works Victor Lowther
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Some more trivial bashification.

---
 mkinitrd-dracut.sh |   27 +++++++--------------------
 1 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
index 59333a7..3943dad 100644
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -1,32 +1,19 @@
 #!/bin/bash --norc
+kver=$(uname -r)
 
-error() {
-    local NONL=""
-    if [ "$1" == "-n" ]; then
-        NONL="-n"
-        shift
-    fi
-    echo $NONL "$@" > /dev/stderr
-}
+error() { echo "$@" >&2; }
 
 usage () {
-    if [ "$1" == "-n" ]; then
-        cmd=echo
-    else
-        cmd=error
-    fi
+    [[ $1 = '-n' ]] && cmd=echo || cmd=error
 
-    $cmd "usage: `basename $0` [--version] [--help] [-v] [-f] [--preload <module>]"
+    $cmd "usage: ${0%/*} [--version] [--help] [-v] [-f] [--preload <module>]"
     $cmd "       [--image-version] [--with=<module>]"
     $cmd "       <initrd-image> <kernel-version>"
     $cmd ""
-    $cmd "       (ex: `basename $0` /boot/initramfs-$(uname -r).img $(uname -r))"
+    $cmd "       (ex: ${0%/*} /boot/initramfs-$kver.img $kver)"
 
-    if [ "$1" == "-n" ]; then
-        exit 0
-    else
-        exit 1
-    fi
+    [[ $1 = '-n' ]] && exit 0
+    exit 1
 }
 
 
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 09/16] Just test the status of the cpio-and-compress pipe directly.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 06/16] Flatten our check to ensure that depmod works Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 07/16] We have $UID, use it instead of $(id -u) Victor Lowther
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 dracut |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dracut b/dracut
index 5c1c4b4..1242f42 100755
--- a/dracut
+++ b/dracut
@@ -340,8 +340,8 @@ type hardlink &>/dev/null && {
 }
 
 [[ $compress = gzip* ]] && type pigz > /dev/null 2>&1 && compress="pigz -9"
-( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |$compress > "$outfile"; ) 
-if [ $? -ne 0 ]; then
+if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \
+    $compress > "$outfile"; ); then 
     derror "dracut: creation of $outfile failed"
     exit 1
 fi 
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 11/16] Bashify mkinitrd-dracut.sh, introduce read_arg.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (9 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 13/16] Trivial bashification and minor code rearrangement for initramfs compression Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 14/16] Trivial bashification of 00dash/install Victor Lowther
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Hack up argument processing in dracut and mkinitrd-dracut.sh to use
read_arg to flexibly process arguments.

---
 dracut             |   50 ++++++++----
 mkinitrd-dracut.sh |  240 ++++++++++++++++++++++------------------------------
 2 files changed, 137 insertions(+), 153 deletions(-)

diff --git a/dracut b/dracut
index 1242f42..1a30cc7 100755
--- a/dracut
+++ b/dracut
@@ -89,23 +89,41 @@ Creates initial ramdisk images for preloading modules
 "
 }
 
+# Little helper function for reading args from the commandline.
+# it automatically handles -a b and -a=b variants, and returns 1 if
+# we need to shift $3.
+read_arg() {
+    # $1 = arg name
+    # $2 = arg value
+    # $3 = arg parameter
+    local rematch='^[^=]*=(.*)$'
+    if [[ $2 =~ $rematch ]]; then
+	read "$1" <<< "${BASH_REMATCH[1]}"
+    else
+	read "$1" <<< "$3"
+	# There is no way to shift our callers args, so
+	# return 1 to indicate they should do it instead.
+	return 1
+    fi
+}
+
 while (($# > 0)); do
-    case $1 in
+    case ${1%%=*} in
 	-f|--force) force=yes;;
-	-m|--modules) dracutmodules_l="$dracutmodules_l $2"; shift;;
-	-o|--omit) omit_dracutmodules_l="$omit_dracutmodules_l $2"; shift;;
-	-a|--add) add_dracutmodules_l="$add_dracutmodules_l $2"; shift;;
-	-d|--drivers) drivers_l="$drivers_l $2"; shift;;
-	--add-drivers) add_drivers_l="$add_drivers_l $2"; shift;;
-	--filesystems) filesystems_l="$filesystems_l $2"; shift;;
-	-k|--kmoddir) drivers_dir_l="$2"; shift;;
-	--fwdir) fw_dir_l="$fw_dir_l:$2"; shift;;
+	-m|--modules) read_arg dracutmodules_l "$@" ||shift;;
+	-o|--omit) read_arg omit_dracutmodules_l "$@" || shift;;
+	-a|--add) read_arg add_dracutmodules_l "$@" || shift;;
+	-d|--drivers) read_arg drivers_l "$@" || shift;;
+	--add-drivers) read_arg add_drivers_l "$@" || shift;;
+	--filesystems) read_arg filesystems_l "$@" || shift;;
+	-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
+	--fwdir) read_arg fw_dir_l "$@" || shift;;
 	--kernel-only) kernel_only="yes"; no_kernel="no";;
 	--no-kernel) kernel_only="no"; no_kernel="yes";;
-    --ignore-kernel-modules) kernel_only="no"; no_kernel="yes"
-        ignore_kmodules="yes"
-        omit_dracutmodules_l+=\ kernel-modules
-        ;;
+        --ignore-kernel-modules) kernel_only="no"; no_kernel="yes"
+            ignore_kmodules="yes"
+            omit_dracutmodules_l+=\ kernel-modules
+            ;;
 	--strip) do_strip_l="yes";;
 	--nostrip) do_strip_l="no";;
         --mdadmconf) mdadmconf_l="yes";;
@@ -115,13 +133,13 @@ while (($# > 0)); do
 	-h|--help) usage; exit 1 ;;
 	--debug) debug="yes";;
 	-v|--verbose) beverbose="yes";;
-	-c|--conf) conffile="$2"; shift;;
-	--confdir) confdir="$2"; shift;;
+	-c|--conf) read_arg conffile "$@" || shift;;
+	--confdir) read_arg confdir "$@" || shift;;
 	-l|--local) allowlocal="yes" ;;
 	-H|--hostonly) hostonly_l="yes" ;;
 	--fstab) use_fstab_l="yes" ;;
 	-i|--include) include_src="$2"; include_target="$3"; shift 2;;
-	-I|--install) install_items="$2"; shift;;
+	-I|--install) read_arg install_items "$@" || shift;;
         --gzip) [[ $compress != cat ]] && compress="gzip -9";;
         --bzip2) [[$compress != cat ]] && compress="bzip2 -9";;
         --xz) [[ $compress != cat ]] && compress="xz -9";;
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
dissimilarity index 61%
index 3943dad..f25ccb9 100644
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -1,137 +1,103 @@
-#!/bin/bash --norc
-kver=$(uname -r)
-
-error() { echo "$@" >&2; }
-
-usage () {
-    [[ $1 = '-n' ]] && cmd=echo || cmd=error
-
-    $cmd "usage: ${0%/*} [--version] [--help] [-v] [-f] [--preload <module>]"
-    $cmd "       [--image-version] [--with=<module>]"
-    $cmd "       <initrd-image> <kernel-version>"
-    $cmd ""
-    $cmd "       (ex: ${0%/*} /boot/initramfs-$kver.img $kver)"
-
-    [[ $1 = '-n' ]] && exit 0
-    exit 1
-}
-
-
-while [ $# -gt 0 ]; do
-    case $1 in
-        --with-usb*)
-            if [ "$1" != "${1##--with-usb=}" ]; then
-                usbmodule=${1##--with-usb=}
-            else
-                usbmodule="usb-storage"
-            fi
-            basicmodules="$basicmodules $usbmodule"
-            unset usbmodule
-            ;;
-        --with-avail*)
-            if [ "$1" != "${1##--with-avail=}" ]; then
-                modname=${1##--with-avail=}
-            else
-                modname=$2
-                shift
-            fi
-
-            basicmodules="$basicmodules $modname"
-            ;;
-        --with*)
-            if [ "$1" != "${1##--with=}" ]; then
-                modname=${1##--with=}
-            else
-                modname=$2
-                shift
-            fi
-
-            basicmodules="$basicmodules $modname"
-            ;;
-        --version)
-            echo "mkinitrd: dracut compatibility wrapper"
-            exit 0
-            ;;
-        -v|--verbose)
-            dracut_args="${dracut_args} -v"
-            ;;
-        -f)
-            dracut_args="${dracut_args} -f"
-            ;;
-        --preload*)
-            if [ "$1" != "${1##--preload=}" ]; then
-                modname=${1##--preload=}
-            else
-                modname=$2
-                shift
-            fi
-            basicmodules="$basicmodules $modname"
-            ;;
-        --image-version)
-            img_vers=yes
-            ;;
-	--rootfs*)
-            if [ "$1" != "${1##--rootfs=}" ]; then
-                rootfs="${1##--rootfs=}"
-            else
-                rootfs="$2"
-                shift
-            fi
-	    dracut_args="${dracut_args} --filesystems $rootfs"
-	    ;;
-        --builtin*) ;;
-        --without*) ;;
-        --without-usb) ;;
-        --fstab*) ;;
-        --nocompress) dracut_args="$dracut_args --no-compress";;
-        --ifneeded) ;;
-        --omit-scsi-modules) ;;
-        --omit-ide-modules) ;;
-        --omit-raid-modules) ;;
-        --omit-lvm-modules) ;;
-        --omit-dmraid) ;;
-        --allow-missing) ;;
-        --net-dev*) ;;
-        --noresume) ;;
-	--rootdev*) ;;
-	--thawdev*) ;;
-	--rootopts*) ;;
-	--root*) ;;
-	--loopdev*) ;;
-	--loopfs*) ;;
-	--loopopts*) ;;
-	--looppath*) ;;
-	--dsdt*) ;;
-        --bootchart) ;;
-        --help)
-            usage -n
-            ;;
-        *)
-            if [ -z "$target" ]; then
-                target=$1
-            elif [ -z "$kernel" ]; then
-                kernel=$1
-            else
-                usage
-            fi
-            ;;
-    esac
-
-    shift
-done
-
-if [ -z "$target" -o -z "$kernel" ]; then
-    usage
-fi
-
-if [ -n "$img_vers" ]; then
-    target="$target-$kernel"
-fi
-
-if [ -n "$basicmodules" ]; then
-	dracut -H $dracut_args --add-drivers "$basicmodules" "$target" "$kernel"
-else
-	dracut -H $dracut_args "$target" "$kernel"
-fi
-
-# vim:ts=8:sw=4:sts=4:et
+#!/bin/bash --norc
+kver=$(uname -r)
+
+error() { echo "$@" >&2; }
+
+usage () {
+    [[ $1 = '-n' ]] && cmd=echo || cmd=error
+
+    $cmd "usage: ${0%/*} [--version] [--help] [-v] [-f] [--preload <module>]"
+    $cmd "       [--image-version] [--with=<module>]"
+    $cmd "       <initrd-image> <kernel-version>"
+    $cmd ""
+    $cmd "       (ex: ${0%/*} /boot/initramfs-$kver.img $kver)"
+
+    [[ $1 = '-n' ]] && exit 0
+    exit 1
+}
+
+# Little helper function for reading args from the commandline.
+# it automatically handles -a b and -a=b variants, and returns 1 if
+# we need to shift $3.
+read_arg() {
+    # $1 = arg name
+    # $2 = arg value
+    # $3 = arg parameter
+    local rematch='^[^=]*=(.*)$'
+    if [[ $2 =~ $rematch ]]; then
+	read "$1" <<< "${BASH_REMATCH[1]}"
+    elif [[ $3 != -* ]]; then
+        # Only read next arg if it not an arg itself.
+	read "$1" <<< "$3"
+	# There is no way to shift our callers args, so
+	# return 1 to indicate they should do it instead.
+	return 1
+    fi
+}
+
+while (($# > 0)); do
+    case ${1%%=*} in
+        --with-usb) read_arg usbmodule "$@" || shift
+            basicmodules="$basicmodules ${usbmodule:-usb-storage}"
+            unset usbmodule;;
+        --with-avail) read_arg modname "$@" || shift
+            basicmodules="$basicmodules $modname";;
+        --with) read_arg modname "$@" || shift
+            basicmodules="$basicmodules $modname";;
+        --version)
+            echo "mkinitrd: dracut compatibility wrapper"
+            exit 0;;
+        -v|--verbose) dracut_args="${dracut_args} -v";;
+        -f) dracut_args="${dracut_args} -f";;
+        --preload) read_args modname "$@" || shift
+            basicmodules="$basicmodules $modname";;
+        --image-version) img_vers=yes;;
+	--rootfs) read_args rootfs "$@" || shift
+            dracut_args="${dracut_args} --filesystems $rootfs";;
+        --nocompress) dracut_args="$dracut_args --no-compress";;
+        --help) usage -n;;
+        --builtin) ;;
+        --without*) ;;
+        --without-usb) ;;
+        --fstab*) ;;
+        --ifneeded) ;;
+        --omit-scsi-modules) ;;
+        --omit-ide-modules) ;;
+        --omit-raid-modules) ;;
+        --omit-lvm-modules) ;;
+        --omit-dmraid) ;;
+        --allow-missing) ;;
+        --net-dev*) ;;
+        --noresume) ;;
+	--rootdev*) ;;
+	--thawdev*) ;;
+	--rootopts*) ;;
+	--root*) ;;
+	--loopdev*) ;;
+	--loopfs*) ;;
+	--loopopts*) ;;
+	--looppath*) ;;
+	--dsdt*) ;;
+        --bootchart) ;;
+        *) if [[ ! $target ]]; then
+            target=$1
+            elif [[ ! $kernel ]]; then
+            kernel=$1
+            else
+            usage
+            fi;;
+    esac
+    shift
+done
+
+[[ $target && $kernel ]] || usage
+[[ $img_vers ]] && target="$target-$kernel"
+fi
+
+if [[ $basicmodules ]]; then
+	dracut -H $dracut_args --add-drivers "$basicmodules" "$target" "$kernel"
+else
+	dracut -H $dracut_args "$target" "$kernel"
+fi
+
+# vim:ts=8:sw=4:sts=4:et
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 15/16] We are precise about hostonly checking these days.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (12 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 12/16] Prettify the option setting loop in dracut Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 16/16] Add a PKGBUILD file to make building on Arch Linux from a git checkout easy Victor Lowther
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

So get rid of the comment in 90crypt/check.
Also do a bit of trivial bashification.

---
 modules.d/90crypt/check |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/modules.d/90crypt/check b/modules.d/90crypt/check
index a34a05e..22a017e 100755
--- a/modules.d/90crypt/check
+++ b/modules.d/90crypt/check
@@ -2,12 +2,7 @@
 
 # if cryptsetup is not installed, then we cannot support encrypted devices.
 which cryptsetup >/dev/null 2>&1 || exit 1
-
-[ "$1" = "-d" ] && echo dm
-
-# hostonly checking should only return true if root is on a LUKS device
-# in some way, but I am too lazy to figure out how to do that.
-# Instead, fail if we do not have a LUKS device in use somewhere.
+[[ $1 = -d ]] && echo dm
 
 . $dracutfunctions
 
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 16/16] Add a PKGBUILD file to make building on Arch Linux from a git checkout easy.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (13 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 15/16] We are precise about hostonly checking these days Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-15  9:10   ` [PATCH 01/16] Trivial cleanups in dracut-functions Luca Berra
  2010-08-23 10:41   ` Harald Hoyer
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

This might come in handy for anyone else trying out dracut on Arch.

---
 PKGBUILD |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..5776c09
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,20 @@
+pkgname=dracut-git
+pkgver=$(date +%s)
+pkgrel=$(git log --pretty=format:%h |head -n 1)
+pkgdesc="Initramfs generation utility"
+arch=('i686' 'x86_64')
+url="http://sourceforge.net/apps/trac/dracut/"
+license=('GPL')
+conflicts=('dracut' 'mkinitcpio')
+provides=('dracut=9999' 'mkinitcpio=9999')
+depends=('bash')
+optdepends=('cryptsetup' 'lvm2')
+makedepends=('libxslt')
+source=()
+md5sums=()
+
+build() {
+  cd ..
+  make sysconfdir=/etc || return 1
+  make DESTDIR="${pkgdir}" sysconfdir=/etc install || return 1
+}
\ No newline at end of file
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 12/16] Prettify the option setting loop in dracut.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (11 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 14/16] Trivial bashification of 00dash/install Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 15/16] We are precise about hostonly checking these days Victor Lowther
                     ` (3 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

THis just makes the args line up all nice and pretty.

---
 dracut |   60 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/dracut b/dracut
index 1a30cc7..fcd32c1 100755
--- a/dracut
+++ b/dracut
@@ -109,41 +109,41 @@ read_arg() {
 
 while (($# > 0)); do
     case ${1%%=*} in
-	-f|--force) force=yes;;
-	-m|--modules) read_arg dracutmodules_l "$@" ||shift;;
-	-o|--omit) read_arg omit_dracutmodules_l "$@" || shift;;
-	-a|--add) read_arg add_dracutmodules_l "$@" || shift;;
-	-d|--drivers) read_arg drivers_l "$@" || shift;;
-	--add-drivers) read_arg add_drivers_l "$@" || shift;;
-	--filesystems) read_arg filesystems_l "$@" || shift;;
-	-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
-	--fwdir) read_arg fw_dir_l "$@" || shift;;
+	-m|--modules)  read_arg dracutmodules_l      "$@" || shift;;
+	-o|--omit)     read_arg omit_dracutmodules_l "$@" || shift;;
+	-a|--add)      read_arg add_dracutmodules_l  "$@" || shift;;
+	-d|--drivers)  read_arg drivers_l            "$@" || shift;;
+	--add-drivers) read_arg add_drivers_l        "$@" || shift;;
+	--filesystems) read_arg filesystems_l        "$@" || shift;;
+	-k|--kmoddir)  read_arg drivers_dir_l        "$@" || shift;;
+	-c|--conf)     read_arg conffile             "$@" || shift;;
+	--confdir)     read_arg confdir              "$@" || shift;;
+	-I|--install)  read_arg install_items        "$@" || shift;;
+	--fwdir)       read_arg fw_dir_l             "$@" || shift;;
+	-f|--force)    force=yes;;
 	--kernel-only) kernel_only="yes"; no_kernel="no";;
-	--no-kernel) kernel_only="no"; no_kernel="yes";;
+	--no-kernel)   kernel_only="no"; no_kernel="yes";;
+	--strip)       do_strip_l="yes";;
+	--nostrip)     do_strip_l="no";;
+        --mdadmconf)   mdadmconf_l="yes";;
+        --nomdadmconf) mdadmconf_l="no";;
+        --lvmconf)     lvmconf_l="yes";;
+        --nolvmconf)   lvmconf_l="no";;
+	--debug)       debug="yes";;
+	-v|--verbose)  beverbose="yes";;
+	-l|--local)    allowlocal="yes" ;;
+	-H|--hostonly) hostonly_l="yes" ;;
+	--fstab)       use_fstab_l="yes" ;;
+	-h|--help)     usage; exit 1 ;;
+	-i|--include)  include_src="$2"; include_target="$3"; shift 2;;
+        --gzip)        [[ $compress != cat ]] && compress="gzip -9";;
+        --bzip2)       [[ $compress != cat ]] && compress="bzip2 -9";;
+        --xz)          [[ $compress != cat ]] && compress="xz -9";;
+        --no-compress) compress="cat";;
         --ignore-kernel-modules) kernel_only="no"; no_kernel="yes"
             ignore_kmodules="yes"
             omit_dracutmodules_l+=\ kernel-modules
             ;;
-	--strip) do_strip_l="yes";;
-	--nostrip) do_strip_l="no";;
-        --mdadmconf) mdadmconf_l="yes";;
-        --nomdadmconf) mdadmconf_l="no";;
-        --lvmconf) lvmconf_l="yes";;
-        --nolvmconf) lvmconf_l="no";;
-	-h|--help) usage; exit 1 ;;
-	--debug) debug="yes";;
-	-v|--verbose) beverbose="yes";;
-	-c|--conf) read_arg conffile "$@" || shift;;
-	--confdir) read_arg confdir "$@" || shift;;
-	-l|--local) allowlocal="yes" ;;
-	-H|--hostonly) hostonly_l="yes" ;;
-	--fstab) use_fstab_l="yes" ;;
-	-i|--include) include_src="$2"; include_target="$3"; shift 2;;
-	-I|--install) read_arg install_items "$@" || shift;;
-        --gzip) [[ $compress != cat ]] && compress="gzip -9";;
-        --bzip2) [[$compress != cat ]] && compress="bzip2 -9";;
-        --xz) [[ $compress != cat ]] && compress="xz -9";;
-        --no-compress) compress="cat";;
 	-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
 	*) break ;;
     esac
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 14/16] Trivial bashification of 00dash/install
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (10 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 11/16] Bashify mkinitrd-dracut.sh, introduce read_arg Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 12/16] Prettify the option setting loop in dracut Victor Lowther
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 modules.d/00dash/install |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/modules.d/00dash/install b/modules.d/00dash/install
index 0b344ca..a197573 100755
--- a/modules.d/00dash/install
+++ b/modules.d/00dash/install
@@ -1,6 +1,6 @@
 #!/bin/bash
 # If another shell is already installed, do not use dash
-[ -x "${initdir}/bin/sh" ] && return
+[[ -x $initdir/bin/sh ]] && return
 
 # Prefer dash as /bin/sh if it is available.
 inst /bin/dash && ln -sf dash "${initdir}/bin/sh"
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 13/16] Trivial bashification and minor code rearrangement for initramfs compression.
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (8 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 07/16] We have $UID, use it instead of $(id -u) Victor Lowther
@ 2010-08-14 19:23   ` Victor Lowther
  2010-08-14 19:23   ` [PATCH 11/16] Bashify mkinitrd-dracut.sh, introduce read_arg Victor Lowther
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-14 19:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 dracut |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dracut b/dracut
index fcd32c1..f70aa50 100755
--- a/dracut
+++ b/dracut
@@ -136,10 +136,13 @@ while (($# > 0)); do
 	--fstab)       use_fstab_l="yes" ;;
 	-h|--help)     usage; exit 1 ;;
 	-i|--include)  include_src="$2"; include_target="$3"; shift 2;;
-        --gzip)        [[ $compress != cat ]] && compress="gzip -9";;
         --bzip2)       [[ $compress != cat ]] && compress="bzip2 -9";;
         --xz)          [[ $compress != cat ]] && compress="xz -9";;
         --no-compress) compress="cat";;
+        --gzip)        if [[ $compress != cat ]]; then
+            type pigz > /dev/null 2>&1 && compress="pigz -9" || \
+                compress="gzip -9"
+            fi;;
         --ignore-kernel-modules) kernel_only="no"; no_kernel="yes"
             ignore_kmodules="yes"
             omit_dracutmodules_l+=\ kernel-modules
@@ -258,7 +261,7 @@ fi
 
 hookdirs="cmdline pre-udev pre-trigger netroot pre-mount pre-pivot mount emergency"
 
-[[ -n "$TMPDIR" ]] && ! [[ -w "$TMPDIR" ]] && unset TMPDIR
+[[ $TMPDIR && ! -w $TMPDIR ]] && unset TMPDIR
 readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
 
 trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT # clean up after ourselves no matter how we die.
@@ -357,7 +360,6 @@ type hardlink &>/dev/null && {
 	hardlink "$initdir" 2>&1
 }
 
-[[ $compress = gzip* ]] && type pigz > /dev/null 2>&1 && compress="pigz -9"
 if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \
     $compress > "$outfile"; ); then 
     derror "dracut: creation of $outfile failed"
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 08/16] Add support for bzip2 and xz compressed initramfs images.
       [not found]     ` <d23e6d8e5281904090c6a05cecf1576ee7f098f6.1281812506.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-08-15  2:02       ` Victor Lowther
  0 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-15  2:02 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

In this one, s/xz/lzma/g.

On Sat, Aug 14, 2010 at 2:23 PM, Victor Lowther
<victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Current kernels know how to uncompress bzip2 and xz, so use them for compressing
> the initramfs if asked.  The more compression the merrier.
>
> Also add support for generating uncompressed images, although they
> are usually not what you want.
>
> ---
>  dracut             |   21 ++++++++++++++++++---
>  mkinitrd-dracut.sh |    2 +-
>  2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/dracut b/dracut
> index a2bc312..5c1c4b4 100755
> --- a/dracut
> +++ b/dracut
> @@ -75,6 +75,17 @@ Creates initial ramdisk images for preloading modules
>                          Target directory in the final initramfs.
>   -I, --install [LIST]  Install the space separated list of files into the
>                          initramfs.
> +  --gzip                Compress the generated initramfs using gzip.
> +                        This will be done by default, unless another
> +                        compression option or --no-compress is passed.
> +  --bzip2               Compress the generated initramfs using bzip2.
> +                        Make sure your kernel has bzip2 decompression support
> +                        compiled in, otherwise you will not be able to boot.
> +  --xz                  Compress the generated initramfs using xz.
> +                        Make sure your kernel has xz support compiled in,
> +                        otherwise you will not be able to boot.
> +  --no-compress         Do not compress the generated initramfs.  This will
> +                        override any other compression options.
>  "
>  }
>
> @@ -111,6 +122,10 @@ while (($# > 0)); do
>        --fstab) use_fstab_l="yes" ;;
>        -i|--include) include_src="$2"; include_target="$3"; shift 2;;
>        -I|--install) install_items="$2"; shift;;
> +        --gzip) [[ $compress != cat ]] && compress="gzip -9";;
> +        --bzip2) [[$compress != cat ]] && compress="bzip2 -9";;
> +        --xz) [[ $compress != cat ]] && compress="xz -9";;
> +        --no-compress) compress="cat";;
>        -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
>        *) break ;;
>     esac
> @@ -174,6 +189,7 @@ fw_dir=${fw_dir//:/ }
>
>  [[ $hostonly = yes ]] && hostonly="-h"
>  [[ $hostonly != "-h" ]] && unset hostonly
> +[[ $compress ]] || compress="gzip -9"
>
>  if [[ -f $dracutbasedir/dracut-functions ]]; then
>    . $dracutbasedir/dracut-functions
> @@ -323,8 +339,8 @@ type hardlink &>/dev/null && {
>        hardlink "$initdir" 2>&1
>  }
>
> -type pigz &>/dev/null && gzip=pigz || gzip=gzip
> -( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |$gzip -9 > "$outfile"; )
> +[[ $compress = gzip* ]] && type pigz > /dev/null 2>&1 && compress="pigz -9"
> +( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet |$compress > "$outfile"; )
>  if [ $? -ne 0 ]; then
>     derror "dracut: creation of $outfile failed"
>     exit 1
> @@ -333,4 +349,3 @@ fi
>  [[ $beverbose = yes ]] && ls -lh "$outfile"
>
>  exit 0
> -
> diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
> index 64b3069..59333a7 100644
> --- a/mkinitrd-dracut.sh
> +++ b/mkinitrd-dracut.sh
> @@ -96,7 +96,7 @@ while [ $# -gt 0 ]; do
>         --without*) ;;
>         --without-usb) ;;
>         --fstab*) ;;
> -        --nocompress) ;;
> +        --nocompress) dracut_args="$dracut_args --no-compress";;
>         --ifneeded) ;;
>         --omit-scsi-modules) ;;
>         --omit-ide-modules) ;;
> --
> 1.7.2.1
>
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 05/16] Shorten permission checking to ensure we can actually write our initramfs.
       [not found]     ` <f25afda727e1ff3ddebccc987268b5fdc2d1332b.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-08-15  2:03       ` Victor Lowther
  0 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-15  2:03 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

On Sat, Aug 14, 2010 at 2:23 PM, Victor Lowther
<victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> These tests can be combined into an if... elif... elif... statement, and
> that makes it clear they are all part of the same test.
>
> ---
>  dracut |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/dracut b/dracut
> index 33d802a..184b0c1 100755
> --- a/dracut
> +++ b/dracut
> @@ -210,18 +210,14 @@ if [[ -f $outfile && ! $force ]]; then
>     exit 1
>  fi
>
> -outdir=$(dirname "$outfile")
> -if ! [[ -d "$outdir" ]]; then
> +outdir=${outfile%/*}
> +if [[ ! -d "$outdir" ]]; then
>     echo "Can't write $outfile: Directory $outdir does not exist."
>     exit 1
> -fi
> -
> -if ! [[ -w "$outdir" ]]; then
> +elif [[ ! -w "$outdir" ]]; then
>     echo "No permission to write $outdir."
>     exit 1
> -fi
> -
> -if [[ -f "$outfile" ]] &&  ! [[ -w "$outfile" ]]; then
> +elif [[ ! -w "$outfile" ]]; then

Stupid thinko.  [[ -f $outfile && ! -w $outfile ]], obviously.

>     echo "No permission to write $outfile."
>     exit 1
>  fi
> --
> 1.7.2.1
>
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 01/16] Trivial cleanups in dracut-functions
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (14 preceding siblings ...)
  2010-08-14 19:23   ` [PATCH 16/16] Add a PKGBUILD file to make building on Arch Linux from a git checkout easy Victor Lowther
@ 2010-08-15  9:10   ` Luca Berra
       [not found]     ` <20100815091056.GA649-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
  2010-08-23 10:41   ` Harald Hoyer
  16 siblings, 1 reply; 24+ messages in thread
From: Luca Berra @ 2010-08-15  9:10 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

On Sat, Aug 14, 2010 at 02:23:24PM -0500, Victor Lowther wrote:
>-    if [[ -f "/sys/dev/block/$2/../dev" ]]; then
>+    if [[ -f /sys/dev/block/$2/../dev ]]; then

I fail to see any advantages in removing quotes from patterns,
on the contrary i think it could lead to weird failures.

if it were me i'd add quotes where they are missing instead.

L.

-- 
Luca Berra -- bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org
         Communication Media & Services S.r.l.
  /"\
  \ /     ASCII RIBBON CAMPAIGN
   X        AGAINST HTML MAIL
  / \

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 02/16] Get rid of unneeded dirname calls.
       [not found]     ` <0e55145f49bde182dc7efec5fa8965f31dc5234e.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-08-15  9:20       ` Luca Berra
       [not found]         ` <20100815092037.GB649-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Luca Berra @ 2010-08-15  9:20 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

On Sat, Aug 14, 2010 at 02:23:24PM -0500, Victor Lowther wrote:
>-[[ $allowlocal && -f "$(readlink -f $(dirname $0))/dracut-functions" ]] && dracutbasedir="$(dirname $0)" 
>+[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && dracutbasedir="${0%/*}" 

note that parameter expansion and dirname behave differently when the
argument is the null string.
dirname will retunrn ".", parameter expansion will return the null
string.

L.

-- 
Luca Berra -- bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org
         Communication Media & Services S.r.l.
  /"\
  \ /     ASCII RIBBON CAMPAIGN
   X        AGAINST HTML MAIL
  / \

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 01/16] Trivial cleanups in dracut-functions
       [not found]     ` <20100815091056.GA649-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
@ 2010-08-15 18:49       ` Victor Lowther
  0 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-15 18:49 UTC (permalink / raw)
  To: Luca Berra, initramfs-u79uwXL29TY76Z2rM5mHXA



"Luca Berra" <bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org> wrote:

>On Sat, Aug 14, 2010 at 02:23:24PM -0500, Victor Lowther wrote:
>>-    if [[ -f "/sys/dev/block/$2/../dev" ]]; then
>>+    if [[ -f /sys/dev/block/$2/../dev ]]; then
>
>I fail to see any advantages in removing quotes from patterns,
>on the contrary i think it could lead to weird failures.
>
>if it were me i'd add quotes where they are missing instead.

No need to in bash when testing conditions inside [[ ]]. Word splitting and path expansion are not performed,  because [[ ]] is syntax, not a built-in command. 

>L.
>
>-- 
>Luca Berra -- bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org
>         Communication Media & Services S.r.l.
>  /"\
>  \ /     ASCII RIBBON CAMPAIGN
>   X        AGAINST HTML MAIL
>  / \
>--
>To unsubscribe from this list: send the line "unsubscribe initramfs" in
>the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Sent from my Nexus One with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 02/16] Get rid of unneeded dirname calls.
       [not found]         ` <20100815092037.GB649-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
@ 2010-08-15 18:54           ` Victor Lowther
  0 siblings, 0 replies; 24+ messages in thread
From: Victor Lowther @ 2010-08-15 18:54 UTC (permalink / raw)
  To: Luca Berra, initramfs-u79uwXL29TY76Z2rM5mHXA



"Luca Berra" <bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org> wrote:

>On Sat, Aug 14, 2010 at 02:23:24PM -0500, Victor Lowther wrote:
>>-[[ $allowlocal && -f "$(readlink -f $(dirname $0))/dracut-functions" ]] && dracutbasedir="$(dirname $0)" 
>>+[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && dracutbasedir="${0%/*}" 
>
>note that parameter expansion and dirname behave differently when the
>argument is the null string.
>dirname will retunrn ".", parameter expansion will return the null
>string.

That should only matter if you have . in your $PATH, in which case you are a crazy person. :-)

>L.
>
>-- 
>Luca Berra -- bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org
>         Communication Media & Services S.r.l.
>  /"\
>  \ /     ASCII RIBBON CAMPAIGN
>   X        AGAINST HTML MAIL
>  / \
>--
>To unsubscribe from this list: send the line "unsubscribe initramfs" in
>the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Sent from my Nexus One with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 03/16] Clean up some conditional checking when trying to find our config files.
       [not found]     ` <ef5afb56d5b0073885e92a7fbe0bd79dfe84fb77.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-08-16  8:47       ` Harald Hoyer
  0 siblings, 0 replies; 24+ messages in thread
From: Harald Hoyer @ 2010-08-16  8:47 UTC (permalink / raw)
  To: Victor Lowther; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On 08/14/2010 09:23 PM, Victor Lowther wrote:
> No point in checking the same condition twice when compound commands will do.
>
> ---
>   dracut |    8 ++++----
>   1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/dracut b/dracut
> index 541bfc0..a653981 100755
> --- a/dracut
> +++ b/dracut
> @@ -131,13 +131,13 @@ export PATH
>
>   # if we were not passed a config file, try the default one
>   if [[ ! -f $conffile ]]; then
> -    [[ $allowlocal ]] || conffile="/etc/dracut.conf"
> -    [[ $allowlocal ]]&&  conffile="$dracutbasedir/dracut.conf"
> +    [[ $allowlocal ]]&&  conffile="$dracutbasedir/dracut.conf" || \
> +        conffile="/etc/dracut.conf"
>   fi
>
>   if [[ ! -d $confdir ]]; then
> -    [[ $allowlocal ]] || confdir="/etc/dracut.conf.d"
> -    [[ $allowlocal ]]&&  confdir="$dracutbasedir/dracut.conf.d"
> +    [[ $allowlocal ]]&&  confdir="$dracutbasedir/dracut.conf.d" \
> +        confdir="/etc/dracut.conf.d"
>   fi
>
>   # source our config file


missing "||" in the second block???

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 01/16] Trivial cleanups in dracut-functions
       [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (15 preceding siblings ...)
  2010-08-15  9:10   ` [PATCH 01/16] Trivial cleanups in dracut-functions Luca Berra
@ 2010-08-23 10:41   ` Harald Hoyer
  16 siblings, 0 replies; 24+ messages in thread
From: Harald Hoyer @ 2010-08-23 10:41 UTC (permalink / raw)
  To: Victor Lowther; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

pushed and corrected all 16 patches

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2010-08-23 10:41 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-14 19:23 [PATCH 01/16] Trivial cleanups in dracut-functions Victor Lowther
     [not found] ` <170ac6ad6189b7d7d31610a797d059d590807484.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-08-14 19:23   ` [PATCH 02/16] Get rid of unneeded dirname calls Victor Lowther
     [not found]     ` <0e55145f49bde182dc7efec5fa8965f31dc5234e.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-08-15  9:20       ` Luca Berra
     [not found]         ` <20100815092037.GB649-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
2010-08-15 18:54           ` Victor Lowther
2010-08-14 19:23   ` [PATCH 05/16] Shorten permission checking to ensure we can actually write our initramfs Victor Lowther
     [not found]     ` <f25afda727e1ff3ddebccc987268b5fdc2d1332b.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-08-15  2:03       ` Victor Lowther
2010-08-14 19:23   ` [PATCH 03/16] Clean up some conditional checking when trying to find our config files Victor Lowther
     [not found]     ` <ef5afb56d5b0073885e92a7fbe0bd79dfe84fb77.1281812505.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-08-16  8:47       ` Harald Hoyer
2010-08-14 19:23   ` [PATCH 04/16] Bashify the code that actually sources out " Victor Lowther
2010-08-14 19:23   ` [PATCH 08/16] Add support for bzip2 and xz compressed initramfs images Victor Lowther
     [not found]     ` <d23e6d8e5281904090c6a05cecf1576ee7f098f6.1281812506.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-08-15  2:02       ` Victor Lowther
2010-08-14 19:23   ` [PATCH 10/16] Bashify error() and usage() in mkinitrd-dracut.sh Victor Lowther
2010-08-14 19:23   ` [PATCH 06/16] Flatten our check to ensure that depmod works Victor Lowther
2010-08-14 19:23   ` [PATCH 09/16] Just test the status of the cpio-and-compress pipe directly Victor Lowther
2010-08-14 19:23   ` [PATCH 07/16] We have $UID, use it instead of $(id -u) Victor Lowther
2010-08-14 19:23   ` [PATCH 13/16] Trivial bashification and minor code rearrangement for initramfs compression Victor Lowther
2010-08-14 19:23   ` [PATCH 11/16] Bashify mkinitrd-dracut.sh, introduce read_arg Victor Lowther
2010-08-14 19:23   ` [PATCH 14/16] Trivial bashification of 00dash/install Victor Lowther
2010-08-14 19:23   ` [PATCH 12/16] Prettify the option setting loop in dracut Victor Lowther
2010-08-14 19:23   ` [PATCH 15/16] We are precise about hostonly checking these days Victor Lowther
2010-08-14 19:23   ` [PATCH 16/16] Add a PKGBUILD file to make building on Arch Linux from a git checkout easy Victor Lowther
2010-08-15  9:10   ` [PATCH 01/16] Trivial cleanups in dracut-functions Luca Berra
     [not found]     ` <20100815091056.GA649-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
2010-08-15 18:49       ` Victor Lowther
2010-08-23 10:41   ` Harald Hoyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.