ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.sh
(Generate patch)

Comparing App-Staticperl/staticperl.sh (file contents):
Revision 1.36 by root, Sun Mar 13 23:20:21 2011 UTC vs.
Revision 1.63 by root, Fri Oct 16 02:43:37 2015 UTC

1#!/bin/sh 1#!/bin/sh
2 2
3############################################################################# 3#############################################################################
4# configuration to fill in 4# configuration to fill in (or to replace in your .staticperlrc)
5 5
6STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
7CPAN=http://mirror.netcologne.de/cpan # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan # which mirror to use
8EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
9DLCACHE=
9 10
10# perl build variables 11# perl build variables
11MAKE=make 12MAKE=make
12PERL_VERSION=5.12.3 # 5.8.9 is also a good choice 13PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds
13PERL_CC=cc 14PERL_CC=cc
14PERL_CONFIGURE="" # additional Configure arguments 15PERL_CONFIGURE="" # additional Configure arguments
15PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" 16PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG"
16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
17 18
18ARCH="$(uname -m)" 19ARCH="$(uname -m)"
19 20
20case "$ARCH" in 21#case "$ARCH" in
21 i*86 | x86_64 | amd64 ) 22# i*86 | x86_64 | amd64 )
22 PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 23# PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64
23 case "$ARCH" in 24# case "$ARCH" in
24 i*86 ) 25# i*86 )
25 PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only 26# PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only
26 ;; 27# ;;
27 esac 28# esac
28 ;; 29# ;;
29esac 30#esac
30 31
31# -Wl,--gc-sections makes it impossible to check for undefined references 32# -Wl,--gc-sections makes it impossible to check for undefined references
32# for some reason so we need to patch away the "-no" after Configure and before make :/ 33# for some reason so we need to patch away the "-no" after Configure and before make :/
33# --allow-multiple-definition exists to work around uclibc's pthread static linking bug 34# --allow-multiple-definition exists to work around uclibc's pthread static linking bug
34PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" 35#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36PERL_LDFLAGS=
35PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 37PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
36 38
37# some configuration options for modules 39# some configuration options for modules
38PERL_MM_USE_DEFAULT=1 40PERL_MM_USE_DEFAULT=1
41PERL_MM_OPT="MAN1PODS= MAN3PODS="
39#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow 42#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
40EV_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' 43#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'
41export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS 44export PERL_MM_USE_DEFAULT PERL_MM_OPT
42 45
43# which extra modules to install by default from CPAN that are 46# which extra modules to install by default from CPAN that are
44# required by mkbundle 47# required by mkbundle
45STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 48STATICPERL_MODULES="ExtUtils::MakeMaker ExtUtils::CBuilder common::sense Pod::Strip PPI PPI::XS Pod::Usage"
46 49
47# which extra modules you might want to install 50# which extra modules you might want to install
48EXTRA_MODULES="" 51EXTRA_MODULES=""
49 52
50# overridable functions 53# overridable functions
51preconfigure() { : ; } 54preconfigure() { : ; }
55patchconfig() { : ; }
52postconfigure() { : ; } 56postconfigure() { : ; }
53postbuild() { : ; } 57postbuild() { : ; }
54postinstall() { : ; } 58postinstall() { : ; }
55 59
56# now source user config, if any 60# now source user config, if any
63fi 67fi
64 68
65############################################################################# 69#############################################################################
66# support 70# support
67 71
68MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" 72# work around ExtUtils::CBuilder and others
73export CC="$PERL_CC"
74export CFLAGS="$PERL_CFLASGS"
75export LD="$PERL_CC"
76export LDFLAGS="$PERL_LDFLAGS"
77unset LIBS
78
69PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed 79PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
70 80
71unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 81unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
82unset PERL_MB_OPT
72LC_ALL=C; export LC_ALL # just to be on the safe side 83LC_ALL=C; export LC_ALL # just to be on the safe side
84
85# prepend PATH - not required by staticperl itself, but might make
86# life easier when working in e.g. "staticperl cpan / look"
87PATH="$PERL_PREFIX/perl/bin:$PATH"
73 88
74# set version in a way that Makefile.PL can extract 89# set version in a way that Makefile.PL can extract
75VERSION=VERSION; eval \ 90VERSION=VERSION; eval \
76$VERSION="1.2" 91$VERSION="1.44"
77
78BZ2=bz2
79BZIP2=bzip2
80 92
81fatal() { 93fatal() {
82 printf -- "\nFATAL: %s\n\n" "$*" >&2 94 printf -- "\nFATAL: %s\n\n" "$*" >&2
83 exit 1 95 exit 1
84} 96}
124 136
125############################################################################# 137#############################################################################
126# download/configure/compile/install perl 138# download/configure/compile/install perl
127 139
128clean() { 140clean() {
129 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 141 rm -rf "$STATICPERL/src"
130} 142}
131 143
132realclean() { 144realclean() {
133 rm -f "$PERL_PREFIX/staticstamp.postinstall" 145 rm -f "$PERL_PREFIX/staticstamp.postinstall"
134 rm -f "$PERL_PREFIX/staticstamp.install" 146 rm -f "$PERL_PREFIX/staticstamp.install"
135 rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" 147 rm -f "$STATICPERL/src/perl/staticstamp.configure"
136} 148}
137 149
138fetch() { 150fetch() {
139 rcd "$STATICPERL" 151 rcd "$STATICPERL"
140 152
141 mkdir -p src 153 mkdir -p src
142 rcd src 154 rcd src
143 155
144 if ! [ -d "perl-$PERL_VERSION" ]; then 156 if ! [ -d "perl" ]; then
145 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 157 rm -rf unpack
158 mkdir -p unpack
146 159
160 case "$PERL_VERSION" in
161 *:* )
162 # url
163 PERLURL="$PERL_VERSION"
164 PERLTAR="$(basename "$PERL_VERSION")"
165 ;;
166 /* )
167 # directory
168 verbose "copying $PERL_VERSION"
169 cp -Rp "$PERL_VERSION/." unpack/.
170 chmod -R u+w unpack
171 mv unpack perl
172 return
173 ;;
174 * )
147 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 175 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
176 PERLTAR=perl-$PERL_VERSION.tar.bz2
177 ;;
178 esac
148 179
180 if ! [ -e "$PERLTAR" ]; then
149 verblock <<EOF 181 verblock <<EOF
150downloading perl 182downloading perl
183
184trying to download from $PERLURL
185
186you can configure a download cache directory via DLCACHE
187in your .staticperlrc to avoid repeated downloads.
188
151to manually download perl yourself, place 189to manually download perl yourself, place a suitable tarball in
152perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 190$DLCACHE/$PERLTAR
153trying $URL
154EOF
155 191
192either curl or wget is required for automatic download.
193curl is tried first, then wget.
194EOF
195
156 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 196 rm -f $PERLTAR~ # just to be on the safe side
157 curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 197 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
158 || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 198 || wget -O $PERLTAR~ "$PERLURL" \
199 || curl -f >$PERLTAR~ "$PERLURL" \
159 || fatal "$URL: unable to download" 200 || fatal "$URL: unable to download"
160 rm -f perl-$PERL_VERSION.tar.$BZ2 201 rm -f $PERLTAR
161 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 202 mv $PERLTAR~ $PERLTAR
203 if [ "$DLCACHE" ]; then
204 mkdir -p "$DLCACHE"
205 cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \
206 mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR
207 fi
162 fi 208 fi
163 209
164 verblock <<EOF 210 verblock <<EOF
165unpacking perl 211unpacking perl
166EOF 212EOF
167 213
168 mkdir -p unpack 214 case "$PERLTAR" in
169 rm -rf unpack/perl-$PERL_VERSION 215 *.xz ) UNCOMPRESS="xz -d" ;;
170 $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | ( cd unpack && tar x ) \ 216 *.lzma ) UNCOMPRESS="lzma -d" ;;
217 *.bz2 ) UNCOMPRESS="bzip2 -d" ;;
218 *.gz ) UNCOMPRESS="gzip -d" ;;
219 *.tar ) UNCOMPRESS="cat" ;;
220 * )
221 fatal "don't know hot to uncompress $PERL_TAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported."
222 exit 1
223 ;;
224 esac
225
226 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
171 || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" 227 || fatal "$PERLTAR: error during unpacking"
172 chmod -R u+w unpack/perl-$PERL_VERSION 228
173 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 229 if [ -d unpack/*/ ]; then
230 chmod -R u+w unpack/*/
231 mv unpack/*/ perl
174 rmdir -p unpack 232 rmdir -p unpack
233 else
234 fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this"
235 fi
236
237 rm "$PERLTAR"
175 fi 238 fi
176} 239}
177 240
178# similar to GNU-sed -i or perl -pi 241# similar to GNU-sed -i or perl -pi
179sedreplace() { 242sedreplace() {
209} 272}
210 273
211configure() { 274configure() {
212 fetch 275 fetch
213 276
214 rcd "$STATICPERL/src/perl-$PERL_VERSION" 277 rcd "$STATICPERL/src/perl"
215 278
216 [ -e staticstamp.configure ] && return 279 [ -e staticstamp.configure ] && return
217 280
218 verblock <<EOF 281 verblock <<EOF
219configuring $STATICPERL/src/perl-$PERL_VERSION 282configuring $STATICPERL/src/perl
220EOF 283EOF
221 284
222 rm -f "$PERL_PREFIX/staticstamp.install" 285 rm -f "$PERL_PREFIX/staticstamp.install"
223 286
224 "$MAKE" distclean >/dev/null 2>&1 287 "$MAKE" distclean >/dev/null 2>&1
227 290
228 # I hate them for this 291 # I hate them for this
229 grep -q -- -fstack-protector Configure && \ 292 grep -q -- -fstack-protector Configure && \
230 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 293 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
231 294
232 preconfigure 295 # what did that bloke think
296 grep -q -- usedl=.define hints/darwin.sh && \
297 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
298
299 preconfigure || fatal "preconfigure hook failed"
233 300
234# trace configure \ 301# trace configure \
235 sh Configure -Duselargefiles \ 302 sh Configure -Duselargefiles \
236 -Uuse64bitint \ 303 -Uuse64bitint \
237 -Dusemymalloc=n \ 304 -Dusemymalloc=n \
269 sedreplace ' 336 sedreplace '
270 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 337 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
271 s/ *-fno-stack-protector */ /g 338 s/ *-fno-stack-protector */ /g
272 ' config.sh 339 ' config.sh
273 340
341 patchconfig || fatal "patchconfig hook failed"
342
274 sh Configure -S || fatal "Configure -S failed" 343 sh Configure -S || fatal "Configure -S failed"
275 344
276 postconfigure || fatal "postconfigure hook failed" 345 postconfigure || fatal "postconfigure hook failed"
277 346
278 touch staticstamp.configure 347 : > staticstamp.configure
348}
349
350write_shellscript() {
351 {
352 echo "#!/bin/sh"
353 echo "STATICPERL=\"$STATICPERL\""
354 echo "PERL_PREFIX=\"$PERL_PREFIX\""
355 echo "MAKE=\"$MAKE\""
356 cat
357 } >"$PERL_PREFIX/bin/$1"
358 chmod 755 "$PERL_PREFIX/bin/$1"
279} 359}
280 360
281build() { 361build() {
282 configure 362 configure
283 363
284 rcd "$STATICPERL/src/perl-$PERL_VERSION" 364 rcd "$STATICPERL/src/perl"
285 365
286 verblock <<EOF 366 verblock <<EOF
287building $STATICPERL/src/perl-$PERL_VERSION 367building $STATICPERL/src/perl
288EOF 368EOF
289 369
290 rm -f "$PERL_PREFIX/staticstamp.install" 370 rm -f "$PERL_PREFIX/staticstamp.install"
291 371
292 "$MAKE" || fatal "make: error while building perl" 372 "$MAKE" || fatal "make: error while building perl"
293 373
294 postbuild || fatal "postbuild hook failed" 374 postbuild || fatal "postbuild hook failed"
375}
376
377_postinstall() {
378 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
379 NOCHECK_INSTALL=+
380 instcpan $STATICPERL_MODULES
381 [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES
382
383 postinstall || fatal "postinstall hook failed"
384
385 : > "$PERL_PREFIX/staticstamp.postinstall"
386 fi
295} 387}
296 388
297install() { 389install() {
298 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 390 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
299 build 391 build
300 392
301 verblock <<EOF 393 verblock <<EOF
302installing $STATICPERL/src/perl-$PERL_VERSION 394installing $STATICPERL/src/perl
303to $PERL_PREFIX 395to $PERL_PREFIX
304EOF 396EOF
305 397
306 ln -sf "perl/bin/" "$STATICPERL/bin" 398 ln -sf "perl/bin/" "$STATICPERL/bin"
307 ln -sf "perl/lib/" "$STATICPERL/lib" 399 ln -sf "perl/lib/" "$STATICPERL/lib"
308 400
401 mkdir "$STATICPERL/patched"
402
309 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 403 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
310 rm -rf "$PERL_PREFIX" # by this rm -rf 404 rm -rf "$PERL_PREFIX" # by this rm -rf
311 405
312 "$MAKE" install || fatal "make install: error while installing" 406 "$MAKE" install || fatal "make install: error while installing"
313 407
314 rcd "$PERL_PREFIX" 408 rcd "$PERL_PREFIX"
315 409
316 # create a "make install" replacement for CPAN 410 # create a "make install" replacement for CPAN
317 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 411 write_shellscript SP-make-install-make <<'EOF'
318"$MAKE" || exit 412#CAT make-install-make.sh
319
320# patch CPAN::HandleConfig.pm
321HCPM="$PERL_PREFIX"/lib/CPAN/HandleConfig.pm
322case "\$(head -n1 "\$HCPM")" in
323 *CPAN::MyConfig* )
324 ;;
325 * )
326 echo "patching \$HCPM for a safer tomorrow"
327 {
328 echo "use CPAN::MyConfig;"
329 cat "\$HCPM"
330 } >"\$HCPM~"
331 rm -f "\$HCPM"
332 mv "\$HCPM~" "\$HCPM"
333 ;;
334esac
335
336if find blib/arch/auto -type f | grep -q -v .exists; then
337 echo Probably an XS module, rebuilding perl
338 if "$MAKE" perl; then
339 mv perl "$PERL_PREFIX"/bin/perl~ \
340 && rm -f "$PERL_PREFIX"/bin/perl \
341 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
342 "$MAKE" -f Makefile.aperl map_clean
343 else
344 "$MAKE" -f Makefile.aperl map_clean
345 exit 1
346 fi
347fi
348
349"$MAKE" install UNINST=1
350EOF 413EOF
351 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
352 414
415 # create a "patch modules" helper
416 write_shellscript SP-patch-postinstall <<'EOF'
417#CAT patch-postinstall.sh
418EOF
419
420 # immediately use it
421 "$PERL_PREFIX/bin/SP-patch-postinstall"
422
353 # trick CPAN into avoiding ~/.cpan completely 423 # help to trick CPAN into avoiding ~/.cpan completely
354 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 424 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
355 425
356 # we call cpan with -MCPAN::MyConfig in this script, but 426 # we call cpan with -MCPAN::MyConfig in this script, which
357 # every make install will patch CPAN::HandleConfig.pm to 427 # is strictly unnecssary as we have to patch CPAN anyway,
358 # protect the user. 428 # so consider it "for good measure".
359
360 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' 429 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
361 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 430 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
362 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 431 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
363 CPAN::Shell->o (conf => q<init>); 432 CPAN::Shell->o (conf => q<init>);
364 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 433 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
365 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 434 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
366 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 435 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
367 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 436 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
368 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 437 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
438 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
369 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 439 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
370 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 440 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
371 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 441 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
372 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); 442 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
373 CPAN::Shell->o (conf => q<commit>); 443 CPAN::Shell->o (conf => q<commit>);
374 ' || fatal "error while initialising CPAN" 444 ' || fatal "error while initialising CPAN"
375 445
376 touch "$PERL_PREFIX/staticstamp.install" 446 : > "$PERL_PREFIX/staticstamp.install"
377 fi 447 fi
378 448
449 _postinstall
450}
451
452import() {
453 IMPORT="$1"
454
455 rcd "$STATICPERL"
456
379 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 457 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
380 NOCHECK_INSTALL=+ 458 verblock <<EOF
381 instcpan $STATICPERL_MODULES 459import perl from $IMPORT to $STATICPERL
382 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 460EOF
383 461
384 postinstall || fatal "postinstall hook failed" 462 rm -rf bin cpan lib patched perl src
463 mkdir -m 755 perl perl/bin
464 ln -s perl/bin/ bin
465 ln -s "$IMPORT" perl/bin/
385 466
467 echo "$IMPORT" > "$PERL_PREFIX/.import"
468
386 touch "$PERL_PREFIX/staticstamp.postinstall" 469 : > "$PERL_PREFIX/staticstamp.install"
387 fi 470 fi
471
472 _postinstall
388} 473}
389 474
390############################################################################# 475#############################################################################
391# install a module from CPAN 476# install a module from CPAN
392 477
396 verblock <<EOF 481 verblock <<EOF
397installing modules from CPAN 482installing modules from CPAN
398$@ 483$@
399EOF 484EOF
400 485
401 for mod in "$@"; do 486 MYCONFIG=
402 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \ 487 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
403 || fatal "$mod: unable to install from CPAN" 488
404 done 489 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
490
491 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
492 fatal "failure while installing modules from CPAN ($@)"
493 fi
405 rm -rf "$STATICPERL/build" 494 rm -f "$STATICPERL/instcpan.log"
406} 495}
407 496
408############################################################################# 497#############################################################################
409# install a module from unpacked sources 498# install a module from unpacked sources
410 499
423 rcd $mod 512 rcd $mod
424 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 513 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
425 "$MAKE" distclean >/dev/null 2>&1 514 "$MAKE" distclean >/dev/null 2>&1
426 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 515 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
427 "$MAKE" || fatal "$mod: error building module" 516 "$MAKE" || fatal "$mod: error building module"
428 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 517 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
429 "$MAKE" distclean >/dev/null 2>&1 518 "$MAKE" distclean >/dev/null 2>&1
430 exit 0 519 exit 0
431 ) || exit $? 520 ) || exit $?
432 done 521 done
433} 522}
465#CAT mkbundle 554#CAT mkbundle
466MKBUNDLE 555MKBUNDLE
467} 556}
468 557
469bundle() { 558bundle() {
559 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
470 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 560 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
471 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 561 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
472 CACHE="$STATICPERL/cache" 562 CACHE="$STATICPERL/cache"
473 mkdir -p "$CACHE" 563 mkdir -p "$CACHE"
474 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" 564 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
482 command="${1#--}"; shift 572 command="${1#--}"; shift
483 case "$command" in 573 case "$command" in
484 version ) 574 version )
485 echo "staticperl version $VERSION" 575 echo "staticperl version $VERSION"
486 ;; 576 ;;
487 fetch | configure | build | install | clean | realclean | distclean) 577 fetch | configure | build | install | clean | realclean | distclean )
488 ( "$command" ) || exit 578 ( "$command" ) || exit
579 ;;
580 import )
581 ( import "$1" ) || exit
582 shift
489 ;; 583 ;;
490 instsrc ) 584 instsrc )
491 ( instsrc "$@" ) || exit 585 ( instsrc "$@" ) || exit
492 exit 586 exit
493 ;; 587 ;;
494 instcpan ) 588 instcpan )
495 ( instcpan "$@" ) || exit 589 ( instcpan "$@" ) || exit
496 exit 590 exit
497 ;; 591 ;;
592 perl )
593 ( install ) || exit
594 exec "$PERL_PREFIX/bin/perl" "$@"
595 exit
596 ;;
498 cpan ) 597 cpan )
499 ( install ) || exit 598 ( install ) || exit
599 PERL="$PERL_PREFIX/bin/perl"
600 export PERL
500 "$PERL_PREFIX/bin/cpan" "$@" 601 exec "$PERL_PREFIX/bin/cpan" "$@"
501 exit 602 exit
502 ;; 603 ;;
503 mkbundle ) 604 mkbundle )
504 ( install ) || exit 605 ( install ) || exit
505 bundle "$@" 606 bundle "$@"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines