SVN: geninitrd/trunk: geninitrd geninitrd.sysconfig
glen
glen at pld-linux.org
Tue Apr 7 00:55:20 CEST 2009
Author: glen
Date: Tue Apr 7 00:55:20 2009
New Revision: 10320
Modified:
geninitrd/trunk/geninitrd
geninitrd/trunk/geninitrd.sysconfig
Log:
- lzma/bzip/gzip compressors
- need to think about image extension which cames from .spec....
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Tue Apr 7 00:55:20 2009
@@ -47,6 +47,7 @@
uname_r=$(uname -r)
echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
echo " [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]"
+ echo " [--compress=yes|lzma|bzip2|gzip]"
echo " [--initrdfs=rom|initramfs|ext2|cram] [--modules-conf=<modules.conf>]"
echo " [--with-raidstart] [--without-raidstart]"
echo " [--with-bootsplash] [--without-bootsplash]"
@@ -761,6 +762,60 @@
ln -s init $DESTDIR/linuxrc
}
+# find if $symbol exists in System.map $mapfile
+sym_exists() {
+ local mapfile="$1"
+ local symbol="$2"
+ if [ ! -f $mapfile ]; then
+ # missing mapfile (not a pld kernel?)
+ return 1
+ fi
+
+ awk -vc=1 -vsymbol="$symbol" '$2 == "T" && $3 == symbol {c = 0} END {exit c}' $mapfile
+}
+
+# find best compressor (or forced one) for initrd
+find_compressor() {
+ local mode="$1"
+ # the best compressor list
+ local compressors='lzma bzip2 gzip'
+
+ # a specified one, take it
+ if ! is_yes "$mode"; then
+ compressors=gzip
+ fi
+
+ debug "finding compressor: $compressors (via $mode)"
+ # check for compressor validity
+ local c prog map=/boot/System.map-$kernel
+ for c in $compressors; do
+ case $c in
+ lzma)
+ sym=unlzma
+ prog=lzma
+ ;;
+ bzip2)
+ sym=bzip2
+ prog=bzip2
+ ;;
+ gzip)
+ sym=gunzip
+ prog=gzip
+ ;;
+ *)
+ die "Unknown compressor $c"
+ ;;
+ esac
+ if sym_exists $map $sum && [ -x $prog ]; then
+ echo $c
+ return
+ fi
+ done
+
+ debug "using gzip for compressor (fallback)"
+ echo gzip
+}
+
if [ -r /etc/sysconfig/geninitrd ]; then
. /etc/sysconfig/geninitrd
fi
@@ -861,6 +916,12 @@
-v)
verbose=-v
;;
+ --compress)
+ COMPRESS=$2
+ ;;
+ --compress=*)
+ COMPRESS="${1#--compress=}"
+ ;;
--nocompress)
COMPRESS=no
;;
@@ -1244,10 +1305,24 @@
die "Filesystem $INITRDFS not supported by $PROGRAM"
esac
-if is_yes "$COMPRESS"; then
+if ! is_no "$COMPRESS"; then
tmp=$(mktemp "$target".XXXXXX) || die "mktemp failed"
- debug "Compressing $target"
- gzip -9 < "$IMAGE" > "$tmp"
+ compressor=$(find_compressor "$COMPRESS")
+ debug "Compressing $target with $compressor"
+
+ # TODO: the image name (specified from kernel.spec) already contains
+ # extension, which is .gz most of the time.
+ case "$compressor" in
+ lzma)
+ lzma -9 < "$IMAGE" > "$tmp"
+ ;;
+ bzip2)
+ bzip2 -9 < "$IMAGE" > "$tmp"
+ ;;
+ gzip)
+ gzip -9 < "$IMAGE" > "$tmp"
+ ;;
+ esac
mv -f "$tmp" "$target"
else
cp -a "$IMAGE" "$target"
Modified: geninitrd/trunk/geninitrd.sysconfig
==============================================================================
--- geninitrd/trunk/geninitrd.sysconfig (original)
+++ geninitrd/trunk/geninitrd.sysconfig Tue Apr 7 00:55:20 2009
@@ -4,8 +4,10 @@
## Modules that should be loaded before anything (i.e. jbd for ext3)
#PREMODS=""
-## Should initrd be compressed?
-COMPRESS=yes
+## Compression for the initrd.
+## lzma / bzip2 / gzip.
+## yes (default) = the 'best' available is chosen.
+#COMPRESS=yes
## What filesystem to use (rom or ext2)?
# PLD Linux kernel has only romfs compiled in.
More information about the pld-cvs-commit
mailing list