dracut-lib.sh: add copytree(), use it where applicable
copytree() recursively copies the contents of SRC into DEST. If DEST doesn't exist it is created; if it exists the contents of SRC get merged into it (duplicate files are overwritten).master
parent
a2ead9a486
commit
31cfc9aa5e
|
|
@ -225,6 +225,6 @@ echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
|
|||
{
|
||||
cp /tmp/net.* /run/initramfs/
|
||||
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
|
||||
cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/*
|
||||
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
|
||||
} > /dev/null 2>&1
|
||||
|
|
|
|||
|
|
@ -27,6 +27,5 @@ if [ $? != 0 ]; then
|
|||
warn "url: $url"
|
||||
return 1
|
||||
fi
|
||||
rm -rf /updates
|
||||
mv -f /updates.tmp.$$ /updates
|
||||
copytree /updates.tmp.$$ /updates
|
||||
mv /tmp/liveupdates.info /tmp/liveupdates.done
|
||||
|
|
|
|||
|
|
@ -532,6 +532,17 @@ mkuniqdir() {
|
|||
echo "${retdir}"
|
||||
}
|
||||
|
||||
# Copy the contents of SRC into DEST, merging the contents of existing
|
||||
# directories (kinda like rsync, or cpio -p).
|
||||
# Creates DEST if it doesn't exist. Overwrites files with the same names.
|
||||
#
|
||||
# copytree SRC DEST
|
||||
copytree() {
|
||||
local src="$1" dest="$2"
|
||||
mkdir -p "$dest"; dest=$(readlink -e -q "$dest")
|
||||
( cd "$src"; cp -af . -t "$dest" )
|
||||
}
|
||||
|
||||
# Evaluates command for UUIDs either given as arguments for this function or all
|
||||
# listed in /dev/disk/by-uuid. UUIDs doesn't have to be fully specified. If
|
||||
# beginning is given it is expanded to all matching UUIDs. To pass full UUID to
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ unpack_fs() {
|
|||
local img="$1" outdir="$2" mnt="$(mkuniqdir /tmp unpack_fs.)"
|
||||
mount -o loop $img $mnt || { rmdir $mnt; return 1; }
|
||||
mkdir -p $outdir; outdir="$(cd $outdir; pwd)"
|
||||
( cd $mnt; cp -a -t $outdir . )
|
||||
copytree $mnt $outdir
|
||||
umount $mnt
|
||||
rmdir $mnt
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue