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.33 by root, Thu Feb 24 07:10:03 2011 UTC vs.
Revision 1.62 by root, Fri Oct 16 01:52:08 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.1" 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 case "$PERL_VERSION" in
146 158 *:* )
159 # assume url
160 PERLURL="$PERL_VERSION"
161 PERLTAR="$(basename "$PERL_VERSION")"
162 ;;
163 * )
147 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 164 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
165 PERLTAR=perl-$PERL_VERSION.tar.bz2
166 ;;
167 esac
148 168
169 if ! [ -e "$PERLTAR" ]; then
149 verblock <<EOF 170 verblock <<EOF
150downloading perl 171downloading perl
172
173trying to download from $PERLURL
174
175you can configure a download cache directory via DLCACHE
176in your .staticperlrc to avoid repeated downloads.
177
151to manually download perl yourself, place 178to manually download perl yourself, place a suitable tarball in
152perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 179$DLCACHE/$PERLTAR
153trying $URL
154EOF
155 180
181either curl or wget is required for automatic download.
182curl is tried first, then wget.
183EOF
184
156 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 185 rm -f $PERLTAR~ # just to be on the safe side
157 curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 186 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
158 || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 187 || wget -O $PERLTAR~ "$PERLURL" \
188 || curl -f >$PERLTAR~ "$PERLURL" \
159 || fatal "$URL: unable to download" 189 || fatal "$URL: unable to download"
160 rm -f perl-$PERL_VERSION.tar.$BZ2 190 rm -f $PERLTAR
161 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 191 mv $PERLTAR~ $PERLTAR
192 if [ "$DLCACHE" ]; then
193 mkdir -p "$DLCACHE"
194 cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \
195 mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR
196 fi
162 fi 197 fi
163 198
164 verblock <<EOF 199 verblock <<EOF
165unpacking perl 200unpacking perl
166EOF 201EOF
167 202
203 rm -rf unpack
168 mkdir -p unpack 204 mkdir -p unpack
169 rm -rf unpack/perl-$PERL_VERSION 205
170 $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | tar xfC - unpack \ 206 case "$PERLTAR" in
207 *.xz ) UNCOMPRESS="xz -d" ;;
208 *.lzma ) UNCOMPRESS="lzma -d" ;;
209 *.bz2 ) UNCOMPRESS="bzip2 -d" ;;
210 *.gz ) UNCOMPRESS="gzip -d" ;;
211 *.tar ) UNCOMPRESS="cat" ;;
212 * )
213 fatal "don't know hot to uncompress $PERL_TAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported."
214 exit 1
215 ;;
216 esac
217
218 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
171 || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" 219 || fatal "$PERLTAR: error during unpacking"
172 chmod -R u+w unpack/perl-$PERL_VERSION 220
173 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 221 if [ -d unpack/*/ ]; then
222 chmod -R u+w unpack/*/
223 mv unpack/*/ perl
174 rmdir -p unpack 224 rmdir -p unpack
225 else
226 fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this"
227 fi
228
229 rm "$PERLTAR"
175 fi 230 fi
176} 231}
177 232
178# similar to GNU-sed -i or perl -pi 233# similar to GNU-sed -i or perl -pi
179sedreplace() { 234sedreplace() {
209} 264}
210 265
211configure() { 266configure() {
212 fetch 267 fetch
213 268
214 rcd "$STATICPERL/src/perl-$PERL_VERSION" 269 rcd "$STATICPERL/src/perl"
215 270
216 [ -e staticstamp.configure ] && return 271 [ -e staticstamp.configure ] && return
217 272
218 verblock <<EOF 273 verblock <<EOF
219configuring $STATICPERL/src/perl-$PERL_VERSION 274configuring $STATICPERL/src/perl
220EOF 275EOF
221 276
222 rm -f "$PERL_PREFIX/staticstamp.install" 277 rm -f "$PERL_PREFIX/staticstamp.install"
223 278
224 "$MAKE" distclean >/dev/null 2>&1 279 "$MAKE" distclean >/dev/null 2>&1
227 282
228 # I hate them for this 283 # I hate them for this
229 grep -q -- -fstack-protector Configure && \ 284 grep -q -- -fstack-protector Configure && \
230 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 285 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
231 286
232 preconfigure 287 # what did that bloke think
288 grep -q -- usedl=.define hints/darwin.sh && \
289 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
290
291 preconfigure || fatal "preconfigure hook failed"
233 292
234# trace configure \ 293# trace configure \
235 sh Configure -Duselargefiles \ 294 sh Configure -Duselargefiles \
236 -Uuse64bitint \ 295 -Uuse64bitint \
237 -Dusemymalloc=n \ 296 -Dusemymalloc=n \
269 sedreplace ' 328 sedreplace '
270 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 329 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
271 s/ *-fno-stack-protector */ /g 330 s/ *-fno-stack-protector */ /g
272 ' config.sh 331 ' config.sh
273 332
333 patchconfig || fatal "patchconfig hook failed"
334
274 sh Configure -S || fatal "Configure -S failed" 335 sh Configure -S || fatal "Configure -S failed"
275 336
276 postconfigure || fatal "postconfigure hook failed" 337 postconfigure || fatal "postconfigure hook failed"
277 338
278 touch staticstamp.configure 339 : > staticstamp.configure
340}
341
342write_shellscript() {
343 {
344 echo "#!/bin/sh"
345 echo "STATICPERL=\"$STATICPERL\""
346 echo "PERL_PREFIX=\"$PERL_PREFIX\""
347 echo "MAKE=\"$MAKE\""
348 cat
349 } >"$PERL_PREFIX/bin/$1"
350 chmod 755 "$PERL_PREFIX/bin/$1"
279} 351}
280 352
281build() { 353build() {
282 configure 354 configure
283 355
284 rcd "$STATICPERL/src/perl-$PERL_VERSION" 356 rcd "$STATICPERL/src/perl"
285 357
286 verblock <<EOF 358 verblock <<EOF
287building $STATICPERL/src/perl-$PERL_VERSION 359building $STATICPERL/src/perl
288EOF 360EOF
289 361
290 rm -f "$PERL_PREFIX/staticstamp.install" 362 rm -f "$PERL_PREFIX/staticstamp.install"
291 363
292 "$MAKE" || fatal "make: error while building perl" 364 "$MAKE" || fatal "make: error while building perl"
293 365
294 postbuild || fatal "postbuild hook failed" 366 postbuild || fatal "postbuild hook failed"
367}
368
369_postinstall() {
370 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
371 NOCHECK_INSTALL=+
372 instcpan $STATICPERL_MODULES
373 [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES
374
375 postinstall || fatal "postinstall hook failed"
376
377 : > "$PERL_PREFIX/staticstamp.postinstall"
378 fi
295} 379}
296 380
297install() { 381install() {
298 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 382 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
299 build 383 build
300 384
301 verblock <<EOF 385 verblock <<EOF
302installing $STATICPERL/src/perl-$PERL_VERSION 386installing $STATICPERL/src/perl
303to $PERL_PREFIX 387to $PERL_PREFIX
304EOF 388EOF
305 389
306 ln -sf "perl/bin/" "$STATICPERL/bin" 390 ln -sf "perl/bin/" "$STATICPERL/bin"
307 ln -sf "perl/lib/" "$STATICPERL/lib" 391 ln -sf "perl/lib/" "$STATICPERL/lib"
308 392
393 mkdir "$STATICPERL/patched"
394
309 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 395 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
310 rm -rf "$PERL_PREFIX" # by this rm -rf 396 rm -rf "$PERL_PREFIX" # by this rm -rf
311 397
312 "$MAKE" install || fatal "make install: error while installing" 398 "$MAKE" install || fatal "make install: error while installing"
313 399
314 rcd "$PERL_PREFIX" 400 rcd "$PERL_PREFIX"
315 401
316 # create a "make install" replacement for CPAN 402 # create a "make install" replacement for CPAN
317 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 403 write_shellscript SP-make-install-make <<'EOF'
318"$MAKE" || exit 404#CAT make-install-make.sh
319
320if find blib/arch/auto -type f | grep -q -v .exists; then
321 echo Probably an XS module, rebuilding perl
322 if "$MAKE" perl; then
323 mv perl "$PERL_PREFIX"/bin/perl~ \
324 && rm -f "$PERL_PREFIX"/bin/perl \
325 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
326 "$MAKE" -f Makefile.aperl map_clean
327 else
328 "$MAKE" -f Makefile.aperl map_clean
329 exit 1
330 fi
331fi
332
333"$MAKE" install UNINST=1
334EOF 405EOF
335 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
336 406
407 # create a "patch modules" helper
408 write_shellscript SP-patch-postinstall <<'EOF'
409#CAT patch-postinstall.sh
410EOF
411
412 # immediately use it
413 "$PERL_PREFIX/bin/SP-patch-postinstall"
414
337 # trick CPAN into avoiding ~/.cpan completely 415 # help to trick CPAN into avoiding ~/.cpan completely
338 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 416 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
339 417
418 # we call cpan with -MCPAN::MyConfig in this script, which
419 # is strictly unnecssary as we have to patch CPAN anyway,
420 # so consider it "for good measure".
340 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 421 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
341 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 422 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
342 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 423 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
343 CPAN::Shell->o (conf => q<init>); 424 CPAN::Shell->o (conf => q<init>);
344 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 425 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
345 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 426 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
346 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 427 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
347 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 428 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
348 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 429 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
430 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
349 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 431 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
350 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 432 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
351 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 433 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
434 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
352 CPAN::Shell->o (conf => q<commit>); 435 CPAN::Shell->o (conf => q<commit>);
353 ' || fatal "error while initialising CPAN" 436 ' || fatal "error while initialising CPAN"
354 437
355 touch "$PERL_PREFIX/staticstamp.install" 438 : > "$PERL_PREFIX/staticstamp.install"
356 fi 439 fi
357 440
441 _postinstall
442}
443
444import() {
445 IMPORT="$1"
446
447 rcd "$STATICPERL"
448
358 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 449 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
359 NOCHECK_INSTALL=+ 450 verblock <<EOF
360 instcpan $STATICPERL_MODULES 451import perl from $IMPORT to $STATICPERL
361 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 452EOF
362 453
363 postinstall || fatal "postinstall hook failed" 454 rm -rf bin cpan lib patched perl src
455 mkdir -m 755 perl perl/bin
456 ln -s perl/bin/ bin
457 ln -s "$IMPORT" perl/bin/
364 458
459 echo "$IMPORT" > "$PERL_PREFIX/.import"
460
365 touch "$PERL_PREFIX/staticstamp.postinstall" 461 : > "$PERL_PREFIX/staticstamp.install"
366 fi 462 fi
463
464 _postinstall
367} 465}
368 466
369############################################################################# 467#############################################################################
370# install a module from CPAN 468# install a module from CPAN
371 469
375 verblock <<EOF 473 verblock <<EOF
376installing modules from CPAN 474installing modules from CPAN
377$@ 475$@
378EOF 476EOF
379 477
380 for mod in "$@"; do 478 MYCONFIG=
381 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 479 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
382 || fatal "$mod: unable to install from CPAN" 480
383 done 481 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
482
483 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
484 fatal "failure while installing modules from CPAN ($@)"
485 fi
384 rm -rf "$STATICPERL/build" 486 rm -f "$STATICPERL/instcpan.log"
385} 487}
386 488
387############################################################################# 489#############################################################################
388# install a module from unpacked sources 490# install a module from unpacked sources
389 491
402 rcd $mod 504 rcd $mod
403 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 505 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
404 "$MAKE" distclean >/dev/null 2>&1 506 "$MAKE" distclean >/dev/null 2>&1
405 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 507 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
406 "$MAKE" || fatal "$mod: error building module" 508 "$MAKE" || fatal "$mod: error building module"
407 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 509 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
408 "$MAKE" distclean >/dev/null 2>&1 510 "$MAKE" distclean >/dev/null 2>&1
409 exit 0 511 exit 0
410 ) || exit $? 512 ) || exit $?
411 done 513 done
412} 514}
444#CAT mkbundle 546#CAT mkbundle
445MKBUNDLE 547MKBUNDLE
446} 548}
447 549
448bundle() { 550bundle() {
551 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
449 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 552 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
450 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 553 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
451 CACHE="$STATICPERL/cache" 554 CACHE="$STATICPERL/cache"
452 mkdir -p "$CACHE" 555 mkdir -p "$CACHE"
453 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" 556 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
461 command="${1#--}"; shift 564 command="${1#--}"; shift
462 case "$command" in 565 case "$command" in
463 version ) 566 version )
464 echo "staticperl version $VERSION" 567 echo "staticperl version $VERSION"
465 ;; 568 ;;
466 fetch | configure | build | install | clean | realclean | distclean) 569 fetch | configure | build | install | clean | realclean | distclean )
467 ( "$command" ) || exit 570 ( "$command" ) || exit
571 ;;
572 import )
573 ( import "$1" ) || exit
574 shift
468 ;; 575 ;;
469 instsrc ) 576 instsrc )
470 ( instsrc "$@" ) || exit 577 ( instsrc "$@" ) || exit
471 exit 578 exit
472 ;; 579 ;;
473 instcpan ) 580 instcpan )
474 ( instcpan "$@" ) || exit 581 ( instcpan "$@" ) || exit
475 exit 582 exit
476 ;; 583 ;;
584 perl )
585 ( install ) || exit
586 exec "$PERL_PREFIX/bin/perl" "$@"
587 exit
588 ;;
477 cpan ) 589 cpan )
478 ( install ) || exit 590 ( install ) || exit
591 PERL="$PERL_PREFIX/bin/perl"
592 export PERL
479 "$PERL_PREFIX/bin/cpan" "$@" 593 exec "$PERL_PREFIX/bin/cpan" "$@"
480 exit 594 exit
481 ;; 595 ;;
482 mkbundle ) 596 mkbundle )
483 ( install ) || exit 597 ( install ) || exit
484 bundle "$@" 598 bundle "$@"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines