Browse Source

target: added squashfs output support

Note:

Actually this implementation is only a slightly changed version of
the initramfs output support.
user/chris/test/arm
Christian Wiese 13 years ago
committed by Alejandro Mery
parent
commit
9ccf551857
2 changed files with 190 additions and 0 deletions
  1. +48
    -0
      target/share/squashfs.in
  2. +142
    -0
      target/share/squashfs/build.sh

+ 48
- 0
target/share/squashfs.in

@ -0,0 +1,48 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/share/squashfs.in
# Copyright (C) 2011 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 ---
# source overlay functions, to wrap overlay_apply behind squashfs_install_overlay
#
. "$base/lib/overlay/overlay-functions.in"
# functions
#
# list the packages active for stage 1
squashfs_list_packages() {
grep '^X' $base/config/$config/packages | cut -d' ' -f5
}
# install a package based on the flist and a given filter
squashfs_install_flist() {
local pkg_name="$1" sandbox="$2" rootfs="$3"
local flist="$sandbox/var/adm/flists/$pkg_name"
shift 3
sed "$@" "$flist" | cut -f2- -d' ' |
tar -C "$sandbox/" -cf- --no-recursion --files-from=- |
tar -C "$rootfs" -xf-
}
# weak functions
#
squashfs_install_overlay() { overlay_apply "$@"; }
# should this package be extracted by flist or not?
# squashfs_install <pkg_name> <sandbox> <rootfs>
squashfs_install() { true; }
# what arguments should it pass to sed to filter the flist?
# squashfs_install_pattern <pkg_name> <default_patterns>
squashfs_install_pattern() { shift; echo "$@"; }

+ 142
- 0
target/share/squashfs/build.sh

@ -0,0 +1,142 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/share/squashfs/build.sh
# Copyright (C) 2011 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: SquashFS rootfs
rootfs="$build_toolchain/squashfs"
rm -rf "$rootfs"
mkdir -p "$rootfs"
# Hooks
#
SQUASHFS_POSTINSTALL_HOOK=
SQUASHFS_POSTOVERLAY_HOOK=
# Lists
#
SQUASHFS_INSTALL_PACKAGES=
SQUASHFS_INSTALL_PATTERN="-e '/ var\/adm/ d;' \
-e '/\.\(h\|o\|a\|a\..*\|la\|pc\)$/d;' -e '/\/aclocal\//d;' \
-e '/ usr\/share\/\(doc\|info\|man\)\//d;' -e'/ opt\/[^\/]*\/\(doc\|info\|man\)\//d;' -e '/\/gtk-doc\//d;'"
SQUASHFS_EMPTY_PATTERN="-e '/\.\/lib\/udev\/devices\//d;'"
# source library, and the target specific overlay
#
. "target/share/squashfs.in"
if [ -f target/$target/build-squashfs.in ]; then
. target/$target/build-squashfs.in
fi
# install what was flisted for stage 1 packages, use $SQUASHFS_INSTALL_PATTERN to skip files
#
[ -n "$SQUASHFS_INSTALL_PACKAGES" ] || SQUASHFS_INSTALL_PACKAGES=$( squashfs_list_packages )
echo_status "Populating ${rootfs#$base/} ..."
for pkg_name in $SQUASHFS_INSTALL_PACKAGES; do
if squashfs_install "$pkg_name" "build/$SDECFG_ID" "$rootfs"; then
echo_status "- $pkg_name"
eval "squashfs_install_flist '$pkg_name' 'build/$SDECFG_ID' '$rootfs' $( squashfs_install_pattern "$pkg_name" "$SQUASHFS_INSTALL_PATTERN" )"
fi
done
# hook $SQUASHFS_POSTINSTALL_HOOK
#
[ -z "$SQUASHFS_POSTINSTALL_HOOK" ] || eval "$SQUASHFS_POSTINSTALL_HOOK"
# Apply overlay
[ ! -d "target/$target/squashfs" ] || squashfs_install_overlay "target/$target/squashfs" "$rootfs"
# hook $SQUASHFS_POSTOVERLAY_HOOK
#
[ -z "$SQUASHFS_POSTOVERLAY_HOOK" ] || eval "$SQUASHFS_POSTOVERLAY_HOOK"
# remove empty directories, use $SQUASHFS_EMPTY_PATTERN to skip directories
#
echo_status "Removing empty directories ..."
( cd "$rootfs"; find . -type d ) | tac | eval "sed -e '/\.\/\(dev\|sys\|proc\|mnt\|srv\|tmp\|root\|var\)\(\|\/.*\)$/d;' $SQUASHFS_EMPTY_PATTERN" | while read folder; do
count=$( find "$rootfs/$folder" | wc -l )
if [ $count -eq 1 ]; then
rm -r "$rootfs/$folder"
# echo_status "- ${folder} deleted."
fi
done
echo_status "Checking for broken symlinks ..."
( cd "$rootfs"; find . -type l | cut -c2- ) | while read link; do
x="$link"
case "$link" in
/dev/*) continue ;;
esac
while true; do
target=$( readlink "$rootfs$x" )
case "$target" in
/proc/*)
continue 2
;;
/*)
;;
*)
# relatives turned into absolute
target="${x%/*}/${target}"
esac
[ -L "$rootfs$target" ] || break 1
x="$target"
done
if [ ! -e "$rootfs$target" ]; then
echo_warning "- $link is broken ($target), deleting."
rm -f "$rootfs$link"
fi
done
# ldconfig
#
if [ -s "$rootfs/etc/ld.so.conf" ]; then
echo_status "Running ldconfig ..."
ldconfig -r "$rootfs"
fi
# sanity checks
#
[ -x "$rootfs/init" ] || echo_warning "This image is missing an /init file, it wont run."
for x in $rootfs/{,usr/}{sbin,bin}/* $rootfs/init $rootfs/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 ;;
*dynamically\ linked*)
[ "$SDECFG_STATIC" == 1 ] || continue ;;
esac
echo_warning "evil signature ($signature) on '${x#$rootfs}'."
done
echo_status "Expanded size: $( du -sh "$rootfs" | cut -f1)."
echo_status "Creating ${rootfs#$base/}.sqx ..."
( mksquashfs $rootfs $build_toolchain/squashfs.sqx -comp gzip )
echo_status "Image size: $( du -sh "$rootfs.sqx" | cut -f1)."

Loading…
Cancel
Save