summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Mueller <ulm@gentoo.org>2010-08-28 09:20:23 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-28 16:12:11 -0700
commit59ea804b01cd711d4235e46e4cc4fdef8390d5fe (patch)
tree397852ab56ee19e7031b874cd335bf5a4bb02b46
parent87b1b094b789f414da007214bbd3f651671f084f (diff)
downloadportage-59ea804b01cd711d4235e46e4cc4fdef8390d5fe.tar.gz
portage-59ea804b01cd711d4235e46e4cc4fdef8390d5fe.tar.bz2
portage-59ea804b01cd711d4235e46e4cc4fdef8390d5fe.zip
Implement controllable compression and docompress, bug #273633.
-rwxr-xr-xbin/ebuild-helpers/dodoc2
-rwxr-xr-xbin/ebuild-helpers/ecompressdir5
-rwxr-xr-xbin/ebuild-helpers/prepalldocs5
-rwxr-xr-xbin/ebuild-helpers/prepallman3
-rwxr-xr-xbin/ebuild-helpers/prepinfo1
-rwxr-xr-xbin/ebuild-helpers/prepman3
-rwxr-xr-xbin/ebuild.sh28
-rw-r--r--bin/isolated-functions.sh2
-rwxr-xr-xbin/misc-functions.sh97
9 files changed, 142 insertions, 4 deletions
diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc
index 29b690112..99410ea85 100755
--- a/bin/ebuild-helpers/dodoc
+++ b/bin/ebuild-helpers/dodoc
@@ -18,7 +18,7 @@ ret=0
for x in "$@" ; do
if [ -s "${x}" ] ; then
install -m0644 "${x}" "${dir}"
- ecompress --queue "${dir}/${x##*/}"
+ hasq "${EAPI}" 0 1 2 3 && ecompress --queue "${dir}/${x##*/}"
elif [ ! -e "${x}" ] ; then
echo "!!! ${0##*/}: $x does not exist" 1>&2
((ret|=1))
diff --git a/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir
index 90c26f9d5..acdb1cd7f 100755
--- a/bin/ebuild-helpers/ecompressdir
+++ b/bin/ebuild-helpers/ecompressdir
@@ -13,7 +13,8 @@ case $1 in
--ignore)
shift
for skip in "$@" ; do
- [[ -d ${D}${skip} ]] && touch "${D}${skip}.ecompress.skip"
+ [[ -d ${D}${skip} || -f ${D}${skip} ]] \
+ && touch "${D}${skip}.ecompress.skip"
done
exit 0
;;
@@ -74,7 +75,7 @@ funk_up_dir() {
}
# _relocate_skip_dirs(srctree, dsttree)
-# Move all the directories we want to skip running compression
+# Move all files and directories we want to skip running compression
# on from srctree to dsttree.
_relocate_skip_dirs() {
local srctree="$1" dsttree="$2"
diff --git a/bin/ebuild-helpers/prepalldocs b/bin/ebuild-helpers/prepalldocs
index 6705f5e79..f7026c679 100755
--- a/bin/ebuild-helpers/prepalldocs
+++ b/bin/ebuild-helpers/prepalldocs
@@ -4,6 +4,11 @@
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+if ! hasq "${EAPI}" 0 1 2 3; then
+ eqawarn "QA Notice: Deprecated call to 'prepalldocs'"
+ exit 0
+fi
+
if [[ -n $1 ]] ; then
vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
fi
diff --git a/bin/ebuild-helpers/prepallman b/bin/ebuild-helpers/prepallman
index f41bcb816..71b79a0ef 100755
--- a/bin/ebuild-helpers/prepallman
+++ b/bin/ebuild-helpers/prepallman
@@ -4,6 +4,9 @@
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+# replaced by controllable compression in EAPI 4
+hasq "${EAPI}" 0 1 2 3 || exit 0
+
ret=0
find "${D}" -type d -name man > "${T}"/prepallman.filelist
diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo
index 1d8c7d1f0..cb39ab86c 100755
--- a/bin/ebuild-helpers/prepinfo
+++ b/bin/ebuild-helpers/prepinfo
@@ -27,4 +27,5 @@ find "${D}${infodir}" -type d -print0 | while read -d $'\0' x ; do
rm -f "${x}"/dir{,.info}{,.gz,.bz2}
done
+hasq "${EAPI}" 0 1 2 3 || exit 0
exec ecompressdir --queue "${infodir}"
diff --git a/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman
index cfbcdd41a..97f2fbf7e 100755
--- a/bin/ebuild-helpers/prepman
+++ b/bin/ebuild-helpers/prepman
@@ -15,6 +15,9 @@ if [[ ! -d ${mandir} ]] ; then
exit 0
fi
+# replaced by controllable compression in EAPI 4
+hasq "${EAPI}" 0 1 2 3 || exit 0
+
shopt -s nullglob
really_is_mandir=0
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index b2ac5b419..393c82ebd 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -303,6 +303,8 @@ export EXEOPTIONS="-m0755"
export LIBOPTIONS="-m0644"
export DIROPTIONS="-m0755"
export MOPREFIX=${PN}
+declare -a PORTAGE_DOCOMPRESS=( /usr/share/{doc,info,man} )
+declare -a PORTAGE_DOCOMPRESS_SKIP=( /usr/share/doc/${PF}/html )
# adds ".keep" files so that dirs aren't auto-cleaned
keepdir() {
@@ -860,6 +862,32 @@ libopts() {
hasq -s ${LIBOPTIONS} && die "Never call libopts() with -s"
}
+docompress() {
+ hasq "${EAPI}" 0 1 2 3 && die "'docompress' not supported in this EAPI"
+
+ local f g
+ if [[ $1 = "-x" ]]; then
+ shift
+ for f; do
+ f=$(strip_duplicate_slashes "${f}"); f=${f%/}
+ [[ ${f:0:1} = / ]] || f="/${f}"
+ for g in "${PORTAGE_DOCOMPRESS_SKIP[@]}"; do
+ [[ ${f} = ${g} ]] && continue 2
+ done
+ PORTAGE_DOCOMPRESS_SKIP[${#PORTAGE_DOCOMPRESS_SKIP[@]}]=${f}
+ done
+ else
+ for f; do
+ f=$(strip_duplicate_slashes "${f}"); f=${f%/}
+ [[ ${f:0:1} = / ]] || f="/${f}"
+ for g in "${PORTAGE_DOCOMPRESS[@]}"; do
+ [[ ${f} = ${g} ]] && continue 2
+ done
+ PORTAGE_DOCOMPRESS[${#PORTAGE_DOCOMPRESS[@]}]=${f}
+ done
+ fi
+}
+
abort_handler() {
local msg
if [ "$2" != "fail" ]; then
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 3df18b53c..cd1039b07 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -572,7 +572,7 @@ save_ebuild_env() {
best_version use_with use_enable register_die_hook \
keepdir unpack strip_duplicate_slashes econf einstall \
dyn_setup dyn_unpack dyn_clean into insinto exeinto docinto \
- insopts diropts exeopts libopts \
+ insopts diropts exeopts libopts docompress \
abort_handler abort_prepare abort_configure abort_compile \
abort_test abort_install dyn_prepare dyn_configure \
dyn_compile dyn_test dyn_install \
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index d8754cd3a..50799976c 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -40,6 +40,102 @@ install_symlink_html_docs() {
fi
}
+# similar to readlink -f, but only expands symlinks up to the last
+# directory component of the path
+canonicalise_dir() {
+ local ret wd=$(pwd)
+ if [[ -d $1 ]]; then
+ cd -P "$1" 2>/dev/null && pwd -P
+ ret=$?
+ else
+ cd -P "${1%"${1##*/}"}" 2>/dev/null && echo "$(pwd -P)/${1##*/}"
+ ret=$?
+ fi
+ cd "${wd}"
+ return ${ret}
+}
+
+prepcompress() {
+ local -a include exclude incl_d incl_f
+ local f g i real_f real_d
+
+ # Canonicalise path names and check for their existence.
+ real_d=$(canonicalise_dir "${D}")
+ for (( i = 0; i < ${#PORTAGE_DOCOMPRESS[@]}; i++ )); do
+ real_f=$(canonicalise_dir "${D}${PORTAGE_DOCOMPRESS[i]}")
+ f=${real_f#"${real_d}"}
+ if [[ ${real_f} != "${f}" ]] && [[ -d ${real_f} || -f ${real_f} ]]
+ then
+ include[${#include[@]}]=${f:-/}
+ elif [[ ${i} -ge 3 ]]; then
+ ewarn "prepcompress:" \
+ "ignoring nonexistent path '${PORTAGE_DOCOMPRESS[i]}'"
+ fi
+ done
+ for (( i = 0; i < ${#PORTAGE_DOCOMPRESS_SKIP[@]}; i++ )); do
+ real_f=$(canonicalise_dir "${D}${PORTAGE_DOCOMPRESS_SKIP[i]}")
+ f=${real_f#"${real_d}"}
+ if [[ ${real_f} != "${f}" ]] && [[ -d ${real_f} || -f ${real_f} ]]
+ then
+ exclude[${#exclude[@]}]=${f:-/}
+ elif [[ ${i} -ge 1 ]]; then
+ ewarn "prepcompress:" \
+ "ignoring nonexistent path '${PORTAGE_DOCOMPRESS_SKIP[i]}'"
+ fi
+ done
+
+ # Remove redundant entries from lists.
+ # For the include list, remove any entries that are
+ # contained in a directory in the include or exclude lists.
+ for (( i = ${#include[@]} - 1; i >= 0; i-- )); do
+ f=${include[i]}
+ for g in "${include[@]}"; do
+ if [[ ${f} == "${g%/}"/* ]]; then
+ unset include[i]
+ continue 2
+ fi
+ done
+ for g in "${exclude[@]}"; do
+ if [[ ${f} = ${g} || ${f} == "${g%/}"/* ]]; then
+ unset include[i]
+ continue 2
+ fi
+ done
+ done
+ # For the exclude list, remove any entries that are:
+ # a) contained in a directory in the exclude list, or
+ # b) _not_ contained in a directory in the include list.
+ for (( i = ${#exclude[@]} - 1; i >= 0; i-- )); do
+ f=${exclude[i]}
+ for g in "${exclude[@]}"; do
+ if [[ ${f} == "${g%/}"/* ]]; then
+ unset exclude[i]
+ continue 2
+ fi
+ done
+ for g in "${include[@]}"; do
+ [[ ${f} == "${g%/}"/* ]] && continue 2
+ done
+ unset exclude[i]
+ done
+
+ # Split the include list into directories and files
+ for f in "${include[@]}"; do
+ if [[ -d ${D}${f} ]]; then
+ incl_d[${#incl_d[@]}]=${f}
+ else
+ incl_f[${#incl_f[@]}]=${f}
+ fi
+ done
+
+ # Queue up for compression.
+ # ecompress{,dir} doesn't like to be called with empty argument lists.
+ [[ ${#incl_d[@]} -gt 0 ]] && ecompressdir --queue "${incl_d[@]}"
+ [[ ${#incl_f[@]} -gt 0 ]] && ecompress --queue "${incl_f[@]/#/${D}}"
+ [[ ${#exclude[@]} -gt 0 ]] && ecompressdir --ignore "${exclude[@]}"
+ return 0
+}
+
install_qa_check() {
local f
@@ -47,6 +143,7 @@ install_qa_check() {
export STRIP_MASK
prepall
+ hasq "${EAPI}" 0 1 2 3 || prepcompress
ecompressdir --dequeue
ecompress --dequeue