# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: target/share/initramfs.in
|
|
# Copyright (C) 2007 - 2008 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 ---
|
|
|
|
# functions
|
|
#
|
|
|
|
# list the packages active for stage 1
|
|
initramfs_list_stage1() {
|
|
grep '^X .1' $base/config/$config/packages | cut -d' ' -f5
|
|
}
|
|
|
|
# install a package based on the flist and a given filter
|
|
initramfs_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-
|
|
}
|
|
|
|
# apply an overlay
|
|
initramfs_install_overlay() {
|
|
local overlaydir="$1" rootfs="$2"
|
|
local file= source= target= ext=
|
|
local type= mode= ref= targetdir=
|
|
|
|
for file in $overlaydir/*; do
|
|
source="${file##*/}"
|
|
ext="${file##*.}"
|
|
|
|
case "$ext" in
|
|
sh|exec|txt|patch|ln)
|
|
case "$ext" in
|
|
sh|exec) type='exec'; mode=0755 ;;
|
|
*) type="$ext"; mode=0644 ;;
|
|
esac
|
|
target="$( echo ${source%.$ext} | tr '_%' '/_' )"
|
|
targetdir="$rootfs/$target"; targetdir="${targetdir%/*}"
|
|
;;
|
|
*) continue ;;
|
|
esac
|
|
|
|
case "$type" in
|
|
exec|txt)
|
|
echo_status "injecting $target ($type)"
|
|
mkdir -p "$targetdir"
|
|
cp -f "$file" "$rootfs/$target"
|
|
chmod $mode "$rootfs/$target"
|
|
;;
|
|
ln) ref=$( cat "$file" )
|
|
echo_status "injecting $target -> $ref"
|
|
mkdir -p "$targetdir"
|
|
ln -snf "$ref" "$rootfs/$target"
|
|
;;
|
|
patch)
|
|
echo_status "$(patch -p1 -d "${rootfs}" 2>&1 < $file )"
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# weak functions
|
|
#
|
|
|
|
# should this package be extracted by flist or not?
|
|
# initramfs_install <pkg_name> <sandbox> <rootfs>
|
|
initramfs_install() { true; }
|
|
|
|
# what arguments should it pass to sed to filter the flist?
|
|
# initramfs_install_pattern <pkg_name> <default_patterns>
|
|
initramfs_install_pattern() { shift; echo "$@"; }
|