{
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
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
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
}