add support for user-customizable compression #9870
authorMike Frysinger <vapier@gentoo.org>
Thu, 11 Jan 2007 18:50:51 +0000 (18:50 -0000)
committerMike Frysinger <vapier@gentoo.org>
Thu, 11 Jan 2007 18:50:51 +0000 (18:50 -0000)
svn path=/main/trunk/; revision=5555

bin/dodoc
bin/doinfo
bin/ecompress [new file with mode: 0755]
bin/ecompressdir [new file with mode: 0755]
bin/misc-functions.sh
bin/prepalldocs
bin/prepallinfo
bin/prepallman
bin/prepinfo
bin/prepman

index 60b6a274f9af0c95a932e891f5b512a7af7f1050..4139cb593b3e218a0ced3649f6a9a29aabb20964 100755 (executable)
--- a/bin/dodoc
+++ b/bin/dodoc
@@ -1,9 +1,10 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
+# $Id$
 
 if [ $# -lt 1 ] ; then
-       echo "$0: at least one argument needed" 1>&2
+       vecho "${0##*/}: at least one argument needed" 1>&2
        exit 1  
 fi
 
@@ -16,7 +17,7 @@ ret=0
 for x in "$@" ; do
        if [ -s "${x}" ] ; then
                install -m0644 "${x}" "${dir}"
-               gzip -f -9 "${dir}/${x##*/}"
+               ecompress "${dir}/${x##*/}"
        elif [ ! -e "${x}" ] ; then
                echo "dodoc: ${x} does not exist" 1>&2
                ((++ret))
index 82db070b80295a65365f8389ff91e492896d9a2a..7e1dd30ca8736aa6b3c3807afff931522926340a 100755 (executable)
@@ -1,21 +1,15 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-if [ ${#} -lt 1 ] ; then
-       echo "doinfo: at least one argument needed"
+if [[ -z $1 ]] ; then
+       vecho "${0##*/}: at least one argument needed"
        exit 1  
 fi
-if [ ! -d "${D}usr/share/info" ] ; then
-       install -d "${D}usr/share/info"
+
+if [[ ! -d ${D}usr/share/info ]] ; then
+       install -d "${D}usr/share/info" || exit 1
 fi
 
-for x in "$@" ; do
-       if [ -e "${x}" ] ; then
-               install -m0644 "${x}" "${D}usr/share/info"
-               gzip -f -9 "${D}usr/share/info/${x##*/}"
-       else
-               echo "doinfo: ${x} does not exist"
-       fi
-done
+exec install -m0644 "$@" "${D}usr/share/info"
diff --git a/bin/ecompress b/bin/ecompress
new file mode 100755 (executable)
index 0000000..9117217
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: prepman 5507 2007-01-10 04:22:27Z zmedico $
+
+if [[ -z $1 ]] ; then
+       echo "${0##*/}: at least one argument needed" 1>&2
+       exit 1
+fi
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+# setup compression stuff
+PORTAGE_COMPRESS=${PORTAGE_COMPRESS:-bzip2}
+if [[ -z ${PORTAGE_COMPRESS_FLAGS} ]] ; then
+       case ${PORTAGE_COMPRESS} in
+               bzip2|gzip)  PORTAGE_COMPRESS_FLAGS="-9";;
+       esac
+fi
+
+case $1 in
+       --suffix)
+               set -e
+               tmpdir="${T}"/.ecompress$$.${RANDOM}
+               mkdir "${tmpdir}"
+               cd "${tmpdir}"
+               # we have to fill the file enough so that there is something
+               # to compress as some programs will refuse to do compression
+               # if it cannot actually compress the file
+               echo {0..1000} > compressme
+               ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme
+               suffix=$(ls compressme*)
+               suffix=${suffix#compressme}
+               cd /
+               rm -rf "${tmpdir}"
+               echo "${suffix}"
+               ;;
+       --bin)
+               echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"
+               ;;
+       *)
+               exec "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
+               ;;
+esac
diff --git a/bin/ecompressdir b/bin/ecompressdir
new file mode 100755 (executable)
index 0000000..405f8e2
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: prepalldocs 3483 2006-06-10 21:40:40Z genone $
+
+if [[ -z $1 ]] ; then
+       echo "${0##*/}: at least one argument needed" 1>&2
+       exit 1
+fi
+
+# figure out the new suffix
+suffix=$(ecompress --suffix)
+[[ -z ${suffix} ]] && exit 0
+
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+ret=0
+
+for dir in "$@" ; do
+       dir="${D}${dir}"
+       if [[ ! -d ${dir} ]] ; then
+               vecho "${0##*/}: ${dir#${D}} does not exist!"
+               continue
+       else
+               vecho "${0##*/}: $(ecompress --bin) ${dir#${D}}"
+       fi
+
+       find "${dir}" -type f -print0 | xargs -0 ecompress
+       ((ret+=$?))
+       find -L "${dir}" -type l | \
+       while read brokenlink ; do
+               olddest=$(readlink "${brokenlink}")
+               newdest="${olddest}${suffix}"
+               if [[ -e ${newdest} ]] ; then
+                       ln -snf "${newdest}" "${brokenlink}"
+                       ((ret+=$?))
+               else
+                       vecho "ecompressdir: unknown broken symlink: ${brokenlink}"
+                       ((++ret))
+               fi
+       done
+done
+
+exit ${ret}
index 55428862146f62b12c07c56304e1462577349220..001fcffd19a29a29933cf09241c6cf2323e5c101 100755 (executable)
@@ -340,9 +340,7 @@ install_qa_check() {
        fi
 
        # Portage regenerates this on the installed system.
-       if [[ -f ${D}/usr/share/info/dir.gz ]] ; then
-               rm -f "${D}"/usr/share/info/dir.gz
-       fi
+       rm -f "${D}"/usr/share/info/dir{,.gz,.bz2}
 
        if hasq multilib-strict ${FEATURES} && \
           [[ -x /usr/bin/file && -x /usr/bin/find ]] && \
index 8d585d2363e1eddc126173f4a656967a319e3d8c..758b134d69192c19d449c961325738b3c4e1cb2b 100755 (executable)
@@ -1,35 +1,25 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+if [[ -n $1 ]] ; then
+       vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
+fi
 
-z="$(find "${D}"usr/share/doc \( -type f -or -type l \) -not -name "*.gz" -not -name "*.js" 2>/dev/null)"
+cd "${D}"
+[[ -d usr/share/doc ]] || exit 0
 
-for y in ${z} ; do
-       if [ -L "${y}" ] ; then
-               # Symlink ...
-               mylink="${y}"
-               linkto="$(readlink "${y}")"
+# 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
 
-               if [ "${linkto##*.}" != "gz" ] ; then
-                       linkto="${linkto}.gz"
-               fi
-               if [ "${mylink##*.}" != "gz" ] ; then
-                       mylink="${mylink}.gz"
-               fi
+ecompressdir /usr/share/doc
+ret=$?
 
-               vecho "fixing doc symlink: ${mylink##*/}"
-               ln -snf "${linkto}" "${mylink}"
-               if [ "${y}" != "${mylink}" ] ; then
-                       vecho "removing old symlink: ${y##*/}"
-                       rm -f "${y}"
-               fi
-       else
-               if [ "${y##*.}" != "gz" ] ; then
-                       vecho "gzipping doc: ${y##*/}"
-                       gzip -f -9 "${y}"
-               fi
-       fi      
-done
+if [[ -d ${T}/ecompressdir-html-backup ]] ; then
+       mv "${T}"/html "${D}"/usr/share/doc/${PF}/html
+fi
+
+exit ${ret}
index f0ed4f3371214b3f7578fab08102a2a6a9b5e36c..af95bbfce7cb77904ad1d418996bad0452fc8fa9 100755 (executable)
@@ -7,5 +7,4 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 [[ ! -d ${D}usr/share/info ]] && exit 0
 
-vecho "info:"
 exec prepinfo
index e89ad7af0c7b68233ccca47c8767ad0b34374f43..747ed1fac511bc3a22921254e08e0545bf78691a 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$
 
@@ -7,14 +7,11 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 ret=0
 
-vecho "man:"
-for x in "${D}"opt/*/man "${D}"usr/share/man "${D}"usr/local/man "${D}"usr/X11R6/man ; do
-       if [[ -d ${x} ]] ; then
-               x=${x#${D}}
-               x=${x%/man}
-               prepman "${x}"
-               ((ret+=$?))
-       fi
-done
+find "${D}" -type d -name man > "${T}"/prepallman.filelist
+while read mandir ; do
+       mandir=${mandir#${D}}
+       prepman "${mandir%/man}"
+       ((ret+=$?))
+done < "${T}"/prepallman.filelist
 
 exit ${ret}
index d624561c70de78715d0a10fb3256dee75f7ab173..2d3c80e0889bc162ee4941cd713307c716e7dde4 100755 (executable)
@@ -1,47 +1,29 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
-if [ -z "$1" ] ; then
-       z="${D}usr/share/info"
+if [[ -z $1 ]] ; then
+       infodir="/usr/share/info"
 else
-       if [ -d "${D}$1/share/info" ] ; then
-               z="${D}$1/share/info"
+       if [[ -d ${D}$1/share/info ]] ; then
+               infodir="$1/share/info"
        else
-               z="${D}$1/info"
+               infodir="$1/info"
        fi
 fi
 
-[ ! -d "${z}" ] && exit 0
-
-rm -f "${z}"/{dir,dir.info,dir.info.gz}
-
-for x in $(find "${z}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) 2>/dev/null) ; do
-       if [ -L "${x}" ] ; then
-               # Symlink ...
-               mylink="${x}"
-               linkto="$(readlink "${x}")"
-
-               if [ "${linkto##*.}" != "gz" ] ; then
-                       linkto="${linkto}.gz"
-               fi
-               if [ "${mylink##*.}" != "gz" ] ; then
-                       mylink="${mylink}.gz"
-               fi
-
-               vecho "fixing GNU info symlink: ${mylink##*/}"
-               ln -snf "${linkto}" "${mylink}"
-               if [ "${x}" != "${mylink}" ] ; then
-                       vecho "removing old symlink: ${x##*/}"
-                       rm -f "${x}"
-               fi
+if [[ ! -d ${D}${infodir} ]] ; then
+       if [[ -n $1 ]] ; then
+               vecho "${0##*/}: '${infodir}' does not exist!"
+               exit 1
        else
-               if [ "${x##*.}" != "gz" ] ; then
-                       vecho "gzipping GNU info page: ${x##*/}"
-                       gzip -f -9 "${x}"
-               fi
+               exit 0
        fi
-done
+fi
+
+rm -f "${D}${infodir}"/dir{,.info}{,.gz,.bz2}
+
+exec ecompressdir "${infodir}"
index beccec8ffb23cd05a327882f888bc1ae7004057b..65144a437bd46f2d4c7d42e2df0593b5bc739710 100755 (executable)
@@ -1,51 +1,30 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 if [[ -z $1 ]] ; then 
-       z="${D}usr/share/man"
+       mandir="${D}usr/share/man"
 else
-       z="${D}$1/man"
+       mandir="${D}$1/man"
 fi
 
-if [[ ! -d ${z} ]] ; then
-       eqawarn "QA Notice: prepman called with non-existent dir '${z#${D}}'"
+if [[ ! -d ${mandir} ]] ; then
+       eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${D}}'"
        exit 0
 fi
 
-for x in $(find "${z}"/ -type d 2>/dev/null) ; do
-       for y in $(find "${x}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) ! -name '.keep_*' 2>/dev/null) ; do
-               if [[ -L ${y} ]] ; then
-                       # Symlink ...
-                       mylink=${y}
-                       linkto=$(readlink "${y}")
-                       
-                       # Do NOT change links to directories
-                       if [[ -d ${z}/${linkto} ]] ; then
-                               continue
-                       fi
+shopt -s nullglob
 
-                       if [[ ${linkto##*.} != "gz" ]] && [[ ${linkto##*.} != "bz2" ]] ; then
-                               linkto="${linkto}.gz"
-                       fi
-                       if [[ ${mylink##*.} != "gz" ]] && [[ ${mylink##*.} != "bz2" ]] ; then
-                               mylink="${mylink}.gz"
-                       fi
+ret=0
 
-                       vecho "fixing man page symlink: ${mylink##*/}"
-                       ln -snf "${linkto}" "${mylink}"
-                       if [[ ${y} != "${mylink}" ]] ; then
-                               vecho "removing old symlink: ${y##*/}"
-                               rm -f "${y}"
-                       fi
-               else
-                       if [[ ${y##*.} != "gz" ]] && [[ ${y##*.} != "bz2" ]] && [[ ! -d ${y} ]] ; then
-                               vecho "gzipping man page: ${y##*/}"
-                               gzip -f -9 "${y}"
-                       fi
-               fi      
-       done
+# compress and fixup links in each dir
+for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do
+       [[ -d ${subdir} ]] || continue # ignore files named 'man*'
+       ecompressdir "/${subdir#${D}}"
+       ((ret+=$?))
 done
+
+exit ${ret}