1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :
# Copyright (c) 2006, 2007, 2008, 2009, 2011 Ciaran McCreesh
# Copyright (c) 2008 Bo Ørsted Andresen
# Copyright (c) 2009 David Leverton
# Copyright (c) 2009 Mike Kelly
#
# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
# Gentoo Foundation and distributed under the terms of the GNU General
# Public License v2.
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
# Public License, version 2, as published by the Free Software Foundation.
#
# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
alias die_unless_nonfatal='paludis_die_unless_nonfatal_func "$FUNCNAME" "$LINENO"'
alias assert_unless_nonfatal='_pipestatus="${PIPESTATUS[*]}"; [[ -z "${_pipestatus//[ 0]/}" ]] || paludis_die_unless_nonfatal_func "$FUNCNAME" "$LINENO" "$_pipestatus"'
nonfatal()
{
PALUDIS_FAILURE_IS_FATAL= PALUDIS_FAILURE_IS_NONFATAL=yes "${@}"
}
is_nonfatal()
{
[[ -n ${PALUDIS_FAILURE_IS_NONFATAL} ]]
}
expatch()
{
if [[ "${!PALUDIS_EBUILD_PHASE_VAR}" != "prepare" ]] ; then
die "expatch called in phase ${!PALUDIS_EBUILD_PHASE_VAR}"
fi
local recognise= patchlevel= options=() cmd= appliedpatches=0 dirpatches=()
if [[ ${1} == "--recognised-suffixes" ]]; then
recognise=true
shift
fi
while [[ $# -gt 0 ]]; do
if [[ ${1} == -p*([[:digit:]]) ]]; then
patchlevel="${1}"
elif [[ ${1} == -+([^[:space:]]) ]]; then
options+=("${1}")
elif [[ -d ${1} ]]; then
dirpatches=("${1}"/*)
[[ -f ${dirpatches[0]} ]] || die "expatch called with empty directory $1"
expatch --recognised-suffixes ${patchlevel} "${options[@]}" "${1}"/* || return 247
((appliedpatches++))
else
case "${1}" in
*.bz2)
cmd="bzip2 -dc"
;;
*.gz|*.Z|*.z)
cmd="gzip -dc"
;;
*.zip|*.ZIP|*.jar)
cmd="unzip -p"
;;
*.diff|*.patch)
cmd="cat"
;;
*)
if [[ -n ${recognise} ]]; then
shift
continue
else
cmd="cat"
fi
;;
esac
echo "${cmd} -- '${1}' | patch -s -f ${patchlevel:--p1} ${options[@]}" 1>&2
${cmd} -- "${1}" | patch -s -f ${patchlevel:--p1} "${options[@]}"
paludis_assert_unless_nonfatal "applying '${1}' failed" || return 247
((appliedpatches++))
fi
shift
done
# Die if no patches were applied and no directories were supplied. Since
# directories get handled recursively by separate instances of expatch we cannot
# reliably count applied patches when directories were supplied.
[[ ${appliedpatches} -gt 0 || -n ${recognise} ]] || paludis_die_unless_nonfatal "No patches applied." || return 247
}
econf()
{
if [[ "${!PALUDIS_EBUILD_PHASE_VAR}" != "configure" ]] ; then
die "econf called in phase ${!PALUDIS_EBUILD_PHASE_VAR}"
fi
[[ -z "${ECONF_SOURCE}" ]] && ECONF_SOURCE=.
if [[ -x "${ECONF_SOURCE}/configure" ]] ; then
if [[ -d /usr/share/gnuconfig ]] ; then
local f
find "${WORKBASE}" -type f -name config.guess -or -name config.sub | while read f; do
echo "econf: updating ${f} with /usr/share/gnuconfig/${f##*/}"
cp -f "/usr/share/gnuconfig/${f##*/}" "${f}"
done
fi
# If the ebuild passed in --prefix, use that to set --libdir. KDE at least needs this.
ECONF_PREFIX=/usr
local i hates= econf_args=()
for i in "$@"; do
case "${i}" in
--prefix=*|--exec-prefix=*)
ECONF_PREFIX=${i#--*prefix=} ;;
--hates=*)
hates+=" ${i#--hates=} "; continue ;;
esac
econf_args+=( "${i}" )
done
local j default_args=()
for i in \
--prefix=/usr \
--host=${CHOST} \
${CBUILD:+--build=${CBUILD}} \
${CTARGET:+--target=${CTARGET}} \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--datadir=/usr/share \
--docdir=/usr/share/doc/${PNVR} \
--sysconfdir=/etc \
--localstatedir=/var/lib \
--disable-dependency-tracking \
--disable-silent-rules \
--enable-fast-install \
--libdir=${ECONF_PREFIX}/${LIBDIR:-lib}; do
j=${i%%=*}
has ${j#--} ${hates} || default_args+=( "${i}" )
done
echo ${ECONF_WRAPPER} "${ECONF_SOURCE}"/configure \
"${default_args[@]}" "${econf_args[@]}" 1>&2
${ECONF_WRAPPER} "${ECONF_SOURCE}"/configure \
"${default_args[@]}" "${econf_args[@]}" || paludis_die_unless_nonfatal "econf failed" || return 247
else
paludis_die_unless_nonfatal "No configure script for econf" || return 247
fi
}
einstall()
{
if [[ "${!PALUDIS_EBUILD_PHASE_VAR}" != "install" ]] ; then
die "einstall called in phase ${!PALUDIS_EBUILD_PHASE_VAR}"
fi
if [[ -f Makefile ]] || [[ -f makefile ]] || [[ -f GNUmakefile ]] ; then
local makecmd=""
type -p gmake &>/dev/null && makecmd="gmake" || makecmd="make"
local cmd="${EINSTALL_WRAPPER} ${makecmd} prefix=${IMAGE}/usr"
cmd="${cmd} mandir=${IMAGE}/usr/share/man"
cmd="${cmd} infodir=${IMAGE}/usr/share/info"
cmd="${cmd} datadir=${IMAGE}/usr/share"
cmd="${cmd} sysconfdir=${IMAGE}/etc"
cmd="${cmd} localstatedir=${IMAGE}/var/lib"
cmd="${cmd} libdir=${IMAGE}/usr/${LIBDIR:-lib}"
cmd="${cmd} ${@} install"
echo "${cmd}" 1>&2
${cmd} || paludis_die_unless_nonfatal "einstall failed" || return 247
else
paludis_die_unless_nonfatal "No Makefile for einstall" || return 247
fi
}
emagicdocs()
{
local done_docs old_set f d p doc e
done_docs=
old_set=$(shopt | grep 'nocaseglob[[:space:]]*on')
shopt -s nocaseglob
for d in '' "${DEFAULT_SRC_INSTALL_EXTRA_SUBDIRS[@]}" ; do
if [[ -n ${d} ]]; then
[[ -d ${d} ]] || die "${d} is not a dir"
pushd "${d}" > /dev/null || die "Failed to enter ${d}"
local docdesttree="${DOCDESTTREE}"
docinto "${d}"
fi
for f in README Change{,s,Log} AUTHORS NEWS TODO ABOUT THANKS {KNOWN_,}BUGS SUBMITTING \
HACKING FAQ CREDITS PKG-INFO HISTORY PACKAGING MAINTAINER{,S} CONTRIBUT{E,OR,ORS} RELEASE \
ANNOUNCE PORTING NOTES PROBLEMS NOTICE "${DEFAULT_SRC_INSTALL_EXTRA_DOCS[@]}"; do
for p in "${DEFAULT_SRC_INSTALL_EXTRA_PREFIXES[@]}" '' ; do
for doc in "${p}"*([[:digit:]])"${f}"{,+([._-])*} ; do
if [[ -s "${doc}" && ! -d "${doc}" ]] ; then
for e in "${DEFAULT_SRC_INSTALL_EXCLUDE[@]}" ; do
[[ ${doc} == ${e} ]] && continue 2
done
done_docs="${done_docs} ${d%/}${d:+/}${doc}"
dodoc "${doc}"
fi
done
done
done
if [[ -n ${d} ]]; then
docinto "${docdesttree}"
popd > /dev/null || die "Failed to leave ${d}"
fi
done
if [[ -n "${done_docs}" ]] ; then
echo "Installed docs ${done_docs# }"
else
echo "Didn't find any docs to install"
fi
[[ -n ${old_set} ]] || shopt -u nocaseglob
}
edo()
{
echo "$@" 1>&2
"$@" || paludis_die_unless_nonfatal "$* failed" || return 247
}
|