|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: target/share/initramfs/build.sh # Copyright (C) 2007 The OpenSDE Project # # More information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. A copy of the # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END ---
#Description: Initial ramfs image (cpio.gz)
initrddir="$build_toolchain/initrd"
rm -rf "$initrddir" mkdir -p "$initrddir"
INITRD_POSTFLIST_HOOK=
INITRD_FLIST_PACKAGES= 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-initramfs.in ]; then . target/$target/build-initramfs.in fi
# install what was flisted for stage 1 packages, use $INITRD_FLIST_PATTERN to skip files # if [ -z "$INITRD_FLIST_PACKAGES" ]; then INITRD_FLIST_PACKAGES=$( grep '^X .1' $base/config/$config/packages | cut -d' ' -f5 | tr '\n' ' ' ) fi
echo_status "Populating ${initrddir#$base/} ..." for pkg_name in $INITRD_FLIST_PACKAGES; do 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- fi done
# hook # [ -z "$INITRD_POSTFLIST_HOOK" ] || eval "$INITRD_POSTFLIST_HOOK"
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" fi
# remove empty folder, use $INITRD_EMPTY_PATTERN to skip folders # echo_status "Removing empty folders ..." ( cd "$initrddir"; find . -type d ) | tac | eval "sed -e '/\.\/\(dev\|sys\|proc\|mnt\|tmp\)\$/d;' $INITRD_EMPTY_PATTERN" | while read folder; do count=$( find "${initrddir}/$folder" | wc -l )
if [ $count -eq 1 ]; then rm -r "${initrddir}/$folder" # echo_status "- ${folder} deleted." 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 ..." ( cd "$initrddir"; find * | cpio -o -H newc ) | gzip -c -9 > "$initrddir.img"
echo_status "Image size: $( du -sh "$initrddir.img" | cut -f1)."
|