forcibly break all hard links so we dont need to rely on --force in compressor and...
authorMike Frysinger <vapier@gentoo.org>
Sat, 17 Mar 2007 02:28:22 +0000 (02:28 -0000)
committerMike Frysinger <vapier@gentoo.org>
Sat, 17 Mar 2007 02:28:22 +0000 (02:28 -0000)
svn path=/main/trunk/; revision=6221

bin/ecompressdir

index 50e8ec7a60ba9bc0979b39f56710958f4bdc9542..a037adc604633f94be1b33083a4d0c8a268f9985 100755 (executable)
@@ -74,14 +74,13 @@ funk_up_dir() {
 # _relocate_skip_dirs(srctree, dsttree)
 # Move all the directories we want to skip running compression
 # on from srctree to dsttree.
-# TODO: this should support whitespace in paths ...
 _relocate_skip_dirs() {
        local srctree="$1" dsttree="$2"
 
        [[ -d ${srctree} ]] || return 0
 
-       local src dst parent
-       for src in $(find "${srctree}" -name '*.ecompress.skip') ; do
+       find "${srctree}" -name '*.ecompress.skip' -print0 | \
+       while read -d $'\0' src ; do
                src=${src%.ecompress.skip}
                dst="${dsttree}${src#${srctree}}"
                parent=${dst%/*}
@@ -117,6 +116,10 @@ for dir in "$@" ; do
        funk_up_dir "decompress" "gz" "gunzip"
        funk_up_dir "decompress" "bz2" "bunzip2"
 
+       # forcibly break all hard links as some compressors whine about it
+       find "${dir}" -type f -links +1 -exec env file="{}" sh -c \
+               'cp -p "${file}"{,.ecompress.break} ; mv -f "${file}"{.ecompress.break,}' \;
+
        # now lets do our work
        [[ -z ${suffix} ]] && continue
        vecho "${0##*/}: $(ecompress --bin) ${dir#${D}}"