Gentoo Archives: gentoo-user

From: meino.cramer@×××.de
To: Gentoo <gentoo-user@l.g.o>
Subject: [gentoo-user] util-linux failed to patch while emergeing
Date: Sun, 13 Feb 2011 06:00:25
Message-Id: 20110213055814.GC5962@solfire
1 Hi,
2
3 this morning I got this while emergeing util-linux:
4
5 >>> Emerging (1 of 1) sys-apps/util-linux-2.19
6 * util-linux-2.19.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
7 * util-linux-ng-2.18-20100706.diff.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
8 * Package: sys-apps/util-linux-2.19
9 * Repository: gentoo
10 * Maintainer: base-system@g.o
11 * USE: amd64 cramfs crypt elibc_glibc kernel_linux loop-aes multilib nls perl userland_GNU
12 >>> Unpacking source...
13 >>> Unpacking util-linux-2.19.tar.bz2 to /var/tmp/portage/sys-apps/util-linux-2.19/work
14 >>> Unpacking util-linux-ng-2.18-20100706.diff.bz2 to /var/tmp/portage/sys-apps/util-linux-2.19/work
15 >>> Source unpacked in /var/tmp/portage/sys-apps/util-linux-2.19/work
16 >>> Preparing source in /var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-2.19 ...
17 * Applying util-linux-ng-2.18-20100706.diff ...
18
19 * Failed Patch: util-linux-ng-2.18-20100706.diff !
20 * ( /var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-ng-2.18-20100706.diff )
21 *
22 * Include in your bugreport the contents of:
23 *
24 * /var/tmp/portage/sys-apps/util-linux-2.19/temp/util-linux-ng-2.18-20100706.diff.out
25
26 * ERROR: sys-apps/util-linux-2.19 failed:
27 * Failed Patch: util-linux-ng-2.18-20100706.diff!
28 *
29 * Call stack:
30 * ebuild.sh, line 56: Called src_prepare
31 * environment, line 3097: Called epatch '/var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-ng-2.18-20100706.diff'
32 * environment, line 1690: Called die
33 * The specific snippet of code:
34 * die "Failed Patch: ${patchname}!";
35 *
36 * If you need support, post the output of 'emerge --info =sys-apps/util-linux-2.19',
37 * the complete build log and the output of 'emerge -pqv =sys-apps/util-linux-2.19'.
38 * The complete build log is located at '/var/tmp/portage/sys-apps/util-linux-2.19/temp/build.log'.
39 * The ebuild environment file is located at '/var/tmp/portage/sys-apps/util-linux-2.19/temp/environment'.
40 * S: '/var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-2.19'
41
42
43 emerge --info =sys-apps/util-linux-2.19:
44
45 zsh: sys-apps/util-linux-2.19 not found
46
47
48 emerge -pqv =sys-apps/util-linux-2.19
49
50 zsh: sys-apps/util-linux-2.19 not found
51
52 /var/tmp/portage/sys-apps/util-linux-2.19/temp/build.log:
53
54 * Package: sys-apps/util-linux-2.19
55 * Repository: gentoo
56 * Maintainer: base-system@g.o
57 * USE: amd64 cramfs crypt elibc_glibc kernel_linux loop-aes multilib nls perl userland_GNU
58 >>> Unpacking source...
59 >>> Unpacking util-linux-2.19.tar.bz2 to /var/tmp/portage/sys-apps/util-linux-2.19/work
60 >>> Unpacking util-linux-ng-2.18-20100706.diff.bz2 to /var/tmp/portage/sys-apps/util-linux-2.19/work
61 >>> Source unpacked in /var/tmp/portage/sys-apps/util-linux-2.19/work
62 >>> Preparing source in /var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-2.19 ...
63 * Applying util-linux-ng-2.18-20100706.diff ...
64
65 * Failed Patch: util-linux-ng-2.18-20100706.diff !
66 * ( /var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-ng-2.18-20100706.diff )
67 *
68 * Include in your bugreport the contents of:
69 *
70 * /var/tmp/portage/sys-apps/util-linux-2.19/temp/util-linux-ng-2.18-20100706.diff.out
71
72 * ERROR: sys-apps/util-linux-2.19 failed:
73 * Failed Patch: util-linux-ng-2.18-20100706.diff!
74 *
75 * Call stack:
76 * ebuild.sh, line 56: Called src_prepare
77 * environment, line 3097: Called epatch '/var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-ng-2.18-20100706.diff'
78 * environment, line 1690: Called die
79 * The specific snippet of code:
80 * die "Failed Patch: ${patchname}!";
81 *
82 * If you need support, post the output of 'emerge --info =sys-apps/util-linux-2.19',
83 * the complete build log and the output of 'emerge -pqv =sys-apps/util-linux-2.19'.
84 * The complete build log is located at '/var/tmp/portage/sys-apps/util-linux-2.19/temp/build.log'.
85 * The ebuild environment file is located at '/var/tmp/portage/sys-apps/util-linux-2.19/temp/environment'.
86 * S: '/var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-2.19'
87
88
89 /var/tmp/portage/sys-apps/util-linux-2.19/temp/environment
90
91
92 declare -x ABI="amd64"
93 declare -x ALSA_CARDS=""
94 declare -x ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
95 declare -x ANT_HOME="/usr/share/ant"
96 declare -x APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
97 declare -x ARCH="amd64"
98 declare -x ASFLAGS_x86="--32"
99 declare -x AXIOM="/usr/axiom/mnt/linux"
100 declare -x CBUILD="x86_64-pc-linux-gnu"
101 declare -x CDEFINE_amd64="__x86_64__"
102 declare -x CDEFINE_default="__unix__"
103 declare -x CDEFINE_x86="__i386__"
104 declare -x CFLAGS="-march=native -O2 -pipe -msse3"
105 declare -x CFLAGS_default=""
106 declare -x CFLAGS_x86="-m32"
107 declare -x CHOST="x86_64-pc-linux-gnu"
108 declare -x CHOST_amd64="x86_64-pc-linux-gnu"
109 declare -x CHOST_default="x86_64-pc-linux-gnu"
110 declare -x CHOST_x86="i686-pc-linux-gnu"
111 declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
112 declare -x CROSSCOMPILE_OPTS=""
113 declare -x CTARGET_default="x86_64-pc-linux-gnu"
114 declare -x CXXFLAGS="-march=native -O2 -pipe -msse3"
115 declare -x DEFAULT_ABI="amd64"
116 declare -x DEFINED_PHASES=" configure install prepare"
117 declare -- DEPEND="!sys-process/schedutils
118 !sys-apps/setarch
119 >=sys-libs/ncurses-5.2-r2
120 !<sys-libs/e2fsprogs-libs-1.41.8
121 !<sys-fs/e2fsprogs-1.41.8
122 cramfs? ( sys-libs/zlib )
123 perl? ( dev-lang/perl )
124 selinux? ( sys-libs/libselinux )
125 slang? ( sys-libs/slang )
126 nls? ( sys-devel/gettext )
127 virtual/os-headers "
128 declare -- DESCRIPTION="Various useful Linux utilities"
129 declare -x DESTTREE="/usr"
130 declare -x DIFMT="SvFUaPTM"
131 declare -x DIROPTIONS="-m0755"
132 declare -x EAPI="2"
133 declare -- EGIT_REPO_URI="git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git"
134 declare -x ELIBC="glibc"
135 declare -- ELT_PATCH_DIR="/usr/portage/eclass/ELT-patches"
136 declare -- EPATCH_EXCLUDE=""
137 declare -- EPATCH_FORCE="no"
138 declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
139 declare -- EPATCH_OPTS="-g0 -E --no-backup-if-mismatch"
140 declare -- EPATCH_SINGLE_MSG=""
141 declare -- EPATCH_SOURCE="/var/tmp/portage/sys-apps/util-linux-2.19/work/patch"
142 declare -- EPATCH_SUFFIX="patch.bz2"
143 declare -x EXEOPTIONS="-m0755"
144 declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\""
145 declare -x FLTK_DOCDIR="/usr/share/doc/fltk-2.0_pre6970/html"
146 declare -x FRACTDIR="/usr/share/xfractint"
147 declare -x GCC_SPECS=""
148 declare -x GDK_USE_XFT="1"
149 declare -x GNOME_LIBCONFIG_PATH="/usr/lib"
150 declare -x GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx"
151 declare -x G_BROKEN_FILENAMES=""
152 declare -x HELPDIR="/usr/local/lib/zsh/help"
153 declare -x HISTSIZE="30000"
154 declare -- HOMEPAGE="http://www.kernel.org/pub/linux/utils/util-linux/"
155 declare -x INHERITED="toolchain-funcs portability flag-o-matic multilib libtool eutils"
156 declare -x INPUT_DEVICES="evdev"
157 declare -x INSDESTTREE=""
158 declare -x INSOPTIONS="-m0644"
159 declare -- IUSE="+cramfs crypt loop-aes nls old-linux perl selinux slang uclibc unicode "
160 declare -x KERNEL="linux"
161 declare -x KERNEL_ABI="amd64"
162 declare -x KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
163 declare -x KFORTH_DIR="/usr/share/kForth"
164 declare -x KV="2.6.37"
165 declare -x LADSPA_PATH="/usr/lib64/ladspa"
166 declare -x LANG="C"
167 declare -x LANGUAGE="C"
168 declare -x LCD_DEVICES=""
169 declare -x LC_ALL="C"
170 declare -x LC_COLLATE="C"
171 declare -x LC_CTYPE="C"
172 declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
173 declare -x LDFLAGS_default=""
174 declare -x LDFLAGS_x86="-m elf_i386"
175 declare -x LIBDIR_amd64="lib64"
176 declare -x LIBDIR_amd64_fbsd="lib64"
177 declare -x LIBDIR_default="lib"
178 declare -x LIBDIR_ppc="lib32"
179 declare -x LIBDIR_ppc64="lib64"
180 declare -x LIBDIR_sparc32="lib32"
181 declare -x LIBDIR_sparc64="lib64"
182 declare -x LIBDIR_x86="lib32"
183 declare -x LIBDIR_x86_fbsd="lib32"
184 declare -x LIBOPTIONS="-m0644"
185 declare -x LICENSE="GPL-2"
186 declare -x MAIL="/var/spool/mail/root"
187 declare -x MAKEOPTS="-j 1"
188 declare -x MC_COLOR_TABLE="base_color=normal=green,black:normal=green,black:menuhot=red,cyan:menuhotsel=red,cyan:directory=cyan,black:executable=green,black:link=red,black:device=green,black:special=green,black:core=green,black:hidden=green,black:temp=green,black:doc=green,black:archive=green,black:source=green,black:media=green,black:graph=green,black:database=green,black:marked=black,yellow:stalelink=black,red:editnormal=green,black"
189 declare -x MULTILIB_ABIS="amd64 x86"
190 declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
191 declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
192 declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage)"
193 declare -- MY_P="util-linux-2.19"
194 declare -- MY_PV="2.19"
195 declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
196 declare -x OPENGL_PROFILE="nvidia"
197 declare -x PATH="/usr/lib64/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.4"
198 declare -- PDEPEND=" "
199 declare -x PERLIO="stdio"
200 declare -x PHP_TARGETS="php5-3"
201 declare -x PILOTPORT="/dev/tts/0"
202 declare -x PKGHOME="/root/NetModule/nmpackages"
203 declare -x PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/lib/pkgconfig"
204 declare -x PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
205 declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
206 declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/util-linux-2.19/html")'
207 declare -x PRELINK_PATH_MASK="/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so"
208 declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
209 declare -x PROPERTIES=""
210 declare -x PROVIDE=""
211 declare -x PYTHONDOCS="/usr/share/doc/python-docs-2.6.5/html/library"
212 declare -x PYTHONDOCS_2_6="/usr/share/doc/python-docs-2.6.5/html/library"
213 declare -x PYTHONDOCS_3_1="/usr/share/doc/python-docs-3.1.2/html/library"
214 declare -x PYTHONDONTWRITEBYTECODE="1"
215 declare -x PYTHONPATH="/usr/local/lib64/python2.6/site-packages"
216 declare -x RDEPEND="!sys-process/schedutils
217 !sys-apps/setarch
218 >=sys-libs/ncurses-5.2-r2
219 !<sys-libs/e2fsprogs-libs-1.41.8
220 !<sys-fs/e2fsprogs-1.41.8
221 cramfs? ( sys-libs/zlib )
222 perl? ( dev-lang/perl )
223 selinux? ( sys-libs/libselinux )
224 slang? ( sys-libs/slang ) "
225 declare -- REQUIRED_USE=" "
226 declare -x RESTRICT=""
227 declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\""
228 declare -x RUBYOPT="-rauto_gem"
229 declare -x RUBY_TARGETS=""
230 declare -x S="/var/tmp/portage/sys-apps/util-linux-2.19/work/util-linux-2.19"
231 declare -x SANDBOX_DEBUG="0"
232 declare -x SANDBOX_DENY=""
233 declare -x SANDBOX_PID="8701"
234 declare -x SANDBOX_PREDICT="/var/tmp/portage/sys-apps/util-linux-2.19/homedir:/dev/crypto:/var/cache/fontconfig"
235 declare -x SANDBOX_READ="/:/dev/stdin:/var/tmp"
236 declare -x SANDBOX_VERBOSE="1"
237 declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/stderr:/dev/stdout:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/sys-apps/util-linux-2.19/homedir/.bash_history"
238 declare -x SGML_CATALOG_FILES="/etc/sgml/sgml-docbook-4.0.cat:/etc/sgml/sgml-lite.cat:/etc/sgml/sgml-docbook-4.1.cat:/etc/sgml/xml-docbook-4.4.cat:/etc/sgml/xml-docbook-4.3.cat:/etc/sgml/sgml-docbook-3.0.cat:/etc/sgml/xml-docbook-4.2.cat:/etc/sgml/xml-docbook-4.5.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/sgml-ent.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/sgml-docbook-3.1.cat"
239 declare -x SLOT="0"
240 declare -x SRCDIR="/home/mccramer/xfractint"
241 declare -- SRC_URI="mirror://kernel/linux/utils/util-linux/v2.19/util-linux-2.19.tar.bz2
242 loop-aes? ( http://loop-aes.sourceforge.net/updates/util-linux-ng-2.18-20100706.diff.bz2 )"
243 declare -x STAGE1_USE="multilib nptl nptlonly unicode"
244 declare -x SUDO_COMMAND="/bin/zsh"
245 declare -x SUDO_GID="100"
246 declare -x SUDO_UID="1001"
247 declare -x SUDO_USER="mccramer"
248 declare -x SYMLINK_LIB="yes"
249 declare -x TEXDOCVIEW_dvi="kgh %s"
250 declare -x TEXDOCVIEW_html="dillo %s"
251 declare -x TEXDOCVIEW_pdf="kgh %s"
252 declare -x TEXDOCVIEW_ps="kghostview %s"
253 declare -x USE="amd64 cramfs crypt elibc_glibc kernel_linux loop-aes multilib nls perl userland_GNU"
254 declare -x USERLAND="GNU"
255 declare -x USERNAME="root"
256 declare -x VIDEO_CARDS=""
257 declare -x XDG_CONFIG_DIRS="/etc/xdg"
258 declare -x XDG_DATA_DIRS="/root/.local/share:/usr/local/share/:/usr/share/"
259 declare -x XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
260 declare -x XZ_OPT="--memory=max"
261 declare -- _="PKG_INSTALL_MASK"
262 declare -x _E_DOCDESTTREE_=""
263 declare -x _E_EXEDESTTREE_=""
264 declare -- ___ECLASS_RECUR_MULTILIB="yes"
265 declare -- ___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes"
266 declare -x zshloader=":/root/.zshenv:/root/.zshrc"
267 ELT_libtool_version ()
268 {
269 ( unset VERSION;
270 eval $(grep -e '^[[:space:]]*VERSION=' "$1");
271 echo "${VERSION:-0}" )
272 }
273 ELT_try_and_apply_patch ()
274 {
275 local ret=0;
276 local file=$1;
277 local patch=$2;
278 if patch -p0 --dry-run "${file}" "${patch}" &>"${T}/elibtool.log"; then
279 einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ...";
280 patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" &>"${T}/elibtool.log";
281 ret=$?;
282 export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}";
283 else
284 ret=1;
285 fi;
286 return "${ret}"
287 }
288 ELT_walk_patches ()
289 {
290 local patch;
291 local ret=1;
292 local file=$1;
293 local patch_set=$2;
294 local patch_dir="${ELT_PATCH_DIR}/${patch_set}";
295 local rem_int_dep=$3;
296 [[ -z ${patch_set} ]] && return 1;
297 [[ ! -d ${patch_dir} ]] && return 1;
298 pushd "${ELT_PATCH_DIR}" > /dev/null;
299 for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r);
300 do
301 if [[ -n ${rem_int_dep} ]]; then
302 local tmp="${T}/$$.rem_int_deps.patch";
303 sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}";
304 patch=${tmp};
305 fi;
306 if ELT_try_and_apply_patch "${file}" "${patch}"; then
307 ret=0;
308 break;
309 fi;
310 done;
311 popd > /dev/null;
312 return ${ret}
313 }
314 VER_major ()
315 {
316 [[ -z $1 ]] && return 1;
317 local VER=$@;
318 echo "${VER%%[^[:digit:]]*}"
319 }
320 VER_micro ()
321 {
322 [[ -z $1 ]] && return 1;
323 local VER=$@;
324 VER=${VER#*.*.};
325 echo "${VER%%[^[:digit:]]*}"
326 }
327 VER_minor ()
328 {
329 [[ -z $1 ]] && return 1;
330 local VER=$@;
331 VER=${VER#*.};
332 echo "${VER%%[^[:digit:]]*}"
333 }
334 VER_to_int ()
335 {
336 [[ -z $1 ]] && return 1;
337 local VER_MAJOR=$(VER_major "$1");
338 local VER_MINOR=$(VER_minor "$1");
339 local VER_MICRO=$(VER_micro "$1");
340 local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO ));
341 if [[ ${VER_int} -ge 65536 ]]; then
342 echo "${VER_int}";
343 return 0;
344 fi;
345 echo 1;
346 return 1
347 }
348 _cdrom_locate_file_on_cd ()
349 {
350 local mline="";
351 local showedmsg=0 showjolietmsg=0;
352 while [[ -z ${CDROM_ROOT} ]]; do
353 local i=0;
354 local -a cdset=(${*//:/ });
355 if [[ -n ${CDROM_SET} ]]; then
356 cdset=(${cdset[${CDROM_SET}]});
357 fi;
358 while [[ -n ${cdset[${i}]} ]]; do
359 local dir=$(dirname ${cdset[${i}]});
360 local file=$(basename ${cdset[${i}]});
361 local point= node= fs= foo=;
362 while read point node fs foo; do
363 [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] && continue;
364 point=${point//\040/ };
365 [[ ! -d ${point}/${dir} ]] && continue;
366 [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue;
367 export CDROM_ROOT=${point};
368 export CDROM_SET=${i};
369 export CDROM_MATCH=${cdset[${i}]};
370 return;
371 done <<< "$(get_mounts)";
372 ((++i));
373 done;
374 echo;
375 if [[ ${showedmsg} -eq 0 ]]; then
376 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
377 if [[ -z ${CDROM_NAME} ]]; then
378 einfo "Please insert+mount the cdrom for ${PN} now !";
379 else
380 einfo "Please insert+mount the ${CDROM_NAME} cdrom now !";
381 fi;
382 else
383 if [[ -z ${CDROM_NAME_1} ]]; then
384 einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !";
385 else
386 local var="CDROM_NAME_${CDROM_CURRENT_CD}";
387 einfo "Please insert+mount the ${!var} cdrom now !";
388 fi;
389 fi;
390 showedmsg=1;
391 fi;
392 einfo "Press return to scan for the cd again";
393 einfo "or hit CTRL+C to abort the emerge.";
394 echo;
395 if [[ ${showjolietmsg} -eq 0 ]]; then
396 showjolietmsg=1;
397 else
398 ewarn "If you are having trouble with the detection";
399 ewarn "of your CD, it is possible that you do not have";
400 ewarn "Joliet support enabled in your kernel. Please";
401 ewarn "check that CONFIG_JOLIET is enabled in your kernel.";
402 ebeep 5;
403 fi;
404 read || die "something is screwed with your system";
405 done
406 }
407 _filter-hardened ()
408 {
409 local f;
410 for f in "$@";
411 do
412 case "${f}" in
413 -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
414 gcc-specs-pie || continue;
415 is-flagq -nopie || append-flags -nopie
416 ;;
417 -fstack-protector)
418 gcc-specs-ssp || continue;
419 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
420 ;;
421 -fstack-protector-all)
422 gcc-specs-ssp-to-all || continue;
423 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
424 ;;
425 -fno-strict-overflow)
426 gcc-specs-nostrict || continue;
427 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
428 ;;
429 esac;
430 done
431 }
432 _filter-var ()
433 {
434 local f x VAR VAL;
435 declare -a new;
436 VAR=$1;
437 shift;
438 eval VAL=\${${VAR}};
439 for f in ${VAL};
440 do
441 for x in "$@";
442 do
443 [[ ${f} == ${x} ]] && continue 2;
444 done;
445 eval new\[\${\#new\[@]}]=\${f};
446 done;
447 eval export ${VAR}=\${new\[*]}
448 }
449 _gcc-install-dir ()
450 {
451 echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
452 }
453 _gcc-specs-directive_raw ()
454 {
455 local cc=$(tc-getCC);
456 local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
457 ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
458 $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
459 outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
460 spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
461 { spec=spec $0 }
462 END { print spec }';
463 return 0
464 }
465 _gcc-specs-exists ()
466 {
467 [[ -f $(_gcc-install-dir)/$1 ]]
468 }
469 _gcc_fullversion ()
470 {
471 local ver="$1";
472 shift;
473 set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
474 eval echo "$ver"
475 }
476 _is_flagq ()
477 {
478 local x;
479 for x in ${!1};
480 do
481 [[ ${x} == $2 ]] && return 0;
482 done;
483 return 1
484 }
485 _unpack_tar ()
486 {
487 if [ "${y}" == "tar" ]; then
488 $1 -c -- "$srcdir$x" | tar xof -;
489 assert_sigpipe_ok "$myfail";
490 else
491 $1 -c -- "${srcdir}${x}" > ${x%.*} || die "$myfail";
492 fi
493 }
494 append-cflags ()
495 {
496 [[ -z $* ]] && return 0;
497 export CFLAGS="${CFLAGS} $*";
498 return 0
499 }
500 append-cppflags ()
501 {
502 [[ -z $* ]] && return 0;
503 export CPPFLAGS="${CPPFLAGS} $*";
504 return 0
505 }
506 append-cxxflags ()
507 {
508 [[ -z $* ]] && return 0;
509 export CXXFLAGS="${CXXFLAGS} $*";
510 return 0
511 }
512 append-fflags ()
513 {
514 [[ -z $* ]] && return 0;
515 export FFLAGS="${FFLAGS} $*";
516 export FCFLAGS="${FCFLAGS} $*";
517 return 0
518 }
519 append-flags ()
520 {
521 [[ -z $* ]] && return 0;
522 append-cflags "$@";
523 append-cxxflags "$@";
524 append-fflags "$@";
525 return 0
526 }
527 append-ldflags ()
528 {
529 [[ -z $* ]] && return 0;
530 local flag;
531 for flag in "$@";
532 do
533 [[ ${flag} == -l* ]] && ewarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
534 done;
535 export LDFLAGS="${LDFLAGS} $*";
536 return 0
537 }
538 append-lfs-flags ()
539 {
540 [[ -n $@ ]] && die "append-lfs-flags takes no arguments";
541 append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
542 }
543 append-libs ()
544 {
545 [[ -z $* ]] && return 0;
546 local flag;
547 for flag in "$@";
548 do
549 [[ ${flag} == -l* ]] && flag=${flag#-l};
550 export LIBS="${LIBS} -l${flag}";
551 done;
552 return 0
553 }
554 built_with_use ()
555 {
556 local hidden="no";
557 if [[ $1 == "--hidden" ]]; then
558 hidden="yes";
559 shift;
560 fi;
561 local missing_action="die";
562 if [[ $1 == "--missing" ]]; then
563 missing_action=$2;
564 shift;
565 shift;
566 case ${missing_action} in
567 true | false | die)
568
569 ;;
570 *)
571 die "unknown action '${missing_action}'"
572 ;;
573 esac;
574 fi;
575 local opt=$1;
576 [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
577 local PKG=$(best_version $1);
578 [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
579 shift;
580 local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
581 local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
582 if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
583 case ${missing_action} in
584 true)
585 return 0
586 ;;
587 false)
588 return 1
589 ;;
590 die)
591 die "Unable to determine what USE flags $PKG was built with"
592 ;;
593 esac;
594 fi;
595 if [[ ${hidden} == "no" ]]; then
596 local IUSE_BUILT=($(<"${IUSEFILE}"));
597 local expand;
598 for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
599 do
600 if [[ $1 == ${expand}_* ]]; then
601 expand="";
602 break;
603 fi;
604 done;
605 if [[ -n ${expand} ]]; then
606 if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
607 case ${missing_action} in
608 true)
609 return 0
610 ;;
611 false)
612 return 1
613 ;;
614 die)
615 die "$PKG does not actually support the $1 USE flag!"
616 ;;
617 esac;
618 fi;
619 fi;
620 fi;
621 local USE_BUILT=$(<${USEFILE});
622 while [[ $# -gt 0 ]]; do
623 if [[ ${opt} = "-o" ]]; then
624 has $1 ${USE_BUILT} && return 0;
625 else
626 has $1 ${USE_BUILT} || return 1;
627 fi;
628 shift;
629 done;
630 [[ ${opt} = "-a" ]]
631 }
632 cdrom_get_cds ()
633 {
634 local cdcnt=0;
635 local f=;
636 for f in "$@";
637 do
638 ((++cdcnt));
639 export CDROM_CHECK_${cdcnt}="$f";
640 done;
641 export CDROM_TOTAL_CDS=${cdcnt};
642 export CDROM_CURRENT_CD=1;
643 if [[ -n ${CD_ROOT}${CD_ROOT_1} ]]; then
644 local var=;
645 cdcnt=0;
646 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
647 ((++cdcnt));
648 var="CD_ROOT_${cdcnt}";
649 [[ -z ${!var} ]] && var="CD_ROOT";
650 if [[ -z ${!var} ]]; then
651 eerror "You must either use just the CD_ROOT";
652 eerror "or specify ALL the CD_ROOT_X variables.";
653 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables.";
654 die "could not locate CD_ROOT_${cdcnt}";
655 fi;
656 done;
657 export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}};
658 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}";
659 export CDROM_SET=-1;
660 for f in ${CDROM_CHECK_1//:/ };
661 do
662 ((++CDROM_SET));
663 [[ -e ${CDROM_ROOT}/${f} ]] && break;
664 done;
665 export CDROM_MATCH=${f};
666 return;
667 fi;
668 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
669 einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}";
670 echo;
671 einfo "If you do not have the CD, but have the data files";
672 einfo "mounted somewhere on your filesystem, just export";
673 einfo "the variable CD_ROOT so that it points to the";
674 einfo "directory containing the files.";
675 echo;
676 einfo "For example:";
677 einfo "export CD_ROOT=/mnt/cdrom";
678 echo;
679 else
680 if [[ -n ${CDROM_NAME_SET} ]]; then
681 cdcnt=0;
682 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
683 ((++cdcnt));
684 export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}";
685 done;
686 fi;
687 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds.";
688 cdcnt=0;
689 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
690 ((++cdcnt));
691 var="CDROM_NAME_${cdcnt}";
692 [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}";
693 done;
694 echo;
695 einfo "If you do not have the CDs, but have the data files";
696 einfo "mounted somewhere on your filesystem, just export";
697 einfo "the following variables so they point to the right place:";
698 einfon "";
699 cdcnt=0;
700 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
701 ((++cdcnt));
702 echo -n " CD_ROOT_${cdcnt}";
703 done;
704 echo;
705 einfo "Or, if you have all the files in the same place, or";
706 einfo "you only have one cdrom, you can export CD_ROOT";
707 einfo "and that place will be used as the same data source";
708 einfo "for all the CDs.";
709 echo;
710 einfo "For example:";
711 einfo "export CD_ROOT_1=/mnt/cdrom";
712 echo;
713 fi;
714 export CDROM_SET="";
715 export CDROM_CURRENT_CD=0;
716 cdrom_load_next_cd
717 }
718 cdrom_load_next_cd ()
719 {
720 local var;
721 ((++CDROM_CURRENT_CD));
722 unset CDROM_ROOT;
723 var=CD_ROOT_${CDROM_CURRENT_CD};
724 [[ -z ${!var} ]] && var="CD_ROOT";
725 if [[ -z ${!var} ]]; then
726 var="CDROM_CHECK_${CDROM_CURRENT_CD}";
727 _cdrom_locate_file_on_cd ${!var};
728 else
729 export CDROM_ROOT=${!var};
730 fi;
731 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
732 }
733 check_license ()
734 {
735 local lic=$1;
736 if [ -z "${lic}" ]; then
737 lic="${PORTDIR}/licenses/${LICENSE}";
738 else
739 if [ -e "${PORTDIR}/licenses/${lic}" ]; then
740 lic="${PORTDIR}/licenses/${lic}";
741 else
742 if [ -e "${PWD}/${lic}" ]; then
743 lic="${PWD}/${lic}";
744 else
745 if [ -e "${lic}" ]; then
746 lic="${lic}";
747 fi;
748 fi;
749 fi;
750 fi;
751 local l="`basename ${lic}`";
752 local alic;
753 eshopts_push -o noglob;
754 for alic in ${ACCEPT_LICENSE};
755 do
756 if [[ ${alic} == ${l} ]]; then
757 eshopts_pop;
758 return 0;
759 fi;
760 done;
761 eshopts_pop;
762 [ ! -f "${lic}" ] && die "Could not find requested license ${lic}";
763 local licmsg=$(emktemp);
764 cat > ${licmsg} <<-EOF
765 **********************************************************
766 The following license outlines the terms of use of this
767 package. You MUST accept this license for installation to
768 continue. When you are done viewing, hit 'q'. If you
769 CTRL+C out of this, the install will not run!
770 **********************************************************
771
772 EOF
773
774 cat ${lic} >> ${licmsg};
775 ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}";
776 einfon "Do you accept the terms of this license (${l})? [yes/no] ";
777 read alic;
778 case ${alic} in
779 yes | Yes | y | Y)
780 return 0
781 ;;
782 *)
783 echo;
784 echo;
785 echo;
786 eerror "You MUST accept the license to continue! Exiting!";
787 die "Failed to accept license"
788 ;;
789 esac
790 }
791 create_ml_includes ()
792 {
793 local dest=$1;
794 shift;
795 local basedirs=$(create_ml_includes-listdirs "$@");
796 create_ml_includes-makedestdirs ${dest} ${basedirs};
797 local file;
798 for file in $(create_ml_includes-allfiles ${basedirs});
799 do
800 ( echo "/* Autogenerated by create_ml_includes() in multilib.eclass */";
801 local dir;
802 for dir in ${basedirs};
803 do
804 if [[ -f ${D}/${dir}/${file} ]]; then
805 echo "";
806 local sym=$(create_ml_includes-sym_for_dir ${dir} "$@");
807 if [[ ${sym/=} != "${sym}" ]]; then
808 echo "#if ${sym}";
809 else
810 if [[ ${sym::1} == "!" ]]; then
811 echo "#ifndef ${sym:1}";
812 else
813 echo "#ifdef ${sym}";
814 fi;
815 fi;
816 echo "# include <$(create_ml_includes-absolute ${dir}/${file})>";
817 echo "#endif /* ${sym} */";
818 fi;
819 done ) > "${D}/${dest}/${file}";
820 done
821 }
822 create_ml_includes-absolute ()
823 {
824 local dst="$(create_ml_includes-tidy_path $1)";
825 dst=(${dst//\// });
826 local i;
827 for ((i=0; i<${#dst[*]}; i++))
828 do
829 [ "${dst[i]}" == "include" ] && break;
830 done;
831 local strip_upto=$i;
832 for ((i=strip_upto+1; i<${#dst[*]}-1; i++))
833 do
834 echo -n ${dst[i]}/;
835 done;
836 echo -n ${dst[i]}
837 }
838 create_ml_includes-allfiles ()
839 {
840 [[ -z ${ED} ]] && local ED=${D};
841 local basedir file;
842 for basedir in "$@";
843 do
844 for file in $(find "${ED}"/${basedir} -type f);
845 do
846 echo ${file/${ED}\/${basedir}\//};
847 done;
848 done | sort | uniq
849 }
850 create_ml_includes-listdirs ()
851 {
852 local dirs;
853 local data;
854 for data in "$@";
855 do
856 dirs="${dirs} ${data/*:/}";
857 done;
858 echo ${dirs:1}
859 }
860 create_ml_includes-makedestdirs ()
861 {
862 local dest=$1;
863 shift;
864 local basedirs=$@;
865 [[ -z ${ED} ]] && local ED=${D};
866 dodir ${dest};
867 local basedir;
868 for basedir in ${basedirs};
869 do
870 local dir;
871 for dir in $(find "${ED}"/${basedir} -type d);
872 do
873 dodir ${dest}/${dir/${ED}\/${basedir}/};
874 done;
875 done
876 }
877 create_ml_includes-sym_for_dir ()
878 {
879 local dir=$1;
880 shift;
881 local data;
882 for data in "$@";
883 do
884 if [[ ${data} == *:${dir} ]]; then
885 echo ${data/:*/};
886 return 0;
887 fi;
888 done;
889 echo "Shouldn't be here -- create_ml_includes-sym_for_dir $1 $@";
890 exit 1
891 }
892 create_ml_includes-tidy_path ()
893 {
894 local removed=$1;
895 if [ -n "${removed}" ]; then
896 while [ "${removed}" != "${removed/\/\//\/}" ]; do
897 removed=${removed/\/\//\/};
898 done;
899 while [ "${removed}" != "${removed//\/.\//\/}" ]; do
900 removed=${removed//\/.\//\/};
901 done;
902 [ "${removed##*/}" = "." ] && removed=${removed%/*};
903 while [ "${removed}" != "${removed//\/..\/}" ]; do
904 local p1="${removed%%\/..\/*}";
905 local p2="${removed#*\/..\/}";
906 removed="${p1%\/*}/${p2}";
907 done;
908 [ "${removed##*/}" = ".." ] && removed=${removed%/*/*};
909 [ "${removed##*/}" = "" ] && removed=${removed%/*};
910 echo ${removed};
911 fi
912 }
913 darwintoolize ()
914 {
915 die "Use elibtoolize"
916 }
917 dlopen_lib ()
918 {
919 case "${CHOST}" in
920 *-linux-gnu* | *-linux-uclibc | *-interix*)
921 echo "-ldl"
922 ;;
923 esac
924 }
925 doicon ()
926 {
927 ( local i j ret;
928 insinto /usr/share/pixmaps;
929 for i in "$@";
930 do
931 if [[ -f ${i} ]]; then
932 doins "${i}";
933 ((ret+=$?));
934 else
935 if [[ -d ${i} ]]; then
936 for j in "${i}"/*.png;
937 do
938 doins "${j}";
939 ((ret+=$?));
940 done;
941 else
942 ((++ret));
943 fi;
944 fi;
945 done;
946 exit ${ret} )
947 }
948 domenu ()
949 {
950 ( local i j ret=0;
951 insinto /usr/share/applications;
952 for i in "$@";
953 do
954 if [[ -f ${i} ]]; then
955 doins "${i}";
956 ((ret+=$?));
957 else
958 if [[ -d ${i} ]]; then
959 for j in "${i}"/*.desktop;
960 do
961 doins "${j}";
962 ((ret+=$?));
963 done;
964 else
965 ((++ret));
966 fi;
967 fi;
968 done;
969 exit ${ret} )
970 }
971 dyn_pretend ()
972 {
973 ebuild_phase_with_hooks pkg_pretend
974 }
975 ebeep ()
976 {
977 local n;
978 if [[ -z ${EBEEP_IGNORE} ]]; then
979 for ((n=1 ; n <= ${1:-5} ; n++))
980 do
981 echo -ne "\a";
982 sleep 0.1 &>/dev/null;
983 sleep 0,1 &>/dev/null;
984 echo -ne "\a";
985 sleep 1;
986 done;
987 fi
988 }
989 ecvs_clean ()
990 {
991 [[ -z $* ]] && set -- .;
992 find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
993 find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
994 }
995 edos2unix ()
996 {
997 echo "$@" | xargs sed -i 's/\r$//'
998 }
999 egetent ()
1000 {
1001 case ${CHOST} in
1002 *-darwin[678])
1003 case "$2" in
1004 *[!0-9]*)
1005 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
1006 ;;
1007 *)
1008 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
1009 ;;
1010 esac
1011 ;;
1012 *-darwin*)
1013 local mytype=$1;
1014 [[ "passwd" == $mytype ]] && mytype="Users";
1015 [[ "group" == $mytype ]] && mytype="Groups";
1016 case "$2" in
1017 *[!0-9]*)
1018 dscl . -read /$mytype/$2 2> /dev/null | grep RecordName
1019 ;;
1020 *)
1021 local mykey="UniqueID";
1022 [[ $mytype == "Groups" ]] && mykey="PrimaryGroupID";
1023 dscl . -search /$mytype $mykey $2 2> /dev/null
1024 ;;
1025 esac
1026 ;;
1027 *-freebsd* | *-dragonfly*)
1028 local opts action="user";
1029 [[ $1 == "passwd" ]] || action="group";
1030 if [[ $2 == [[:digit:]]* ]]; then
1031 [[ ${action} == "user" ]] && opts="-u" || opts="-g";
1032 fi;
1033 pw show ${action} ${opts} "$2" -q
1034 ;;
1035 *-netbsd* | *-openbsd*)
1036 grep "$2:\*:" /etc/$1
1037 ;;
1038 *)
1039 type -p nscd &>/dev/null && nscd -i "$1";
1040 getent "$1" "$2"
1041 ;;
1042 esac
1043 }
1044 egethome ()
1045 {
1046 ent=$(egetent passwd $1);
1047 case ${CHOST} in
1048 *-darwin* | *-freebsd* | *-dragonfly*)
1049 echo ${ent} | cut -d: -f9
1050 ;;
1051 *)
1052 echo ${ent} | cut -d: -f6
1053 ;;
1054 esac
1055 }
1056 egetshell ()
1057 {
1058 ent=$(egetent passwd "$1");
1059 case ${CHOST} in
1060 *-darwin* | *-freebsd* | *-dragonfly*)
1061 echo ${ent} | cut -d: -f10
1062 ;;
1063 *)
1064 echo ${ent} cut -d: -f7
1065 ;;
1066 esac
1067 }
1068 elibtoolize ()
1069 {
1070 local x;
1071 local do_portage="no";
1072 local do_reversedeps="no";
1073 local do_only_patches="no";
1074 local do_uclibc="yes";
1075 local deptoremove=;
1076 local do_shallow="no";
1077 local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed";
1078 for x in "$@";
1079 do
1080 case ${x} in
1081 --portage)
1082 do_portage="yes"
1083 ;;
1084 --reverse-deps)
1085 do_reversedeps="yes";
1086 elt_patches+=" fix-relink"
1087 ;;
1088 --patch-only)
1089 do_only_patches="yes"
1090 ;;
1091 --remove-internal-dep=*)
1092 deptoremove=${x#--remove-internal-dep=};
1093 [[ -n ${deptoremove} ]] && elt_patches+=" rem-int-dep"
1094 ;;
1095 --shallow)
1096 do_shallow="yes"
1097 ;;
1098 --no-uclibc)
1099 do_uclibc="no"
1100 ;;
1101 *)
1102 eerror "Invalid elibtoolize option: ${x}";
1103 die "elibtoolize called with ${x} ??"
1104 ;;
1105 esac;
1106 done;
1107 [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf";
1108 case ${CHOST} in
1109 *-aix*)
1110 elt_patches+=" hardcode aixrtl aix-noundef"
1111 ;;
1112 *-darwin*)
1113 elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf"
1114 ;;
1115 *-freebsd*)
1116 elt_patches+=" fbsd-conf fbsd-ltconf"
1117 ;;
1118 *-hpux*)
1119 elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc"
1120 ;;
1121 *-irix*)
1122 elt_patches+=" irix-ltmain"
1123 ;;
1124 *-mint*)
1125 elt_patches+=" mint-conf"
1126 ;;
1127 esac;
1128 set --;
1129 if [[ ${do_shallow} == "yes" ]]; then
1130 [[ -f ${S}/ltmain.sh ]] && set -- "${S}";
1131 else
1132 set -- $(find "${S}" -name ltmain.sh -printf '%h ');
1133 fi;
1134 local d p;
1135 for d in "$@";
1136 do
1137 export ELT_APPLIED_PATCHES=;
1138 [[ -f ${d}/.elibtoolized ]] && continue;
1139 einfo "Running elibtoolize in: ${d#${WORKDIR}/}/";
1140 for p in ${elt_patches};
1141 do
1142 local ret=0;
1143 case ${p} in
1144 portage)
1145 if ! grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
1146 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1147 ret=$?;
1148 fi
1149 ;;
1150 rem-int-dep)
1151 ELT_walk_patches "${d}/ltmain.sh" "${p}" "${deptoremove}";
1152 ret=$?
1153 ;;
1154 fix-relink)
1155 if grep -qs 'inst_prefix_dir' "${d}/ltmain.sh"; then
1156 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1157 ret=$?;
1158 fi
1159 ;;
1160 max_cmd_len)
1161 if grep -qs 'max_cmd_len' "${d}/ltmain.sh"; then
1162 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1163 ret=$?;
1164 fi
1165 ;;
1166 as-needed)
1167 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1168 ret=$?
1169 ;;
1170 uclibc-conf)
1171 if grep -qs 'Transform linux' "${d}/configure"; then
1172 ELT_walk_patches "${d}/configure" "${p}";
1173 ret=$?;
1174 else
1175 if [[ ! -e ${d}/configure ]] && grep -qs 'Transform linux' "${d}/../configure"; then
1176 ELT_walk_patches "${d}/../configure" "${p}";
1177 ret=$?;
1178 fi;
1179 fi
1180 ;;
1181 uclibc-ltconf)
1182 if [[ -s ${d}/ltconfig ]]; then
1183 ELT_walk_patches "${d}/ltconfig" "${p}";
1184 ret=$?;
1185 fi
1186 ;;
1187 fbsd-conf)
1188 if grep -qs 'version_type=freebsd-' "${d}/configure"; then
1189 ELT_walk_patches "${d}/configure" "${p}";
1190 ret=$?;
1191 else
1192 if [[ ! -e ${d}/configure ]] && grep -qs 'version_type=freebsd-' "${d}/../configure"; then
1193 ELT_walk_patches "${d}/../configure" "${p}";
1194 ret=$?;
1195 fi;
1196 fi
1197 ;;
1198 fbsd-ltconf)
1199 if [[ -s ${d}/ltconfig ]]; then
1200 ELT_walk_patches "${d}/ltconfig" "${p}";
1201 ret=$?;
1202 fi
1203 ;;
1204 darwin-conf)
1205 if grep -qs '&& echo \.so ||' "${d}/configure"; then
1206 ELT_walk_patches "${d}/configure" "${p}";
1207 ret=$?;
1208 else
1209 if [[ ! -e ${d}/configure ]] && grep -qs '&& echo \.so ||' "${d}/../configure"; then
1210 ELT_walk_patches "${d}/../configure" "${p}";
1211 ret=$?;
1212 fi;
1213 fi
1214 ;;
1215 darwin-ltconf)
1216 if [[ -s ${d}/ltconfig ]]; then
1217 ELT_walk_patches "${d}/ltconfig" "${p}";
1218 ret=$?;
1219 fi
1220 ;;
1221 darwin-ltmain)
1222 if [[ -e ${d}/ltmain.sh ]] && ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh"; then
1223 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1224 ret=$?;
1225 fi
1226 ;;
1227 aixrtl | hpux-conf)
1228 ret=1;
1229 local subret=0;
1230 while [[ $subret -eq 0 ]]; do
1231 subret=1;
1232 if [[ -e ${d}/configure ]]; then
1233 ELT_walk_patches "${d}/configure" "${p}";
1234 subret=$?;
1235 else
1236 if [[ ! -e ${d}/configure && -e ${d}/../configure ]]; then
1237 ELT_walk_patches "${d}/../configure" "${p}";
1238 subret=$?;
1239 fi;
1240 fi;
1241 if [[ $subret -eq 0 ]]; then
1242 ret=0;
1243 fi;
1244 done
1245 ;;
1246 mint-conf)
1247 ret=1;
1248 local subret=1;
1249 if [[ -e ${d}/configure ]]; then
1250 ELT_walk_patches "${d}/configure" "${p}";
1251 subret=$?;
1252 else
1253 if [[ ! -e ${d}/configure && -e ${d}/../configure ]]; then
1254 ELT_walk_patches "${d}/../configure" "${p}";
1255 subret=$?;
1256 fi;
1257 fi;
1258 if [[ $subret -eq 0 ]]; then
1259 ret=0;
1260 fi
1261 ;;
1262 install-sh)
1263 ELT_walk_patches "${d}/install-sh" "${p}";
1264 ret=$?
1265 ;;
1266 cross)
1267 if tc-is-cross-compiler; then
1268 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1269 ret=$?;
1270 fi
1271 ;;
1272 *)
1273 ELT_walk_patches "${d}/ltmain.sh" "${p}";
1274 ret=$?
1275 ;;
1276 esac;
1277 if [[ ${ret} -ne 0 ]]; then
1278 case ${p} in
1279 relink)
1280 local version=$(ELT_libtool_version "${d}/ltmain.sh");
1281 if ! grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" && [[ $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]]; then
1282 ewarn " Could not apply relink.patch!";
1283 fi
1284 ;;
1285 portage)
1286 if [[ ${do_portage} == "yes" ]]; then
1287 if ! grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
1288 echo;
1289 eerror "Portage patch requested, but failed to apply!";
1290 eerror "Please file a bug report to add a proper patch.";
1291 die "Portage patch requested, but failed to apply!";
1292 fi;
1293 else
1294 if grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
1295 :;
1296 else
1297 local version=$(ELT_libtool_version "${d}"/ltmain.sh);
1298 echo;
1299 eerror "Portage patch failed to apply (ltmain.sh version ${version})!";
1300 eerror "Please file a bug report to add a proper patch.";
1301 die "Portage patch failed to apply!";
1302 fi;
1303 ELT_APPLIED_PATCHES="portage";
1304 fi
1305 ;;
1306 uclibc-*)
1307 [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!"
1308 ;;
1309 fbsd-*)
1310 if [[ ${CHOST} == *-freebsd* ]]; then
1311 if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' "${d}/configure" "${d}/../configure" 2>/dev/null) ]]; then
1312 eerror " FreeBSD patch set '${p}' failed to apply!";
1313 die "FreeBSD patch set '${p}' failed to apply!";
1314 fi;
1315 fi
1316 ;;
1317 darwin-*)
1318 [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to apply!"
1319 ;;
1320 esac;
1321 fi;
1322 done;
1323 if [[ -z ${ELT_APPLIED_PATCHES} ]]; then
1324 if [[ ${do_portage} == "no" && ${do_reversedeps} == "no" && ${do_only_patches} == "no" && ${deptoremove} == "" ]]; then
1325 ewarn "Cannot apply any patches, please file a bug about this";
1326 die;
1327 fi;
1328 fi;
1329 rm -f "${d}/libtool";
1330 > "${d}/.elibtoolized";
1331 done
1332 }
1333 emktemp ()
1334 {
1335 local exe="touch";
1336 [[ $1 == -d ]] && exe="mkdir" && shift;
1337 local topdir=$1;
1338 if [[ -z ${topdir} ]]; then
1339 [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
1340 fi;
1341 if ! type -P mktemp > /dev/null; then
1342 local tmp=/;
1343 while [[ -e ${tmp} ]]; do
1344 tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
1345 done;
1346 ${exe} "${tmp}" || ${exe} -p "${tmp}";
1347 echo "${tmp}";
1348 else
1349 if [[ ${exe} == "touch" ]]; then
1350 TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
1351 else
1352 TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
1353 fi;
1354 fi
1355 }
1356 enewgroup ()
1357 {
1358 case ${EBUILD_PHASE} in
1359 unpack | compile | test | install)
1360 eerror "'enewgroup()' called from '${EBUILD_PHASE}()' which is not a pkg_* function.";
1361 eerror "Package fails at QA and at life. Please file a bug.";
1362 die "Bad package! enewgroup is only for use in pkg_* functions!"
1363 ;;
1364 esac;
1365 local egroup="$1";
1366 shift;
1367 if [ -z "${egroup}" ]; then
1368 eerror "No group specified !";
1369 die "Cannot call enewgroup without a group";
1370 fi;
1371 if [[ -n $(egetent group "${egroup}") ]]; then
1372 return 0;
1373 fi;
1374 einfo "Adding group '${egroup}' to your system ...";
1375 local opts=;
1376 local egid="$1";
1377 shift;
1378 if [ ! -z "${egid}" ]; then
1379 if [ "${egid}" -gt 0 ]; then
1380 if [ -z "`egetent group ${egid}`" ]; then
1381 if [[ "${CHOST}" == *-darwin* ]]; then
1382 opts="${opts} ${egid}";
1383 else
1384 opts="${opts} -g ${egid}";
1385 fi;
1386 else
1387 egid="next available; requested gid taken";
1388 fi;
1389 else
1390 eerror "Groupid given but is not greater than 0 !";
1391 die "${egid} is not a valid GID";
1392 fi;
1393 else
1394 egid="next available";
1395 fi;
1396 einfo " - Groupid: ${egid}";
1397 local eextra="$@";
1398 opts="${opts} ${eextra}";
1399 local oldsandbox="${SANDBOX_ON}";
1400 export SANDBOX_ON="0";
1401 case ${CHOST} in
1402 *-darwin*)
1403 if [ ! -z "${eextra}" ]; then
1404 einfo "Extra options are not supported on Darwin/OS X yet";
1405 einfo "Please report the ebuild along with the info below";
1406 einfo "eextra: ${eextra}";
1407 die "Required function missing";
1408 fi;
1409 case ${egid} in
1410 *[!0-9]*)
1411 for ((egid = 101; egid <= 999; egid++))
1412 do
1413 [[ -z $(egetent group ${egid}) ]] && break;
1414 done
1415 ;;
1416 esac;
1417 dscl . create /groups/${egroup} gid ${egid};
1418 dscl . create /groups/${egroup} passwd '*'
1419 ;;
1420 *-freebsd* | *-dragonfly*)
1421 case ${egid} in
1422 *[!0-9]*)
1423 for ((egid = 101; egid <= 999; egid++))
1424 do
1425 [[ -z $(egetent group ${egid}) ]] && break;
1426 done
1427 ;;
1428 esac;
1429 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
1430 ;;
1431 *-netbsd*)
1432 case ${egid} in
1433 *[!0-9]*)
1434 for ((egid = 101; egid <= 999; egid++))
1435 do
1436 [[ -z $(egetent group ${egid}) ]] && break;
1437 done
1438 ;;
1439 esac;
1440 groupadd -g ${egid} ${egroup} || die "enewgroup failed"
1441 ;;
1442 *)
1443 groupadd -r ${opts} ${egroup} || die "enewgroup failed"
1444 ;;
1445 esac;
1446 export SANDBOX_ON="${oldsandbox}"
1447 }
1448 enewuser ()
1449 {
1450 case ${EBUILD_PHASE} in
1451 unpack | compile | test | install)
1452 eerror "'enewuser()' called from '${EBUILD_PHASE}()' which is not a pkg_* function.";
1453 eerror "Package fails at QA and at life. Please file a bug.";
1454 die "Bad package! enewuser is only for use in pkg_* functions!"
1455 ;;
1456 esac;
1457 local euser=$1;
1458 shift;
1459 if [[ -z ${euser} ]]; then
1460 eerror "No username specified !";
1461 die "Cannot call enewuser without a username";
1462 fi;
1463 if [[ -n $(egetent passwd "${euser}") ]]; then
1464 return 0;
1465 fi;
1466 einfo "Adding user '${euser}' to your system ...";
1467 local opts=;
1468 local euid=$1;
1469 shift;
1470 if [[ -n ${euid} && ${euid} != -1 ]]; then
1471 if [[ ${euid} -gt 0 ]]; then
1472 if [[ -n $(egetent passwd ${euid}) ]]; then
1473 euid="next";
1474 fi;
1475 else
1476 eerror "Userid given but is not greater than 0 !";
1477 die "${euid} is not a valid UID";
1478 fi;
1479 else
1480 euid="next";
1481 fi;
1482 if [[ ${euid} == "next" ]]; then
1483 for ((euid = 101; euid <= 999; euid++))
1484 do
1485 [[ -z $(egetent passwd ${euid}) ]] && break;
1486 done;
1487 fi;
1488 opts="${opts} -u ${euid}";
1489 einfo " - Userid: ${euid}";
1490 local eshell=$1;
1491 shift;
1492 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
1493 if [[ ! -e ${ROOT}${eshell} ]]; then
1494 eerror "A shell was specified but it does not exist !";
1495 die "${eshell} does not exist in ${ROOT}";
1496 fi;
1497 if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
1498 eerror "Do not specify ${eshell} yourself, use -1";
1499 die "Pass '-1' as the shell parameter";
1500 fi;
1501 else
1502 for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
1503 do
1504 [[ -x ${ROOT}${shell} ]] && break;
1505 done;
1506 if [[ ${shell} == "/dev/null" ]]; then
1507 eerror "Unable to identify the shell to use, proceeding with userland default.";
1508 case ${USERLAND} in
1509 GNU)
1510 shell="/bin/false"
1511 ;;
1512 BSD)
1513 shell="/sbin/nologin"
1514 ;;
1515 Darwin)
1516 shell="/usr/sbin/nologin"
1517 ;;
1518 *)
1519 die "Unable to identify the default shell for userland ${USERLAND}"
1520 ;;
1521 esac;
1522 fi;
1523 eshell=${shell};
1524 fi;
1525 einfo " - Shell: ${eshell}";
1526 opts="${opts} -s ${eshell}";
1527 local ehome=$1;
1528 shift;
1529 if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
1530 ehome="/dev/null";
1531 fi;
1532 einfo " - Home: ${ehome}";
1533 opts="${opts} -d ${ehome}";
1534 local egroups=$1;
1535 shift;
1536 if [[ ! -z ${egroups} ]]; then
1537 local oldifs=${IFS};
1538 local defgroup="" exgroups="";
1539 export IFS=",";
1540 for g in ${egroups};
1541 do
1542 export IFS=${oldifs};
1543 if [[ -z $(egetent group "${g}") ]]; then
1544 eerror "You must add group ${g} to the system first";
1545 die "${g} is not a valid GID";
1546 fi;
1547 if [[ -z ${defgroup} ]]; then
1548 defgroup=${g};
1549 else
1550 exgroups="${exgroups},${g}";
1551 fi;
1552 export IFS=",";
1553 done;
1554 export IFS=${oldifs};
1555 opts="${opts} -g ${defgroup}";
1556 if [[ ! -z ${exgroups} ]]; then
1557 opts="${opts} -G ${exgroups:1}";
1558 fi;
1559 else
1560 egroups="(none)";
1561 fi;
1562 einfo " - Groups: ${egroups}";
1563 local oldsandbox=${SANDBOX_ON};
1564 export SANDBOX_ON="0";
1565 case ${CHOST} in
1566 *-darwin*)
1567 if [[ -z $@ ]]; then
1568 dscl . create /users/${euser} uid ${euid};
1569 dscl . create /users/${euser} shell ${eshell};
1570 dscl . create /users/${euser} home ${ehome};
1571 dscl . create /users/${euser} realname "added by portage for ${PN}";
1572 local oldifs=${IFS};
1573 export IFS=",";
1574 for g in ${egroups};
1575 do
1576 dscl . merge /groups/${g} users ${euser};
1577 done;
1578 export IFS=${oldifs};
1579 else
1580 einfo "Extra options are not supported on Darwin yet";
1581 einfo "Please report the ebuild along with the info below";
1582 einfo "eextra: $@";
1583 die "Required function missing";
1584 fi
1585 ;;
1586 *-freebsd* | *-dragonfly*)
1587 if [[ -z $@ ]]; then
1588 pw useradd ${euser} ${opts} -c "added by portage for ${PN}" die "enewuser failed";
1589 else
1590 einfo " - Extra: $@";
1591 pw useradd ${euser} ${opts} "$@" || die "enewuser failed";
1592 fi
1593 ;;
1594 *-netbsd*)
1595 if [[ -z $@ ]]; then
1596 useradd ${opts} ${euser} || die "enewuser failed";
1597 else
1598 einfo " - Extra: $@";
1599 useradd ${opts} ${euser} "$@" || die "enewuser failed";
1600 fi
1601 ;;
1602 *-openbsd*)
1603 if [[ -z $@ ]]; then
1604 useradd -u ${euid} -s ${eshell} -d ${ehome} -c "Added by portage for ${PN}" -g ${egroups} ${euser} || die "enewuser failed";
1605 else
1606 einfo " - Extra: $@";
1607 useradd -u ${euid} -s ${eshell} -d ${ehome} -c "Added by portage for ${PN}" -g ${egroups} ${euser} "$@" || die "enewuser failed";
1608 fi
1609 ;;
1610 *)
1611 if [[ -z $@ ]]; then
1612 useradd -r ${opts} -c "added by portage for ${PN}" ${euser} || die "enewuser failed";
1613 else
1614 einfo " - Extra: $@";
1615 useradd -r ${opts} "$@" ${euser} || die "enewuser failed";
1616 fi
1617 ;;
1618 esac;
1619 if [[ ! -e ${ROOT}/${ehome} ]]; then
1620 einfo " - Creating ${ehome} in ${ROOT}";
1621 mkdir -p "${ROOT}/${ehome}";
1622 chown ${euser} "${ROOT}/${ehome}";
1623 chmod 755 "${ROOT}/${ehome}";
1624 fi;
1625 export SANDBOX_ON=${oldsandbox}
1626 }
1627 epatch ()
1628 {
1629 function _epatch_draw_line ()
1630 {
1631 [[ -z $1 ]] && set "$(printf "%65s" '')";
1632 echo "${1//?/=}"
1633 };
1634 unset P4CONFIG P4PORT P4USER;
1635 if [[ $# -gt 1 ]]; then
1636 local m;
1637 for m in "$@";
1638 do
1639 epatch "${m}";
1640 done;
1641 return 0;
1642 fi;
1643 local SINGLE_PATCH="no";
1644 [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
1645 if [[ -f $1 ]]; then
1646 SINGLE_PATCH="yes";
1647 set -- "$1";
1648 local EPATCH_SUFFIX=$1;
1649 else
1650 if [[ -d $1 ]]; then
1651 set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
1652 else
1653 [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
1654 echo;
1655 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
1656 eerror;
1657 eerror " ${EPATCH_SOURCE}";
1658 eerror " ( ${EPATCH_SOURCE##*/} )";
1659 echo;
1660 die "Cannot find \$EPATCH_SOURCE!";
1661 fi;
1662 fi;
1663 local PIPE_CMD;
1664 case ${EPATCH_SUFFIX##*\.} in
1665 xz)
1666 PIPE_CMD="xz -dc"
1667 ;;
1668 lzma)
1669 PIPE_CMD="lzma -dc"
1670 ;;
1671 bz2)
1672 PIPE_CMD="bzip2 -dc"
1673 ;;
1674 gz | Z | z)
1675 PIPE_CMD="gzip -dc"
1676 ;;
1677 ZIP | zip)
1678 PIPE_CMD="unzip -p"
1679 ;;
1680 *)
1681
1682 ;;
1683 esac;
1684 [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
1685 local x;
1686 for x in "$@";
1687 do
1688 [[ ! -f ${x} ]] && continue;
1689 local patchname=${x##*/};
1690 local a=${patchname#*_};
1691 a=${a%%_*};
1692 if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
1693 continue;
1694 fi;
1695 if [[ -n ${EPATCH_EXCLUDE} ]]; then
1696 eshopts_push -o noglob;
1697 local ex;
1698 for ex in ${EPATCH_EXCLUDE};
1699 do
1700 if [[ ${patchname} == ${ex} ]]; then
1701 eshopts_pop;
1702 continue 2;
1703 fi;
1704 done;
1705 eshopts_pop;
1706 fi;
1707 if [[ ${SINGLE_PATCH} == "yes" ]]; then
1708 if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
1709 einfo "${EPATCH_SINGLE_MSG}";
1710 else
1711 einfo "Applying ${patchname} ...";
1712 fi;
1713 else
1714 einfo " ${patchname} ...";
1715 fi;
1716 local STDERR_TARGET="${T}/${patchname}.out";
1717 if [[ -e ${STDERR_TARGET} ]]; then
1718 STDERR_TARGET="${T}/${patchname}-$$.out";
1719 fi;
1720 printf "***** %s *****\n\n" "${patchname}" > "${STDERR_TARGET}";
1721 local count=0;
1722 local PATCH_TARGET;
1723 if [[ -n ${PIPE_CMD} ]]; then
1724 PATCH_TARGET="${T}/$$.patch";
1725 echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
1726 if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
1727 echo;
1728 eerror "Could not extract patch!";
1729 count=5;
1730 break;
1731 fi;
1732 else
1733 PATCH_TARGET=${x};
1734 fi;
1735 local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
1736 if [[ -n ${abs_paths} ]]; then
1737 count=1;
1738 printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
1739 fi;
1740 local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
1741 if [[ -n ${rel_paths} ]]; then
1742 eqawarn "QA Notice: Your patch uses relative paths '../'.";
1743 eqawarn " In the future this will cause a failure.";
1744 eqawarn "${rel_paths}";
1745 fi;
1746 while [[ ${count} -lt 5 ]]; do
1747 ( _epatch_draw_line "***** ${patchname} *****";
1748 echo;
1749 echo "PATCH COMMAND: patch -p${count} ${EPATCH_OPTS} < '${PATCH_TARGET}'";
1750 echo;
1751 _epatch_draw_line "***** ${patchname} *****" ) >> "${STDERR_TARGET}";
1752 if ( patch -p${count} ${EPATCH_OPTS} --dry-run -f < "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
1753 ( _epatch_draw_line "***** ${patchname} *****";
1754 echo;
1755 echo "ACTUALLY APPLYING ${patchname} ...";
1756 echo;
1757 _epatch_draw_line "***** ${patchname} *****";
1758 patch -p${count} ${EPATCH_OPTS} < "${PATCH_TARGET}" 2>&1 ) >> "${STDERR_TARGET}";
1759 if [ $? -ne 0 ]; then
1760 echo;
1761 eerror "A dry-run of patch command succeeded, but actually";
1762 eerror "applying the patch failed!";
1763 count=5;
1764 fi;
1765 break;
1766 fi;
1767 : $(( count++ ));
1768 done;
1769 if [[ -n ${PIPE_CMD} ]]; then
1770 rm -f "${PATCH_TARGET}";
1771 fi;
1772 if [[ ${count} -ge 5 ]]; then
1773 echo;
1774 eerror "Failed Patch: ${patchname} !";
1775 eerror " ( ${PATCH_TARGET} )";
1776 eerror;
1777 eerror "Include in your bugreport the contents of:";
1778 eerror;
1779 eerror " ${STDERR_TARGET}";
1780 echo;
1781 die "Failed Patch: ${patchname}!";
1782 fi;
1783 rm -f "${STDERR_TARGET}";
1784 eend 0;
1785 done;
1786 [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
1787 :
1788 }
1789 epatch_user ()
1790 {
1791 [[ $# -ne 0 ]] && die "epatch_user takes no options";
1792 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
1793 for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}};
1794 do
1795 EPATCH_SOURCE=${base}/${CTARGET}/${check};
1796 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
1797 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
1798 if [[ -d ${EPATCH_SOURCE} ]]; then
1799 EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
1800 return 0;
1801 fi;
1802 done;
1803 return 1
1804 }
1805 epause ()
1806 {
1807 [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
1808 }
1809 epunt_cxx ()
1810 {
1811 local dir=$1;
1812 [[ -z ${dir} ]] && dir=${S};
1813 ebegin "Removing useless C++ checks";
1814 local f;
1815 find "${dir}" -name configure | while read f; do
1816 patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
1817 done;
1818 eend 0
1819 }
1820 eshopts_pop ()
1821 {
1822 [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments";
1823 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 ));
1824 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair";
1825 local s=${__ESHOPTS_SAVE__[$i]};
1826 unset __ESHOPTS_SAVE__[$i];
1827 if [[ ${s} == "shopt -"* ]]; then
1828 eval "${s}" || die "eshopts_pop: sanity: invalid shopt options: ${s}";
1829 else
1830 set +$- || die "eshopts_pop: sanity: invalid shell settings: $-";
1831 set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}";
1832 fi
1833 }
1834 eshopts_push ()
1835 {
1836 local i=${#__ESHOPTS_SAVE__[@]};
1837 if [[ $1 == -[su] ]]; then
1838 __ESHOPTS_SAVE__[$i]=$(shopt -p);
1839 [[ $# -eq 0 ]] && return 0;
1840 shopt "$@" || die "eshopts_push: bad options to shopt: $*";
1841 else
1842 __ESHOPTS_SAVE__[$i]=$-;
1843 [[ $# -eq 0 ]] && return 0;
1844 set "$@" || die "eshopts_push: bad options to set: $*";
1845 fi
1846 }
1847 esvn_clean ()
1848 {
1849 [[ -z $* ]] && set -- .;
1850 find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
1851 }
1852 filter-flags ()
1853 {
1854 _filter-hardened "$@";
1855 _filter-var CFLAGS "$@";
1856 _filter-var CPPFLAGS "$@";
1857 _filter-var CXXFLAGS "$@";
1858 _filter-var FFLAGS "$@";
1859 _filter-var FCFLAGS "$@";
1860 return 0
1861 }
1862 filter-ldflags ()
1863 {
1864 _filter-var LDFLAGS "$@";
1865 return 0
1866 }
1867 filter-lfs-flags ()
1868 {
1869 [[ -n $@ ]] && die "filter-lfs-flags takes no arguments";
1870 filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
1871 }
1872 filter-mfpmath ()
1873 {
1874 local orig_mfpmath new_math prune_math;
1875 orig_mfpmath=$(get-flag -mfpmath);
1876 new_math=$(get-flag mfpmath);
1877 new_math=" ${new_math//,/ } ";
1878 prune_math="";
1879 for prune_math in "$@";
1880 do
1881 new_math=${new_math/ ${prune_math} / };
1882 done;
1883 new_math=$(echo ${new_math});
1884 new_math=${new_math// /,};
1885 if [[ -z ${new_math} ]]; then
1886 filter-flags ${orig_mfpmath};
1887 else
1888 replace-flags ${orig_mfpmath} -mfpmath=${new_math};
1889 fi;
1890 return 0
1891 }
1892 find_unpackable_file ()
1893 {
1894 local src=$1;
1895 if [[ -z ${src} ]]; then
1896 src=${DISTDIR}/${A};
1897 else
1898 if [[ -e ${DISTDIR}/${src} ]]; then
1899 src=${DISTDIR}/${src};
1900 else
1901 if [[ -e ${PWD}/${src} ]]; then
1902 src=${PWD}/${src};
1903 else
1904 if [[ -e ${src} ]]; then
1905 src=${src};
1906 fi;
1907 fi;
1908 fi;
1909 fi;
1910 [[ ! -e ${src} ]] && return 1;
1911 echo "${src}"
1912 }
1913 gcc-fullversion ()
1914 {
1915 _gcc_fullversion '$1.$2.$3' "$@"
1916 }
1917 gcc-major-version ()
1918 {
1919 _gcc_fullversion '$1' "$@"
1920 }
1921 gcc-micro-version ()
1922 {
1923 _gcc_fullversion '$3' "$@"
1924 }
1925 gcc-minor-version ()
1926 {
1927 _gcc_fullversion '$2' "$@"
1928 }
1929 gcc-specs-directive ()
1930 {
1931 local directive subdname subdirective;
1932 directive="$(_gcc-specs-directive_raw $1)";
1933 while [[ ${directive} == *%\(*\)* ]]; do
1934 subdname=${directive/*%\(};
1935 subdname=${subdname/\)*};
1936 subdirective="$(_gcc-specs-directive_raw ${subdname})";
1937 directive="${directive//\%(${subdname})/${subdirective}}";
1938 done;
1939 echo "${directive}";
1940 return 0
1941 }
1942 gcc-specs-nostrict ()
1943 {
1944 local directive;
1945 directive=$(gcc-specs-directive cc1);
1946 return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
1947 }
1948 gcc-specs-now ()
1949 {
1950 local directive;
1951 directive=$(gcc-specs-directive link_command);
1952 return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
1953 }
1954 gcc-specs-pie ()
1955 {
1956 local directive;
1957 directive=$(gcc-specs-directive cc1);
1958 return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
1959 }
1960 gcc-specs-relro ()
1961 {
1962 local directive;
1963 directive=$(gcc-specs-directive link_command);
1964 return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
1965 }
1966 gcc-specs-ssp ()
1967 {
1968 local directive;
1969 directive=$(gcc-specs-directive cc1);
1970 return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
1971 }
1972 gcc-specs-ssp-to-all ()
1973 {
1974 local directive;
1975 directive=$(gcc-specs-directive cc1);
1976 return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
1977 }
1978 gcc-version ()
1979 {
1980 _gcc_fullversion '$1.$2' "$@"
1981 }
1982 gen_usr_ldscript ()
1983 {
1984 local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
1985 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
1986 tc-is-static-only && return;
1987 dodir /usr/${libdir};
1988 if [[ $1 == "-a" ]]; then
1989 auto=true;
1990 shift;
1991 dodir /${libdir};
1992 fi;
1993 output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
1994 [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
1995 for lib in "$@";
1996 do
1997 local tlib;
1998 if ${auto}; then
1999 lib="lib${lib}${suffix}";
2000 else
2001 [[ -r ${ED}/${libdir}/${lib} ]] || continue;
2002 fi;
2003 case ${CTARGET:-${CHOST}} in
2004 *-darwin*)
2005 if ${auto}; then
2006 tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
2007 else
2008 tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
2009 fi;
2010 [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
2011 tlib=${tlib##*/};
2012 if ${auto}; then
2013 mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
2014 if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
2015 mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
2016 fi;
2017 rm -f "${ED}"/${libdir}/${lib};
2018 fi;
2019 if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
2020 chmod u+w "${ED}${libdir}/${tlib}";
2021 local nowrite=yes;
2022 fi;
2023 install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
2024 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
2025 pushd "${ED}/usr/${libdir}" > /dev/null;
2026 ln -snf "../../${libdir}/${tlib}" "${lib}";
2027 popd > /dev/null
2028 ;;
2029 *-aix* | *-irix* | *64*-hpux* | *-interix* | *-winnt*)
2030 if ${auto}; then
2031 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
2032 tlib=$(readlink "${ED}"/${libdir}/${lib});
2033 tlib=${tlib##*/};
2034 if [[ -z ${tlib} ]]; then
2035 tlib=${lib};
2036 else
2037 rm -f "${ED}"/${libdir}/${lib};
2038 fi;
2039 else
2040 tlib=${lib};
2041 fi;
2042 pushd "${ED}/usr/${libdir}" > /dev/null;
2043 ln -snf "../../${libdir}/${tlib}" "${lib}";
2044 popd > /dev/null
2045 ;;
2046 hppa*-hpux*)
2047 if ${auto}; then
2048 tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
2049 [[ -z ${tlib} ]] && tlib=${lib};
2050 tlib=${tlib##*/};
2051 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
2052 if [[ ${tlib} != ${lib}* ]]; then
2053 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
2054 fi;
2055 [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
2056 else
2057 tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
2058 [[ -z ${tlib} ]] && tlib=${lib};
2059 tlib=${tlib##*/};
2060 fi;
2061 pushd "${ED}"/usr/${libdir} > /dev/null;
2062 ln -snf "../../${libdir}/${tlib}" "${lib}";
2063 [[ ${tlib} != ${lib} ]] && ln -snf "../../${libdir}/${tlib}" "${tlib}";
2064 popd > /dev/null
2065 ;;
2066 *)
2067 if ${auto}; then
2068 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
2069 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
2070 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
2071 if [[ ${tlib} != ${lib}* ]]; then
2072 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
2073 fi;
2074 rm -f "${ED}"/${libdir}/${lib};
2075 else
2076 tlib=${lib};
2077 fi;
2078 cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
2079 /* GNU ld script
2080 Since Gentoo has critical dynamic libraries in /lib, and the static versions
2081 in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
2082 run into linking problems. This "fake" dynamic lib is a linker script that
2083 redirects the linker to the real lib. And yes, this works in the cross-
2084 compiling scenario as the sysroot-ed linker will prepend the real path.
2085
2086 See bug http://bugs.gentoo.org/4411 for more info.
2087 */
2088 ${output_format}
2089 GROUP ( ${EPREFIX}/${libdir}/${tlib} )
2090 END_LDSCRIPT
2091
2092 ;;
2093 esac
2094 fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
2095 done
2096 }
2097 get-flag ()
2098 {
2099 local f findflag="$1";
2100 for f in ${CFLAGS} ${CXXFLAGS} ${FFLAGS} ${FCFLAGS};
2101 do
2102 if [ "${f/${findflag}}" != "${f}" ]; then
2103 printf "%s\n" "${f/-${findflag}=}";
2104 return 0;
2105 fi;
2106 done;
2107 return 1
2108 }
2109 get_abi_ASFLAGS ()
2110 {
2111 get_abi_var ASFLAGS "$@"
2112 }
2113 get_abi_CDEFINE ()
2114 {
2115 get_abi_var CDEFINE "$@"
2116 }
2117 get_abi_CFLAGS ()
2118 {
2119 get_abi_var CFLAGS "$@"
2120 }
2121 get_abi_CHOST ()
2122 {
2123 get_abi_var CHOST "$@"
2124 }
2125 get_abi_CTARGET ()
2126 {
2127 get_abi_var CTARGET "$@"
2128 }
2129 get_abi_FAKE_TARGETS ()
2130 {
2131 get_abi_var FAKE_TARGETS "$@"
2132 }
2133 get_abi_LDFLAGS ()
2134 {
2135 get_abi_var LDFLAGS "$@"
2136 }
2137 get_abi_LIBDIR ()
2138 {
2139 get_abi_var LIBDIR "$@"
2140 }
2141 get_abi_var ()
2142 {
2143 local flag=$1;
2144 local abi;
2145 if [ $# -gt 1 ]; then
2146 abi=${2};
2147 else
2148 if [ -n "${ABI}" ]; then
2149 abi=${ABI};
2150 else
2151 if [ -n "${DEFAULT_ABI}" ]; then
2152 abi=${DEFAULT_ABI};
2153 else
2154 abi="default";
2155 fi;
2156 fi;
2157 fi;
2158 local var="${flag}_${abi}";
2159 echo ${!var}
2160 }
2161 get_all_abis ()
2162 {
2163 local order="";
2164 if [[ -z ${MULTILIB_ABIS} ]]; then
2165 echo "default";
2166 return 0;
2167 fi;
2168 for x in ${MULTILIB_ABIS};
2169 do
2170 if [[ ${x} != ${DEFAULT_ABI} ]]; then
2171 order="${order:+${order} }${x}";
2172 fi;
2173 done;
2174 order="${order:+${order} }${DEFAULT_ABI}";
2175 echo ${order};
2176 return 0
2177 }
2178 get_all_libdirs ()
2179 {
2180 local libdirs="lib";
2181 local abi;
2182 local dir;
2183 for abi in ${MULTILIB_ABIS};
2184 do
2185 [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})";
2186 done;
2187 echo "${libdirs}"
2188 }
2189 get_bmake ()
2190 {
2191 if [[ ${USERLAND} == *BSD ]]; then
2192 echo make;
2193 else
2194 if [[ ${USERLAND} == "Darwin" ]]; then
2195 echo bsdmake;
2196 else
2197 echo pmake;
2198 fi;
2199 fi
2200 }
2201 get_install_abis ()
2202 {
2203 local order="";
2204 if [[ -z ${MULTILIB_ABIS} ]]; then
2205 echo "default";
2206 return 0;
2207 fi;
2208 if [[ ${EMULTILIB_PKG} == "true" ]]; then
2209 for x in ${MULTILIB_ABIS};
2210 do
2211 if [[ ${x} != "${DEFAULT_ABI}" ]]; then
2212 hasq ${x} ${ABI_DENY} || ordera="${ordera} ${x}";
2213 fi;
2214 done;
2215 hasq ${DEFAULT_ABI} ${ABI_DENY} || order="${ordera} ${DEFAULT_ABI}";
2216 if [[ -n ${ABI_ALLOW} ]]; then
2217 local ordera="";
2218 for x in ${order};
2219 do
2220 if hasq ${x} ${ABI_ALLOW}; then
2221 ordera="${ordera} ${x}";
2222 fi;
2223 done;
2224 order=${ordera};
2225 fi;
2226 else
2227 order=${DEFAULT_ABI};
2228 fi;
2229 if [[ -z ${order} ]]; then
2230 die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package.";
2231 fi;
2232 echo ${order};
2233 return 0
2234 }
2235 get_libdir ()
2236 {
2237 local CONF_LIBDIR;
2238 if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
2239 echo ${CONF_LIBDIR_OVERRIDE};
2240 else
2241 get_abi_LIBDIR;
2242 fi
2243 }
2244 get_libdir_override ()
2245 {
2246 if has_multilib_profile; then
2247 eerror "get_libdir_override called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@g.o";
2248 exit 1;
2249 fi;
2250 CONF_LIBDIR="$1";
2251 CONF_LIBDIR_OVERRIDE="$1";
2252 LIBDIR_default="$1"
2253 }
2254 get_libname ()
2255 {
2256 local libname;
2257 local ver=$1;
2258 case ${CHOST} in
2259 *-cygwin | mingw* | *-mingw*)
2260 libname="dll"
2261 ;;
2262 *-darwin*)
2263 libname="dylib"
2264 ;;
2265 *-mint*)
2266 libname="irrelevant"
2267 ;;
2268 hppa*-hpux*)
2269 libname="sl"
2270 ;;
2271 *)
2272 libname="so"
2273 ;;
2274 esac;
2275 if [[ -z $* ]]; then
2276 echo ".${libname}";
2277 else
2278 for ver in "$@";
2279 do
2280 case ${CHOST} in
2281 *-darwin*)
2282 echo ".${ver}.${libname}"
2283 ;;
2284 *-mint*)
2285 echo ".${libname}"
2286 ;;
2287 *)
2288 echo ".${libname}.${ver}"
2289 ;;
2290 esac;
2291 done;
2292 fi
2293 }
2294 get_ml_incdir ()
2295 {
2296 local dir=/usr/include;
2297 if [[ $# -gt 0 ]]; then
2298 incdir=$1;
2299 shift;
2300 fi;
2301 if [[ -z "${MULTILIB_ABIS}" ]]; then
2302 echo ${incdir};
2303 return 0;
2304 fi;
2305 local abi=${ABI-${DEFAULT_ABI}};
2306 if [[ $# -gt 0 ]]; then
2307 abi=$1;
2308 shift;
2309 fi;
2310 if [[ -d "${dir}/gentoo-multilib/${abi}" ]]; then
2311 echo ${dir}/gentoo-multilib/${abi};
2312 else
2313 echo ${dir};
2314 fi
2315 }
2316 get_modname ()
2317 {
2318 local modname;
2319 local ver=$1;
2320 case ${CHOST} in
2321 *-darwin*)
2322 modname="bundle"
2323 ;;
2324 *)
2325 modname="so"
2326 ;;
2327 esac;
2328 echo ".${modname}"
2329 }
2330 get_mounts ()
2331 {
2332 local point= node= fs= opts= foo=;
2333 if [[ $(uname -s) == "Linux" ]]; then
2334 while read node point fs opts foo; do
2335 echo "${point} ${node} ${fs} ${opts}";
2336 done < /proc/mounts;
2337 return;
2338 fi;
2339 local IFS=' ';
2340 LC_ALL=C mount -p | while read node point fs foo; do
2341 opts=${fs#* };
2342 fs=${fs%% *};
2343 echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}";
2344 done
2345 }
2346 get_multilibdir ()
2347 {
2348 if has_multilib_profile; then
2349 eerror "get_multilibdir called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@g.o";
2350 exit 1;
2351 fi;
2352 echo ${CONF_MULTILIBDIR:=lib32}
2353 }
2354 has_hardened ()
2355 {
2356 ewarn "has_hardened: deprecated, please use gcc-specs-{relro,now}()!" 1>&2;
2357 test_version_info Hardened && return 0;
2358 [[ -f ${GCC_SPECS} && ${GCC_SPECS} != ${GCC_SPECS/hardened/} ]]
2359 }
2360 has_m32 ()
2361 {
2362 [ "$(tc-arch)" = "amd64" ] && has_multilib_profile && return 0;
2363 local temp=$(emktemp);
2364 echo "int main() { return(0); }" > "${temp}".c;
2365 MY_CC=$(tc-getCC);
2366 ${MY_CC/ .*/} -m32 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
2367 local ret=$?;
2368 rm -f "${temp}".c;
2369 [[ ${ret} != 1 ]] && return 0;
2370 return 1
2371 }
2372 has_m64 ()
2373 {
2374 local temp="$(emktemp)";
2375 echo "int main() { return(0); }" > "${temp}".c;
2376 MY_CC=$(tc-getCC);
2377 ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
2378 local ret=$?;
2379 rm -f "${temp}".c;
2380 [[ ${ret} != 1 ]] && return 0;
2381 return 1
2382 }
2383 has_multilib_profile ()
2384 {
2385 [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
2386 }
2387 has_pic ()
2388 {
2389 ewarn "has_pic: deprecated, please use gcc-specs-pie()!" 1>&2;
2390 [[ ${CFLAGS/-fPIC} != ${CFLAGS} || ${CFLAGS/-fpic} != ${CFLAGS} ]] || gcc-specs-pie
2391 }
2392 has_pie ()
2393 {
2394 ewarn "has_pie: deprecated, please use gcc-specs-pie()!" 1>&2;
2395 [[ ${CFLAGS/-fPIE} != ${CFLAGS} || ${CFLAGS/-fpie} != ${CFLAGS} ]] || gcc-specs-pie
2396 }
2397 has_ssp ()
2398 {
2399 ewarn "has_ssp: deprecated, please use gcc-specs-ssp()!" 1>&2;
2400 [[ ${CFLAGS/-fstack-protector} != ${CFLAGS} || -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP__) ]] || gcc-specs-ssp
2401 }
2402 has_ssp_all ()
2403 {
2404 ewarn "has_ssp_all: deprecated, please use gcc-specs-ssp()!" 1>&2;
2405 [[ ${CFLAGS/-fstack-protector-all} != ${CFLAGS} || -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP_ALL__) ]] || gcc-specs-ssp-to-all
2406 }
2407 helpers_die ()
2408 {
2409 case "${EAPI:-0}" in
2410 0 | 1 | 2 | 3)
2411 echo -e "$@" 1>&2
2412 ;;
2413 *)
2414 die "$@"
2415 ;;
2416 esac
2417 }
2418 is-flag ()
2419 {
2420 is-flagq "$@" && echo true
2421 }
2422 is-flagq ()
2423 {
2424 [[ -n $2 ]] && die "Usage: is-flag <flag>";
2425 _is_flagq CFLAGS $1 || _is_flagq CXXFLAGS $1 || _is_flagq FFLAGS $1 || _is_flagq FCFLAGS $1
2426 }
2427 is-ldflag ()
2428 {
2429 is-ldflagq "$@" && echo true
2430 }
2431 is-ldflagq ()
2432 {
2433 [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
2434 _is_flagq LDFLAGS $1
2435 }
2436 is-login-disabled ()
2437 {
2438 shell=$(egetshell "$1");
2439 case ${shell} in
2440 /bin/false | /usr/bin/false | /sbin/nologin | /usr/sbin/nologin)
2441 return 0
2442 ;;
2443 *)
2444 return 1
2445 ;;
2446 esac
2447 }
2448 is_final_abi ()
2449 {
2450 has_multilib_profile || return 0;
2451 local ALL_ABIS=$(get_install_abis);
2452 local LAST_ABI=${ALL_ABIS/* /};
2453 [[ ${LAST_ABI} == ${ABI} ]]
2454 }
2455 lfs_fallocate_test ()
2456 {
2457 cat > "${T}"/fallocate.c <<-EOF
2458 #define _GNU_SOURCE
2459 #include <fcntl.h>
2460 main() { return fallocate(0, 0, 0, 0); }
2461 EOF
2462
2463 append-lfs-flags
2464 $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} "${T}"/fallocate.c -o /dev/null > /dev/null 2>&1 || export ac_cv_func_fallocate=no;
2465 rm -f "${T}"/fallocate.c
2466 }
2467 make_desktop_entry ()
2468 {
2469 [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
2470 local exec=${1};
2471 local name=${2:-${PN}};
2472 local icon=${3:-${PN}};
2473 local type=${4};
2474 local fields=${5};
2475 if [[ -z ${type} ]]; then
2476 local catmaj=${CATEGORY%%-*};
2477 local catmin=${CATEGORY##*-};
2478 case ${catmaj} in
2479 app)
2480 case ${catmin} in
2481 accessibility)
2482 type=Accessibility
2483 ;;
2484 admin)
2485 type=System
2486 ;;
2487 antivirus)
2488 type=System
2489 ;;
2490 arch)
2491 type=Archiving
2492 ;;
2493 backup)
2494 type=Archiving
2495 ;;
2496 cdr)
2497 type=DiscBurning
2498 ;;
2499 dicts)
2500 type=Dictionary
2501 ;;
2502 doc)
2503 type=Documentation
2504 ;;
2505 editors)
2506 type=TextEditor
2507 ;;
2508 emacs)
2509 type=TextEditor
2510 ;;
2511 emulation)
2512 type=Emulator
2513 ;;
2514 laptop)
2515 type=HardwareSettings
2516 ;;
2517 office)
2518 type=Office
2519 ;;
2520 pda)
2521 type=PDA
2522 ;;
2523 vim)
2524 type=TextEditor
2525 ;;
2526 xemacs)
2527 type=TextEditor
2528 ;;
2529 esac
2530 ;;
2531 dev)
2532 type="Development"
2533 ;;
2534 games)
2535 case ${catmin} in
2536 action | fps)
2537 type=ActionGame
2538 ;;
2539 arcade)
2540 type=ArcadeGame
2541 ;;
2542 board)
2543 type=BoardGame
2544 ;;
2545 emulation)
2546 type=Emulator
2547 ;;
2548 kids)
2549 type=KidsGame
2550 ;;
2551 puzzle)
2552 type=LogicGame
2553 ;;
2554 roguelike)
2555 type=RolePlaying
2556 ;;
2557 rpg)
2558 type=RolePlaying
2559 ;;
2560 simulation)
2561 type=Simulation
2562 ;;
2563 sports)
2564 type=SportsGame
2565 ;;
2566 strategy)
2567 type=StrategyGame
2568 ;;
2569 esac;
2570 type="Game;${type}"
2571 ;;
2572 gnome)
2573 type="Gnome;GTK"
2574 ;;
2575 kde)
2576 type="KDE;Qt"
2577 ;;
2578 mail)
2579 type="Network;Email"
2580 ;;
2581 media)
2582 case ${catmin} in
2583 gfx)
2584 type=Graphics
2585 ;;
2586 *)
2587 case ${catmin} in
2588 radio)
2589 type=Tuner
2590 ;;
2591 sound)
2592 type=Audio
2593 ;;
2594 tv)
2595 type=TV
2596 ;;
2597 video)
2598 type=Video
2599 ;;
2600 esac;
2601 type="AudioVideo;${type}"
2602 ;;
2603 esac
2604 ;;
2605 net)
2606 case ${catmin} in
2607 dialup)
2608 type=Dialup
2609 ;;
2610 ftp)
2611 type=FileTransfer
2612 ;;
2613 im)
2614 type=InstantMessaging
2615 ;;
2616 irc)
2617 type=IRCClient
2618 ;;
2619 mail)
2620 type=Email
2621 ;;
2622 news)
2623 type=News
2624 ;;
2625 nntp)
2626 type=News
2627 ;;
2628 p2p)
2629 type=FileTransfer
2630 ;;
2631 voip)
2632 type=Telephony
2633 ;;
2634 esac;
2635 type="Network;${type}"
2636 ;;
2637 sci)
2638 case ${catmin} in
2639 astro*)
2640 type=Astronomy
2641 ;;
2642 bio*)
2643 type=Biology
2644 ;;
2645 calc*)
2646 type=Calculator
2647 ;;
2648 chem*)
2649 type=Chemistry
2650 ;;
2651 elec*)
2652 type=Electronics
2653 ;;
2654 geo*)
2655 type=Geology
2656 ;;
2657 math*)
2658 type=Math
2659 ;;
2660 physics)
2661 type=Physics
2662 ;;
2663 visual*)
2664 type=DataVisualization
2665 ;;
2666 esac;
2667 type="Education;Science;${type}"
2668 ;;
2669 sys)
2670 type="System"
2671 ;;
2672 www)
2673 case ${catmin} in
2674 client)
2675 type=WebBrowser
2676 ;;
2677 esac;
2678 type="Network;${type}"
2679 ;;
2680 *)
2681 type=
2682 ;;
2683 esac;
2684 fi;
2685 if [ "${SLOT}" == "0" ]; then
2686 local desktop_name="${PN}";
2687 else
2688 local desktop_name="${PN}-${SLOT}";
2689 fi;
2690 local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
2691 type=${type%;}${type:+;};
2692 eshopts_push -s extglob;
2693 if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
2694 ewarn "As described in the Icon Theme Specification, icon file extensions are not";
2695 ewarn "allowed in .desktop files if the value is not an absolute path.";
2696 icon=${icon%.@(xpm|png|svg)};
2697 fi;
2698 eshopts_pop;
2699 cat > "${desktop}" <<-EOF
2700 [Desktop Entry]
2701 Name=${name}
2702 Type=Application
2703 Comment=${DESCRIPTION}
2704 Exec=${exec}
2705 TryExec=${exec%% *}
2706 Icon=${icon}
2707 Categories=${type}
2708 EOF
2709
2710 if [[ ${fields:-=} != *=* ]]; then
2711 ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
2712 fields="Path=${fields}";
2713 fi;
2714 [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
2715 ( insinto /usr/share/applications;
2716 doins "${desktop}" ) || die "installing desktop file failed"
2717 }
2718 make_session_desktop ()
2719 {
2720 [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
2721 [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
2722 local title=$1;
2723 local command=$2;
2724 local desktop=${T}/${wm:-${PN}}.desktop;
2725 shift 2;
2726 cat > "${desktop}" <<-EOF
2727 [Desktop Entry]
2728 Name=${title}
2729 Comment=This session logs you into ${title}
2730 Exec=${command} $*
2731 TryExec=${command}
2732 Type=XSession
2733 EOF
2734
2735 ( insinto /usr/share/xsessions;
2736 doins "${desktop}" )
2737 }
2738 make_wrapper ()
2739 {
2740 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
2741 local tmpwrapper=$(emktemp);
2742 cat > "${tmpwrapper}" <<EOF
2743 #!/bin/sh
2744 cd "${chdir:-.}"
2745 if [ -n "${libdir}" ] ; then
2746 if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
2747 export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
2748 else
2749 export LD_LIBRARY_PATH="${libdir}"
2750 fi
2751 fi
2752 exec ${bin} "\$@"
2753 EOF
2754
2755 chmod go+rx "${tmpwrapper}";
2756 if [[ -n ${path} ]]; then
2757 ( exeinto "${path}";
2758 newexe "${tmpwrapper}" "${wrapper}" ) || die;
2759 else
2760 newbin "${tmpwrapper}" "${wrapper}" || die;
2761 fi
2762 }
2763 multilib_env ()
2764 {
2765 local CTARGET=${1:-${CTARGET}};
2766 case ${CTARGET} in
2767 x86_64*)
2768 export CFLAGS_x86=${CFLAGS_x86--m32};
2769 export CHOST_x86=${CTARGET/x86_64/i686};
2770 export CTARGET_x86=${CHOST_x86};
2771 export CDEFINE_x86="__i386__";
2772 export LIBDIR_x86="lib";
2773 export CFLAGS_amd64=${CFLAGS_amd64--m64};
2774 export CHOST_amd64=${CTARGET};
2775 export CTARGET_amd64=${CHOST_amd64};
2776 export CDEFINE_amd64="__x86_64__";
2777 export LIBDIR_amd64="lib64";
2778 export MULTILIB_ABIS="amd64 x86";
2779 export DEFAULT_ABI="amd64"
2780 ;;
2781 mips64*)
2782 export CFLAGS_o32=${CFLAGS_o32--mabi=32};
2783 export CHOST_o32=${CTARGET/mips64/mips};
2784 export CTARGET_o32=${CHOST_o32};
2785 export CDEFINE_o32="_MIPS_SIM == _ABIO32";
2786 export LIBDIR_o32="lib";
2787 export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
2788 export CHOST_n32=${CTARGET};
2789 export CTARGET_n32=${CHOST_n32};
2790 export CDEFINE_n32="_MIPS_SIM == _ABIN32";
2791 export LIBDIR_n32="lib32";
2792 export CFLAGS_n64=${CFLAGS_n64--mabi=64};
2793 export CHOST_n64=${CTARGET};
2794 export CTARGET_n64=${CHOST_n64};
2795 export CDEFINE_n64="_MIPS_SIM == _ABI64";
2796 export LIBDIR_n64="lib64";
2797 export MULTILIB_ABIS="n64 n32 o32";
2798 export DEFAULT_ABI="n32"
2799 ;;
2800 powerpc64*)
2801 export CFLAGS_ppc=${CFLAGS_ppc--m32};
2802 export CHOST_ppc=${CTARGET/powerpc64/powerpc};
2803 export CTARGET_ppc=${CHOST_ppc};
2804 export CDEFINE_ppc="!__powerpc64__";
2805 export LIBDIR_ppc="lib";
2806 export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
2807 export CHOST_ppc64=${CTARGET};
2808 export CTARGET_ppc64=${CHOST_ppc64};
2809 export CDEFINE_ppc64="__powerpc64__";
2810 export LIBDIR_ppc64="lib64";
2811 export MULTILIB_ABIS="ppc64 ppc";
2812 export DEFAULT_ABI="ppc64"
2813 ;;
2814 s390x*)
2815 export CFLAGS_s390=${CFLAGS_s390--m31};
2816 export CHOST_s390=${CTARGET/s390x/s390};
2817 export CTARGET_s390=${CHOST_s390};
2818 export CDEFINE_s390="!__s390x__";
2819 export LIBDIR_s390="lib";
2820 export CFLAGS_s390x=${CFLAGS_s390x--m64};
2821 export CHOST_s390x=${CTARGET};
2822 export CTARGET_s390x=${CHOST_s390x};
2823 export CDEFINE_s390x="__s390x__";
2824 export LIBDIR_s390x="lib64";
2825 export MULTILIB_ABIS="s390x s390";
2826 export DEFAULT_ABI="s390x"
2827 ;;
2828 sparc*)
2829 export CFLAGS_sparc32=${CFLAGS_sparc32};
2830 export CHOST_sparc32=${CTARGET/sparc64/sparc};
2831 export CTARGET_sparc32=${CHOST_sparc32};
2832 export CDEFINE_sparc32="!__arch64__";
2833 export LIBDIR_sparc32="lib";
2834 export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
2835 export CHOST_sparc64=${CTARGET};
2836 export CTARGET_sparc64=${CHOST_sparc64};
2837 export CDEFINE_sparc64="__arch64__";
2838 export LIBDIR_sparc64="lib64";
2839 export MULTILIB_ABIS="${MULTILIB_ABIS-sparc64 sparc32}";
2840 export DEFAULT_ABI="${DEFAULT_ABI-sparc64}"
2841 ;;
2842 *)
2843 export MULTILIB_ABIS="default";
2844 export DEFAULT_ABI="default"
2845 ;;
2846 esac
2847 }
2848 multilib_toolchain_setup ()
2849 {
2850 local v vv;
2851 export ABI=$1;
2852 if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
2853 if [[ ${DEFAULT_ABI_SAVED} != "true" ]]; then
2854 for v in CHOST CBUILD AS CC CXX LD;
2855 do
2856 export __abi_saved_${v}="${!v}";
2857 done;
2858 export DEFAULT_ABI_SAVED="true";
2859 fi;
2860 export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
2861 export AS="$(tc-getAS) $(get_abi_ASFLAGS)";
2862 export CC="$(tc-getCC) $(get_abi_CFLAGS)";
2863 export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
2864 export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
2865 export CHOST=$(get_abi_CHOST $1);
2866 export CBUILD=$(get_abi_CHOST $1);
2867 else
2868 if [[ ${DEFAULT_ABI_SAVED} == "true" ]]; then
2869 for v in CHOST CBUILD AS CC CXX LD;
2870 do
2871 vv="__abi_saved_${v}";
2872 export ${v}="${!vv}";
2873 done;
2874 fi;
2875 fi
2876 }
2877 newicon ()
2878 {
2879 ( insinto /usr/share/pixmaps;
2880 newins "$@" )
2881 }
2882 newmenu ()
2883 {
2884 ( insinto /usr/share/applications;
2885 newins "$@" )
2886 }
2887 no-as-needed ()
2888 {
2889 case $($(tc-getLD) -v 2>&1 </dev/null) in
2890 *GNU*)
2891 echo "-Wl,--no-as-needed"
2892 ;;
2893 esac
2894 }
2895 nonfatal ()
2896 {
2897 if has "${EAPI:-0}" 0 1 2 3 3_pre2; then
2898 die "$FUNCNAME() not supported in this EAPI";
2899 fi;
2900 if [[ $# -lt 1 ]]; then
2901 die "$FUNCNAME(): Missing argument";
2902 fi;
2903 PORTAGE_NONFATAL=1 "$@"
2904 }
2905 number_abis ()
2906 {
2907 get_install_abis | wc -w
2908 }
2909 path_exists ()
2910 {
2911 local opt=$1;
2912 [[ ${opt} == -[ao] ]] && shift || opt="-a";
2913 [[ $# -eq 0 ]] && return 1;
2914 local p r=0;
2915 for p in "$@";
2916 do
2917 [[ -e ${p} ]];
2918 : $(( r += $? ));
2919 done;
2920 case ${opt} in
2921 -a)
2922 return $(( r != 0 ))
2923 ;;
2924 -o)
2925 return $(( r == $# ))
2926 ;;
2927 esac
2928 }
2929 pkg_nofetch ()
2930 {
2931 _eapi0_pkg_nofetch "$@"
2932 }
2933 post_src_install ()
2934 {
2935 lafilefixer "${D}"
2936 }
2937 prep_ml_includes ()
2938 {
2939 if [[ $(number_abis) -gt 1 ]]; then
2940 local dir;
2941 local dirs;
2942 local base;
2943 if [[ $# -eq 0 ]]; then
2944 dirs=/usr/include;
2945 else
2946 dirs="$@";
2947 fi;
2948 for dir in ${dirs};
2949 do
2950 base=${T}/gentoo-multilib/${dir}/gentoo-multilib;
2951 mkdir -p "${base}";
2952 [[ -d ${base}/${ABI} ]] && rm -rf "${base}/${ABI}";
2953 mv "${D}/${dir}" "${base}/${ABI}";
2954 done;
2955 if is_final_abi; then
2956 base=${T}/gentoo-multilib;
2957 pushd "${base}";
2958 find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C "${D}";
2959 popd;
2960 set --;
2961 for dir in ${dirs};
2962 do
2963 set -- "$@" "${dir}";
2964 local abi;
2965 for abi in $(get_install_abis);
2966 do
2967 set -- "$@" "$(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}";
2968 done;
2969 create_ml_includes "$@";
2970 done;
2971 fi;
2972 fi
2973 }
2974 preserve_old_lib ()
2975 {
2976 if [[ ${EBUILD_PHASE} != "preinst" ]]; then
2977 eerror "preserve_old_lib() must be called from pkg_preinst() only";
2978 die "Invalid preserve_old_lib() usage";
2979 fi;
2980 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
2981 has preserve-libs ${FEATURES} && return 0;
2982 local lib dir;
2983 for lib in "$@";
2984 do
2985 [[ -e ${ROOT}/${lib} ]] || continue;
2986 dir=${lib%/*};
2987 dodir ${dir} || die "dodir ${dir} failed";
2988 cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
2989 touch "${D}"/${lib};
2990 done
2991 }
2992 preserve_old_lib_notify ()
2993 {
2994 if [[ ${EBUILD_PHASE} != "postinst" ]]; then
2995 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
2996 die "Invalid preserve_old_lib_notify() usage";
2997 fi;
2998 has preserve-libs ${FEATURES} && return 0;
2999 local lib notice=0;
3000 for lib in "$@";
3001 do
3002 [[ -e ${ROOT}/${lib} ]] || continue;
3003 if [[ ${notice} -eq 0 ]]; then
3004 notice=1;
3005 ewarn "Old versions of installed libraries were detected on your system.";
3006 ewarn "In order to avoid breaking packages that depend on these old libs,";
3007 ewarn "the libraries are not being removed. You need to run revdep-rebuild";
3008 ewarn "in order to remove these old dependencies. If you do not have this";
3009 ewarn "helper program, simply emerge the 'gentoolkit' package.";
3010 ewarn;
3011 fi;
3012 ewarn " # revdep-rebuild --library '${lib}'";
3013 done;
3014 if [[ ${notice} -eq 1 ]]; then
3015 ewarn;
3016 ewarn "Once you've finished running revdep-rebuild, it should be safe to";
3017 ewarn "delete the old libraries. Here is a copy & paste for the lazy:";
3018 for lib in "$@";
3019 do
3020 ewarn " # rm '${lib}'";
3021 done;
3022 fi
3023 }
3024 raw-ldflags ()
3025 {
3026 local x input="$@";
3027 [[ -z ${input} ]] && input=${LDFLAGS};
3028 set --;
3029 for x in ${input};
3030 do
3031 x=${x#-Wl,};
3032 set -- "$@" ${x//,/ };
3033 done;
3034 echo "$@"
3035 }
3036 register_success_hook ()
3037 {
3038 local x;
3039 for x in $*;
3040 do
3041 hasq $x $EBUILD_SUCCESS_HOOKS || export EBUILD_SUCCESS_HOOKS="$EBUILD_SUCCESS_HOOKS $x";
3042 done
3043 }
3044 replace-cpu-flags ()
3045 {
3046 local newcpu="$#";
3047 newcpu="${!newcpu}";
3048 while [ $# -gt 1 ]; do
3049 replace-flags "-march=${1}" "-march=${newcpu}";
3050 replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
3051 replace-flags "-mtune=${1}" "-mtune=${newcpu}";
3052 shift;
3053 done;
3054 return 0
3055 }
3056 replace-flags ()
3057 {
3058 [[ $# != 2 ]] && echo && eerror "Usage: replace-flags <old flag> <new flag>" && die "replace-flags takes 2 arguments, not $#";
3059 local f fset;
3060 declare -a new_CFLAGS new_CXXFLAGS new_FFLAGS new_FCFLAGS;
3061 for fset in CFLAGS CXXFLAGS FFLAGS FCFLAGS;
3062 do
3063 for f in ${!fset};
3064 do
3065 [[ ${f} == ${1} ]] && f=${2};
3066 eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f};
3067 done;
3068 eval export ${fset}=\${new_${fset}\[*]};
3069 done;
3070 return 0
3071 }
3072 replace-sparc64-flags ()
3073 {
3074 local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
3075 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
3076 for x in ${SPARC64_CPUS};
3077 do
3078 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
3079 done;
3080 else
3081 for x in ${SPARC64_CPUS};
3082 do
3083 CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
3084 done;
3085 fi;
3086 if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
3087 for x in ${SPARC64_CPUS};
3088 do
3089 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
3090 done;
3091 else
3092 for x in ${SPARC64_CPUS};
3093 do
3094 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
3095 done;
3096 fi;
3097 export CFLAGS CXXFLAGS
3098 }
3099 seq ()
3100 {
3101 local p=$(type -P seq);
3102 if [[ -n ${p} ]]; then
3103 "${p}" "$@";
3104 return $?;
3105 fi;
3106 case $# in
3107 1)
3108 min=1 max=$1 step=1
3109 ;;
3110 2)
3111 min=$1 max=$2 step=1
3112 ;;
3113 3)
3114 min=$1 max=$3 step=$2
3115 ;;
3116 *)
3117 die "seq called with wrong number of arguments"
3118 ;;
3119 esac;
3120 p=$(type -P jot);
3121 if [[ -n ${p} ]]; then
3122 local reps;
3123 if [[ ${step} != 0 ]]; then
3124 reps=$(( (max - min) / step + 1 ));
3125 else
3126 reps=0;
3127 fi;
3128 jot $reps $min $max $step;
3129 return $?;
3130 fi;
3131 while :; do
3132 [[ $max < $min && $step > 0 ]] && break;
3133 [[ $min < $max && $step < 0 ]] && break;
3134 echo $min;
3135 : $(( min += step ));
3136 done;
3137 return 0
3138 }
3139 setup-allowed-flags ()
3140 {
3141 if [[ -z ${ALLOWED_FLAGS} ]]; then
3142 export ALLOWED_FLAGS="-pipe";
3143 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -O -O0 -O1 -O2 -mcpu -march -mtune";
3144 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fstack-protector-all";
3145 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fbounds-checking -fno-strict-overflow";
3146 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-PIE -fno-pie -fno-unit-at-a-time";
3147 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+";
3148 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident";
3149 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -W* -w";
3150 fi;
3151 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer";
3152 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt -m*-toc -D* -U*";
3153 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fma4 -mno-movbe -mno-xop -mno-lwp";
3154 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm";
3155 export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks";
3156 return 0
3157 }
3158 src_compile ()
3159 {
3160 _eapi2_src_compile "$@"
3161 }
3162 src_configure ()
3163 {
3164 lfs_fallocate_test;
3165 econf --enable-fs-paths-extra=/usr/sbin $(use_enable nls) --enable-agetty $(use_enable cramfs) $(use_enable old-linux elvtune) --disable-init --disable-kill --disable-last --disable-mesg --enable-partx --enable-raw --enable-rename --disable-reset --disable-login-utils --enable-schedutils --disable-wall --enable-write --without-pam $(use unicode || echo --with-ncurses) $(use_with selinux) $(use_with slang) $(tc-has-tls || echo --disable-tls)
3166 }
3167 src_install ()
3168 {
3169 emake install DESTDIR="${D}" || die "install failed";
3170 dodoc AUTHORS NEWS README* TODO docs/*;
3171 if ! use perl; then
3172 rm "${D}"/usr/bin/chkdupexe || die;
3173 rm "${D}"/usr/share/man/man1/chkdupexe.1 || die;
3174 fi;
3175 gen_usr_ldscript -a blkid uuid;
3176 rm -f "${D}"/usr/$(get_libdir)/*.la;
3177 if use crypt; then
3178 newinitd "${FILESDIR}"/crypto-loop.initd crypto-loop || die;
3179 newconfd "${FILESDIR}"/crypto-loop.confd crypto-loop || die;
3180 fi
3181 }
3182 src_prepare ()
3183 {
3184 if [[ ${PV} == "9999" ]]; then
3185 autopoint --force;
3186 eautoreconf;
3187 else
3188 use loop-aes && epatch "${WORKDIR}"/util-linux-ng-*.diff;
3189 fi;
3190 use uclibc && sed -i -e s/versionsort/alphasort/g -e s/strverscmp.h/dirent.h/g mount/lomount.c;
3191 elibtoolize
3192 }
3193 src_test ()
3194 {
3195 _eapi0_src_test "$@"
3196 }
3197 src_unpack ()
3198 {
3199 _eapi0_src_unpack "$@"
3200 }
3201 strip-flags ()
3202 {
3203 local x y flag NEW_CFLAGS NEW_CXXFLAGS NEW_FFLAGS NEW_FCFLAGS;
3204 setup-allowed-flags;
3205 local NEW_CFLAGS="";
3206 local NEW_CXXFLAGS="";
3207 local NEW_FFLAGS="";
3208 local NEW_FCFLAGS="";
3209 if has "~$(tc-arch)" ${ACCEPT_KEYWORDS}; then
3210 ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}";
3211 fi;
3212 set -f;
3213 for x in ${CFLAGS};
3214 do
3215 for y in ${ALLOWED_FLAGS};
3216 do
3217 flag=${x%%=*};
3218 if [ "${flag%%${y}}" = "" ]; then
3219 NEW_CFLAGS="${NEW_CFLAGS} ${x}";
3220 break;
3221 fi;
3222 done;
3223 done;
3224 for x in ${CXXFLAGS};
3225 do
3226 for y in ${ALLOWED_FLAGS};
3227 do
3228 flag=${x%%=*};
3229 if [ "${flag%%${y}}" = "" ]; then
3230 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}";
3231 break;
3232 fi;
3233 done;
3234 done;
3235 for x in ${FFLAGS};
3236 do
3237 for y in ${ALLOWED_FLAGS};
3238 do
3239 flag=${x%%=*};
3240 if [ "${flag%%${y}}" = "" ]; then
3241 NEW_FFLAGS="${NEW_FFLAGS} ${x}";
3242 break;
3243 fi;
3244 done;
3245 done;
3246 for x in ${FCFLAGS};
3247 do
3248 for y in ${ALLOWED_FLAGS};
3249 do
3250 flag=${x%%=*};
3251 if [ "${flag%%${y}}" = "" ]; then
3252 NEW_FCFLAGS="${NEW_FCFLAGS} ${x}";
3253 break;
3254 fi;
3255 done;
3256 done;
3257 if [ "${CFLAGS/-O}" != "${CFLAGS}" -a "${NEW_CFLAGS/-O}" = "${NEW_CFLAGS}" ]; then
3258 NEW_CFLAGS="${NEW_CFLAGS} -O2";
3259 fi;
3260 if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then
3261 NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2";
3262 fi;
3263 if [ "${FFLAGS/-O}" != "${FFLAGS}" -a "${NEW_FFLAGS/-O}" = "${NEW_FFLAGS}" ]; then
3264 NEW_FFLAGS="${NEW_FFLAGS} -O2";
3265 fi;
3266 if [ "${FCFLAGS/-O}" != "${FCFLAGS}" -a "${NEW_FCFLAGS/-O}" = "${NEW_FCFLAGS}" ]; then
3267 NEW_FCFLAGS="${NEW_FCFLAGS} -O2";
3268 fi;
3269 set +f;
3270 export CFLAGS="${NEW_CFLAGS}";
3271 export CXXFLAGS="${NEW_CXXFLAGS}";
3272 export FFLAGS="${NEW_FFLAGS}";
3273 export FCFLAGS="${NEW_FCFLAGS}";
3274 return 0
3275 }
3276 strip-linguas ()
3277 {
3278 local ls newls nols;
3279 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
3280 local op=$1;
3281 shift;
3282 ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
3283 shift;
3284 local d f;
3285 for d in "$@";
3286 do
3287 if [[ ${op} == "-u" ]]; then
3288 newls=${ls};
3289 else
3290 newls="";
3291 fi;
3292 for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
3293 do
3294 if [[ ${op} == "-i" ]]; then
3295 hasq ${f} ${ls} && newls="${newls} ${f}";
3296 else
3297 hasq ${f} ${ls} || newls="${newls} ${f}";
3298 fi;
3299 done;
3300 ls=${newls};
3301 done;
3302 else
3303 ls="$@";
3304 fi;
3305 nols="";
3306 newls="";
3307 for f in ${LINGUAS};
3308 do
3309 if hasq ${f} ${ls}; then
3310 newls="${newls} ${f}";
3311 else
3312 nols="${nols} ${f}";
3313 fi;
3314 done;
3315 [[ -n ${nols} ]] && ewarn "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
3316 export LINGUAS=${newls:1}
3317 }
3318 strip-unsupported-flags ()
3319 {
3320 export CFLAGS=$(test-flags-CC ${CFLAGS});
3321 export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
3322 export FFLAGS=$(test-flags-F77 ${FFLAGS});
3323 export FCFLAGS=$(test-flags-FC ${FCFLAGS})
3324 }
3325 tc-arch ()
3326 {
3327 tc-ninja_magic_to_arch portage "$@"
3328 }
3329 tc-arch-kernel ()
3330 {
3331 tc-ninja_magic_to_arch kern "$@"
3332 }
3333 tc-endian ()
3334 {
3335 local host=$1;
3336 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
3337 host=${host%%-*};
3338 case ${host} in
3339 alpha*)
3340 echo big
3341 ;;
3342 arm*b*)
3343 echo big
3344 ;;
3345 arm*)
3346 echo little
3347 ;;
3348 cris*)
3349 echo little
3350 ;;
3351 hppa*)
3352 echo big
3353 ;;
3354 i?86*)
3355 echo little
3356 ;;
3357 ia64*)
3358 echo little
3359 ;;
3360 m68*)
3361 echo big
3362 ;;
3363 mips*l*)
3364 echo little
3365 ;;
3366 mips*)
3367 echo big
3368 ;;
3369 powerpc*)
3370 echo big
3371 ;;
3372 s390*)
3373 echo big
3374 ;;
3375 sh*b*)
3376 echo big
3377 ;;
3378 sh*)
3379 echo little
3380 ;;
3381 sparc*)
3382 echo big
3383 ;;
3384 x86_64*)
3385 echo little
3386 ;;
3387 *)
3388 echo wtf
3389 ;;
3390 esac
3391 }
3392 tc-export ()
3393 {
3394 local var;
3395 for var in "$@";
3396 do
3397 [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
3398 eval tc-get${var} > /dev/null;
3399 done
3400 }
3401 tc-getAR ()
3402 {
3403 tc-getPROG AR ar "$@"
3404 }
3405 tc-getAS ()
3406 {
3407 tc-getPROG AS as "$@"
3408 }
3409 tc-getBUILD_CC ()
3410 {
3411 local v;
3412 for v in CC_FOR_BUILD BUILD_CC HOSTCC;
3413 do
3414 if [[ -n ${!v} ]]; then
3415 export BUILD_CC=${!v};
3416 echo "${!v}";
3417 return 0;
3418 fi;
3419 done;
3420 local search=;
3421 if [[ -n ${CBUILD} ]]; then
3422 search=$(type -p ${CBUILD}-gcc);
3423 search=${search##*/};
3424 fi;
3425 search=${search:-gcc};
3426 export BUILD_CC=${search};
3427 echo "${search}"
3428 }
3429 tc-getCC ()
3430 {
3431 tc-getPROG CC gcc "$@"
3432 }
3433 tc-getCPP ()
3434 {
3435 tc-getPROG CPP cpp "$@"
3436 }
3437 tc-getCXX ()
3438 {
3439 tc-getPROG CXX g++ "$@"
3440 }
3441 tc-getDLLWRAP ()
3442 {
3443 tc-getPROG DLLWRAP dllwrap "$@"
3444 }
3445 tc-getF77 ()
3446 {
3447 tc-getPROG F77 gfortran "$@"
3448 }
3449 tc-getFC ()
3450 {
3451 tc-getPROG FC gfortran "$@"
3452 }
3453 tc-getGCJ ()
3454 {
3455 tc-getPROG GCJ gcj "$@"
3456 }
3457 tc-getLD ()
3458 {
3459 tc-getPROG LD ld "$@"
3460 }
3461 tc-getNM ()
3462 {
3463 tc-getPROG NM nm "$@"
3464 }
3465 tc-getOBJCOPY ()
3466 {
3467 tc-getPROG OBJCOPY objcopy "$@"
3468 }
3469 tc-getPKG_CONFIG ()
3470 {
3471 tc-getPROG PKG_CONFIG pkg-config "$@"
3472 }
3473 tc-getPROG ()
3474 {
3475 local var=$1;
3476 local prog=$2;
3477 if [[ -n ${!var} ]]; then
3478 echo "${!var}";
3479 return 0;
3480 fi;
3481 local search=;
3482 [[ -n $3 ]] && search=$(type -p "$3-${prog}");
3483 [[ -z ${search} && -n ${CHOST} ]] && search=$(type -p "${CHOST}-${prog}");
3484 [[ -n ${search} ]] && prog=${search##*/};
3485 export ${var}=${prog};
3486 echo "${!var}"
3487 }
3488 tc-getRANLIB ()
3489 {
3490 tc-getPROG RANLIB ranlib "$@"
3491 }
3492 tc-getRC ()
3493 {
3494 tc-getPROG RC windres "$@"
3495 }
3496 tc-getSTRIP ()
3497 {
3498 tc-getPROG STRIP strip "$@"
3499 }
3500 tc-has-openmp ()
3501 {
3502 local base="${T}/test-tc-openmp";
3503 cat > "${base}.c" <<-EOF
3504 #include <omp.h>
3505 int main() {
3506 int nthreads, tid, ret = 0;
3507 #pragma omp parallel private(nthreads, tid)
3508 {
3509 tid = omp_get_thread_num();
3510 nthreads = omp_get_num_threads(); ret += tid + nthreads;
3511 }
3512 return ret;
3513 }
3514 EOF
3515
3516 $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
3517 local ret=$?;
3518 rm -f "${base}"*;
3519 return ${ret}
3520 }
3521 tc-has-tls ()
3522 {
3523 local base="${T}/test-tc-tls";
3524 cat > "${base}.c" <<-EOF
3525 int foo(int *i) {
3526 static __thread int j = 0;
3527 return *i ? j : *i;
3528 }
3529 EOF
3530
3531 local flags;
3532 case $1 in
3533 -s)
3534 flags="-S"
3535 ;;
3536 -c)
3537 flags="-c"
3538 ;;
3539 -l)
3540
3541 ;;
3542 -*)
3543 die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
3544 ;;
3545 esac;
3546 : ${flags:=-fPIC -shared -Wl,-z,defs};
3547 [[ $1 == -* ]] && shift;
3548 $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
3549 local ret=$?;
3550 rm -f "${base}"*;
3551 return ${ret}
3552 }
3553 tc-is-cross-compiler ()
3554 {
3555 return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
3556 }
3557 tc-is-hardfloat ()
3558 {
3559 [[ ${CTARGET//_/-} == *-hardfloat-* ]] && echo "yes" || echo "no"
3560 }
3561 tc-is-softfloat ()
3562 {
3563 case ${CTARGET} in
3564 bfin* | h8300*)
3565 echo "only"
3566 ;;
3567 *)
3568 [[ ${CTARGET//_/-} == *-softfloat-* ]] && echo "yes" || echo "no"
3569 ;;
3570 esac
3571 }
3572 tc-is-static-only ()
3573 {
3574 local host=${CTARGET:-${CHOST}};
3575 return $([[ ${host} == *-mint* ]])
3576 }
3577 tc-ninja_magic_to_arch ()
3578 {
3579 function ninj ()
3580 {
3581 [[ ${type} == "kern" ]] && echo $1 || echo $2
3582 };
3583 local type=$1;
3584 local host=$2;
3585 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
3586 case ${host} in
3587 alpha*)
3588 echo alpha
3589 ;;
3590 arm*)
3591 echo arm
3592 ;;
3593 avr*)
3594 ninj avr32 avr
3595 ;;
3596 bfin*)
3597 ninj blackfin bfin
3598 ;;
3599 cris*)
3600 echo cris
3601 ;;
3602 hppa*)
3603 ninj parisc hppa
3604 ;;
3605 i?86*)
3606 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
3607 echo i386;
3608 else
3609 echo x86;
3610 fi
3611 ;;
3612 ia64*)
3613 echo ia64
3614 ;;
3615 m68*)
3616 echo m68k
3617 ;;
3618 mips*)
3619 echo mips
3620 ;;
3621 nios2*)
3622 echo nios2
3623 ;;
3624 nios*)
3625 echo nios
3626 ;;
3627 powerpc*)
3628 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
3629 echo powerpc;
3630 else
3631 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
3632 if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
3633 echo powerpc;
3634 else
3635 echo ppc;
3636 fi;
3637 else
3638 if [[ ${host} == powerpc64* ]]; then
3639 echo ppc64;
3640 else
3641 if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
3642 ninj ppc64 ppc;
3643 else
3644 echo ppc;
3645 fi;
3646 fi;
3647 fi;
3648 fi
3649 ;;
3650 s390*)
3651 echo s390
3652 ;;
3653 sh64*)
3654 ninj sh64 sh
3655 ;;
3656 sh*)
3657 echo sh
3658 ;;
3659 sparc64*)
3660 ninj sparc64 sparc
3661 ;;
3662 sparc*)
3663 [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
3664 ;;
3665 vax*)
3666 echo vax
3667 ;;
3668 x86_64*)
3669 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
3670 echo x86;
3671 else
3672 ninj x86_64 amd64;
3673 fi
3674 ;;
3675 *)
3676 echo unknown
3677 ;;
3678 esac
3679 }
3680 test-flag-CC ()
3681 {
3682 test-flag-PROG "CC" "$1"
3683 }
3684 test-flag-CXX ()
3685 {
3686 test-flag-PROG "CXX" "$1"
3687 }
3688 test-flag-F77 ()
3689 {
3690 test-flag-PROG "F77" "$1"
3691 }
3692 test-flag-FC ()
3693 {
3694 test-flag-PROG "FC" "$1"
3695 }
3696 test-flag-PROG ()
3697 {
3698 local comp=$1;
3699 local flags="$2";
3700 [[ -z ${comp} || -z ${flags} ]] && return 1;
3701 local PROG=$(tc-get${comp});
3702 ${PROG} ${flags} -S -o /dev/null -xc /dev/null > /dev/null 2>&1
3703 }
3704 test-flags ()
3705 {
3706 test-flags-CC "$@"
3707 }
3708 test-flags-CC ()
3709 {
3710 test-flags-PROG "CC" "$@"
3711 }
3712 test-flags-CXX ()
3713 {
3714 test-flags-PROG "CXX" "$@"
3715 }
3716 test-flags-F77 ()
3717 {
3718 test-flags-PROG "F77" "$@"
3719 }
3720 test-flags-FC ()
3721 {
3722 test-flags-PROG "FC" "$@"
3723 }
3724 test-flags-PROG ()
3725 {
3726 local comp=$1;
3727 local flags;
3728 local x;
3729 shift;
3730 [[ -z ${comp} ]] && return 1;
3731 x="";
3732 for x in "$@";
3733 do
3734 test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}";
3735 done;
3736 echo "${flags}";
3737 [[ -n ${flags} ]]
3738 }
3739 test_flag ()
3740 {
3741 ewarn "test_flag: deprecated, please use test-flags()!" 1>&2;
3742 test-flags-CC "$@"
3743 }
3744 test_version_info ()
3745 {
3746 if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
3747 return 0;
3748 else
3749 return 1;
3750 fi
3751 }
3752 treecopy ()
3753 {
3754 dest=${!#};
3755 files_count=$#;
3756 while (( $# > 1 )); do
3757 dirstruct=$(dirname "$1");
3758 mkdir -p "${dest}/${dirstruct}";
3759 cp -pPR "$1" "${dest}/${dirstruct}";
3760 shift;
3761 done
3762 }
3763 uclibctoolize ()
3764 {
3765 die "Use elibtoolize"
3766 }
3767 unpack_makeself ()
3768 {
3769 local src_input=${1:-${A}};
3770 local src=$(find_unpackable_file "${src_input}");
3771 local skip=$2;
3772 local exe=$3;
3773 [[ -z ${src} ]] && die "Could not locate source for '${src_input}'";
3774 local shrtsrc=$(basename "${src}");
3775 echo ">>> Unpacking ${shrtsrc} to ${PWD}";
3776 if [[ -z ${skip} ]]; then
3777 local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}');
3778 local skip=0;
3779 exe=tail;
3780 case ${ver} in
3781 1.5.* | 1.6.0-nv)
3782 skip=$(grep -a ^skip= "${src}" | cut -d= -f2)
3783 ;;
3784 2.0 | 2.0.1)
3785 skip=$(grep -a ^' 'tail "${src}" | awk '{print $2}' | cut -b2-)
3786 ;;
3787 2.1.1)
3788 skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-);
3789 (( skip++ ))
3790 ;;
3791 2.1.2)
3792 skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1);
3793 (( skip++ ))
3794 ;;
3795 2.1.3)
3796 skip=`grep -a ^offset= "${src}" | awk '{print $3}'`;
3797 (( skip++ ))
3798 ;;
3799 2.1.4 | 2.1.5)
3800 skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1);
3801 skip=$(head -n ${skip} "${src}" | wc -c);
3802 exe="dd"
3803 ;;
3804 *)
3805 eerror "I'm sorry, but I was unable to support the Makeself file.";
3806 eerror "The version I detected was '${ver}'.";
3807 eerror "Please file a bug about the file ${shrtsrc} at";
3808 eerror "http://bugs.gentoo.org/ so that support can be added.";
3809 die "makeself version '${ver}' not supported"
3810 ;;
3811 esac;
3812 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset";
3813 fi;
3814 case ${exe} in
3815 tail)
3816 exe="tail -n +${skip} '${src}'"
3817 ;;
3818 dd)
3819 exe="dd ibs=${skip} skip=1 if='${src}'"
3820 ;;
3821 *)
3822 die "makeself cant handle exe '${exe}'"
3823 ;;
3824 esac;
3825 local tmpfile=$(emktemp);
3826 eval ${exe} 2> /dev/null | head -c 512 > "${tmpfile}";
3827 local filetype=$(file -b "${tmpfile}");
3828 case ${filetype} in
3829 *tar\ archive*)
3830 eval ${exe} | tar --no-same-owner -xf -
3831 ;;
3832 bzip2*)
3833 eval ${exe} | bzip2 -dc | tar --no-same-owner -xf -
3834 ;;
3835 gzip*)
3836 eval ${exe} | tar --no-same-owner -xzf -
3837 ;;
3838 compress*)
3839 eval ${exe} | gunzip | tar --no-same-owner -xf -
3840 ;;
3841 *)
3842 eerror "Unknown filetype \"${filetype}\" ?";
3843 false
3844 ;;
3845 esac;
3846 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
3847 }
3848 unpack_pdv ()
3849 {
3850 local src=$(find_unpackable_file "$1");
3851 local sizeoff_t=$2;
3852 [[ -z ${src} ]] && die "Could not locate source for '$1'";
3853 [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :(";
3854 local shrtsrc=$(basename "${src}");
3855 echo ">>> Unpacking ${shrtsrc} to ${PWD}";
3856 local metaskip=$(tail -c ${sizeoff_t} "${src}" | hexdump -e \"%i\");
3857 local tailskip=$(tail -c $((${sizeoff_t}*2)) "${src}" | head -c ${sizeoff_t} | hexdump -e \"%i\");
3858 local metafile=$(emktemp);
3859 tail -c +$((${metaskip}+1)) "${src}" > "${metafile}";
3860 local datafile=$(tail -c +$((${metaskip}+1)) "${src}" | strings | head -n 1);
3861 datafile=$(basename "${datafile}");
3862 local tmpfile=$(emktemp);
3863 tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c 512 > ${tmpfile};
3864 local iscompressed=$(file -b "${tmpfile}");
3865 if [[ ${iscompressed:0:8} == "compress" ]]; then
3866 iscompressed=1;
3867 mv ${tmpfile}{,.Z};
3868 gunzip ${tmpfile};
3869 else
3870 iscompressed=0;
3871 fi;
3872 local istar=$(file -b "${tmpfile}");
3873 if [[ ${istar:0:9} == "POSIX tar" ]]; then
3874 istar=1;
3875 else
3876 istar=0;
3877 fi;
3878 if [ ${iscompressed} -eq 1 ]; then
3879 if [ ${istar} -eq 1 ]; then
3880 tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar -xzf -;
3881 else
3882 tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | gzip -dc > ${datafile};
3883 fi;
3884 else
3885 if [ ${istar} -eq 1 ]; then
3886 tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar --no-same-owner -xf -;
3887 else
3888 tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) > ${datafile};
3889 fi;
3890 fi;
3891 true
3892 }
3893 validate_desktop_entries ()
3894 {
3895 if [[ -x /usr/bin/desktop-file-validate ]]; then
3896 einfo "Checking desktop entry validity";
3897 local directories="";
3898 for d in /usr/share/applications $@;
3899 do
3900 [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
3901 done;
3902 if [[ -n ${directories} ]]; then
3903 for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
3904 do
3905 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
3906 [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
3907 done;
3908 fi;
3909 echo "";
3910 else
3911 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
3912 fi
3913 }
3914
3915
3916
3917
3918
3919 How can I fix this issue?
3920
3921 Thank you very much for any help in advance!
3922
3923 Best regards,
3924 mcc

Replies

Subject Author
[gentoo-user] Re: util-linux failed to patch while emergeing walt <w41ter@×××××.com>