Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 273651 | Differences between
and this patch

Collapse All | Expand All

(-)a/bin/ebuild-helpers/4/dobin (+29 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [[ $# -lt 1 ]] ; then
8
	die "$0: at least one argument needed"
9
	exit 1
10
fi
11
12
if [[ ! -d ${D}${DESTTREE}/bin ]] ; then
13
	install -d "${D}${DESTTREE}/bin" || { die "$0 failed to install ${D}${DESTTREE}/bin"; exit 2; }
14
fi
15
16
ret=0
17
18
for x in "$@" ; do
19
	if [[ -e ${x} ]] ; then
20
		install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${D}${DESTTREE}/bin"
21
	else
22
		echo "!!! ${0##*/}: $x does not exist" 1>&2
23
		false
24
	fi
25
	((ret|=$?))
26
done
27
28
[[ $ret -ne 0 ]] && die "$0 failed"
29
exit ${ret}
(-)a/bin/ebuild-helpers/4/doconfd (+13 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ $# -lt 1 ]] ; then
6
	die "$0: at least one argument needed"
7
	exit 1
8
fi
9
10
exec \
11
env \
12
INSDESTTREE="/etc/conf.d/" \
13
doins "$@"
(-)a/bin/ebuild-helpers/4/dodir (+8 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
install -d ${DIROPTIONS} "${@/#/${D}/}"
6
ret=$?
7
[[ $ret -ne 0 ]] && die "$0 failed"
8
exit $?
(-)a/bin/ebuild-helpers/4/dodoc (-1 / +2 lines)
Lines 5-11 Link Here
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
6
7
if [ $# -lt 1 ] ; then
7
if [ $# -lt 1 ] ; then
8
	vecho "${0##*/}: at least one argument needed" 1>&2
8
	die "${0##*/}: at least one argument needed"
9
	exit 1
9
	exit 1
10
fi
10
fi
11
11
Lines 46-49 for x in "$@" ; do Link Here
46
46
47
done
47
done
48
48
49
[[ $ret -ne 0 ]] && die "$0 failed"
49
exit ${ret}
50
exit ${ret}
(-)a/bin/ebuild-helpers/4/doenvd (+13 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ $# -lt 1 ]] ; then
6
	die "$0: at least one argument needed"
7
	exit 1
8
fi
9
10
exec \
11
env \
12
INSDESTTREE="/etc/env.d/" \
13
doins "$@"
(-)a/bin/ebuild-helpers/4/doexe (+43 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2007 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [[ $# -lt 1 ]] ; then
8
	die "$0: at least one argument needed"
9
	exit 1
10
fi
11
12
if [[ ! -d ${D}${_E_EXEDESTTREE_} ]] ; then
13
	install -d "${D}${_E_EXEDESTTREE_}"
14
fi
15
16
TMP=$T/.doexe_tmp
17
mkdir "$TMP"
18
19
ret=0
20
21
for x in "$@" ; do
22
	if [ -L "${x}" ] ; then
23
		cp "$x" "$TMP"
24
		mysrc=$TMP/${x##*/}
25
	elif [ -d "${x}" ] ; then
26
		vecho "doexe: warning, skipping directory ${x}"
27
		continue
28
	else
29
		mysrc="${x}"
30
	fi
31
	if [ -e "$mysrc" ] ; then
32
		install $EXEOPTIONS "$mysrc" "$D$_E_EXEDESTTREE_"
33
	else
34
		echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
35
		false
36
	fi
37
	((ret|=$?))
38
done
39
40
rm -rf "$TMP"
41
42
[[ $ret -ne 0 ]] && die "$0 failed"
43
exit $ret
(-)a/bin/ebuild-helpers/4/dohtml (+14 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 2009 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}
6
PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}
7
# Set EPYTHON variable as empty so that dohtml doesn't try
8
# to use potentially unsupported version of Python.
9
EPYTHON= PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \
10
	"$PORTAGE_BIN_PATH/dohtml.py" "$@"
11
12
ret=$?
13
[[ $ret -ne 0 ]] && die "$0 failed"
14
exit $?
(-)a/bin/ebuild-helpers/4/doinfo (+24 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2010 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [[ -z $1 ]] ; then
8
	die "$0: at least one argument needed"
9
	exit 1
10
fi
11
12
if [[ ! -d ${D}usr/share/info ]] ; then
13
	install -d "${D}usr/share/info" || { die "$0: failed to install ${D}usr/share/info"; exit 1; }
14
fi
15
16
install -m0644 "$@" "${D}usr/share/info"
17
rval=$?
18
if [ $rval -ne 0 ] ; then
19
	for x in "$@" ; do
20
		[ -e "$x" ] || echo "!!! ${0##*/}: $x does not exist" 1>&2
21
	done
22
fi
23
[[ $rval -ne 0 ]] && die "$0 failed"
24
exit $rval
(-)a/bin/ebuild-helpers/4/doinitd (+13 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2007 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ $# -lt 1 ]] ; then
6
	die "$0: at least one argument needed"
7
	exit 1
8
fi
9
10
exec \
11
env \
12
_E_EXEDESTTREE_="/etc/init.d/" \
13
doexe "$@"
(-)a/bin/ebuild-helpers/4/doins (+130 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2009 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [ $# -lt 1 ] ; then
8
	die "${0##*/}: at least one argument needed"
9
	exit 1
10
fi
11
12
if [[ "$1" == "-r" ]] ; then
13
	DOINSRECUR=y
14
	shift
15
else
16
	DOINSRECUR=n
17
fi
18
19
if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then
20
	vecho "-------------------------------------------------------" 1>&2
21
	vecho "You should not use \${D} with helpers." 1>&2
22
	vecho "  --> ${INSDESTTREE}" 1>&2
23
	vecho "-------------------------------------------------------" 1>&2
24
	die "$0: \${D} used with helpers"
25
	exit 1
26
fi
27
28
case "$EAPI" in
29
	0|1|2|3|3_pre2)
30
		PRESERVE_SYMLINKS=n
31
		;;
32
	*)
33
		PRESERVE_SYMLINKS=y
34
		;;
35
esac
36
37
export TMP=$T/.doins_tmp
38
# Use separate directories to avoid potential name collisions.
39
mkdir -p "$TMP"/{1,2}
40
41
[[ ! -d ${D}${INSDESTTREE} ]] && dodir "${INSDESTTREE}"
42
43
_doins() {
44
	local mysrc="$1" mydir="$2" cleanup="" rval
45
46
	if [ -L "$mysrc" ] ; then
47
		if [ $PRESERVE_SYMLINKS = y ] ; then
48
			rm -rf "$D$INSDESTTREE/$mydir/${mysrc##*/}" || return $?
49
			cp -P "$mysrc" "$D$INSDESTTREE/$mydir/${mysrc##*/}"
50
			return $?
51
		else
52
			cp "$mysrc" "$TMP/2/${mysrc##*/}" || return $?
53
			mysrc="$TMP/2/${mysrc##*/}"
54
			cleanup=$mysrc
55
		fi
56
	fi
57
58
	install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}/${mydir}"
59
	rval=$?
60
	[[ -n ${cleanup} ]] && rm -f "${cleanup}"
61
	[ $rval -ne 0 ] && echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
62
	return $rval
63
}
64
65
_xdoins() {
66
	local -i failed=0
67
	while read -d $'\0' x ; do
68
		_doins "$x" "${x%/*}"
69
		((failed|=$?))
70
	done
71
	return $failed
72
}
73
74
success=0
75
failed=0
76
77
for x in "$@" ; do
78
	if [[ $PRESERVE_SYMLINKS = n && -d $x ]] || \
79
		[[ $PRESERVE_SYMLINKS = y && -d $x && ! -L $x ]] ; then
80
		if [ "${DOINSRECUR}" == "n" ] ; then
81
			continue
82
		fi
83
84
		while [ "$x" != "${x%/}" ] ; do
85
			x=${x%/}
86
		done
87
		if [ "$x" = "${x%/*}" ] ; then
88
			pushd "$PWD" >/dev/null
89
		else
90
			pushd "${x%/*}" >/dev/null
91
		fi
92
		x=${x##*/}
93
		x_orig=$x
94
		# Follow any symlinks recursively until we've got
95
		# a normal directory for 'find' to traverse.
96
		while [ -L "$x" ] ; do
97
			pushd "$(readlink "$x")" >/dev/null
98
			x=${PWD##*/}
99
			pushd "${PWD%/*}" >/dev/null
100
		done
101
		if [[ $x != $x_orig ]] ; then
102
			mv "$x" "$TMP/1/$x_orig"
103
			pushd "$TMP/1" >/dev/null
104
		fi
105
		find "$x_orig" -type d -exec dodir "${INSDESTTREE}/{}" \;
106
		find "$x_orig" \( -type f -or -type l \) -print0 | _xdoins
107
		if [[ ${PIPESTATUS[1]} -eq 0 ]] ; then
108
			# NOTE: Even if only an empty directory is installed here, it
109
			# still counts as success, since an empty directory given as
110
			# an argument to doins -r should not trigger failure.
111
			((success|=1))
112
		else
113
			((failed|=1))
114
		fi
115
		if [[ $x != $x_orig ]] ; then
116
			popd >/dev/null
117
			mv "$TMP/1/$x_orig" "$x"
118
		fi
119
		while popd >/dev/null 2>&1 ; do true ; done
120
	else
121
		_doins "${x}"
122
		if [[ $? -eq 0 ]] ; then
123
			((success|=1))
124
		else
125
			((failed|=1))
126
		fi
127
	fi
128
done
129
rm -rf "$TMP"
130
[[ $failed -ne 0 || $success -eq 0 ]] && { die "$0 failed"; exit 1; } || exit 0
(-)a/bin/ebuild-helpers/4/dolib (+41 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
# Setup ABI cruft
6
LIBDIR_VAR="LIBDIR_${ABI}"
7
if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
8
	CONF_LIBDIR=${!LIBDIR_VAR}
9
fi
10
unset LIBDIR_VAR
11
# we need this to default to lib so that things dont break
12
CONF_LIBDIR=${CONF_LIBDIR:-lib}
13
libdir="${D}${DESTTREE}/${CONF_LIBDIR}"
14
15
16
if [[ $# -lt 1 ]] ; then
17
	die "$0: at least one argument needed"
18
	exit 1
19
fi
20
if [[ ! -d ${libdir} ]] ; then
21
	install -d "${libdir}" || { die "$0 failed to install ${libdir}"; exit 1; }
22
fi
23
24
ret=0
25
26
for x in "$@" ; do
27
	if [[ -e ${x} ]] ; then
28
		if [[ ! -L ${x} ]] ; then
29
			install ${LIBOPTIONS} "${x}" "${libdir}"
30
		else
31
			ln -s "$(readlink "${x}")" "${libdir}/${x##*/}"
32
		fi
33
	else
34
		echo "!!! ${0##*/}: ${x} does not exist" 1>&2
35
		false
36
	fi
37
	((ret|=$?))
38
done
39
40
[[ $ret -ne 0 ]] && die "$0 failed"
41
exit ${ret}
(-)a/bin/ebuild-helpers/4/doman (+64 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [[ $# -lt 1 ]] ; then
8
	die "$0: at least one argument needed"
9
	exit 1
10
fi
11
12
i18n=""
13
14
ret=0
15
16
for x in "$@" ; do
17
	if [[ ${x:0:6} == "-i18n=" ]] ; then
18
		i18n=${x:6}/
19
		continue
20
	fi
21
	if [[ ${x:0:6} == ".keep_" ]] ; then
22
		continue
23
	fi
24
25
	suffix=${x##*.}
26
27
	# These will be automatically decompressed by ecompressdir.
28
	if hasq ${suffix} Z gz bz2 ; then
29
		realname=${x%.*}
30
		suffix=${realname##*.}
31
	fi
32
33
	if hasq "${EAPI:-0}" 2 3 || [[ -z ${i18n} ]] \
34
		&& ! hasq "${EAPI:-0}" 0 1 \
35
		&& [[ $x =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
36
	then
37
		name=${BASH_REMATCH[1]##*/}.${BASH_REMATCH[4]}
38
		mandir=${BASH_REMATCH[2]}/man${suffix:0:1}
39
	else
40
		name=${x##*/}
41
		mandir=${i18n#/}man${suffix:0:1}
42
	fi
43
44
45
	if [[ ${mandir} =~ man[0-9n](f|p|pm)?$ ]] ; then
46
		if [[ -s ${x} ]] ; then
47
			if [[ ! -d ${D}/usr/share/man/${mandir} ]] ; then
48
				install -d "${D}/usr/share/man/${mandir}"
49
			fi
50
51
			install -m0644 "${x}" "${D}/usr/share/man/${mandir}/${name}"
52
			((ret|=$?))
53
		elif [[ ! -e ${x} ]] ; then
54
			echo "!!! ${0##*/}: $x does not exist" 1>&2
55
			((ret|=1))
56
		fi
57
	else
58
		vecho "doman: '${x}' is probably not a man page; skipping" 1>&2
59
		((ret|=1))
60
	fi
61
done
62
63
[[ $ret -ne 0 ]] && die "$0 failed"
64
exit ${ret}
(-)a/bin/ebuild-helpers/4/domo (+32 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
mynum=${#}
6
if [ ${mynum} -lt 1 ] ; then
7
	die "$0: at least one argument needed"
8
	exit 1
9
fi
10
if [ ! -d "${D}${DESTTREE}/share/locale" ] ; then
11
	install -d "${D}${DESTTREE}/share/locale/"
12
fi
13
14
ret=0
15
16
for x in "$@" ; do
17
	if [ -e "${x}" ] ; then
18
		mytiny="${x##*/}"
19
		mydir="${D}${DESTTREE}/share/locale/${mytiny%.*}/LC_MESSAGES"
20
		if [ ! -d "${mydir}" ] ; then
21
			install -d "${mydir}"
22
		fi
23
		install -m0644 "${x}" "${mydir}/${MOPREFIX}.mo"
24
	else
25
		echo "!!! ${0##*/}: $x does not exist" 1>&2
26
		false
27
	fi
28
	((ret|=$?))
29
done
30
31
[[ $ret -ne 0 ]] && die "$0 failed"
32
exit $ret
(-)a/bin/ebuild-helpers/4/dosbin (+27 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ $# -lt 1 ]] ; then
6
	die "$0: at least one argument needed"
7
	exit 1
8
fi
9
10
if [[ ! -d ${D}${DESTTREE}/sbin ]] ; then
11
	install -d "${D}${DESTTREE}/sbin" || { die "$0 failed to install ${D}${DESTTREE}/sbin"; exit 2; }
12
fi
13
14
ret=0
15
16
for x in "$@" ; do
17
	if [[ -e ${x} ]] ; then
18
		install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${D}${DESTTREE}/sbin"
19
	else
20
		echo "!!! ${0##*/}: ${x} does not exist" 1>&2
21
		false
22
	fi
23
	((ret|=$?))
24
done
25
26
[[ $ret -ne 0 ]] && die "$0 failed"
27
exit ${ret}
(-)a/bin/ebuild-helpers/4/dosym (+13 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ $# -ne 2 ]] ; then
6
	die "$0: two arguments needed"
7
	exit 1
8
fi
9
10
destdir=${2%/*}
11
[[ ! -d ${D}${destdir} ]] && dodir "${destdir}"
12
13
exec ln -snf "$1" "${D}$2"
(-)a/bin/ebuild-helpers/4/ecompress (+153 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2007 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [[ -z $1 ]] ; then
8
	die "${0##*/}: at least one argument needed"
9
	exit 1
10
fi
11
12
# setup compression stuff
13
PORTAGE_COMPRESS=${PORTAGE_COMPRESS-bzip2}
14
[[ -z ${PORTAGE_COMPRESS} ]] && exit 0
15
16
if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then
17
	case ${PORTAGE_COMPRESS} in
18
		bzip2|gzip)  PORTAGE_COMPRESS_FLAGS="-9";;
19
	esac
20
fi
21
22
# decompress_args(suffix, binary)
23
#	- suffix: the compression suffix to work with
24
#	- binary: the program to execute that'll compress/decompress
25
# new_args: global array used to return revised arguments
26
decompress_args() {
27
	local suffix=$1 binary=$2
28
	shift 2
29
30
	# Initialize the global new_args array.
31
	new_args=()
32
	declare -a decompress_args=()
33
	local x i=0 decompress_count=0
34
	for x in "$@" ; do
35
		if [[ ${x%$suffix} = $x ]] ; then
36
			new_args[$i]=$x
37
		else
38
			new_args[$i]=${x%$suffix}
39
			decompress_args[$decompress_count]=$x
40
			((decompress_count++))
41
		fi
42
		((i++))
43
	done
44
45
	if [ $decompress_count -gt 0 ] ; then
46
		${binary} "${decompress_args[@]}"
47
		if [ $? -ne 0 ] ; then
48
			# Apparently decompression failed for one or more files, so
49
			# drop those since we don't want to compress them twice.
50
			new_args=()
51
			local x i=0
52
			for x in "$@" ; do
53
				if [[ ${x%$suffix} = $x ]] ; then
54
					new_args[$i]=$x
55
					((i++))
56
				elif [[ -f ${x%$suffix} ]] ; then
57
					new_args[$i]=${x%$suffix}
58
					((i++))
59
				else
60
					# Apparently decompression failed for this one, so drop
61
					# it since we don't want to compress it twice.
62
					true
63
				fi
64
			done
65
		fi
66
	fi
67
}
68
69
case $1 in
70
	--suffix)
71
		[[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
72
73
		if [[ ! -e ${T}/.ecompress.suffix ]] ; then
74
			set -e
75
			tmpdir="${T}"/.ecompress$$.${RANDOM}
76
			mkdir "${tmpdir}"
77
			cd "${tmpdir}"
78
			# we have to fill the file enough so that there is something
79
			# to compress as some programs will refuse to do compression
80
			# if it cannot actually compress the file
81
			echo {0..1000} > compressme
82
			${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
83
			suffix=$(ls compressme*)
84
			suffix=${suffix#compressme}
85
			cd /
86
			rm -rf "${tmpdir}"
87
			echo "${suffix}" > "${T}/.ecompress.suffix"
88
		fi
89
		cat "${T}/.ecompress.suffix"
90
		;;
91
	--bin)
92
		[[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2
93
94
		echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"
95
		;;
96
	--queue)
97
		shift
98
		touch "${@/%/.ecompress.file}"
99
		ret=$?
100
		[[ $ret -ne 0 ]] && die "$0 failed"
101
		exit $ret
102
		;;
103
	--dequeue)
104
		[[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
105
		find "${D}" -name '*.ecompress.file' -print0 \
106
			| sed -e 's:\.ecompress\.file::g' \
107
			| ${XARGS} -0 ecompress
108
		find "${D}" -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f
109
		;;
110
	--*)
111
		die "${0##*/}: unknown arguments '$*'"
112
		exit 1
113
		;;
114
	*)
115
		# Since dodoc calls ecompress on files that are already compressed,
116
		# perform decompression here (similar to ecompressdir behavior).
117
		decompress_args ".Z" "gunzip -f" "$@"
118
		set -- "${new_args[@]}"
119
		decompress_args ".gz" "gunzip -f" "$@"
120
		set -- "${new_args[@]}"
121
		decompress_args ".bz2" "bunzip2 -f" "$@"
122
		set -- "${new_args[@]}"
123
124
		mask_ext_re=""
125
		set -f
126
		for x in $PORTAGE_COMPRESS_EXCLUDE_SUFFIXES ; do
127
			mask_ext_re+="|$x"
128
		done
129
		set +f
130
		mask_ext_re="^(${mask_ext_re:1})\$"
131
		declare -a filtered_args=()
132
		i=0
133
		for x in "$@" ; do
134
			[[ ${x##*.} =~ $mask_ext_re ]] && continue
135
			filtered_args[$i]=$x
136
			((i++))
137
		done
138
		[ $i -eq 0 ] && exit 0
139
		set -- "${filtered_args[@]}"
140
141
		# If a compressed version of the file already exists, simply
142
		# delete it so that the compressor doesn't whine (bzip2 will
143
		# complain and skip, gzip will prompt for input)
144
		suffix=$(ecompress --suffix)
145
		[[ -n ${suffix} ]] && echo -n "${@/%/${suffix}$'\001'}" | \
146
			tr '\001' '\000' | ${XARGS} -0 rm -f
147
		# Finally, let's actually do some real work
148
		"${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
149
		ret=$?
150
		[[ $ret -ne 0 ]] && die "$0 failed"
151
		exit $ret
152
		;;
153
esac
(-)a/bin/ebuild-helpers/4/ecompressdir (+139 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2007 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7
if [[ -z $1 ]] ; then
8
	die "${0##*/}: at least one argument needed"
9
	exit 1
10
fi
11
12
case $1 in
13
	--ignore)
14
		shift
15
		for skip in "$@" ; do
16
			[[ -d ${D}${skip} ]] && touch "${D}${skip}.ecompress.skip"
17
		done
18
		exit 0
19
		;;
20
	--queue)
21
		shift
22
		set -- "${@/%/.ecompress.dir}"
23
		set -- "${@/#/${D}}"
24
		touch "$@"
25
		ret=$?
26
		[[ $ret -ne 0 ]] && die "$0 failed"
27
		exit $ret
28
		;;
29
	--dequeue)
30
		[[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2
31
		find "${D}" -name '*.ecompress.dir' -print0 \
32
			| sed -e 's:\.ecompress\.dir::g' -e "s:${D}:/:g" \
33
			| ${XARGS} -0 ecompressdir
34
		find "${D}" -name '*.ecompress.skip' -print0 | ${XARGS} -0 rm -f
35
		exit 0
36
		;;
37
	--*)
38
		die "${0##*/}: unknown arguments '$*'"
39
		exit 1
40
		;;
41
esac
42
43
# figure out the new suffix
44
suffix=$(ecompress --suffix)
45
46
# funk_up_dir(action, suffix, binary)
47
#	- action: compress or decompress
48
#	- suffix: the compression suffix to work with
49
#	- binary: the program to execute that'll compress/decompress
50
# The directory we act on is implied in the ${dir} variable
51
funk_up_dir() {
52
	local act=$1 suffix=$2 binary=$3
53
54
	local negate=""
55
	[[ ${act} == "compress" ]] && negate="!"
56
57
	# first we act on all the files
58
	find "${dir}" -type f ${negate} -iname '*'${suffix} -print0 | ${XARGS} -0 ${binary}
59
	((ret|=$?))
60
61
	find "${dir}" -type l -print0 | \
62
	while read -d $'\0' brokenlink ; do
63
		[[ -e ${brokenlink} ]] && continue
64
		olddest=$(readlink "${brokenlink}")
65
		[[ ${act} == "compress" ]] \
66
			&& newdest="${olddest}${suffix}" \
67
			|| newdest="${olddest%${suffix}}"
68
		rm -f "${brokenlink}"
69
		[[ ${act} == "compress" ]] \
70
			&& ln -snf "${newdest}" "${brokenlink}${suffix}" \
71
			|| ln -snf "${newdest}" "${brokenlink%${suffix}}"
72
		((ret|=$?))
73
	done
74
}
75
76
# _relocate_skip_dirs(srctree, dsttree)
77
# Move all the directories we want to skip running compression
78
# on from srctree to dsttree.
79
_relocate_skip_dirs() {
80
	local srctree="$1" dsttree="$2"
81
82
	[[ -d ${srctree} ]] || return 0
83
84
	find "${srctree}" -name '*.ecompress.skip' -print0 | \
85
	while read -d $'\0' src ; do
86
		src=${src%.ecompress.skip}
87
		dst="${dsttree}${src#${srctree}}"
88
		parent=${dst%/*}
89
		mkdir -p "${parent}"
90
		mv "${src}" "${dst}"
91
		mv "${src}.ecompress.skip" "${dst}.ecompress.skip"
92
	done
93
}
94
hide_skip_dirs()    { _relocate_skip_dirs "${D}" "${T}"/ecompress-skip/ ; }
95
restore_skip_dirs() { _relocate_skip_dirs "${T}"/ecompress-skip/ "${D}" ; }
96
97
ret=0
98
99
rm -rf "${T}"/ecompress-skip
100
101
for dir in "$@" ; do
102
	dir=${dir#/}
103
	dir="${D}${dir}"
104
	if [[ ! -d ${dir} ]] ; then
105
		vecho "${0##*/}: /${dir#${D}} does not exist!"
106
		continue
107
	fi
108
	cd "${dir}"
109
	actual_dir=${dir}
110
	dir=. # use relative path to avoid 'Argument list too long' errors
111
112
	# hide all the stuff we want to skip
113
	hide_skip_dirs "${dir}"
114
115
	# since we've been requested to compress the whole dir,
116
	# delete any individual queued requests
117
	rm -f "${actual_dir}.ecompress.dir"
118
	find "${dir}" -type f -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f
119
120
	# not uncommon for packages to compress doc files themselves
121
	funk_up_dir "decompress" ".Z" "gunzip -f"
122
	funk_up_dir "decompress" ".gz" "gunzip -f"
123
	funk_up_dir "decompress" ".bz2" "bunzip2 -f"
124
125
	# forcibly break all hard links as some compressors whine about it
126
	find "${dir}" -type f -links +1 -exec env file="{}" sh -c \
127
		'cp -p "${file}" "${file}.ecompress.break" ; mv -f "${file}.ecompress.break" "${file}"' \;
128
129
	# now lets do our work
130
	[[ -z ${suffix} ]] && continue
131
	vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${D}}"
132
	funk_up_dir "compress" "${suffix}" "ecompress"
133
134
	# finally, restore the skipped stuff
135
	restore_skip_dirs
136
done
137
138
[[ $ret -ne 0 ]] && die "$0 failed"
139
exit ${ret}
(-)a/bin/ebuild-helpers/4/fowners (+11 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2007 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
# we can't prefix all arguments because
6
# chown takes random options
7
slash="/"
8
chown "${@/#${slash}/${D}${slash}}"
9
ret=$?
10
[[ $ret -ne 0 ]] && die "$0 failed"
11
exit $ret
(-)a/bin/ebuild-helpers/4/fperms (+11 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2007 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
# we can't prefix all arguments because
6
# chmod takes random options
7
slash="/"
8
chmod "${@/#${slash}/${D}${slash}}"
9
ret=$?
10
[[ $ret -ne 0 ]] && die "$0 failed"
11
exit $ret
(-)a/bin/ebuild-helpers/4/newbin (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec dobin "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newconfd (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec doconfd "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newdoc (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec dodoc "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newenvd (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec doenvd "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newexe (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec doexe "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newinitd (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec doinitd "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newins (+21 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2009 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" || { ret=$?; die "$0 failed"; exit $ret; }
16
cp -P "$1" "$T/$2" || { ret=$?; die "$0 failed"; exit $ret; }
17
doins "${T}/${2}"
18
ret=$?
19
rm -rf "${T}/${2}"
20
[[ $ret -ne 0 ]] && die "$0 failed"
21
exit $ret
(-)a/bin/ebuild-helpers/4/newlib.a (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec dolib.a "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newlib.so (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec dolib.so "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newman (+17 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec doman "${T}/${2}"
(-)a/bin/ebuild-helpers/4/newsbin (-1 / +17 lines)
Line 0 Link Here
0
- 
1
#!/bin/bash
2
# Copyright 1999-2006 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
if [[ -z ${T} ]] || [[ -z ${2} ]] ; then
6
	die "$0: Need two arguments, old file and new file"
7
	exit 1
8
fi
9
10
if [ ! -e "$1" ] ; then
11
	die "!!! ${0##*/}: $1 does not exist"
12
	exit 1
13
fi
14
15
rm -rf "${T}/${2}" && \
16
cp -f "${1}" "${T}/${2}" && \
17
exec dosbin "${T}/${2}"

Return to bug 273651