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.64 by root, Mon Jun 26 20:33:30 2017 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 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 | tar xfC - unpack \ 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 \
262 -Demail="$EMAIL" \ 329 -Demail="$EMAIL" \
263 -Dcf_email="$EMAIL" \ 330 -Dcf_email="$EMAIL" \
264 -Dcf_by="$EMAIL" \ 331 -Dcf_by="$EMAIL" \
265 $PERL_CONFIGURE \ 332 $PERL_CONFIGURE \
266 -Duseperlio \ 333 -Duseperlio \
334 -Uversiononly \
267 -dE || configure_failure 335 -dE || configure_failure
268 336
269 sedreplace ' 337 sedreplace '
270 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 338 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
271 s/ *-fno-stack-protector */ /g 339 s/ *-fno-stack-protector */ /g
272 ' config.sh 340 ' config.sh
273 341
342 patchconfig || fatal "patchconfig hook failed"
343
274 sh Configure -S || fatal "Configure -S failed" 344 sh Configure -S || fatal "Configure -S failed"
275 345
276 postconfigure || fatal "postconfigure hook failed" 346 postconfigure || fatal "postconfigure hook failed"
277 347
278 touch staticstamp.configure 348 : > staticstamp.configure
349}
350
351write_shellscript() {
352 {
353 echo "#!/bin/sh"
354 echo "STATICPERL=\"$STATICPERL\""
355 echo "PERL_PREFIX=\"$PERL_PREFIX\""
356 echo "MAKE=\"$MAKE\""
357 cat
358 } >"$PERL_PREFIX/bin/$1"
359 chmod 755 "$PERL_PREFIX/bin/$1"
279} 360}
280 361
281build() { 362build() {
282 configure 363 configure
283 364
284 rcd "$STATICPERL/src/perl-$PERL_VERSION" 365 rcd "$STATICPERL/src/perl"
285 366
286 verblock <<EOF 367 verblock <<EOF
287building $STATICPERL/src/perl-$PERL_VERSION 368building $STATICPERL/src/perl
288EOF 369EOF
289 370
290 rm -f "$PERL_PREFIX/staticstamp.install" 371 rm -f "$PERL_PREFIX/staticstamp.install"
291 372
292 "$MAKE" || fatal "make: error while building perl" 373 "$MAKE" || fatal "make: error while building perl"
293 374
294 postbuild || fatal "postbuild hook failed" 375 postbuild || fatal "postbuild hook failed"
376}
377
378_postinstall() {
379 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
380 NOCHECK_INSTALL=+
381 instcpan $STATICPERL_MODULES
382 [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES
383
384 postinstall || fatal "postinstall hook failed"
385
386 : > "$PERL_PREFIX/staticstamp.postinstall"
387 fi
295} 388}
296 389
297install() { 390install() {
298 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 391 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
299 build 392 build
300 393
301 verblock <<EOF 394 verblock <<EOF
302installing $STATICPERL/src/perl-$PERL_VERSION 395installing $STATICPERL/src/perl
303to $PERL_PREFIX 396to $PERL_PREFIX
304EOF 397EOF
305 398
306 ln -sf "perl/bin/" "$STATICPERL/bin" 399 ln -sf "perl/bin/" "$STATICPERL/bin"
307 ln -sf "perl/lib/" "$STATICPERL/lib" 400 ln -sf "perl/lib/" "$STATICPERL/lib"
308 401
402 mkdir "$STATICPERL/patched"
403
309 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 404 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
310 rm -rf "$PERL_PREFIX" # by this rm -rf 405 rm -rf "$PERL_PREFIX" # by this rm -rf
311 406
312 "$MAKE" install || fatal "make install: error while installing" 407 "$MAKE" install || fatal "make install: error while installing"
313 408
314 rcd "$PERL_PREFIX" 409 rcd "$PERL_PREFIX"
315 410
316 # create a "make install" replacement for CPAN 411 # create a "make install" replacement for CPAN
317 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 412 write_shellscript SP-make-install-make <<'EOF'
318"$MAKE" || exit 413#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 414EOF
335 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
336 415
416 # create a "patch modules" helper
417 write_shellscript SP-patch-postinstall <<'EOF'
418#CAT patch-postinstall.sh
419EOF
420
421 # immediately use it
422 "$PERL_PREFIX/bin/SP-patch-postinstall"
423
337 # trick CPAN into avoiding ~/.cpan completely 424 # help to trick CPAN into avoiding ~/.cpan completely
338 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 425 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
339 426
427 # we call cpan with -MCPAN::MyConfig in this script, which
428 # is strictly unnecssary as we have to patch CPAN anyway,
429 # so consider it "for good measure".
340 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 430 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
341 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 431 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
342 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 432 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
343 CPAN::Shell->o (conf => q<init>); 433 CPAN::Shell->o (conf => q<init>);
344 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 434 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
345 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 435 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
346 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 436 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
347 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 437 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
348 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 438 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
439 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"); 440 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>); 441 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
351 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 442 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
443 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
352 CPAN::Shell->o (conf => q<commit>); 444 CPAN::Shell->o (conf => q<commit>);
353 ' || fatal "error while initialising CPAN" 445 ' || fatal "error while initialising CPAN"
354 446
355 touch "$PERL_PREFIX/staticstamp.install" 447 : > "$PERL_PREFIX/staticstamp.install"
356 fi 448 fi
357 449
450 _postinstall
451}
452
453import() {
454 IMPORT="$1"
455
456 rcd "$STATICPERL"
457
358 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 458 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
359 NOCHECK_INSTALL=+ 459 verblock <<EOF
360 instcpan $STATICPERL_MODULES 460import perl from $IMPORT to $STATICPERL
361 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 461EOF
362 462
363 postinstall || fatal "postinstall hook failed" 463 rm -rf bin cpan lib patched perl src
464 mkdir -m 755 perl perl/bin
465 ln -s perl/bin/ bin
466 ln -s "$IMPORT" perl/bin/
364 467
468 echo "$IMPORT" > "$PERL_PREFIX/.import"
469
365 touch "$PERL_PREFIX/staticstamp.postinstall" 470 : > "$PERL_PREFIX/staticstamp.install"
366 fi 471 fi
472
473 _postinstall
367} 474}
368 475
369############################################################################# 476#############################################################################
370# install a module from CPAN 477# install a module from CPAN
371 478
375 verblock <<EOF 482 verblock <<EOF
376installing modules from CPAN 483installing modules from CPAN
377$@ 484$@
378EOF 485EOF
379 486
380 for mod in "$@"; do 487 MYCONFIG=
381 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 488 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
382 || fatal "$mod: unable to install from CPAN" 489
383 done 490 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
491
492 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
493 fatal "failure while installing modules from CPAN ($@)"
494 fi
384 rm -rf "$STATICPERL/build" 495 rm -f "$STATICPERL/instcpan.log"
385} 496}
386 497
387############################################################################# 498#############################################################################
388# install a module from unpacked sources 499# install a module from unpacked sources
389 500
402 rcd $mod 513 rcd $mod
403 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 514 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
404 "$MAKE" distclean >/dev/null 2>&1 515 "$MAKE" distclean >/dev/null 2>&1
405 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 516 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
406 "$MAKE" || fatal "$mod: error building module" 517 "$MAKE" || fatal "$mod: error building module"
407 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 518 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
408 "$MAKE" distclean >/dev/null 2>&1 519 "$MAKE" distclean >/dev/null 2>&1
409 exit 0 520 exit 0
410 ) || exit $? 521 ) || exit $?
411 done 522 done
412} 523}
444#CAT mkbundle 555#CAT mkbundle
445MKBUNDLE 556MKBUNDLE
446} 557}
447 558
448bundle() { 559bundle() {
560 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
449 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 561 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
450 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 562 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
451 CACHE="$STATICPERL/cache" 563 CACHE="$STATICPERL/cache"
452 mkdir -p "$CACHE" 564 mkdir -p "$CACHE"
453 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" 565 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
461 command="${1#--}"; shift 573 command="${1#--}"; shift
462 case "$command" in 574 case "$command" in
463 version ) 575 version )
464 echo "staticperl version $VERSION" 576 echo "staticperl version $VERSION"
465 ;; 577 ;;
466 fetch | configure | build | install | clean | realclean | distclean) 578 fetch | configure | build | install | clean | realclean | distclean )
467 ( "$command" ) || exit 579 ( "$command" ) || exit
580 ;;
581 import )
582 ( import "$1" ) || exit
583 shift
468 ;; 584 ;;
469 instsrc ) 585 instsrc )
470 ( instsrc "$@" ) || exit 586 ( instsrc "$@" ) || exit
471 exit 587 exit
472 ;; 588 ;;
473 instcpan ) 589 instcpan )
474 ( instcpan "$@" ) || exit 590 ( instcpan "$@" ) || exit
475 exit 591 exit
476 ;; 592 ;;
593 perl )
594 ( install ) || exit
595 exec "$PERL_PREFIX/bin/perl" "$@"
596 exit
597 ;;
477 cpan ) 598 cpan )
478 ( install ) || exit 599 ( install ) || exit
600 PERL="$PERL_PREFIX/bin/perl"
601 export PERL
479 "$PERL_PREFIX/bin/cpan" "$@" 602 exec "$PERL_PREFIX/bin/cpan" "$@"
480 exit 603 exit
481 ;; 604 ;;
482 mkbundle ) 605 mkbundle )
483 ( install ) || exit 606 ( install ) || exit
484 bundle "$@" 607 bundle "$@"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines