Copy perms/ownership from source when creating linkfiles dest dirs.
[live-boot-grml.git] / scripts / live-helpers
index 5306cf5..78de240 100644 (file)
@@ -1158,8 +1158,8 @@ link_files ()
        # live-boot normally does (into $rootmnt)).
 
        # remove multiple /:s and ensure ending on /
-       local src_dir="$(echo "${1}"/ | sed -e 's|/\+|/|g')"
-       local dest_dir="$(echo "${2}"/ | sed -e 's|/\+|/|g')"
+       local src_dir="$(trim_path ${1})/"
+       local dest_dir="$(trim_path ${2})/"
        local src_mask="${3}"
 
        # This check can only trigger on the inital, non-recursive call since
@@ -1181,9 +1181,8 @@ link_files ()
                        if [ ! -d "${dest}" ]
                        then
                                mkdir -p "${dest}"
-                               prev="$(dirname "${dest}")"
-                               chown_ref "${prev}" "${dest}"
-                               chmod_ref "${prev}" "${dest}"
+                               chown_ref "${src}" "${dest}"
+                               chmod_ref "${src}" "${dest}"
                        fi
                        link_files "${src}" "${dest}" "${src_mask}"
                else
@@ -1323,7 +1322,7 @@ get_custom_mounts ()
                                        linkfiles)
                                                opt_linkfiles="yes"
                                                ;;
-                                       union)
+                                       union|bind)
                                                ;;
                                        *)
                                                log_warning_msg "Skipping custom mount with unkown option: ${opt}"
@@ -1389,25 +1388,27 @@ activate_custom_mounts ()
 
        while read device source dest options # < ${custom_mounts}
        do
+               local opt_bind="yes"
                local opt_linkfiles=""
                local opt_union=""
                for opt in $(echo ${options} | tr ',' ' ');
                do
                        case "${opt}" in
+                               bind)
+                                       opt_bind="yes"
+                                       unset opt_linkfiles opt_union
+                                       ;;
                                linkfiles)
                                        opt_linkfiles="yes"
+                                       unset opt_bind opt_union
                                        ;;
                                union)
                                        opt_union="yes"
+                                       unset opt_bind opt_linkfiles
                                        ;;
                        esac
                done
 
-               if [ -n "${opt_linkfiles}" ] && [ -n "${opt_union}" ]
-               then
-                       log_warning_msg "Skipping custom mount ${dest} with options ${options}: \"linkfiles\" and \"union\" are mutually exclusive options"
-               fi
-
                if [ -n "$(what_is_mounted_on "${dest}")" ]
                then
                        log_warning_msg "Skipping custom mount ${dest}: $(what_is_mounted_on "${dest}") is already mounted there"
@@ -1455,7 +1456,8 @@ activate_custom_mounts ()
                                mkdir -p "${source}"
                                chown_ref "${dest}" "${source}"
                                chmod_ref "${dest}" "${source}"
-                       else
+                       elif [ -n "${opt_bind}" ]
+                       then
                                # ensure that $dest is not copied *into* $source
                                mkdir -p "$(dirname ${source})"
                                cp -a "${dest}" "${source}"