summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-01-11 18:50:51 +0000
committerMike Frysinger <vapier@gentoo.org>2007-01-11 18:50:51 +0000
commit71a41f72cc38e646ed2945f4c7b343a60247d968 (patch)
tree55ef76b63b008882005facc90084df255a80e4b5 /bin/ecompressdir
parentUse dict.get() to prevent a potential (bug unlikely) KeyError. (diff)
downloadportage-multirepo-71a41f72cc38e646ed2945f4c7b343a60247d968.tar.gz
portage-multirepo-71a41f72cc38e646ed2945f4c7b343a60247d968.tar.bz2
portage-multirepo-71a41f72cc38e646ed2945f4c7b343a60247d968.zip
add support for user-customizable compression #9870
svn path=/main/trunk/; revision=5555
Diffstat (limited to 'bin/ecompressdir')
-rwxr-xr-xbin/ecompressdir44
1 files changed, 44 insertions, 0 deletions
diff --git a/bin/ecompressdir b/bin/ecompressdir
new file mode 100755
index 00000000..405f8e2f
--- /dev/null
+++ b/bin/ecompressdir
@@ -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}