From 4e196129e5f4c2c49012e886e7dfaef55edae123 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 11 Mar 2008 02:54:26 +0000 Subject: [PATCH] Moved initramfs output format's initramfs_install_overlay to a global lib/overlay/overlay-functions.in under the name of overlay_apply --- lib/overlay/overlay-functions.in | 56 ++++++++++++++++++++++++++++++++ lib/overlay/parse-config | 15 +++++++++ target/share/initramfs.in | 47 +++------------------------ 3 files changed, 76 insertions(+), 42 deletions(-) create mode 100644 lib/overlay/overlay-functions.in create mode 100644 lib/overlay/parse-config diff --git a/lib/overlay/overlay-functions.in b/lib/overlay/overlay-functions.in new file mode 100644 index 0000000..7ef4144 --- /dev/null +++ b/lib/overlay/overlay-functions.in @@ -0,0 +1,56 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: lib/overlay/overlay-functions.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 --- + +# apply an overlay dir +overlay_apply() { + local overlaydir="$1" rootfs="${2:-$root}" + 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" + [ ! -e "$rootfs/$target" ] || rm -f "$rootfs/$target" + 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 +} + diff --git a/lib/overlay/parse-config b/lib/overlay/parse-config new file mode 100644 index 0000000..fd04cec --- /dev/null +++ b/lib/overlay/parse-config @@ -0,0 +1,15 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: lib/overlay/parse-config +# 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 --- + +. "$base/lib/overlay/overlay-functions.in" diff --git a/target/share/initramfs.in b/target/share/initramfs.in index 0ce5452..b37b2a5 100644 --- a/target/share/initramfs.in +++ b/target/share/initramfs.in @@ -12,6 +12,10 @@ # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END --- +# source overlay functions, to wrap overlay_apply behind initramfs_install_overlay +# +. "$base/lib/overlay/overlay-functions.in" + # functions # @@ -31,50 +35,9 @@ initramfs_install_flist() { 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" - [ ! -e "$rootfs/$target" ] || rm -f "$rootfs/$target" - 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 # +initramfs_install_overlay() { overlay_apply "$@"; } # should this package be extracted by flist or not? # initramfs_install