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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines