Browse Source

overlay: added sopport for -n to overlay_apply to disable overwriting

karasz/new-early
Alejandro Mery 15 years ago
parent
commit
e7739ea147
1 changed files with 23 additions and 10 deletions
  1. +23
    -10
      lib/overlay/overlay-functions.in

+ 23
- 10
lib/overlay/overlay-functions.in

@ -2,7 +2,7 @@
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: lib/overlay/overlay-functions.in
# Copyright (C) 2007 - 2008 The OpenSDE Project
# Copyright (C) 2007 - 2009 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
@ -14,8 +14,7 @@
# returns the type of overlay based on the extension of the overlay file
#
overlay_get_type()
{
overlay_get_type() {
local ext="${1##*.}"
case "$ext" in
@ -28,8 +27,7 @@ overlay_get_type()
# returns the name of a target file based on the name overlay file
#
overlay_get_filename()
{
overlay_get_filename() {
local filename="${1##*/}"; filename="${filename%.*}"
# rock_substitute will add a leading / for most translations
@ -38,10 +36,18 @@ overlay_get_filename()
# apply an overlay dir
overlay_apply() {
local overlaydir="$1" rootfs="${2:-$root}"
local file= source= target= ext=
local overlaydir= rootfs=
local file= source= target= fulltarget= ext=
local type= mode= ref= targetdir=
local patchopt="-p1 --no-backup-if-mismatch -N"
local overwrite=yes
if [ "x$1" = "x-n" ]; then
overwrite=
shift
fi
overlaydir="$1" rootfs="${2:-$root}"
for file in "$overlaydir"/*; do
# only consider known overlay types
@ -50,7 +56,16 @@ overlay_apply() {
# full filename of the target file, and it's directory
target=$( overlay_get_filename "$file" )
targetdir="$rootfs/$target"; targetdir="${targetdir%/*}"
fulltarget="$rootfs/$target" targetdir="${fulltarget%/*}"
if [ -L "$rootfs/$target" -o -e "$rootfs/$target" ]; then
if [ "$overwrite" = yes ]; then
[ "$type" = patch ] || rm -f "$fulltarget"
else
echo_status "skipping $target ($type)"
continue
fi
fi
# final adjustments based on the type
case "$type" in
@ -63,7 +78,6 @@ overlay_apply() {
exec|txt)
echo_status "injecting $target ($type)"
mkdir -p "$targetdir"
[ ! -L "$rootfs/$target" ] || rm -f "$rootfs/$target"
cat "$file" | rock_substitute > "$rootfs/$target"
chmod $mode "$rootfs/$target"
;;
@ -79,4 +93,3 @@ overlay_apply() {
esac
done
}

Loading…
Cancel
Save