Browse Source

initramfs: added pack_and_push.sh helper, which first uses mkinitramfs and the rsync

karasz/new-early
Alejandro Mery 16 years ago
parent
commit
5a7e812114
1 changed files with 93 additions and 0 deletions
  1. +93
    -0
      target/share/initramfs/pack_and_push.sh

+ 93
- 0
target/share/initramfs/pack_and_push.sh

@ -0,0 +1,93 @@
#!/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
}
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."
cat <<EOT
packing: $config_build + $config_early
EOT
if "$BUILD/usr/sbin/mkinitramfs" -R "$BUILD" -T "$INITRD" "$KERVER"; then
vmlinuz="$BUILD/boot/vmlinuz_$KERVER"
initrd="$BUILD/boot/initrd-$KERVER.img"
[ -s "$vmlinuz" ] || die "\${root}/boot/vmlinuz_$KERVER: not found."
[ -s "$initrd" ] || die "\${root}/boot/initrd-$KERVER.img: not found."
if [ -n "$TARGETDIR" ]; then
echo "pushing: $TARGETDIR/vmlinuz${SUFFIX:+-$SUFFIX}"
rsync -ztqP "$vmlinuz" "$TARGETDIR/vmlinuz${SUFFIX:+-$SUFFIX}"
echo "pushing: $TARGETDIR/initrd${SUFFIX:+-$SUFFIX}.img"
rsync -ztqP "$initrd" "$TARGETDIR/initrd${SUFFIX:+-$SUFFIX}.img"
fi
fi

Loading…
Cancel
Save