From 71b7b710bf87223b80a3cc0615a8380656bca442 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 11 Nov 2008 17:09:32 +0200 Subject: [PATCH] mkinitramfs: Enhanced to try to install the template from $SDECFG_PKG_MKINITRAMFS_TPL config if possible --- base/mkinitramfs/find_template.in | 44 +++++++++++++++++++++++++++++++ base/mkinitramfs/mkinitramfs.conf | 18 +++++-------- 2 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 base/mkinitramfs/find_template.in diff --git a/base/mkinitramfs/find_template.in b/base/mkinitramfs/find_template.in new file mode 100644 index 000000000..0ddd5423f --- /dev/null +++ b/base/mkinitramfs/find_template.in @@ -0,0 +1,44 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../mkinitramfs/find_template.in +# 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 --- + +# find the image +# +initrd_img="$base/config/$config/initrd.img" +if [ -s "$initrd_img" ]; then + # explicit overwrite + echo_status "mkinitramfs: Using given ${mkinitramfs_tpl#$base/}." +elif [ -z "$SDECFG_PKG_MKINITRAMFS_TPL" ]; then + initrd_img= +else + # wanted initramfs config + x="$base/config/$SDECFG_PKG_MKINITRAMFS_TPL/config" + if [ ! -s "$x" ]; then + echo_error "mkinitramfs: '$SDECFG_PKG_MKINITRAMFS_TPL' config not found." + initrd_img= + else + x=$(grep SDECFG_ID= "$x" | cut -d"'" -f2) + if [ -d "$base/loop/build" ]; then + initrd_img="$base/loop/build/$x/TOOLCHAIN/initrd.img" + else + initrd_img="$base/build/$x/TOOLCHAIN/initrd.img" + fi + + if [ -s "$initrd_img" ]; then + echo_status "mkinitramfs: Using $SDECFG_PKG_MKINITRAMFS_TPL's initrd.img" + else + echo_error "mkinitramfs: '$SDECFG_PKG_MKINITRAMFS_TPL' doesn't contain an initrd.img" + initrd_img= + fi + fi +fi diff --git a/base/mkinitramfs/mkinitramfs.conf b/base/mkinitramfs/mkinitramfs.conf index d8737a61f..30807ffff 100644 --- a/base/mkinitramfs/mkinitramfs.conf +++ b/base/mkinitramfs/mkinitramfs.conf @@ -18,8 +18,14 @@ libdir=$libdir/mkinitrd makeopt= makeinstopt= +. $confdir/find_template.in + hook_add postmake 5 'mkinitrd_install' -hook_add postmake 7 'mkinitrd_install_img' +if [ -s "$initrd_img" ]; then + hook_add postmake 7 "cp -vf '$initrd_img' '$root/boot/initrd.img'" +else + echo_warning "No initrd.img found." +fi mkinitrd_install() { install -v -m 755 "$confdir/mkinitramfs.sh" "$root$sbindir/mkinitramfs" @@ -27,13 +33,3 @@ mkinitrd_install() { cp -vf "$x" "$root$libdir/" done } - -mkinitrd_install_img() { - local image=initrd.img - if [ -r "$base/config/$config/$image" ]; then - echo_status "Injecting $image file from config/$config" - cp -vf "$base/config/$config"/$image "$root/boot/" - else - echo_warning "No $image file found in config/$config" - fi -}