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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines