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))
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}"
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
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)
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
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}
#!@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 $
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
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