1 |
root |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
############################################################################# |
4 |
root |
1.45 |
# configuration to fill in (or to replace in your .staticperlrc) |
5 |
root |
1.1 |
|
6 |
|
|
STATICPERL=~/.staticperl |
7 |
root |
1.14 |
CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
8 |
root |
1.1 |
EMAIL="read the documentation <rtfm@example.org>" |
9 |
root |
1.45 |
DLCACHE= |
10 |
root |
1.1 |
|
11 |
|
|
# perl build variables |
12 |
root |
1.21 |
MAKE=make |
13 |
root |
1.62 |
PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds |
14 |
root |
1.19 |
PERL_CC=cc |
15 |
root |
1.4 |
PERL_CONFIGURE="" # additional Configure arguments |
16 |
root |
1.32 |
PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
17 |
root |
1.51 |
PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
18 |
root |
1.1 |
|
19 |
|
|
ARCH="$(uname -m)" |
20 |
|
|
|
21 |
root |
1.51 |
#case "$ARCH" in |
22 |
|
|
# i*86 | x86_64 | amd64 ) |
23 |
|
|
# PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 |
24 |
|
|
# case "$ARCH" in |
25 |
|
|
# i*86 ) |
26 |
|
|
# PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only |
27 |
|
|
# ;; |
28 |
|
|
# esac |
29 |
|
|
# ;; |
30 |
|
|
#esac |
31 |
root |
1.1 |
|
32 |
|
|
# -Wl,--gc-sections makes it impossible to check for undefined references |
33 |
|
|
# for some reason so we need to patch away the "-no" after Configure and before make :/ |
34 |
root |
1.16 |
# --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
35 |
root |
1.37 |
#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
36 |
|
|
PERL_LDFLAGS= |
37 |
root |
1.1 |
PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
38 |
|
|
|
39 |
|
|
# some configuration options for modules |
40 |
root |
1.24 |
PERL_MM_USE_DEFAULT=1 |
41 |
root |
1.39 |
PERL_MM_OPT="MAN1PODS= MAN3PODS=" |
42 |
root |
1.24 |
#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
43 |
root |
1.47 |
#EV_EXTRA_DEFS='-DEV_FEATURES=4+8+16+64 -DEV_USE_SELECT=0 -DEV_USE_POLL=1 -DEV_USE_EPOLL=1 -DEV_NO_LOOPS -DEV_COMPAT3=0' |
44 |
|
|
export PERL_MM_USE_DEFAULT PERL_MM_OPT |
45 |
root |
1.1 |
|
46 |
|
|
# which extra modules to install by default from CPAN that are |
47 |
|
|
# required by mkbundle |
48 |
root |
1.58 |
STATICPERL_MODULES="ExtUtils::MakeMaker ExtUtils::CBuilder common::sense Pod::Strip PPI PPI::XS Pod::Usage" |
49 |
root |
1.2 |
|
50 |
|
|
# which extra modules you might want to install |
51 |
|
|
EXTRA_MODULES="" |
52 |
root |
1.1 |
|
53 |
|
|
# overridable functions |
54 |
root |
1.7 |
preconfigure() { : ; } |
55 |
root |
1.37 |
patchconfig() { : ; } |
56 |
root |
1.1 |
postconfigure() { : ; } |
57 |
|
|
postbuild() { : ; } |
58 |
|
|
postinstall() { : ; } |
59 |
|
|
|
60 |
|
|
# now source user config, if any |
61 |
root |
1.14 |
if [ "$STATICPERLRC" ]; then |
62 |
|
|
. "$STATICPERLRC" |
63 |
|
|
else |
64 |
|
|
[ -r /etc/staticperlrc ] && . /etc/staticperlrc |
65 |
|
|
[ -r ~/.staticperlrc ] && . ~/.staticperlrc |
66 |
|
|
[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
67 |
|
|
fi |
68 |
root |
1.1 |
|
69 |
|
|
############################################################################# |
70 |
|
|
# support |
71 |
|
|
|
72 |
root |
1.58 |
# work around ExtUtils::CBuilder and others |
73 |
|
|
export CC="$PERL_CC" |
74 |
root |
1.66 |
export CFLAGS="$PERL_CFLAGS" |
75 |
root |
1.58 |
export LD="$PERL_CC" |
76 |
|
|
export LDFLAGS="$PERL_LDFLAGS" |
77 |
|
|
unset LIBS |
78 |
|
|
|
79 |
root |
1.14 |
PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
80 |
|
|
|
81 |
root |
1.38 |
unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
82 |
root |
1.39 |
unset PERL_MB_OPT |
83 |
root |
1.24 |
LC_ALL=C; export LC_ALL # just to be on the safe side |
84 |
root |
1.12 |
|
85 |
root |
1.38 |
# prepend PATH - not required by staticperl itself, but might make |
86 |
|
|
# life easier when working in e.g. "staticperl cpan / look" |
87 |
|
|
PATH="$PERL_PREFIX/perl/bin:$PATH" |
88 |
|
|
|
89 |
root |
1.1 |
# set version in a way that Makefile.PL can extract |
90 |
|
|
VERSION=VERSION; eval \ |
91 |
root |
1.65 |
$VERSION="1.45" |
92 |
root |
1.1 |
|
93 |
|
|
fatal() { |
94 |
|
|
printf -- "\nFATAL: %s\n\n" "$*" >&2 |
95 |
|
|
exit 1 |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
verbose() { |
99 |
|
|
printf -- "%s\n" "$*" |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
verblock() { |
103 |
|
|
verbose |
104 |
|
|
verbose "***" |
105 |
|
|
while read line; do |
106 |
|
|
verbose "*** $line" |
107 |
|
|
done |
108 |
|
|
verbose "***" |
109 |
|
|
verbose |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
rcd() { |
113 |
|
|
cd "$1" || fatal "$1: cannot enter" |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
trace() { |
117 |
|
|
prefix="$1"; shift |
118 |
|
|
# "$@" 2>&1 | while read line; do |
119 |
|
|
# echo "$prefix: $line" |
120 |
|
|
# done |
121 |
|
|
"$@" |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
trap wait 0 |
125 |
|
|
|
126 |
|
|
############################################################################# |
127 |
|
|
# clean |
128 |
|
|
|
129 |
|
|
distclean() { |
130 |
|
|
verblock <<EOF |
131 |
root |
1.14 |
deleting everything installed by this script (rm -rf $STATICPERL) |
132 |
root |
1.1 |
EOF |
133 |
|
|
|
134 |
|
|
rm -rf "$STATICPERL" |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
############################################################################# |
138 |
|
|
# download/configure/compile/install perl |
139 |
|
|
|
140 |
|
|
clean() { |
141 |
root |
1.48 |
rm -rf "$STATICPERL/src" |
142 |
root |
1.1 |
} |
143 |
|
|
|
144 |
root |
1.23 |
realclean() { |
145 |
|
|
rm -f "$PERL_PREFIX/staticstamp.postinstall" |
146 |
|
|
rm -f "$PERL_PREFIX/staticstamp.install" |
147 |
root |
1.62 |
rm -f "$STATICPERL/src/perl/staticstamp.configure" |
148 |
root |
1.23 |
} |
149 |
|
|
|
150 |
root |
1.1 |
fetch() { |
151 |
root |
1.65 |
( |
152 |
root |
1.1 |
rcd "$STATICPERL" |
153 |
|
|
|
154 |
|
|
mkdir -p src |
155 |
|
|
rcd src |
156 |
|
|
|
157 |
root |
1.62 |
if ! [ -d "perl" ]; then |
158 |
root |
1.63 |
rm -rf unpack |
159 |
|
|
mkdir -p unpack |
160 |
|
|
|
161 |
root |
1.62 |
case "$PERL_VERSION" in |
162 |
|
|
*:* ) |
163 |
root |
1.63 |
# url |
164 |
root |
1.62 |
PERLURL="$PERL_VERSION" |
165 |
|
|
PERLTAR="$(basename "$PERL_VERSION")" |
166 |
|
|
;; |
167 |
root |
1.63 |
/* ) |
168 |
|
|
# directory |
169 |
|
|
verbose "copying $PERL_VERSION" |
170 |
|
|
cp -Rp "$PERL_VERSION/." unpack/. |
171 |
|
|
chmod -R u+w unpack |
172 |
|
|
mv unpack perl |
173 |
|
|
return |
174 |
|
|
;; |
175 |
root |
1.62 |
* ) |
176 |
|
|
PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2" |
177 |
|
|
PERLTAR=perl-$PERL_VERSION.tar.bz2 |
178 |
|
|
;; |
179 |
|
|
esac |
180 |
root |
1.1 |
|
181 |
root |
1.62 |
if ! [ -e "$PERLTAR" ]; then |
182 |
root |
1.1 |
verblock <<EOF |
183 |
|
|
downloading perl |
184 |
root |
1.42 |
|
185 |
root |
1.62 |
trying to download from $PERLURL |
186 |
root |
1.45 |
|
187 |
|
|
you can configure a download cache directory via DLCACHE |
188 |
|
|
in your .staticperlrc to avoid repeated downloads. |
189 |
root |
1.62 |
|
190 |
|
|
to manually download perl yourself, place a suitable tarball in |
191 |
|
|
$DLCACHE/$PERLTAR |
192 |
|
|
|
193 |
|
|
either curl or wget is required for automatic download. |
194 |
|
|
curl is tried first, then wget. |
195 |
root |
1.1 |
EOF |
196 |
|
|
|
197 |
root |
1.45 |
rm -f $PERLTAR~ # just to be on the safe side |
198 |
root |
1.48 |
{ [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
199 |
root |
1.62 |
|| wget -O $PERLTAR~ "$PERLURL" \ |
200 |
|
|
|| curl -f >$PERLTAR~ "$PERLURL" \ |
201 |
root |
1.5 |
|| fatal "$URL: unable to download" |
202 |
root |
1.45 |
rm -f $PERLTAR |
203 |
|
|
mv $PERLTAR~ $PERLTAR |
204 |
|
|
if [ "$DLCACHE" ]; then |
205 |
|
|
mkdir -p "$DLCACHE" |
206 |
root |
1.57 |
cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \ |
207 |
|
|
mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR |
208 |
root |
1.45 |
fi |
209 |
root |
1.1 |
fi |
210 |
|
|
|
211 |
|
|
verblock <<EOF |
212 |
|
|
unpacking perl |
213 |
|
|
EOF |
214 |
|
|
|
215 |
root |
1.62 |
case "$PERLTAR" in |
216 |
|
|
*.xz ) UNCOMPRESS="xz -d" ;; |
217 |
|
|
*.lzma ) UNCOMPRESS="lzma -d" ;; |
218 |
|
|
*.bz2 ) UNCOMPRESS="bzip2 -d" ;; |
219 |
|
|
*.gz ) UNCOMPRESS="gzip -d" ;; |
220 |
|
|
*.tar ) UNCOMPRESS="cat" ;; |
221 |
|
|
* ) |
222 |
root |
1.66 |
fatal "don't know hot to uncompress $PERLTAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported." |
223 |
root |
1.62 |
exit 1 |
224 |
|
|
;; |
225 |
|
|
esac |
226 |
|
|
|
227 |
|
|
<"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \ |
228 |
root |
1.45 |
|| fatal "$PERLTAR: error during unpacking" |
229 |
root |
1.62 |
|
230 |
|
|
if [ -d unpack/*/ ]; then |
231 |
|
|
chmod -R u+w unpack/*/ |
232 |
|
|
mv unpack/*/ perl |
233 |
|
|
rmdir -p unpack |
234 |
|
|
else |
235 |
|
|
fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this" |
236 |
|
|
fi |
237 |
|
|
|
238 |
|
|
rm "$PERLTAR" |
239 |
root |
1.1 |
fi |
240 |
root |
1.65 |
) || exit |
241 |
root |
1.1 |
} |
242 |
|
|
|
243 |
|
|
# similar to GNU-sed -i or perl -pi |
244 |
|
|
sedreplace() { |
245 |
|
|
sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
246 |
root |
1.20 |
rm -f "$2" |
247 |
root |
1.1 |
mv "$2~" "$2" |
248 |
|
|
} |
249 |
|
|
|
250 |
root |
1.22 |
configure_failure() { |
251 |
|
|
cat <<EOF |
252 |
|
|
|
253 |
|
|
|
254 |
|
|
*** |
255 |
|
|
*** Configure failed - see above for the exact error message(s). |
256 |
|
|
*** |
257 |
|
|
*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE |
258 |
|
|
*** flags are not supported by your compiler. Less often, this is because |
259 |
|
|
*** PERL_LIBS either contains a library not available on your system (such as |
260 |
|
|
*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl). |
261 |
|
|
*** |
262 |
|
|
*** You can provide your own flags by creating a ~/.staticperlrc file with |
263 |
|
|
*** variable assignments. For example (these are the actual values used): |
264 |
|
|
*** |
265 |
|
|
|
266 |
|
|
PERL_CC="$PERL_CC" |
267 |
|
|
PERL_CCFLAGS="$PERL_CCFLAGS" |
268 |
|
|
PERL_OPTIMIZE="$PERL_OPTIMIZE" |
269 |
|
|
PERL_LDFLAGS="$PERL_LDFLAGS" |
270 |
|
|
PERL_LIBS="$PERL_LIBS" |
271 |
|
|
|
272 |
|
|
EOF |
273 |
|
|
exit 1 |
274 |
|
|
} |
275 |
|
|
|
276 |
root |
1.1 |
configure() { |
277 |
root |
1.65 |
( |
278 |
root |
1.1 |
fetch |
279 |
|
|
|
280 |
root |
1.62 |
rcd "$STATICPERL/src/perl" |
281 |
root |
1.1 |
|
282 |
|
|
[ -e staticstamp.configure ] && return |
283 |
|
|
|
284 |
|
|
verblock <<EOF |
285 |
root |
1.62 |
configuring $STATICPERL/src/perl |
286 |
root |
1.1 |
EOF |
287 |
|
|
|
288 |
root |
1.8 |
rm -f "$PERL_PREFIX/staticstamp.install" |
289 |
root |
1.1 |
|
290 |
root |
1.21 |
"$MAKE" distclean >/dev/null 2>&1 |
291 |
root |
1.1 |
|
292 |
root |
1.23 |
sedreplace '/^#define SITELIB/d' config_h.SH |
293 |
|
|
|
294 |
|
|
# I hate them for this |
295 |
root |
1.1 |
grep -q -- -fstack-protector Configure && \ |
296 |
|
|
sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
297 |
|
|
|
298 |
root |
1.37 |
# what did that bloke think |
299 |
|
|
grep -q -- usedl=.define hints/darwin.sh && \ |
300 |
|
|
sedreplace '/^usedl=.define.;$/d' hints/darwin.sh |
301 |
|
|
|
302 |
|
|
preconfigure || fatal "preconfigure hook failed" |
303 |
root |
1.7 |
|
304 |
root |
1.1 |
# trace configure \ |
305 |
|
|
sh Configure -Duselargefiles \ |
306 |
|
|
-Uuse64bitint \ |
307 |
|
|
-Dusemymalloc=n \ |
308 |
|
|
-Uusedl \ |
309 |
|
|
-Uusethreads \ |
310 |
|
|
-Uuseithreads \ |
311 |
|
|
-Uusemultiplicity \ |
312 |
|
|
-Uusesfio \ |
313 |
|
|
-Uuseshrplib \ |
314 |
root |
1.26 |
-Uinstallusrbinperl \ |
315 |
root |
1.22 |
-A ccflags=" $PERL_CCFLAGS" \ |
316 |
root |
1.19 |
-Dcc="$PERL_CC" \ |
317 |
root |
1.1 |
-Doptimize="$PERL_OPTIMIZE" \ |
318 |
|
|
-Dldflags="$PERL_LDFLAGS" \ |
319 |
|
|
-Dlibs="$PERL_LIBS" \ |
320 |
root |
1.6 |
-Dprefix="$PERL_PREFIX" \ |
321 |
|
|
-Dbin="$PERL_PREFIX/bin" \ |
322 |
|
|
-Dprivlib="$PERL_PREFIX/lib" \ |
323 |
|
|
-Darchlib="$PERL_PREFIX/lib" \ |
324 |
root |
1.1 |
-Uusevendorprefix \ |
325 |
root |
1.6 |
-Dsitelib="$PERL_PREFIX/lib" \ |
326 |
|
|
-Dsitearch="$PERL_PREFIX/lib" \ |
327 |
root |
1.1 |
-Uman1dir \ |
328 |
|
|
-Uman3dir \ |
329 |
|
|
-Usiteman1dir \ |
330 |
|
|
-Usiteman3dir \ |
331 |
|
|
-Dpager=/usr/bin/less \ |
332 |
|
|
-Demail="$EMAIL" \ |
333 |
|
|
-Dcf_email="$EMAIL" \ |
334 |
|
|
-Dcf_by="$EMAIL" \ |
335 |
root |
1.4 |
$PERL_CONFIGURE \ |
336 |
root |
1.19 |
-Duseperlio \ |
337 |
root |
1.64 |
-Uversiononly \ |
338 |
root |
1.22 |
-dE || configure_failure |
339 |
root |
1.1 |
|
340 |
|
|
sedreplace ' |
341 |
|
|
s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
342 |
|
|
s/ *-fno-stack-protector */ /g |
343 |
|
|
' config.sh |
344 |
|
|
|
345 |
root |
1.37 |
patchconfig || fatal "patchconfig hook failed" |
346 |
|
|
|
347 |
root |
1.1 |
sh Configure -S || fatal "Configure -S failed" |
348 |
|
|
|
349 |
|
|
postconfigure || fatal "postconfigure hook failed" |
350 |
|
|
|
351 |
root |
1.48 |
: > staticstamp.configure |
352 |
root |
1.65 |
) || exit |
353 |
root |
1.1 |
} |
354 |
|
|
|
355 |
root |
1.39 |
write_shellscript() { |
356 |
|
|
{ |
357 |
|
|
echo "#!/bin/sh" |
358 |
|
|
echo "STATICPERL=\"$STATICPERL\"" |
359 |
|
|
echo "PERL_PREFIX=\"$PERL_PREFIX\"" |
360 |
|
|
echo "MAKE=\"$MAKE\"" |
361 |
|
|
cat |
362 |
|
|
} >"$PERL_PREFIX/bin/$1" |
363 |
|
|
chmod 755 "$PERL_PREFIX/bin/$1" |
364 |
|
|
} |
365 |
|
|
|
366 |
root |
1.1 |
build() { |
367 |
root |
1.65 |
( |
368 |
root |
1.1 |
configure |
369 |
|
|
|
370 |
root |
1.62 |
rcd "$STATICPERL/src/perl" |
371 |
root |
1.1 |
|
372 |
|
|
verblock <<EOF |
373 |
root |
1.62 |
building $STATICPERL/src/perl |
374 |
root |
1.1 |
EOF |
375 |
|
|
|
376 |
root |
1.6 |
rm -f "$PERL_PREFIX/staticstamp.install" |
377 |
root |
1.1 |
|
378 |
root |
1.21 |
"$MAKE" || fatal "make: error while building perl" |
379 |
root |
1.1 |
|
380 |
|
|
postbuild || fatal "postbuild hook failed" |
381 |
root |
1.65 |
) || exit |
382 |
root |
1.1 |
} |
383 |
|
|
|
384 |
root |
1.48 |
_postinstall() { |
385 |
|
|
if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
386 |
|
|
NOCHECK_INSTALL=+ |
387 |
|
|
instcpan $STATICPERL_MODULES |
388 |
root |
1.56 |
[ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES |
389 |
root |
1.48 |
|
390 |
|
|
postinstall || fatal "postinstall hook failed" |
391 |
|
|
|
392 |
|
|
: > "$PERL_PREFIX/staticstamp.postinstall" |
393 |
|
|
fi |
394 |
|
|
} |
395 |
|
|
|
396 |
root |
1.1 |
install() { |
397 |
root |
1.65 |
( |
398 |
root |
1.9 |
if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
399 |
|
|
build |
400 |
root |
1.1 |
|
401 |
root |
1.9 |
verblock <<EOF |
402 |
root |
1.62 |
installing $STATICPERL/src/perl |
403 |
root |
1.6 |
to $PERL_PREFIX |
404 |
root |
1.1 |
EOF |
405 |
|
|
|
406 |
root |
1.14 |
ln -sf "perl/bin/" "$STATICPERL/bin" |
407 |
|
|
ln -sf "perl/lib/" "$STATICPERL/lib" |
408 |
|
|
|
409 |
root |
1.39 |
mkdir "$STATICPERL/patched" |
410 |
|
|
|
411 |
root |
1.14 |
ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
412 |
|
|
rm -rf "$PERL_PREFIX" # by this rm -rf |
413 |
|
|
|
414 |
root |
1.65 |
rcd "$STATICPERL/src/perl" |
415 |
|
|
|
416 |
root |
1.21 |
"$MAKE" install || fatal "make install: error while installing" |
417 |
root |
1.1 |
|
418 |
root |
1.9 |
rcd "$PERL_PREFIX" |
419 |
root |
1.2 |
|
420 |
root |
1.9 |
# create a "make install" replacement for CPAN |
421 |
root |
1.65 |
write_shellscript SP-make-make <<'end_of_make' |
422 |
|
|
#CAT make-make.sh |
423 |
|
|
end_of_make |
424 |
|
|
|
425 |
|
|
# create a "make install" replacement for CPAN |
426 |
|
|
write_shellscript SP-make-install-make <<'end_of_make_install_make' |
427 |
root |
1.39 |
#CAT make-install-make.sh |
428 |
root |
1.65 |
end_of_make_install_make |
429 |
root |
1.10 |
|
430 |
root |
1.39 |
# create a "patch modules" helper |
431 |
root |
1.65 |
write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall' |
432 |
root |
1.39 |
#CAT patch-postinstall.sh |
433 |
root |
1.65 |
end_of_patch_postinstall |
434 |
root |
1.10 |
|
435 |
root |
1.58 |
# immediately use it |
436 |
root |
1.39 |
"$PERL_PREFIX/bin/SP-patch-postinstall" |
437 |
root |
1.9 |
|
438 |
root |
1.39 |
# help to trick CPAN into avoiding ~/.cpan completely |
439 |
root |
1.9 |
echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
440 |
root |
1.1 |
|
441 |
root |
1.39 |
# we call cpan with -MCPAN::MyConfig in this script, which |
442 |
|
|
# is strictly unnecssary as we have to patch CPAN anyway, |
443 |
|
|
# so consider it "for good measure". |
444 |
root |
1.36 |
"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
445 |
root |
1.9 |
CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
446 |
|
|
CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
447 |
|
|
CPAN::Shell->o (conf => q<init>); |
448 |
|
|
CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
449 |
|
|
CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
450 |
|
|
CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
451 |
|
|
CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
452 |
|
|
CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
453 |
root |
1.59 |
CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl"); |
454 |
root |
1.65 |
CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make"); |
455 |
root |
1.39 |
CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
456 |
root |
1.9 |
CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
457 |
root |
1.57 |
CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>); |
458 |
root |
1.36 |
CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); |
459 |
root |
1.9 |
CPAN::Shell->o (conf => q<commit>); |
460 |
|
|
' || fatal "error while initialising CPAN" |
461 |
root |
1.2 |
|
462 |
root |
1.48 |
: > "$PERL_PREFIX/staticstamp.install" |
463 |
root |
1.9 |
fi |
464 |
|
|
|
465 |
root |
1.48 |
_postinstall |
466 |
root |
1.65 |
) || exit |
467 |
root |
1.48 |
} |
468 |
|
|
|
469 |
|
|
import() { |
470 |
root |
1.65 |
( |
471 |
root |
1.48 |
IMPORT="$1" |
472 |
|
|
|
473 |
|
|
rcd "$STATICPERL" |
474 |
|
|
|
475 |
|
|
if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
476 |
|
|
verblock <<EOF |
477 |
|
|
import perl from $IMPORT to $STATICPERL |
478 |
|
|
EOF |
479 |
root |
1.1 |
|
480 |
root |
1.48 |
rm -rf bin cpan lib patched perl src |
481 |
|
|
mkdir -m 755 perl perl/bin |
482 |
|
|
ln -s perl/bin/ bin |
483 |
|
|
ln -s "$IMPORT" perl/bin/ |
484 |
root |
1.1 |
|
485 |
root |
1.51 |
echo "$IMPORT" > "$PERL_PREFIX/.import" |
486 |
|
|
|
487 |
root |
1.48 |
: > "$PERL_PREFIX/staticstamp.install" |
488 |
root |
1.9 |
fi |
489 |
root |
1.48 |
|
490 |
|
|
_postinstall |
491 |
root |
1.65 |
) || exit |
492 |
root |
1.1 |
} |
493 |
|
|
|
494 |
|
|
############################################################################# |
495 |
|
|
# install a module from CPAN |
496 |
|
|
|
497 |
|
|
instcpan() { |
498 |
|
|
[ $NOCHECK_INSTALL ] || install |
499 |
|
|
|
500 |
|
|
verblock <<EOF |
501 |
|
|
installing modules from CPAN |
502 |
|
|
$@ |
503 |
|
|
EOF |
504 |
|
|
|
505 |
root |
1.51 |
MYCONFIG= |
506 |
|
|
[ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig |
507 |
|
|
|
508 |
|
|
"$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
509 |
root |
1.48 |
|
510 |
|
|
if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
511 |
|
|
fatal "failure while installing modules from CPAN ($@)" |
512 |
|
|
fi |
513 |
|
|
rm -f "$STATICPERL/instcpan.log" |
514 |
root |
1.1 |
} |
515 |
|
|
|
516 |
|
|
############################################################################# |
517 |
|
|
# install a module from unpacked sources |
518 |
|
|
|
519 |
|
|
instsrc() { |
520 |
|
|
[ $NOCHECK_INSTALL ] || install |
521 |
|
|
|
522 |
|
|
verblock <<EOF |
523 |
|
|
installing modules from source |
524 |
|
|
$@ |
525 |
|
|
EOF |
526 |
|
|
|
527 |
|
|
for mod in "$@"; do |
528 |
|
|
echo |
529 |
|
|
echo $mod |
530 |
|
|
( |
531 |
|
|
rcd $mod |
532 |
root |
1.21 |
"$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
533 |
|
|
"$MAKE" distclean >/dev/null 2>&1 |
534 |
root |
1.6 |
"$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
535 |
root |
1.21 |
"$MAKE" || fatal "$mod: error building module" |
536 |
root |
1.39 |
"$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
537 |
root |
1.21 |
"$MAKE" distclean >/dev/null 2>&1 |
538 |
root |
1.1 |
exit 0 |
539 |
|
|
) || exit $? |
540 |
|
|
done |
541 |
|
|
} |
542 |
|
|
|
543 |
|
|
############################################################################# |
544 |
|
|
# main |
545 |
|
|
|
546 |
|
|
podusage() { |
547 |
|
|
echo |
548 |
root |
1.17 |
|
549 |
root |
1.6 |
if [ -e "$PERL_PREFIX/bin/perl" ]; then |
550 |
|
|
"$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
551 |
root |
1.1 |
'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
552 |
|
|
2>/dev/null && exit |
553 |
|
|
fi |
554 |
root |
1.17 |
|
555 |
root |
1.1 |
# try whatever perl we can find |
556 |
|
|
perl -MPod::Usage -e \ |
557 |
|
|
'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
558 |
|
|
2>/dev/null && exit |
559 |
|
|
|
560 |
root |
1.17 |
fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" |
561 |
root |
1.1 |
} |
562 |
|
|
|
563 |
|
|
usage() { |
564 |
|
|
podusage 0 |
565 |
|
|
} |
566 |
|
|
|
567 |
|
|
catmkbundle() { |
568 |
|
|
{ |
569 |
|
|
read dummy |
570 |
root |
1.6 |
echo "#!$PERL_PREFIX/bin/perl" |
571 |
root |
1.1 |
cat |
572 |
root |
1.65 |
} <<'end_of_mkbundle' |
573 |
root |
1.1 |
#CAT mkbundle |
574 |
root |
1.65 |
end_of_mkbundle |
575 |
root |
1.1 |
} |
576 |
|
|
|
577 |
|
|
bundle() { |
578 |
root |
1.39 |
MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
579 |
root |
1.1 |
catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
580 |
|
|
chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
581 |
root |
1.12 |
CACHE="$STATICPERL/cache" |
582 |
|
|
mkdir -p "$CACHE" |
583 |
|
|
"$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
584 |
root |
1.1 |
} |
585 |
|
|
|
586 |
|
|
if [ $# -gt 0 ]; then |
587 |
|
|
while [ $# -gt 0 ]; do |
588 |
|
|
mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
589 |
root |
1.6 |
mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
590 |
root |
1.1 |
|
591 |
|
|
command="${1#--}"; shift |
592 |
|
|
case "$command" in |
593 |
root |
1.14 |
version ) |
594 |
|
|
echo "staticperl version $VERSION" |
595 |
|
|
;; |
596 |
root |
1.48 |
fetch | configure | build | install | clean | realclean | distclean ) |
597 |
root |
1.22 |
( "$command" ) || exit |
598 |
root |
1.1 |
;; |
599 |
root |
1.48 |
import ) |
600 |
|
|
( import "$1" ) || exit |
601 |
|
|
shift |
602 |
|
|
;; |
603 |
root |
1.1 |
instsrc ) |
604 |
root |
1.22 |
( instsrc "$@" ) || exit |
605 |
root |
1.1 |
exit |
606 |
|
|
;; |
607 |
|
|
instcpan ) |
608 |
root |
1.22 |
( instcpan "$@" ) || exit |
609 |
root |
1.1 |
exit |
610 |
|
|
;; |
611 |
root |
1.39 |
perl ) |
612 |
|
|
( install ) || exit |
613 |
|
|
exec "$PERL_PREFIX/bin/perl" "$@" |
614 |
|
|
exit |
615 |
|
|
;; |
616 |
root |
1.1 |
cpan ) |
617 |
root |
1.22 |
( install ) || exit |
618 |
root |
1.48 |
PERL="$PERL_PREFIX/bin/perl" |
619 |
|
|
export PERL |
620 |
root |
1.39 |
exec "$PERL_PREFIX/bin/cpan" "$@" |
621 |
root |
1.1 |
exit |
622 |
|
|
;; |
623 |
|
|
mkbundle ) |
624 |
root |
1.22 |
( install ) || exit |
625 |
root |
1.40 |
bundle "$@" |
626 |
root |
1.1 |
exit |
627 |
|
|
;; |
628 |
|
|
mkperl ) |
629 |
root |
1.22 |
( install ) || exit |
630 |
root |
1.40 |
bundle --perl "$@" |
631 |
root |
1.1 |
exit |
632 |
|
|
;; |
633 |
root |
1.11 |
mkapp ) |
634 |
root |
1.22 |
( install ) || exit |
635 |
root |
1.40 |
bundle --app "$@" |
636 |
root |
1.11 |
exit |
637 |
|
|
;; |
638 |
root |
1.1 |
help ) |
639 |
|
|
podusage 2 |
640 |
|
|
;; |
641 |
|
|
* ) |
642 |
|
|
exec 1>&2 |
643 |
|
|
echo |
644 |
|
|
echo "Unknown command: $command" |
645 |
|
|
podusage 0 |
646 |
|
|
;; |
647 |
|
|
esac |
648 |
|
|
done |
649 |
|
|
else |
650 |
|
|
usage |
651 |
|
|
fi |
652 |
|
|
|
653 |
|
|
exit 0 |
654 |
|
|
|
655 |
|
|
#CAT staticperl.pod |
656 |
|
|
|