Merged from trunk 6218:6221
authorFabian Groffen <grobian@gentoo.org>
Sat, 17 Mar 2007 14:32:58 +0000 (14:32 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 17 Mar 2007 14:32:58 +0000 (14:32 -0000)
drop the need for the force flag by default and just delete the existing
files automatically #171007 (SpankMan)

redo compression so that it is queued up in src_install and then
dequeued post src_install (SpankMan)

forcibly break all hard links so we dont need to rely on --force in
compressor and tweak the _relocate_skip_dirs() func to handle whitespace
in paths (thanks to zmedico for tip) (SpankMan)

svn path=/main/branches/prefix/; revision=6236

bin/dodoc
bin/ecompress
bin/ecompressdir
bin/prepall
bin/prepalldocs

index b26a7659da0e725ee3ab29ea951650b8acccd653..06fbfc055a915224b07a0cd693deb038cae5eae6 100755 (executable)
--- a/bin/dodoc
+++ b/bin/dodoc
@@ -17,7 +17,7 @@ ret=0
 for x in "$@" ; do
        if [ -s "${x}" ] ; then
                install -m0644 "${x}" "${dir}"
-               ecompress "${dir}/${x##*/}"
+               ecompress --queue "${dir}/${x##*/}"
        elif [ ! -e "${x}" ] ; then
                echo "dodoc: ${x} does not exist" 1>&2
                ((++ret))
index f80e6e28ba3b7c1ccb23312b2c4f809aee9c91ad..49db5f48ee0736e01d56b86348a31df80aad1a46 100755 (executable)
@@ -16,12 +16,14 @@ PORTAGE_COMPRESS=${PORTAGE_COMPRESS-bzip2}
 
 if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then
        case ${PORTAGE_COMPRESS} in
-               bzip2|gzip)  PORTAGE_COMPRESS_FLAGS="-f9";;
+               bzip2|gzip)  PORTAGE_COMPRESS_FLAGS="-9";;
        esac
 fi
 
 case $1 in
        --suffix)
+               [[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
+
                set -e
                tmpdir="${T}"/.ecompress$$.${RANDOM}
                mkdir "${tmpdir}"
@@ -38,9 +40,32 @@ case $1 in
                echo "${suffix}"
                ;;
        --bin)
+               [[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2
+
                echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"
                ;;
+       --queue)
+               shift
+               exec touch "${@/%/.ecompress.file}"
+               ;;
+       --dequeue)
+               [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
+               find "${ED}" -name '*.ecompress.file' -print0 \
+                       | sed -e 's:\.ecompress\.file::g' \
+                       | ${XARGS} -0 ecompress
+               find "${ED}" -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f
+               ;;
+       --*)
+               vecho "${0##*/}: unknown arguments '$*'" 1>&2
+               exit 1
+               ;;
        *)
+               # If a compressed version of the file already exists, simply
+               # delete it so that the compressor doesn't whine (bzip2 will
+               # complain and skip, gzip will prompt for input)
+               suffix=$(ecompress --suffix)
+               [[ -n ${suffix} ]] && rm -f "${@/%/${suffix}}"
+               # Finally, let's actually do some real work
                exec "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
                ;;
 esac
index 0c2e0a5d1aec8d59675bd4a401721e5890acab8f..1bffed950ab4572c6ba3eed5edf9fd812e2572e5 100755 (executable)
@@ -10,6 +10,34 @@ if [[ -z $1 ]] ; then
        exit 1
 fi
 
+case $1 in
+       --ignore)
+               shift
+               for skip in "$@" ; do
+                       [[ -d ${ED}${skip} ]] && touch "${ED}${skip}.ecompress.skip"
+               done
+               exit 0
+               ;;
+       --queue)
+               shift
+               set -- "${@/%/.ecompress.dir}"
+               set -- "${@/#/${ED}}"
+               exec touch "$@"
+               ;;
+       --dequeue)
+               [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
+               find "${ED}" -name '*.ecompress.dir' -print0 \
+                       | sed -e 's:\.ecompress\.dir::g' -e "s:${ED}:/:g" \
+                       | ${XARGS} -0 ecompressdir
+               find "${ED}" -name '*.ecompress.skip' -print0 | ${XARGS} -0 rm -f
+               exit 0
+               ;;
+       --*)
+               vecho "${0##*/}: unknown arguments '$*'"
+               exit 1
+               ;;
+esac
+
 # figure out the new suffix
 suffix=$(ecompress --suffix)
 
@@ -43,8 +71,31 @@ funk_up_dir() {
        done
 }
 
+# _relocate_skip_dirs(srctree, dsttree)
+# Move all the directories we want to skip running compression
+# on from srctree to dsttree.
+_relocate_skip_dirs() {
+       local srctree="$1" dsttree="$2"
+
+       [[ -d ${srctree} ]] || return 0
+
+       find "${srctree}" -name '*.ecompress.skip' -print0 | \
+       while read -d $'\0' src ; do
+               src=${src%.ecompress.skip}
+               dst="${dsttree}${src#${srctree}}"
+               parent=${dst%/*}
+               mkdir -p "${parent}"
+               mv "${src}" "${dst}"
+               mv "${src}.ecompress.skip" "${dst}.ecompress.skip"
+       done
+}
+hide_skip_dirs()    { _relocate_skip_dirs "${ED}" "${T}"/ecompress-skip/ ; }
+restore_skip_dirs() { _relocate_skip_dirs "${T}"/ecompress-skip/ "${ED}" ; }
+
 ret=0
 
+rm -rf "${T}"/ecompress-skip
+
 for dir in "$@" ; do
        dir="${ED}${dir}"
        if [[ ! -d ${dir} ]] ; then
@@ -52,15 +103,30 @@ for dir in "$@" ; do
                continue
        fi
 
+       # hide all the stuff we want to skip
+       hide_skip_dirs "${dir}"
+
+       # since we've been requested to compress the whole dir,
+       # delete any individual queued requests
+       rm -f "${dir}.ecompress.dir"
+       find "${dir}" -type f -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f
+
        # not uncommon for packages to compress doc files themselves
        funk_up_dir "decompress" "Z" "gunzip"
        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}}"
        funk_up_dir "compress" "${suffix}" "ecompress"
+
+       # finally, restore the skipped stuff
+       restore_skip_dirs
 done
 
 exit ${ret}
index 1f756f0d3a31a0cc3b95b5625b991e5e0227f215..c687f09b4718e97eb623c8cd71cfa4bfc9f62d9d 100755 (executable)
@@ -1,5 +1,5 @@
 #!@BASH@
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: prepall 2230 2005-11-01 01:35:59Z vapier $
 
@@ -15,6 +15,9 @@ prepallman
 prepallinfo
 prepallstrip
 
+ecompressdir --dequeue
+ecompress --dequeue
+
 if type -p chflags &>/dev/null && type -p mtree &>/dev/null; then
        # Restore all the file flags that were saved at the beginning of prepall.
        mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
index cb75fc44356d60fb2850cd7b1a0dd875a1286467..eea839631f458a58251208bcc1cc4a3eb8b36b5f 100755 (executable)
@@ -10,16 +10,5 @@ fi
 cd "${ED}"
 [[ -d usr/share/doc ]] || exit 0
 
-# we dont want to compress the html subdir
-if [[ -d ${ED}usr/share/doc/${PF}/html ]] ; then
-       mv "${ED}"usr/share/doc/${PF}/html "${T}"/ecompressdir-html-backup || exit 1
-fi
-
-ecompressdir /usr/share/doc
-ret=$?
-
-if [[ -d ${T}/ecompressdir-html-backup ]] ; then
-       mv "${T}"/ecompressdir-html-backup "${ED}"/usr/share/doc/${PF}/html
-fi
-
-exit ${ret}
+ecompressdir --ignore /usr/share/doc/${PF}/html
+ecompressdir --queue /usr/share/doc