initial import
[patches.git] / portage-ecompress.patch
CommitLineData
5e993f12 1Index: dodoc
2===================================================================
3--- dodoc (revision 5536)
4+++ dodoc (working copy)
5@@ -1,9 +1,10 @@
6 #!/bin/bash
7-# Copyright 1999-2006 Gentoo Foundation
8+# Copyright 1999-2007 Gentoo Foundation
9 # Distributed under the terms of the GNU General Public License v2
10+# $Id$
11
12 if [ $# -lt 1 ] ; then
13- echo "$0: at least one argument needed" 1>&2
14+ vecho "${0##*/}: at least one argument needed" 1>&2
15 exit 1
16 fi
17
18@@ -16,7 +17,7 @@ ret=0
19 for x in "$@" ; do
20 if [ -s "${x}" ] ; then
21 install -m0644 "${x}" "${dir}"
22- gzip -f -9 "${dir}/${x##*/}"
23+ ecompress "${dir}/${x##*/}"
24 elif [ ! -e "${x}" ] ; then
25 echo "dodoc: ${x} does not exist" 1>&2
26 ((++ret))
27Index: prepallman
28===================================================================
29--- prepallman (revision 5536)
30+++ prepallman (working copy)
31@@ -1,5 +1,5 @@
32 #!/bin/bash
33-# Copyright 1999-2006 Gentoo Foundation
34+# Copyright 1999-2007 Gentoo Foundation
35 # Distributed under the terms of the GNU General Public License v2
36 # $Id$
37
38@@ -7,14 +7,11 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/por
39
40 ret=0
41
42-vecho "man:"
43-for x in "${D}"opt/*/man "${D}"usr/share/man "${D}"usr/local/man "${D}"usr/X11R6/man ; do
44- if [[ -d ${x} ]] ; then
45- x=${x#${D}}
46- x=${x%/man}
47- prepman "${x}"
48- ((ret+=$?))
49- fi
50-done
51+find "${D}" -type d -name man > "${T}"/prepallman.filelist
52+while read mandir ; do
53+ mandir=${mandir#${D}}
54+ prepman "${mandir%/man}"
55+ ((ret+=$?))
56+done < "${T}"/prepallman.filelist
57
58 exit ${ret}
59Index: prepman
60===================================================================
61--- prepman (revision 5536)
62+++ prepman (working copy)
63@@ -1,51 +1,33 @@
64 #!/bin/bash
65-# Copyright 1999-2006 Gentoo Foundation
66+# Copyright 1999-2007 Gentoo Foundation
67 # Distributed under the terms of the GNU General Public License v2
68 # $Id$
69
70 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
71
72 if [[ -z $1 ]] ; then
73- z="${D}usr/share/man"
74+ mandir="${D}usr/share/man"
75 else
76- z="${D}$1/man"
77+ mandir="${D}$1/man"
78 fi
79
80-if [[ ! -d ${z} ]] ; then
81- eqawarn "QA Notice: prepman called with non-existent dir '${z#${D}}'"
82+if [[ ! -d ${mandir} ]] ; then
83+ eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${D}}'"
84 exit 0
85 fi
86
87-for x in $(find "${z}"/ -type d 2>/dev/null) ; do
88- for y in $(find "${x}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) ! -name '.keep_*' 2>/dev/null) ; do
89- if [[ -L ${y} ]] ; then
90- # Symlink ...
91- mylink=${y}
92- linkto=$(readlink "${y}")
93-
94- # Do NOT change links to directories
95- if [[ -d ${z}/${linkto} ]] ; then
96- continue
97- fi
98-
99- if [[ ${linkto##*.} != "gz" ]] && [[ ${linkto##*.} != "bz2" ]] ; then
100- linkto="${linkto}.gz"
101- fi
102- if [[ ${mylink##*.} != "gz" ]] && [[ ${mylink##*.} != "bz2" ]] ; then
103- mylink="${mylink}.gz"
104- fi
105-
106- vecho "fixing man page symlink: ${mylink##*/}"
107- ln -snf "${linkto}" "${mylink}"
108- if [[ ${y} != "${mylink}" ]] ; then
109- vecho "removing old symlink: ${y##*/}"
110- rm -f "${y}"
111- fi
112- else
113- if [[ ${y##*.} != "gz" ]] && [[ ${y##*.} != "bz2" ]] && [[ ! -d ${y} ]] ; then
114- vecho "gzipping man page: ${y##*/}"
115- gzip -f -9 "${y}"
116- fi
117- fi
118- done
119+shopt -s nullglob
120+
121+# figure out the new suffix
122+suffix=$(ecompress --suffix)
123+[[ -z ${suffix} ]] && exit 0
124+
125+ret=0
126+
127+# compress and fixup links in each dir
128+for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do
129+ ecompressdir "${subdir#${D}}"
130+ ((ret+=$?))
131 done
132+
133+exit ${ret}
134Index: misc-functions.sh
135===================================================================
136--- misc-functions.sh (revision 5536)
137+++ misc-functions.sh (working copy)
138@@ -340,9 +340,7 @@ install_qa_check() {
139 fi
140
141 # Portage regenerates this on the installed system.
142- if [[ -f ${D}/usr/share/info/dir.gz ]] ; then
143- rm -f "${D}"/usr/share/info/dir.gz
144- fi
145+ rm -f "${D}"/usr/share/info/dir{,.gz,.bz2}
146
147 if hasq multilib-strict ${FEATURES} && \
148 [[ -x /usr/bin/file && -x /usr/bin/find ]] && \
149Index: doinfo
150===================================================================
151--- doinfo (revision 5536)
152+++ doinfo (working copy)
153@@ -1,10 +1,10 @@
154 #!/bin/bash
155-# Copyright 1999-2006 Gentoo Foundation
156+# Copyright 1999-2007 Gentoo Foundation
157 # Distributed under the terms of the GNU General Public License v2
158 # $Id$
159
160 if [ ${#} -lt 1 ] ; then
161- echo "doinfo: at least one argument needed"
162+ vecho "${0##*/}: at least one argument needed"
163 exit 1
164 fi
165 if [ ! -d "${D}usr/share/info" ] ; then
166@@ -14,7 +14,7 @@ fi
167 for x in "$@" ; do
168 if [ -e "${x}" ] ; then
169 install -m0644 "${x}" "${D}usr/share/info"
170- gzip -f -9 "${D}usr/share/info/${x##*/}"
171+ ecompress "${D}usr/share/info/${x##*/}"
172 else
173 echo "doinfo: ${x} does not exist"
174 fi
175Index: prepinfo
176===================================================================
177--- prepinfo (revision 5536)
178+++ prepinfo (working copy)
179@@ -1,47 +1,22 @@
180 #!/bin/bash
181-# Copyright 1999-2006 Gentoo Foundation
182+# Copyright 1999-2007 Gentoo Foundation
183 # Distributed under the terms of the GNU General Public License v2
184 # $Id$
185
186 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
187
188-if [ -z "$1" ] ; then
189- z="${D}usr/share/info"
190+if [[ -z $1 ]] ; then
191+ infodir=="${D}usr/share/info"
192 else
193- if [ -d "${D}$1/share/info" ] ; then
194- z="${D}$1/share/info"
195+ if [[ -d ${D}$1/share/info ]] ; then
196+ infodir="${D}$1/share/info"
197 else
198- z="${D}$1/info"
199+ infodir="${D}$1/info"
200 fi
201 fi
202
203-[ ! -d "${z}" ] && exit 0
204+[[ ! -d ${infodir} ]] && exit 0
205
206-rm -f "${z}"/{dir,dir.info,dir.info.gz}
207+rm -f "${infodir}"/dir{,.info}{,.gz,.bz2}
208
209-for x in $(find "${z}"/ -mindepth 1 -maxdepth 1 \( -type f -or -type l \) 2>/dev/null) ; do
210- if [ -L "${x}" ] ; then
211- # Symlink ...
212- mylink="${x}"
213- linkto="$(readlink "${x}")"
214-
215- if [ "${linkto##*.}" != "gz" ] ; then
216- linkto="${linkto}.gz"
217- fi
218- if [ "${mylink##*.}" != "gz" ] ; then
219- mylink="${mylink}.gz"
220- fi
221-
222- vecho "fixing GNU info symlink: ${mylink##*/}"
223- ln -snf "${linkto}" "${mylink}"
224- if [ "${x}" != "${mylink}" ] ; then
225- vecho "removing old symlink: ${x##*/}"
226- rm -f "${x}"
227- fi
228- else
229- if [ "${x##*.}" != "gz" ] ; then
230- vecho "gzipping GNU info page: ${x##*/}"
231- gzip -f -9 "${x}"
232- fi
233- fi
234-done
235+exec ecompressdir "${infodir}"
236Index: ecompress
237===================================================================
238--- ecompress (revision 0)
239+++ ecompress (revision 0)
240@@ -0,0 +1,38 @@
241+#!/bin/bash
242+# Copyright 1999-2007 Gentoo Foundation
243+# Distributed under the terms of the GNU General Public License v2
244+# $Id: prepman 5507 2007-01-10 04:22:27Z zmedico $
245+
246+if [[ -z $1 ]] ; then
247+ echo "${0##*/}: at least one argument needed" 1>&2
248+ exit 1
249+fi
250+
251+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
252+
253+# setup compression stuff
254+PORTAGE_COMPRESS=${PORTAGE_COMPRESS:-bzip2}
255+if [[ -z ${PORTAGE_COMPRESS_FLAGS} ]] ; then
256+ case ${PORTAGE_COMPRESS} in
257+ bzip2|gzip) PORTAGE_COMPRESS_FLAGS="-9";;
258+ esac
259+fi
260+
261+if [[ $1 == "--suffix" ]] ; then
262+ set -e
263+ tmpdir="${T}"/.ecompress$$.${RANDOM}
264+ mkdir "${tmpdir}"
265+ cd "${tmpdir}"
266+ # we have to fill the file enough so that there is something
267+ # to compress as some programs will refuse to do compression
268+ # if it cannot actually compress the file
269+ echo {0..1000} > compressme
270+ ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme
271+ suffix=$(ls compressme*)
272+ suffix=${suffix#compressme}
273+ cd /
274+ rm -rf "${tmpdir}"
275+ echo "${suffix}"
276+else
277+ exec "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
278+fi
279
280Property changes on: ecompress
281___________________________________________________________________
282Name: svn:executable
283 + *
284
285Index: prepalldocs
286===================================================================
287--- prepalldocs (revision 5536)
288+++ prepalldocs (working copy)
289@@ -1,35 +1,13 @@
290 #!/bin/bash
291-# Copyright 1999-2006 Gentoo Foundation
292+# Copyright 1999-2007 Gentoo Foundation
293 # Distributed under the terms of the GNU General Public License v2
294 # $Id$
295
296-source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
297+if [[ -n $1 ]] ; then
298+ vecho "${0##*/}: invalid usage; takes no arguments" 1>&2
299+fi
300
301-z="$(find "${D}"usr/share/doc \( -type f -or -type l \) -not -name "*.gz" -not -name "*.js" 2>/dev/null)"
302+cd "${D}"
303+[[ -d usr/share/doc ]] || exit 0
304
305-for y in ${z} ; do
306- if [ -L "${y}" ] ; then
307- # Symlink ...
308- mylink="${y}"
309- linkto="$(readlink "${y}")"
310-
311- if [ "${linkto##*.}" != "gz" ] ; then
312- linkto="${linkto}.gz"
313- fi
314- if [ "${mylink##*.}" != "gz" ] ; then
315- mylink="${mylink}.gz"
316- fi
317-
318- vecho "fixing doc symlink: ${mylink##*/}"
319- ln -snf "${linkto}" "${mylink}"
320- if [ "${y}" != "${mylink}" ] ; then
321- vecho "removing old symlink: ${y##*/}"
322- rm -f "${y}"
323- fi
324- else
325- if [ "${y##*.}" != "gz" ] ; then
326- vecho "gzipping doc: ${y##*/}"
327- gzip -f -9 "${y}"
328- fi
329- fi
330-done
331+exec ecompressdir "${D}"usr/share/doc
332Index: ecompressdir
333===================================================================
334--- ecompressdir (revision 0)
335+++ ecompressdir (revision 0)
336@@ -0,0 +1,44 @@
337+#!/bin/bash
338+# Copyright 1999-2007 Gentoo Foundation
339+# Distributed under the terms of the GNU General Public License v2
340+# $Id: prepalldocs 3483 2006-06-10 21:40:40Z genone $
341+
342+if [[ -z $1 ]] ; then
343+ echo "${0##*/}: at least one argument needed" 1>&2
344+ exit 1
345+fi
346+
347+# figure out the new suffix
348+suffix=$(ecompress --suffix)
349+[[ -z ${suffix} ]] && exit 0
350+
351+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
352+
353+ret=0
354+
355+for dir in "$@" ; do
356+ dir="${D}${dir}"
357+ if [[ ! -d ${dir} ]] ; then
358+ vecho "${0##*/}: ${dir#${D}} does not exist!"
359+ continue
360+ else
361+ vecho "${0##*/}: compressing ${dir#${D}}"
362+ fi
363+
364+ find "${dir}" -type f -print0 | xargs -0 ecompress
365+ ((ret+=$?))
366+ find -L "${dir}" -type l | \
367+ while read brokenlink ; do
368+ olddest=$(readlink "${brokenlink}")
369+ newdest="${olddest}${suffix}"
370+ if [[ -e ${newdest} ]] ; then
371+ ln -snf "${newdest}" "${brokenlink}"
372+ ((ret+=$?))
373+ else
374+ vecho "ecompressdir: unknown broken symlink: ${brokenlink}"
375+ ((++ret))
376+ fi
377+ done
378+done
379+
380+exit ${ret}
381
382Property changes on: ecompressdir
383___________________________________________________________________
384Name: svn:executable
385 + *
386