Browse Source

* improved initrd output format

* weak function initrd_flist_install_filter() used to decide if a
		  package has to be expanded by filtered flist or not
		* filtered out .a.* files by default
		* added sanity check, like the presence of /init and the check for
		  safe file types on {usr/,}{sbin,bin}/* and lib/udev/*


git-svn-id: svn://svn.opensde.net/opensde/opensde/trunk@21353 10447126-35f2-4685-b0cf-6dd780d3921f
misl/sde-wrapper
Alejandro Mery 17 years ago
parent
commit
11e9e9d7f1
1 changed files with 29 additions and 8 deletions
  1. +29
    -8
      target/share/initrd/build.sh

+ 29
- 8
target/share/initrd/build.sh

@ -22,9 +22,12 @@ mkdir -p "$initrddir"
INITRD_POSTFLIST_HOOK=
INITRD_FLIST_PACKAGES=
INITRD_FLIST_PATTERN="-e '/\.\(h\|o\|a\|la\|pc\)$/d;' -e '/ usr\/share\/\(doc\|info\|man\)\//d;'"
INITRD_FLIST_PATTERN="-e '/\.\(h\|o\|a\|a\..*\|la\|pc\)$/d;' -e '/ usr\/share\/\(doc\|info\|man\)\//d;'"
INITRD_EMPTY_PATTERN="-e '/\.\/lib\/udev\/devices\//d;'"
# weak function, should this package be extracted by flist or not?
initrd_flist_install_filter() { true; }
# source target specific code
#
if [ -f target/$target/build-initrd.in ]; then
@ -39,12 +42,14 @@ fi
echo_status "Populating ${initrddir#$base/} ..."
for pkg_name in $INITRD_FLIST_PACKAGES; do
echo_status "- $pkg_name"
flist="build/${SDECFG_ID}/var/adm/flists/$pkg_name"
if initrd_flist_install_filter $pkg_name; then
echo_status "- $pkg_name"
flist="build/${SDECFG_ID}/var/adm/flists/$pkg_name"
eval "sed -e '/ var\/adm/ d;' $INITRD_FLIST_PATTERN '$flist'" | cut -f2- -d' ' |
tar -C "build/${SDECFG_ID}/" -cf- --no-recursion --files-from=- |
tar -C "$initrddir" -xf-
eval "sed -e '/ var\/adm/ d;' $INITRD_FLIST_PATTERN '$flist'" | cut -f2- -d' ' |
tar -C "build/${SDECFG_ID}/" -cf- --no-recursion --files-from=- |
tar -C "$initrddir" -xf-
fi
done
# hook
@ -55,8 +60,6 @@ if [ -r "target/$target/init.sh" ]; then
echo_status "Copying target's /init script."
cp "target/$target/init.sh" "${initrddir}/init"
chmod +x "${initrddir}/init"
else
echo_warning "Target '$target' doesn't provide an init script."
fi
# remove empty folder, use $INITRD_EMPTY_PATTERN to skip folders
@ -71,6 +74,24 @@ echo_status "Removing empty folders ..."
fi
done
# sanity check
[ -x "${initrddir}/init" ] || echo_warning "This image is missing an /init file, it wont run."
for x in ${initrddir}/{,usr/}{sbin,bin}/* ${initrddir}/init ${initrddir}/lib/udev/*; do
[ -e "$x" ] || continue
signature="$( file "$x" 2> /dev/null | cut -d' ' -f2- )"
case "$signature" in
directory) continue ;;
ASCII\ English\ text)
continue ;;
*symbolic*|*statically*|*shell*)
continue ;;
esac
echo_warning "evil signature ($signature) on '${x#$initrddir}'."
done
echo_status "Expanded size: $( du -sh "$initrddir" | cut -f1)."
echo_status "Creating ${initrddir#$base/}.img ..."

Loading…
Cancel
Save