redo compression so that it is queued up in src_install and then dequeued post src_in...
authorMike Frysinger <vapier@gentoo.org>
Sat, 17 Mar 2007 02:08:23 +0000 (02:08 -0000)
committerMike Frysinger <vapier@gentoo.org>
Sat, 17 Mar 2007 02:08:23 +0000 (02:08 -0000)
svn path=/main/trunk/; revision=6220

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

index 4139cb593b3e218a0ced3649f6a9a29aabb20964..4a89aa061a9a47ce71aa6f24a1c8c188c8900076 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 7e51e3c44622077a61b8a18353785543c9ae18ba..de01cfdec7d4a12181ee860938d67fc2cef87f2d 100755 (executable)
@@ -22,6 +22,8 @@ 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,8 +40,25 @@ 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 "${D}" -name '*.ecompress.file' -print0 \
+                       | sed -e 's:\.ecompress\.file::g' \
+                       | ${XARGS} -0 ecompress
+               find "${D}" -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
index cad0ce26c0c454079e8dc56b42cf5aa5044ae85e..50e8ec7a60ba9bc0979b39f56710958f4bdc9542 100755 (executable)
@@ -10,6 +10,34 @@ if [[ -z $1 ]] ; then
        exit 1
 fi
 
+case $1 in
+       --ignore)
+               shift
+               for skip in "$@" ; do
+                       [[ -d ${D}${skip} ]] && touch "${D}${skip}.ecompress.skip"
+               done
+               exit 0
+               ;;
+       --queue)
+               shift
+               set -- "${@/%/.ecompress.dir}"
+               set -- "${@/#/${D}}"
+               exec touch "$@"
+               ;;
+       --dequeue)
+               [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
+               find "${D}" -name '*.ecompress.dir' -print0 \
+                       | sed -e 's:\.ecompress\.dir::g' -e "s:${D}:/:g" \
+                       | ${XARGS} -0 ecompressdir
+               find "${D}" -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,32 @@ funk_up_dir() {
        done
 }
 
+# _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
+               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 "${D}" "${T}"/ecompress-skip/ ; }
+restore_skip_dirs() { _relocate_skip_dirs "${T}"/ecompress-skip/ "${D}" ; }
+
 ret=0
 
+rm -rf "${T}"/ecompress-skip
+
 for dir in "$@" ; do
        dir="${D}${dir}"
        if [[ ! -d ${dir} ]] ; then
@@ -52,6 +104,14 @@ 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"
@@ -61,6 +121,9 @@ for dir in "$@" ; do
        [[ -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 3ab8215730e7bbeeedbc0f73cbf3268d0b91f7c4..a192db545ebedf31a54663c6e0aeaafc97c9d866 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -17,6 +17,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 "${D}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
index e188329d61eff38fe340c9afb9e1ac2767658cb8..cd1328e5f088c328005ac17cab7144b360c097af 100755 (executable)
@@ -10,16 +10,5 @@ fi
 cd "${D}"
 [[ -d usr/share/doc ]] || exit 0
 
-# we dont want to compress the html subdir
-if [[ -d ${D}usr/share/doc/${PF}/html ]] ; then
-       mv "${D}"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 "${D}"/usr/share/doc/${PF}/html
-fi
-
-exit ${ret}
+ecompressdir --ignore /usr/share/doc/${PF}/html
+ecompressdir --queue /usr/share/doc