From: Fabian Groffen Date: Sat, 17 Mar 2007 14:32:58 +0000 (-0000) Subject: Merged from trunk 6218:6221 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=e94a2db231dde91c13fecf561d719b934b0a2289;p=portage.git Merged from trunk 6218:6221 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 --- diff --git a/bin/dodoc b/bin/dodoc index b26a7659d..06fbfc055 100755 --- 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)) diff --git a/bin/ecompress b/bin/ecompress index f80e6e28b..49db5f48e 100755 --- a/bin/ecompress +++ b/bin/ecompress @@ -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 diff --git a/bin/ecompressdir b/bin/ecompressdir index 0c2e0a5d1..1bffed950 100755 --- a/bin/ecompressdir +++ b/bin/ecompressdir @@ -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} diff --git a/bin/prepall b/bin/prepall index 1f756f0d3..c687f09b4 100755 --- a/bin/prepall +++ b/bin/prepall @@ -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 diff --git a/bin/prepalldocs b/bin/prepalldocs index cb75fc443..eea839631 100755 --- a/bin/prepalldocs +++ b/bin/prepalldocs @@ -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