1 |
vapier |
1.18 |
# Copyright 1999-2003 Gentoo Technologies, Inc. |
2 |
azarah |
1.1 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
vapier |
1.41 |
# $Header: /home/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.40 2003/07/02 23:01:08 vapier Exp $ |
4 |
vapier |
1.18 |
# |
5 |
azarah |
1.1 |
# Author: Martin Schlemmer <azarah@gentoo.org> |
6 |
vapier |
1.18 |
# |
7 |
azarah |
1.1 |
# This eclass is for general purpose functions that most ebuilds |
8 |
vapier |
1.7 |
# have to implement themselves. |
9 |
azarah |
1.1 |
# |
10 |
|
|
# NB: If you add anything, please comment it! |
11 |
|
|
|
12 |
|
|
ECLASS=eutils |
13 |
|
|
INHERITED="$INHERITED $ECLASS" |
14 |
|
|
|
15 |
drobbins |
1.31 |
DEPEND="$DEPEND !bootstrap? ( sys-devel/patch )" |
16 |
azarah |
1.1 |
|
17 |
vapier |
1.22 |
DESCRIPTION="Based on the ${ECLASS} eclass" |
18 |
azarah |
1.1 |
|
19 |
|
|
# This function generate linker scripts in /usr/lib for dynamic |
20 |
|
|
# libs in /lib. This is to fix linking problems when you have |
21 |
|
|
# the .so in /lib, and the .a in /usr/lib. What happens is that |
22 |
|
|
# in some cases when linking dynamic, the .a in /usr/lib is used |
23 |
|
|
# instead of the .so in /lib due to gcc/libtool tweaking ld's |
24 |
|
|
# library search path. This cause many builds to fail. |
25 |
|
|
# See bug #4411 for more info. |
26 |
|
|
# |
27 |
|
|
# To use, simply call: |
28 |
|
|
# |
29 |
|
|
# gen_usr_ldscript libfoo.so |
30 |
|
|
# |
31 |
|
|
# Note that you should in general use the unversioned name of |
32 |
|
|
# the library, as ldconfig should usually update it correctly |
33 |
|
|
# to point to the latest version of the library present. |
34 |
|
|
# |
35 |
|
|
# <azarah@gentoo.org> (26 Oct 2002) |
36 |
|
|
# |
37 |
|
|
gen_usr_ldscript() { |
38 |
|
|
|
39 |
|
|
# Just make sure it exists |
40 |
|
|
dodir /usr/lib |
41 |
danarmak |
1.32 |
|
42 |
azarah |
1.1 |
cat > ${D}/usr/lib/$1 <<"END_LDSCRIPT" |
43 |
|
|
/* GNU ld script |
44 |
|
|
Because Gentoo have critical dynamic libraries |
45 |
|
|
in /lib, and the static versions in /usr/lib, we |
46 |
|
|
need to have a "fake" dynamic lib in /usr/lib, |
47 |
|
|
otherwise we run into linking problems. |
48 |
|
|
See bug #4411 on http://bugs.gentoo.org/ for |
49 |
|
|
more info. */ |
50 |
|
|
GROUP ( /lib/libxxx ) |
51 |
|
|
END_LDSCRIPT |
52 |
|
|
|
53 |
|
|
dosed "s:libxxx:$1:" /usr/lib/$1 |
54 |
azarah |
1.5 |
|
55 |
|
|
return 0 |
56 |
azarah |
1.2 |
} |
57 |
|
|
|
58 |
azarah |
1.5 |
# Simple function to draw a line consisting of '=' the same length as $* |
59 |
|
|
# |
60 |
|
|
# <azarah@gentoo.org> (11 Nov 2002) |
61 |
|
|
# |
62 |
|
|
draw_line() { |
63 |
|
|
local i=0 |
64 |
|
|
local str_length="" |
65 |
|
|
|
66 |
|
|
# Handle calls that do not have args, or wc not being installed ... |
67 |
|
|
if [ -z "$1" -o ! -x "$(which wc 2>/dev/null)" ] |
68 |
|
|
then |
69 |
|
|
echo "===============================================================" |
70 |
|
|
return 0 |
71 |
|
|
fi |
72 |
|
|
|
73 |
|
|
# Get the length of $* |
74 |
|
|
str_length="$(echo -n "$*" | wc -m)" |
75 |
danarmak |
1.32 |
|
76 |
azarah |
1.5 |
while [ "$i" -lt "${str_length}" ] |
77 |
|
|
do |
78 |
|
|
echo -n "=" |
79 |
danarmak |
1.32 |
|
80 |
azarah |
1.5 |
i=$((i + 1)) |
81 |
|
|
done |
82 |
|
|
|
83 |
|
|
echo |
84 |
|
|
|
85 |
|
|
return 0 |
86 |
|
|
} |
87 |
azarah |
1.2 |
|
88 |
|
|
# Default directory where patches are located |
89 |
|
|
EPATCH_SOURCE="${WORKDIR}/patch" |
90 |
|
|
# Default extension for patches |
91 |
|
|
EPATCH_SUFFIX="patch.bz2" |
92 |
|
|
# Default options for patch |
93 |
|
|
EPATCH_OPTS="" |
94 |
azarah |
1.6 |
# List of patches not to apply. Not this is only file names, |
95 |
|
|
# and not the full path .. |
96 |
|
|
EPATCH_EXCLUDE="" |
97 |
azarah |
1.9 |
# Change the printed message for a single patch. |
98 |
|
|
EPATCH_SINGLE_MSG="" |
99 |
azarah |
1.29 |
# Force applying bulk patches even if not following the style: |
100 |
|
|
# |
101 |
|
|
# ??_${ARCH}_foo.${EPATCH_SUFFIX} |
102 |
|
|
# |
103 |
|
|
EPATCH_FORCE="no" |
104 |
azarah |
1.2 |
|
105 |
|
|
# This function is for bulk patching, or in theory for just one |
106 |
|
|
# or two patches. |
107 |
|
|
# |
108 |
|
|
# It should work with .bz2, .gz, .zip and plain text patches. |
109 |
|
|
# Currently all patches should be the same format. |
110 |
|
|
# |
111 |
|
|
# You do not have to specify '-p' option to patch, as it will |
112 |
|
|
# try with -p0 to -p5 until it succeed, or fail at -p5. |
113 |
|
|
# |
114 |
|
|
# Above EPATCH_* variables can be used to control various defaults, |
115 |
|
|
# bug they should be left as is to ensure an ebuild can rely on |
116 |
|
|
# them for. |
117 |
|
|
# |
118 |
azarah |
1.3 |
# Patches are applied in current directory. |
119 |
|
|
# |
120 |
|
|
# Bulk Patches should preferibly have the form of: |
121 |
azarah |
1.2 |
# |
122 |
|
|
# ??_${ARCH}_foo.${EPATCH_SUFFIX} |
123 |
|
|
# |
124 |
|
|
# For example: |
125 |
|
|
# |
126 |
|
|
# 01_all_misc-fix.patch.bz2 |
127 |
|
|
# 02_sparc_another-fix.patch.bz2 |
128 |
|
|
# |
129 |
|
|
# This ensures that there are a set order, and you can have ARCH |
130 |
|
|
# specific patches. |
131 |
|
|
# |
132 |
azarah |
1.3 |
# If you however give an argument to epatch(), it will treat it as a |
133 |
|
|
# single patch that need to be applied if its a file. If on the other |
134 |
|
|
# hand its a directory, it will set EPATCH_SOURCE to this. |
135 |
|
|
# |
136 |
azarah |
1.2 |
# <azarah@gentoo.org> (10 Nov 2002) |
137 |
|
|
# |
138 |
|
|
epatch() { |
139 |
|
|
local PIPE_CMD="" |
140 |
|
|
local STDERR_TARGET="${T}/$$.out" |
141 |
azarah |
1.8 |
local PATCH_TARGET="${T}/$$.patch" |
142 |
|
|
local PATCH_SUFFIX="" |
143 |
azarah |
1.3 |
local SINGLE_PATCH="no" |
144 |
azarah |
1.4 |
local x="" |
145 |
azarah |
1.3 |
|
146 |
|
|
if [ "$#" -gt 1 ] |
147 |
|
|
then |
148 |
|
|
eerror "Invalid arguments to epatch()" |
149 |
|
|
die "Invalid arguments to epatch()" |
150 |
|
|
fi |
151 |
|
|
|
152 |
|
|
if [ -n "$1" -a -f "$1" ] |
153 |
|
|
then |
154 |
|
|
SINGLE_PATCH="yes" |
155 |
danarmak |
1.32 |
|
156 |
azarah |
1.4 |
local EPATCH_SOURCE="$1" |
157 |
|
|
local EPATCH_SUFFIX="${1##*\.}" |
158 |
danarmak |
1.32 |
|
159 |
azarah |
1.3 |
elif [ -n "$1" -a -d "$1" ] |
160 |
|
|
then |
161 |
azarah |
1.29 |
# Allow no extension if EPATCH_FORCE=yes ... used by vim for example ... |
162 |
|
|
if [ "${EPATCH_FORCE}" = "yes" ] && [ -z "${EPATCH_SUFFIX}" ] |
163 |
|
|
then |
164 |
|
|
local EPATCH_SOURCE="$1/*" |
165 |
|
|
else |
166 |
|
|
local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" |
167 |
|
|
fi |
168 |
azarah |
1.3 |
else |
169 |
azarah |
1.8 |
if [ ! -d ${EPATCH_SOURCE} ] |
170 |
|
|
then |
171 |
azarah |
1.19 |
if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ] |
172 |
|
|
then |
173 |
|
|
EPATCH_SOURCE="$1" |
174 |
|
|
fi |
175 |
|
|
|
176 |
azarah |
1.8 |
echo |
177 |
azarah |
1.11 |
eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:" |
178 |
|
|
eerror |
179 |
|
|
eerror " ${EPATCH_SOURCE}" |
180 |
azarah |
1.8 |
echo |
181 |
|
|
die "Cannot find \$EPATCH_SOURCE!" |
182 |
|
|
fi |
183 |
danarmak |
1.32 |
|
184 |
azarah |
1.4 |
local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" |
185 |
azarah |
1.3 |
fi |
186 |
azarah |
1.2 |
|
187 |
|
|
case ${EPATCH_SUFFIX##*\.} in |
188 |
|
|
bz2) |
189 |
|
|
PIPE_CMD="bzip2 -dc" |
190 |
azarah |
1.8 |
PATCH_SUFFIX="bz2" |
191 |
azarah |
1.2 |
;; |
192 |
azarah |
1.6 |
gz|Z|z) |
193 |
azarah |
1.2 |
PIPE_CMD="gzip -dc" |
194 |
azarah |
1.8 |
PATCH_SUFFIX="gz" |
195 |
azarah |
1.2 |
;; |
196 |
azarah |
1.6 |
ZIP|zip) |
197 |
azarah |
1.2 |
PIPE_CMD="unzip -p" |
198 |
azarah |
1.8 |
PATCH_SUFFIX="zip" |
199 |
azarah |
1.2 |
;; |
200 |
|
|
*) |
201 |
|
|
PIPE_CMD="cat" |
202 |
azarah |
1.8 |
PATCH_SUFFIX="patch" |
203 |
azarah |
1.2 |
;; |
204 |
|
|
esac |
205 |
|
|
|
206 |
azarah |
1.3 |
if [ "${SINGLE_PATCH}" = "no" ] |
207 |
|
|
then |
208 |
|
|
einfo "Applying various patches (bugfixes/updates)..." |
209 |
|
|
fi |
210 |
|
|
for x in ${EPATCH_SOURCE} |
211 |
azarah |
1.2 |
do |
212 |
|
|
# New ARCH dependant patch naming scheme... |
213 |
|
|
# |
214 |
|
|
# ???_arch_foo.patch |
215 |
|
|
# |
216 |
|
|
if [ -f ${x} ] && \ |
217 |
azarah |
1.29 |
([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ |
218 |
|
|
[ "${EPATCH_FORCE}" = "yes" ]) |
219 |
azarah |
1.2 |
then |
220 |
|
|
local count=0 |
221 |
|
|
local popts="${EPATCH_OPTS}" |
222 |
azarah |
1.6 |
|
223 |
|
|
if [ -n "${EPATCH_EXCLUDE}" ] |
224 |
|
|
then |
225 |
azarah |
1.9 |
if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ] |
226 |
azarah |
1.6 |
then |
227 |
|
|
continue |
228 |
|
|
fi |
229 |
|
|
fi |
230 |
danarmak |
1.32 |
|
231 |
azarah |
1.3 |
if [ "${SINGLE_PATCH}" = "yes" ] |
232 |
|
|
then |
233 |
azarah |
1.9 |
if [ -n "${EPATCH_SINGLE_MSG}" ] |
234 |
|
|
then |
235 |
|
|
einfo "${EPATCH_SINGLE_MSG}" |
236 |
|
|
else |
237 |
|
|
einfo "Applying ${x##*/}..." |
238 |
|
|
fi |
239 |
azarah |
1.3 |
else |
240 |
|
|
einfo " ${x##*/}..." |
241 |
|
|
fi |
242 |
azarah |
1.2 |
|
243 |
azarah |
1.8 |
echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
244 |
|
|
echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
245 |
azarah |
1.2 |
|
246 |
|
|
# Allow for prefix to differ ... im lazy, so shoot me :/ |
247 |
|
|
while [ "${count}" -lt 5 ] |
248 |
|
|
do |
249 |
azarah |
1.5 |
# Generate some useful debug info ... |
250 |
azarah |
1.8 |
draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
251 |
|
|
echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
252 |
|
|
|
253 |
|
|
if [ "${PATCH_SUFFIX}" != "patch" ] |
254 |
|
|
then |
255 |
|
|
echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
256 |
|
|
echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
257 |
|
|
else |
258 |
|
|
PATCH_TARGET="${x}" |
259 |
|
|
fi |
260 |
danarmak |
1.32 |
|
261 |
azarah |
1.8 |
echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
262 |
|
|
echo "patch ${popts} -p${count} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
263 |
danarmak |
1.32 |
|
264 |
azarah |
1.8 |
echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
265 |
|
|
draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
266 |
|
|
|
267 |
|
|
if [ "${PATCH_SUFFIX}" != "patch" ] |
268 |
|
|
then |
269 |
|
|
if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 |
270 |
|
|
then |
271 |
|
|
echo |
272 |
|
|
eerror "Could not extract patch!" |
273 |
|
|
#die "Could not extract patch!" |
274 |
|
|
count=5 |
275 |
|
|
break |
276 |
|
|
fi |
277 |
|
|
fi |
278 |
danarmak |
1.32 |
|
279 |
azarah |
1.19 |
if (cat ${PATCH_TARGET} | patch ${popts} --dry-run -f -p${count}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 |
280 |
azarah |
1.2 |
then |
281 |
azarah |
1.8 |
draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real |
282 |
|
|
echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real |
283 |
|
|
echo "ACTUALLY APPLYING ${x##*/}..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real |
284 |
|
|
echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real |
285 |
|
|
draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real |
286 |
|
|
|
287 |
azarah |
1.19 |
cat ${PATCH_TARGET} | patch ${popts} -p${count} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 |
288 |
azarah |
1.8 |
|
289 |
|
|
if [ "$?" -ne 0 ] |
290 |
|
|
then |
291 |
|
|
cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
292 |
|
|
echo |
293 |
|
|
eerror "A dry-run of patch command succeeded, but actually" |
294 |
|
|
eerror "applying the patch failed!" |
295 |
|
|
#die "Real world sux compared to the dreamworld!" |
296 |
|
|
count=5 |
297 |
|
|
fi |
298 |
|
|
|
299 |
|
|
rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real |
300 |
danarmak |
1.32 |
|
301 |
azarah |
1.2 |
break |
302 |
|
|
fi |
303 |
|
|
|
304 |
|
|
count=$((count + 1)) |
305 |
|
|
done |
306 |
|
|
|
307 |
azarah |
1.8 |
if [ "${PATCH_SUFFIX}" != "patch" ] |
308 |
|
|
then |
309 |
|
|
rm -f ${PATCH_TARGET} |
310 |
|
|
fi |
311 |
|
|
|
312 |
azarah |
1.2 |
if [ "${count}" -eq 5 ] |
313 |
|
|
then |
314 |
azarah |
1.8 |
echo |
315 |
azarah |
1.2 |
eerror "Failed Patch: ${x##*/}!" |
316 |
|
|
eerror |
317 |
|
|
eerror "Include in your bugreport the contents of:" |
318 |
|
|
eerror |
319 |
azarah |
1.8 |
eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}" |
320 |
|
|
echo |
321 |
azarah |
1.2 |
die "Failed Patch: ${x##*/}!" |
322 |
|
|
fi |
323 |
azarah |
1.8 |
|
324 |
|
|
rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} |
325 |
azarah |
1.3 |
|
326 |
|
|
eend 0 |
327 |
azarah |
1.2 |
fi |
328 |
|
|
done |
329 |
azarah |
1.3 |
if [ "${SINGLE_PATCH}" = "no" ] |
330 |
|
|
then |
331 |
|
|
einfo "Done with patching" |
332 |
azarah |
1.10 |
fi |
333 |
azarah |
1.26 |
} |
334 |
|
|
|
335 |
|
|
# This function return true if we are using the NPTL pthreads |
336 |
|
|
# implementation. |
337 |
|
|
# |
338 |
|
|
# <azarah@gentoo.org> (06 March 2003) |
339 |
|
|
# |
340 |
|
|
|
341 |
|
|
have_NPTL() { |
342 |
|
|
|
343 |
|
|
cat > ${T}/test-nptl.c <<-"END" |
344 |
|
|
#define _XOPEN_SOURCE |
345 |
|
|
#include <unistd.h> |
346 |
|
|
#include <stdio.h> |
347 |
|
|
|
348 |
|
|
int main() |
349 |
|
|
{ |
350 |
|
|
char buf[255]; |
351 |
|
|
char *str = buf; |
352 |
|
|
|
353 |
|
|
confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255); |
354 |
|
|
if (NULL != str) { |
355 |
|
|
printf("%s\n", str); |
356 |
|
|
if (NULL != strstr(str, "NPTL")) |
357 |
|
|
return 0; |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
return 1; |
361 |
|
|
} |
362 |
|
|
END |
363 |
|
|
|
364 |
|
|
einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ... " |
365 |
|
|
if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null |
366 |
|
|
then |
367 |
|
|
echo "yes" |
368 |
|
|
einfon "Checking what PTHREADS implementation we have ... " |
369 |
|
|
if ${T}/nptl |
370 |
|
|
then |
371 |
|
|
return 0 |
372 |
|
|
else |
373 |
|
|
return 1 |
374 |
|
|
fi |
375 |
|
|
else |
376 |
|
|
echo "no" |
377 |
|
|
fi |
378 |
|
|
|
379 |
|
|
return 1 |
380 |
azarah |
1.10 |
} |
381 |
|
|
|
382 |
|
|
# This function check how many cpu's are present, and then set |
383 |
|
|
# -j in MAKEOPTS accordingly. |
384 |
|
|
# |
385 |
|
|
# Thanks to nall <nall@gentoo.org> for this. |
386 |
|
|
# |
387 |
|
|
get_number_of_jobs() { |
388 |
azarah |
1.13 |
local jobs=0 |
389 |
|
|
|
390 |
azarah |
1.10 |
if [ ! -r /proc/cpuinfo ] |
391 |
|
|
then |
392 |
|
|
return 1 |
393 |
|
|
fi |
394 |
|
|
|
395 |
azarah |
1.14 |
# This bit is from H?kan Wessberg <nacka-gentoo@refug.org>, bug #13565. |
396 |
|
|
if [ "`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | wc -l`" -gt 0 ] |
397 |
|
|
then |
398 |
|
|
ADMINOPTS="`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | cut -d= -f2 | sed 's/\"//g'`" |
399 |
azarah |
1.17 |
ADMINPARAM="`echo ${ADMINOPTS} | gawk '{match($0, /-j *[0-9]*/, opt); print opt[0]}'`" |
400 |
|
|
ADMINPARAM="${ADMINPARAM/-j}" |
401 |
azarah |
1.14 |
fi |
402 |
|
|
|
403 |
azarah |
1.17 |
export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`" |
404 |
danarmak |
1.32 |
|
405 |
drobbins |
1.35 |
if [ "${ARCH}" = "amd64" -o "${ARCH}" = "x86" -o "${ARCH}" = "hppa" -o \ |
406 |
zwelch |
1.21 |
"${ARCH}" = "arm" -o "${ARCH}" = "mips" ] |
407 |
azarah |
1.10 |
then |
408 |
zwelch |
1.21 |
# these archs will always have "[Pp]rocessor" |
409 |
|
|
jobs="$((`grep -c ^[Pp]rocessor /proc/cpuinfo` * 2))" |
410 |
danarmak |
1.32 |
|
411 |
azarah |
1.10 |
elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ] |
412 |
|
|
then |
413 |
|
|
# sparc always has "ncpus active" |
414 |
azarah |
1.13 |
jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" |
415 |
danarmak |
1.32 |
|
416 |
azarah |
1.10 |
elif [ "${ARCH}" = "alpha" ] |
417 |
|
|
then |
418 |
|
|
# alpha has "cpus active", but only when compiled with SMP |
419 |
azarah |
1.13 |
if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ] |
420 |
azarah |
1.10 |
then |
421 |
azarah |
1.13 |
jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))" |
422 |
azarah |
1.10 |
else |
423 |
azarah |
1.13 |
jobs=2 |
424 |
azarah |
1.10 |
fi |
425 |
danarmak |
1.32 |
|
426 |
azarah |
1.10 |
elif [ "${ARCH}" = "ppc" ] |
427 |
|
|
then |
428 |
|
|
# ppc has "processor", but only when compiled with SMP |
429 |
azarah |
1.13 |
if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ] |
430 |
azarah |
1.10 |
then |
431 |
azarah |
1.13 |
jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))" |
432 |
azarah |
1.10 |
else |
433 |
azarah |
1.13 |
jobs=2 |
434 |
azarah |
1.10 |
fi |
435 |
|
|
else |
436 |
azarah |
1.13 |
jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))" |
437 |
azarah |
1.10 |
die "Unknown ARCH -- ${ARCH}!" |
438 |
azarah |
1.3 |
fi |
439 |
azarah |
1.13 |
|
440 |
|
|
# Make sure the number is valid ... |
441 |
|
|
if [ "${jobs}" -lt 1 ] |
442 |
|
|
then |
443 |
|
|
jobs=1 |
444 |
|
|
fi |
445 |
danarmak |
1.32 |
|
446 |
azarah |
1.15 |
if [ -n "${ADMINPARAM}" ] |
447 |
azarah |
1.14 |
then |
448 |
azarah |
1.15 |
if [ "${jobs}" -gt "${ADMINPARAM}" ] |
449 |
|
|
then |
450 |
|
|
einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge..." |
451 |
|
|
export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}" |
452 |
|
|
else |
453 |
|
|
einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge..." |
454 |
|
|
export MAKEOPTS="${MAKEOPTS} -j${jobs}" |
455 |
|
|
fi |
456 |
azarah |
1.14 |
fi |
457 |
azarah |
1.1 |
} |
458 |
|
|
|
459 |
vapier |
1.23 |
# Simplify/standardize adding users to the system |
460 |
|
|
# vapier@gentoo.org |
461 |
|
|
# |
462 |
|
|
# enewuser(username, uid, shell, homedir, groups, extra options) |
463 |
|
|
# |
464 |
|
|
# Default values if you do not specify any: |
465 |
|
|
# username: REQUIRED ! |
466 |
|
|
# uid: next available (see useradd(8)) |
467 |
vapier |
1.27 |
# note: pass -1 to get default behavior |
468 |
vapier |
1.23 |
# shell: /bin/false |
469 |
|
|
# homedir: /dev/null |
470 |
|
|
# groups: none |
471 |
|
|
# extra: comment of 'added by portage for ${PN}' |
472 |
|
|
enewuser() { |
473 |
|
|
# get the username |
474 |
|
|
local euser="$1"; shift |
475 |
|
|
if [ -z "${euser}" ] ; then |
476 |
|
|
eerror "No username specified !" |
477 |
|
|
die "Cannot call enewuser without a username" |
478 |
|
|
fi |
479 |
|
|
einfo "Adding user '${euser}' to your system ..." |
480 |
|
|
|
481 |
|
|
# setup a file for testing usernames/groups |
482 |
|
|
local tmpfile="`mktemp -p ${T}`" |
483 |
|
|
touch ${tmpfile} |
484 |
|
|
chown ${euser} ${tmpfile} >& /dev/null |
485 |
|
|
local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" |
486 |
|
|
|
487 |
|
|
# see if user already exists |
488 |
|
|
if [ "${euser}" == "${realuser}" ] ; then |
489 |
|
|
einfo "${euser} already exists on your system :)" |
490 |
|
|
return 0 |
491 |
|
|
fi |
492 |
|
|
|
493 |
|
|
# options to pass to useradd |
494 |
|
|
local opts="" |
495 |
|
|
|
496 |
|
|
# handle uid |
497 |
|
|
local euid="$1"; shift |
498 |
vapier |
1.27 |
if [ ! -z "${euid}" ] && [ "${euid}" != "-1" ] ; then |
499 |
vapier |
1.23 |
if [ ${euid} -gt 0 ] ; then |
500 |
|
|
opts="${opts} -u ${euid}" |
501 |
|
|
else |
502 |
|
|
eerror "Userid given but is not greater than 0 !" |
503 |
|
|
die "${euid} is not a valid UID" |
504 |
|
|
fi |
505 |
|
|
else |
506 |
|
|
euid="next available" |
507 |
|
|
fi |
508 |
|
|
einfo " - Userid: ${euid}" |
509 |
|
|
|
510 |
|
|
# handle shell |
511 |
|
|
local eshell="$1"; shift |
512 |
|
|
if [ ! -z "${eshell}" ] ; then |
513 |
|
|
if [ ! -e ${eshell} ] ; then |
514 |
|
|
eerror "A shell was specified but it does not exist !" |
515 |
|
|
die "${eshell} does not exist" |
516 |
|
|
fi |
517 |
|
|
else |
518 |
|
|
eshell=/bin/false |
519 |
|
|
fi |
520 |
|
|
einfo " - Shell: ${eshell}" |
521 |
|
|
opts="${opts} -s ${eshell}" |
522 |
|
|
|
523 |
|
|
# handle homedir |
524 |
|
|
local ehome="$1"; shift |
525 |
|
|
if [ -z "${ehome}" ] ; then |
526 |
|
|
ehome=/dev/null |
527 |
|
|
fi |
528 |
|
|
einfo " - Home: ${ehome}" |
529 |
|
|
opts="${opts} -d ${ehome}" |
530 |
|
|
|
531 |
|
|
# handle groups |
532 |
|
|
local egroups="$1"; shift |
533 |
|
|
if [ ! -z "${egroups}" ] ; then |
534 |
|
|
local realgroup |
535 |
|
|
local oldifs="${IFS}" |
536 |
|
|
export IFS="," |
537 |
|
|
for g in ${egroups} ; do |
538 |
|
|
chgrp ${g} ${tmpfile} >& /dev/null |
539 |
|
|
realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" |
540 |
|
|
if [ "${g}" != "${realgroup}" ] ; then |
541 |
|
|
eerror "You must add ${g} to the system first" |
542 |
|
|
die "${g} is not a valid GID" |
543 |
|
|
fi |
544 |
|
|
done |
545 |
|
|
export IFS="${oldifs}" |
546 |
|
|
opts="${opts} -g ${egroups}" |
547 |
|
|
else |
548 |
|
|
egroups="(none)" |
549 |
|
|
fi |
550 |
|
|
einfo " - Groups: ${egroups}" |
551 |
|
|
|
552 |
|
|
# handle extra and add the user |
553 |
|
|
local eextra="$@" |
554 |
vapier |
1.36 |
local oldsandbox=${SANDBOX_ON} |
555 |
vapier |
1.23 |
export SANDBOX_ON="0" |
556 |
|
|
if [ -z "${eextra}" ] ; then |
557 |
|
|
useradd ${opts} ${euser} \ |
558 |
|
|
-c "added by portage for ${PN}" \ |
559 |
|
|
|| die "enewuser failed" |
560 |
|
|
else |
561 |
|
|
einfo " - Extra: ${eextra}" |
562 |
|
|
useradd ${opts} ${euser} ${eextra} \ |
563 |
danarmak |
1.32 |
|| die "enewuser failed" |
564 |
vapier |
1.23 |
fi |
565 |
|
|
export SANDBOX_ON="${oldsandbox}" |
566 |
|
|
|
567 |
|
|
if [ ! -e ${ehome} ] && [ ! -e ${D}/${ehome} ] ; then |
568 |
|
|
einfo " - Creating ${ehome} in ${D}" |
569 |
|
|
dodir ${ehome} |
570 |
vapier |
1.37 |
fowners ${euser} ${ehome} |
571 |
vapier |
1.38 |
fperms 755 ${ehome} |
572 |
vapier |
1.23 |
fi |
573 |
|
|
} |
574 |
|
|
|
575 |
|
|
# Simplify/standardize adding groups to the system |
576 |
|
|
# vapier@gentoo.org |
577 |
|
|
# |
578 |
|
|
# enewgroup(group, gid) |
579 |
|
|
# |
580 |
|
|
# Default values if you do not specify any: |
581 |
|
|
# groupname: REQUIRED ! |
582 |
|
|
# gid: next available (see groupadd(8)) |
583 |
|
|
# extra: none |
584 |
|
|
enewgroup() { |
585 |
|
|
# get the group |
586 |
|
|
local egroup="$1"; shift |
587 |
|
|
if [ -z "${egroup}" ] ; then |
588 |
|
|
eerror "No group specified !" |
589 |
|
|
die "Cannot call enewgroup without a group" |
590 |
|
|
fi |
591 |
|
|
einfo "Adding group '${egroup}' to your system ..." |
592 |
|
|
|
593 |
|
|
# setup a file for testing groupname |
594 |
|
|
local tmpfile="`mktemp -p ${T}`" |
595 |
|
|
touch ${tmpfile} |
596 |
|
|
chgrp ${egroup} ${tmpfile} >& /dev/null |
597 |
|
|
local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" |
598 |
|
|
|
599 |
|
|
# see if group already exists |
600 |
|
|
if [ "${egroup}" == "${realgroup}" ] ; then |
601 |
|
|
einfo "${egroup} already exists on your system :)" |
602 |
|
|
return 0 |
603 |
|
|
fi |
604 |
|
|
|
605 |
|
|
# options to pass to useradd |
606 |
|
|
local opts="" |
607 |
|
|
|
608 |
|
|
# handle gid |
609 |
|
|
local egid="$1"; shift |
610 |
|
|
if [ ! -z "${egid}" ] ; then |
611 |
|
|
if [ ${egid} -gt 0 ] ; then |
612 |
|
|
opts="${opts} -g ${egid}" |
613 |
|
|
else |
614 |
|
|
eerror "Groupid given but is not greater than 0 !" |
615 |
|
|
die "${egid} is not a valid GID" |
616 |
|
|
fi |
617 |
|
|
else |
618 |
|
|
egid="next available" |
619 |
|
|
fi |
620 |
|
|
einfo " - Groupid: ${egid}" |
621 |
|
|
|
622 |
|
|
# handle extra |
623 |
|
|
local eextra="$@" |
624 |
|
|
opts="${opts} ${eextra}" |
625 |
|
|
|
626 |
|
|
# add the group |
627 |
vapier |
1.36 |
local oldsandbox=${SANDBOX_ON} |
628 |
vapier |
1.23 |
export SANDBOX_ON="0" |
629 |
|
|
groupadd ${opts} ${egroup} || die "enewgroup failed" |
630 |
|
|
export SANDBOX_ON="${oldsandbox}" |
631 |
vapier |
1.24 |
} |
632 |
|
|
|
633 |
|
|
# Simple script to replace 'dos2unix' binaries |
634 |
|
|
# vapier@gentoo.org |
635 |
|
|
# |
636 |
|
|
# edos2unix(file, <more files>...) |
637 |
|
|
edos2unix() { |
638 |
|
|
for f in $@ ; do |
639 |
vapier |
1.28 |
cp ${f} ${T}/edos2unix |
640 |
|
|
sed 's/\r$//' ${T}/edos2unix > ${f} |
641 |
vapier |
1.24 |
done |
642 |
vapier |
1.39 |
} |
643 |
|
|
|
644 |
|
|
# Make a desktop file ! |
645 |
|
|
# Great for making those icons in kde/gnome startmenu ! |
646 |
|
|
# Amaze your friends ! Get the women ! Join today ! |
647 |
|
|
# gnome2 /usr/share/applications |
648 |
|
|
# gnome1 /usr/share/gnome/apps/ |
649 |
|
|
# KDE ${KDEDIR}/share/applnk /usr/share/applnk |
650 |
|
|
# |
651 |
|
|
# make_desktop_entry(<binary>, [name], [icon], [type], [path]) |
652 |
|
|
# |
653 |
|
|
# binary: what binary does the app run with ? |
654 |
|
|
# name: the name that will show up in the menu |
655 |
|
|
# icon: give your little like a pretty little icon ... |
656 |
|
|
# this can be relative (to /usr/share/pixmaps) or |
657 |
|
|
# a full path to an icon |
658 |
|
|
# type: what kind of application is this ? for categories: |
659 |
|
|
# http://www.freedesktop.org/standards/menu/draft/menu-spec/menu-spec.html |
660 |
|
|
# path: if your app needs to startup in a specific dir |
661 |
|
|
make_desktop_entry() { |
662 |
|
|
[ -z "$1" ] && eerror "You must specify the executable" && return 1 |
663 |
|
|
|
664 |
|
|
local exec=${1} |
665 |
|
|
local name=${2:-${PN}} |
666 |
|
|
local icon=${3:-${PN}.png} |
667 |
|
|
local type=${4} |
668 |
|
|
local path=${5:-${GAMES_PREFIX}} |
669 |
|
|
if [ -z "${type}" ] ; then |
670 |
|
|
case ${CATEGORY} in |
671 |
|
|
app-emulation) type=Emulator ;; |
672 |
|
|
app-games) type=Game ;; |
673 |
|
|
*) type="" ;; |
674 |
|
|
esac |
675 |
|
|
fi |
676 |
vapier |
1.40 |
local desktop=${T}/${exec}.desktop |
677 |
vapier |
1.39 |
|
678 |
|
|
echo "[Desktop Entry] |
679 |
|
|
Encoding=UTF-8 |
680 |
|
|
Version=0.9.2 |
681 |
|
|
Name=${name} |
682 |
|
|
Type=Application |
683 |
|
|
Comment=${DESCRIPTION} |
684 |
|
|
Exec=${exec} |
685 |
|
|
Path=${path} |
686 |
|
|
Icon=${icon} |
687 |
vapier |
1.40 |
Categories=Application;${type};" > ${desktop} |
688 |
vapier |
1.39 |
|
689 |
|
|
if [ -d /usr/share/applications ] ; then |
690 |
|
|
insinto /usr/share/applications |
691 |
vapier |
1.40 |
doins ${desktop} |
692 |
vapier |
1.39 |
fi |
693 |
|
|
|
694 |
vapier |
1.40 |
#if [ -d /usr/share/gnome/apps ] ; then |
695 |
|
|
# insinto /usr/share/gnome/apps/Games |
696 |
|
|
# doins ${desktop} |
697 |
|
|
#fi |
698 |
|
|
|
699 |
|
|
#if [ ! -z "`ls /usr/kde/* 2>/dev/null`" ] ; then |
700 |
|
|
# for ver in /usr/kde/* ; do |
701 |
|
|
# insinto ${ver}/share/applnk/Games |
702 |
|
|
# doins ${desktop} |
703 |
|
|
# done |
704 |
|
|
#fi |
705 |
vapier |
1.39 |
|
706 |
|
|
if [ -d /usr/share/applnk ] ; then |
707 |
vapier |
1.40 |
insinto /usr/share/applnk/${type} |
708 |
|
|
doins ${desktop} |
709 |
vapier |
1.39 |
fi |
710 |
|
|
|
711 |
|
|
return 0 |
712 |
danarmak |
1.32 |
} |
713 |
|
|
|
714 |
danarmak |
1.34 |
# new convenience patch wrapper function to eventually replace epatch(), |
715 |
|
|
# $PATCHES, $PATCHES1, src_unpack:patch, src_unpack:autopatch and |
716 |
|
|
# /usr/bin/patch |
717 |
danarmak |
1.32 |
# Features: |
718 |
|
|
# - bulk patch handling similar to epatch()'s |
719 |
|
|
# - automatic patch level detection like epatch()'s |
720 |
danarmak |
1.34 |
# - automatic patch uncompression like epatch()'s |
721 |
|
|
# - doesn't have the --dry-run overhead of epatch() - inspects patchfiles |
722 |
|
|
# manually instead |
723 |
|
|
# - once I decide it's production-ready, it'll be called from base_src_unpack |
724 |
|
|
# to handle $PATCHES to avoid defining src_unpack just to use xpatch |
725 |
danarmak |
1.32 |
|
726 |
|
|
# accepts zero or more parameters specifying patchfiles and/or patchdirs |
727 |
|
|
|
728 |
|
|
# known issues: |
729 |
danarmak |
1.34 |
# - only supports unified style patches (does anyone _really_ use anything |
730 |
|
|
# else?) |
731 |
|
|
# - because it doesn't use --dry-run there is a risk of it failing |
732 |
|
|
# to find the files to patch, ie detect the patchlevel, properly. It doesn't use |
733 |
|
|
# any of the backup heuristics that patch employs to discover a filename. |
734 |
|
|
# however, this isn't dangerous because if it works for the developer who's |
735 |
|
|
# writing the ebuild, it'll always work for the users, and if it doesn't, |
736 |
|
|
# then we'll fix it :-) |
737 |
|
|
# - no support as yet for patches applying outside $S (and not directly in $WORKDIR). |
738 |
danarmak |
1.32 |
xpatch() { |
739 |
|
|
|
740 |
|
|
debug-print-function $FUNCNAME $* |
741 |
|
|
|
742 |
|
|
local list="" |
743 |
|
|
local list2="" |
744 |
|
|
declare -i plevel |
745 |
|
|
|
746 |
|
|
# parse patch sources |
747 |
|
|
for x in $*; do |
748 |
|
|
debug-print "$FUNCNAME: parsing parameter $x" |
749 |
|
|
if [ -f "$x" ]; then |
750 |
|
|
list="$list $x" |
751 |
|
|
elif [ -d "$x" ]; then |
752 |
|
|
# handles patchdirs like epatch() for now: no recursion. |
753 |
|
|
# patches are sorted by filename, so with an xy_foo naming scheme you'll get the right order. |
754 |
|
|
# only patches with _$ARCH_ or _all_ in their filenames are applied. |
755 |
|
|
for file in `ls -A $x`; do |
756 |
|
|
debug-print "$FUNCNAME: parsing in subdir: file $file" |
757 |
|
|
if [ -f "$x/$file" ] && [ "${file}" != "${file/_all_}" -o "${file}" != "${file/_$ARCH_}" ]; then |
758 |
|
|
list2="$list2 $x/$file" |
759 |
|
|
fi |
760 |
|
|
done |
761 |
|
|
list="`echo $list2 | sort` $list" |
762 |
|
|
else |
763 |
|
|
die "Couldn't find $x" |
764 |
|
|
fi |
765 |
|
|
done |
766 |
|
|
|
767 |
|
|
debug-print "$FUNCNAME: final list of patches: $list" |
768 |
|
|
|
769 |
|
|
for x in $list; do |
770 |
|
|
debug-print "$FUNCNAME: processing $x" |
771 |
|
|
# deal with compressed files. /usr/bin/file is in the system profile, or should be. |
772 |
|
|
case "`/usr/bin/file -b $x`" in |
773 |
|
|
*gzip*) patchfile="${T}/current.patch"; ungzip -c "$x" > "${patchfile}";; |
774 |
|
|
*bzip2*) patchfile="${T}/current.patch"; bunzip2 -c "$x" > "${patchfile}";; |
775 |
|
|
*text*) patchfile="$x";; |
776 |
|
|
*) die "Could not determine filetype of patch $x";; |
777 |
|
|
esac |
778 |
|
|
debug-print "$FUNCNAME: patchfile=$patchfile" |
779 |
|
|
|
780 |
|
|
# determine patchlevel. supports p0 and higher with either $S or $WORKDIR as base. |
781 |
danarmak |
1.34 |
target="`/bin/grep -m 1 '^+++ ' $patchfile`" |
782 |
danarmak |
1.32 |
debug-print "$FUNCNAME: raw target=$target" |
783 |
danarmak |
1.34 |
# strip target down to the path/filename, remove leading +++ |
784 |
|
|
target="${target/+++ }"; target="${target%% *}" |
785 |
|
|
# duplicate slashes are discarded by patch wrt the patchlevel. therefore we need |
786 |
|
|
# to discard them as well to calculate the correct patchlevel. |
787 |
|
|
target="${target//\/\//\/}" |
788 |
danarmak |
1.32 |
debug-print "$FUNCNAME: stripped target=$target" |
789 |
|
|
|
790 |
|
|
# look for target |
791 |
danarmak |
1.34 |
for basedir in "$S" "$WORKDIR" "${PWD}"; do |
792 |
danarmak |
1.32 |
debug-print "$FUNCNAME: looking in basedir=$basedir" |
793 |
|
|
cd "$basedir" |
794 |
|
|
|
795 |
|
|
# try stripping leading directories |
796 |
|
|
target2="$target" |
797 |
|
|
plevel=0 |
798 |
|
|
debug-print "$FUNCNAME: trying target2=$target2, plevel=$plevel" |
799 |
|
|
while [ ! -f "$target2" ]; do |
800 |
|
|
target2="${target2#*/}" # removes piece of target2 upto the first occurence of / |
801 |
|
|
plevel=plevel+1 |
802 |
|
|
debug-print "$FUNCNAME: trying target2=$target2, plevel=$plevel" |
803 |
|
|
[ "$target2" == "${target2/\/}" ] && break |
804 |
|
|
done |
805 |
|
|
test -f "$target2" && break |
806 |
|
|
|
807 |
|
|
# try stripping filename - needed to support patches creating new files |
808 |
|
|
target2="${target%/*}" |
809 |
|
|
plevel=0 |
810 |
|
|
debug-print "$FUNCNAME: trying target2=$target2, plevel=$plevel" |
811 |
|
|
while [ ! -d "$target2" ]; do |
812 |
|
|
target2="${target2#*/}" # removes piece of target2 upto the first occurence of / |
813 |
|
|
plevel=plevel+1 |
814 |
|
|
debug-print "$FUNCNAME: trying target2=$target2, plevel=$plevel" |
815 |
|
|
[ "$target2" == "${target2/\/}" ] && break |
816 |
|
|
done |
817 |
|
|
test -d "$target2" && break |
818 |
|
|
|
819 |
|
|
done |
820 |
|
|
|
821 |
|
|
test -f "${basedir}/${target2}" || test -d "${basedir}/${target2}" || die "Could not determine patchlevel for $x" |
822 |
|
|
debug-print "$FUNCNAME: determined plevel=$plevel" |
823 |
|
|
# do the patching |
824 |
|
|
ebegin "Applying patch ${x##*/}..." |
825 |
|
|
/usr/bin/patch -p$plevel < "$patchfile" > /dev/null || die "Failed to apply patch $x" |
826 |
|
|
eend $? |
827 |
|
|
|
828 |
|
|
done |
829 |
|
|
|
830 |
vapier |
1.41 |
} |
831 |
|
|
|
832 |
|
|
# Unpack those pesky makeself generated files ... |
833 |
|
|
# They're shell scripts with the binary package tagged onto |
834 |
|
|
# the end of the archive. Loki utilized the format as does |
835 |
|
|
# many other game companies. |
836 |
|
|
# |
837 |
|
|
# Usage: unpack_makeself [file to unpack] [offset] |
838 |
|
|
# - If the file is not specified then unpack will utilize ${A}. |
839 |
|
|
# - If the offset is not specified then we will attempt to extract |
840 |
|
|
# the proper offset from the script itself. |
841 |
|
|
unpack_makeself() { |
842 |
|
|
local src=$1 |
843 |
|
|
local skip=$2 |
844 |
|
|
|
845 |
|
|
[ -z "${src}" ] && src=${A} |
846 |
|
|
[ -e ./${src} ] \ |
847 |
|
|
&& src=${PWD}/${src} \ |
848 |
|
|
|| src=${DISTDIR}/${src} |
849 |
|
|
local shrtsrc=`basename ${src}` |
850 |
|
|
echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
851 |
|
|
if [ -z "${skip}" ] ; then |
852 |
|
|
local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`" |
853 |
|
|
local skip=0 |
854 |
|
|
case ${ver} in |
855 |
|
|
1.5.*) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same |
856 |
|
|
skip=`grep -a ^skip= ${src} | cut -d= -f2` |
857 |
|
|
;; |
858 |
|
|
2.0|2.0.1) |
859 |
|
|
skip=`grep -a ^$'\t'tail ${src} | awk '{print $2}' | cut -b2-` |
860 |
|
|
;; |
861 |
|
|
2.1.1) |
862 |
|
|
skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-` |
863 |
|
|
let skip="skip + 1" |
864 |
|
|
;; |
865 |
|
|
*) |
866 |
|
|
eerror "I'm sorry, but I was unable to support the Makeself file." |
867 |
|
|
eerror "The version I detected was '${ver}'." |
868 |
|
|
eerror "Please file a bug about the file ${shrtsrc} at" |
869 |
|
|
eerror "http://bugs.gentoo.org/ so that support can be added." |
870 |
|
|
die "makeself version '${ver}' not supported" |
871 |
|
|
;; |
872 |
|
|
esac |
873 |
|
|
debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" |
874 |
|
|
fi |
875 |
|
|
|
876 |
|
|
# we do this because otherwise a failure in gzip will cause 0 bytes to be sent |
877 |
|
|
# to tar which will make tar not extract anything and exit with 0 |
878 |
|
|
local out="`tail +${skip} ${src} | gzip -cd | tar -x --no-same-owner -v -f -`" |
879 |
|
|
[ -z "${out}" ] && die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})" |
880 |
vapier |
1.23 |
} |