]> git.wh0rd.org - home.git/commitdiff
custom-chroot: skip files that do not exist
authorMike Frysinger <vapier@gentoo.org>
Sat, 18 Jan 2014 10:14:08 +0000 (05:14 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 18 Jan 2014 10:14:08 +0000 (05:14 -0500)
.bin/custom-chroot

index 113ccfad31e27faff8574e351cb3dff325bb23ab..1306cb95928709137da5e234dbfbc08d5f84c878 100755 (executable)
@@ -38,10 +38,9 @@ init_chroot() {
        [[ -w . ]] || return 0
 
        if [[ ! -L etc/mtab ]] ; then
-               rm -f etc/mtab
-               ln -sf /proc/mounts etc/mtab
+               ln -sfT /proc/mounts etc/mtab
        fi
-       local f
+       local f dst
        local etc=(
                hosts
                locale.gen
@@ -57,14 +56,22 @@ init_chroot() {
        for f in \
                $(printf 'etc/%s ' "${etc[@]}") \
        ; do
-               if [ -e "/${f}" ] ; then
-                       cp /${f} ${f}
+               if [[ -e /${f} ]] ; then
+                       cp "/${f}" "${f}"
                fi
        done
        for f in "${home[@]}" ; do
-               cp "${HOME}/${f}" "root/${f}"
+               df="root/${f}"
+               f="${HOME}/${f}"
+               if [[ -e ${f} ]] ; then
+                       cp "${f}" "${df}"
+               fi
        done
-       cat ~/.profile.d/aliases.sh > root/.bash_profile
+
+       f="${HOME}/.profile.d/aliases.sh"
+       if [[ -e ${f} ]] ; then
+               cat "${f}" > root/.bash_profile
+       fi
 }
 
 usage() {