OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
2.6 KiB

#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/share/initramfs/pack_and_push.sh
# Copyright (C) 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 ---
die() { echo "ERROR: $*" >&2; exit 127; }
usage() {
[ $# -eq 0 ] || echo "ERROR: $*"
cat <<-EOT
Usage: ${0##*/} -c <config_build> -e <config_early> [-s <suffix>] [<target>]
EOT
exit 1
}
rsyncopt="-ztqP"
config_build=
config_early=
SUFFIX=
while [ $# -gt 0 ]; do
case "$1" in
-c|--cfg)
config_build="$2"; shift ;;
-e|--early)
config_early="$2"; shift ;;
-s|--suffix)
SUFFIX="$2"; shift ;;
--)
shift; break ;;
-*)
usage "$1: Invalid option."
;;
*)
break
;;
esac
shift
done
case "$#" in
0) TARGETDIR= ;;
1) TARGETDIR="$1"; shift ;;
*) usage "Too many arguments." ;;
esac
[ -n "$config_build" -a -n "$config_early" ] || usage
BUILD=$(grep SDECFG_ID= config/$config_build/config | cut -d"'" -f2)
EARLY=$(grep SDECFG_ID= config/$config_early/config | cut -d"'" -f2)
[ -n "$BUILD" -a -d "build/$BUILD/TOOLCHAIN" ] ||
die "$config_build: Invalid config."
[ -n "$EARLY" -a -d "build/$EARLY/TOOLCHAIN" ] ||
die "$config_early: Invalid config."
BUILD="build/$BUILD"
EARLY="build/$EARLY"
INITRD="$EARLY/TOOLCHAIN/initrd.img"
KERVER=$(cd "$BUILD/boot" && ls -1 vmlinuz_* | tail -n1 | cut -d_ -f2-)
[ -n "$KERVER" ] || die "$config_build: no kernel found."
[ -s "$INITRD" ] || die "$config_early: no initrd template found."
echo "packing: $config_build + $config_early"
vmlinuz="$BUILD/boot/vmlinuz_$KERVER"
initrd="$BUILD/boot/initrd-$KERVER.img"
errno=0
if [ "$vmlinuz" -nt "$initrd" -o "$INITRD" -nt "$initrd" ]; then
"$BUILD/usr/sbin/mkinitramfs" -R "$BUILD" -T "$INITRD" "$KERVER"
errno=$?
fi
[ $errno -eq 0 ] || exit $errno
[ -s "$vmlinuz" ] || die "\${root}/boot/vmlinuz_$KERVER: not found."
[ -s "$initrd" ] || die "\${root}/boot/initrd-$KERVER.img: not found."
if [ -n "$TARGETDIR" ]; then
source=$(mktemp -d -p "$BUILD/tmp/")
[ -d "$source" ] || die "failed to create tempdir."
cp -l "$initrd" "$source/initrd${SUFFIX:+-$SUFFIX}.img"
cp -l "$vmlinuz" "$source/vmlinuz${SUFFIX:+-$SUFFIX}"
rsync $rsyncopt "$source"/* "$TARGETDIR/"
rm -rf "$source"
fi