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.62 by root, Fri Oct 16 01:52:08 2015 UTC vs.
Revision 1.75 by root, Tue Aug 1 03:48:59 2023 UTC

49 49
50# which extra modules you might want to install 50# which extra modules you might want to install
51EXTRA_MODULES="" 51EXTRA_MODULES=""
52 52
53# overridable functions 53# overridable functions
54preconfigure() { : ; } 54preconfigure() { : ; }
55patchconfig() { : ; } 55patchconfig() { : ; }
56postconfigure() { : ; } 56postconfigure() { : ; }
57postbuild() { : ; } 57postbuild() { : ; }
58postcpanconfig() { : ; }
58postinstall() { : ; } 59postinstall() { : ; }
59 60
60# now source user config, if any 61# now source user config, if any
61if [ "$STATICPERLRC" ]; then 62if [ "$STATICPERLRC" ]; then
62 . "$STATICPERLRC" 63 . "$STATICPERLRC"
63else 64else
69############################################################################# 70#############################################################################
70# support 71# support
71 72
72# work around ExtUtils::CBuilder and others 73# work around ExtUtils::CBuilder and others
73export CC="$PERL_CC" 74export CC="$PERL_CC"
74export CFLAGS="$PERL_CFLASGS" 75export CFLAGS="$PERL_CFLAGS"
75export LD="$PERL_CC" 76export LD="$PERL_CC"
76export LDFLAGS="$PERL_LDFLAGS" 77export LDFLAGS="$PERL_LDFLAGS"
77unset LIBS 78unset LIBS
78 79
79PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed 80PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
86# life easier when working in e.g. "staticperl cpan / look" 87# life easier when working in e.g. "staticperl cpan / look"
87PATH="$PERL_PREFIX/perl/bin:$PATH" 88PATH="$PERL_PREFIX/perl/bin:$PATH"
88 89
89# set version in a way that Makefile.PL can extract 90# set version in a way that Makefile.PL can extract
90VERSION=VERSION; eval \ 91VERSION=VERSION; eval \
91$VERSION="1.44" 92$VERSION="1.46"
92 93
93fatal() { 94fatal() {
94 printf -- "\nFATAL: %s\n\n" "$*" >&2 95 printf -- "\nFATAL: %s\n\n" "$*" >&2
95 exit 1 96 exit 1
96} 97}
146 rm -f "$PERL_PREFIX/staticstamp.install" 147 rm -f "$PERL_PREFIX/staticstamp.install"
147 rm -f "$STATICPERL/src/perl/staticstamp.configure" 148 rm -f "$STATICPERL/src/perl/staticstamp.configure"
148} 149}
149 150
150fetch() { 151fetch() {
152(
151 rcd "$STATICPERL" 153 rcd "$STATICPERL"
152 154
153 mkdir -p src 155 mkdir -p src
154 rcd src 156 rcd src
155 157
156 if ! [ -d "perl" ]; then 158 if ! [ -d "perl" ]; then
159 rm -rf unpack
160 mkdir -p unpack
161
157 case "$PERL_VERSION" in 162 case "$PERL_VERSION" in
158 *:* ) 163 *:* )
159 # assume url 164 # url
160 PERLURL="$PERL_VERSION" 165 PERLURL="$PERL_VERSION"
161 PERLTAR="$(basename "$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
162 ;; 175 ;;
163 * ) 176 * )
164 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2" 177 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
165 PERLTAR=perl-$PERL_VERSION.tar.bz2 178 PERLTAR=perl-$PERL_VERSION.tar.bz2
166 ;; 179 ;;
198 211
199 verblock <<EOF 212 verblock <<EOF
200unpacking perl 213unpacking perl
201EOF 214EOF
202 215
203 rm -rf unpack
204 mkdir -p unpack
205
206 case "$PERLTAR" in 216 case "$PERLTAR" in
207 *.xz ) UNCOMPRESS="xz -d" ;; 217 *.xz ) UNCOMPRESS="xz -d" ;;
208 *.lzma ) UNCOMPRESS="lzma -d" ;; 218 *.lzma ) UNCOMPRESS="lzma -d" ;;
209 *.bz2 ) UNCOMPRESS="bzip2 -d" ;; 219 *.bz2 ) UNCOMPRESS="bzip2 -d" ;;
210 *.gz ) UNCOMPRESS="gzip -d" ;; 220 *.gz ) UNCOMPRESS="gzip -d" ;;
211 *.tar ) UNCOMPRESS="cat" ;; 221 *.tar ) UNCOMPRESS="cat" ;;
212 * ) 222 * )
213 fatal "don't know hot to uncompress $PERL_TAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported." 223 fatal "don't know hot to uncompress $PERLTAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported."
214 exit 1 224 exit 1
215 ;; 225 ;;
216 esac 226 esac
217 227
218 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \ 228 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
226 fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this" 236 fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this"
227 fi 237 fi
228 238
229 rm "$PERLTAR" 239 rm "$PERLTAR"
230 fi 240 fi
241) || exit
231} 242}
232 243
233# similar to GNU-sed -i or perl -pi 244# similar to GNU-sed -i or perl -pi
234sedreplace() { 245sedreplace() {
235 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 246 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
262EOF 273EOF
263 exit 1 274 exit 1
264} 275}
265 276
266configure() { 277configure() {
278(
267 fetch 279 fetch
268 280
269 rcd "$STATICPERL/src/perl" 281 rcd "$STATICPERL/src/perl"
270 282
271 [ -e staticstamp.configure ] && return 283 [ -e staticstamp.configure ] && return
321 -Demail="$EMAIL" \ 333 -Demail="$EMAIL" \
322 -Dcf_email="$EMAIL" \ 334 -Dcf_email="$EMAIL" \
323 -Dcf_by="$EMAIL" \ 335 -Dcf_by="$EMAIL" \
324 $PERL_CONFIGURE \ 336 $PERL_CONFIGURE \
325 -Duseperlio \ 337 -Duseperlio \
338 -Uversiononly \
326 -dE || configure_failure 339 -dE || configure_failure
327 340
328 sedreplace ' 341 sedreplace '
329 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 342 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
330 s/ *-fno-stack-protector */ /g 343 s/ *-fno-stack-protector */ /g
335 sh Configure -S || fatal "Configure -S failed" 348 sh Configure -S || fatal "Configure -S failed"
336 349
337 postconfigure || fatal "postconfigure hook failed" 350 postconfigure || fatal "postconfigure hook failed"
338 351
339 : > staticstamp.configure 352 : > staticstamp.configure
353) || exit
340} 354}
341 355
342write_shellscript() { 356write_shellscript() {
343 { 357 {
344 echo "#!/bin/sh" 358 echo "#!/bin/sh"
349 } >"$PERL_PREFIX/bin/$1" 363 } >"$PERL_PREFIX/bin/$1"
350 chmod 755 "$PERL_PREFIX/bin/$1" 364 chmod 755 "$PERL_PREFIX/bin/$1"
351} 365}
352 366
353build() { 367build() {
368(
354 configure 369 configure
355 370
356 rcd "$STATICPERL/src/perl" 371 rcd "$STATICPERL/src/perl"
357 372
358 verblock <<EOF 373 verblock <<EOF
362 rm -f "$PERL_PREFIX/staticstamp.install" 377 rm -f "$PERL_PREFIX/staticstamp.install"
363 378
364 "$MAKE" || fatal "make: error while building perl" 379 "$MAKE" || fatal "make: error while building perl"
365 380
366 postbuild || fatal "postbuild hook failed" 381 postbuild || fatal "postbuild hook failed"
382) || exit
367} 383}
368 384
369_postinstall() { 385_postinstall() {
370 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 386 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
371 NOCHECK_INSTALL=+ 387 NOCHECK_INSTALL=+
377 : > "$PERL_PREFIX/staticstamp.postinstall" 393 : > "$PERL_PREFIX/staticstamp.postinstall"
378 fi 394 fi
379} 395}
380 396
381install() { 397install() {
398(
382 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 399 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
383 build 400 build
384 401
385 verblock <<EOF 402 verblock <<EOF
386installing $STATICPERL/src/perl 403installing $STATICPERL/src/perl
393 mkdir "$STATICPERL/patched" 410 mkdir "$STATICPERL/patched"
394 411
395 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 412 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
396 rm -rf "$PERL_PREFIX" # by this rm -rf 413 rm -rf "$PERL_PREFIX" # by this rm -rf
397 414
415 rcd "$STATICPERL/src/perl"
416
398 "$MAKE" install || fatal "make install: error while installing" 417 "$MAKE" install || fatal "make install: error while installing"
399 418
400 rcd "$PERL_PREFIX" 419 rcd "$PERL_PREFIX"
401 420
402 # create a "make install" replacement for CPAN 421 # create a "make install" replacement for CPAN
403 write_shellscript SP-make-install-make <<'EOF' 422 write_shellscript SP-make-make <<'end_of_make'
423#CAT make-make.sh
424end_of_make
425
426 # create a "make install" replacement for CPAN
427 write_shellscript SP-make-install-make <<'end_of_make_install_make'
404#CAT make-install-make.sh 428#CAT make-install-make.sh
405EOF 429end_of_make_install_make
406 430
407 # create a "patch modules" helper 431 # create a "patch modules" helper
408 write_shellscript SP-patch-postinstall <<'EOF' 432 write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall'
409#CAT patch-postinstall.sh 433#CAT patch-postinstall.sh
410EOF 434end_of_patch_postinstall
411 435
412 # immediately use it 436 # immediately use it
413 "$PERL_PREFIX/bin/SP-patch-postinstall" 437 "$PERL_PREFIX/bin/SP-patch-postinstall"
414 438
415 # help to trick CPAN into avoiding ~/.cpan completely 439 # help to trick CPAN into avoiding ~/.cpan completely
416 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 440 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
417 441
418 # we call cpan with -MCPAN::MyConfig in this script, which 442 # we call cpan with -MCPAN::MyConfig in this script, which
419 # is strictly unnecssary as we have to patch CPAN anyway, 443 # is strictly unnecessary as we have to patch CPAN anyway,
420 # so consider it "for good measure". 444 # so consider it "for good measure".
421 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' 445 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
422 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 446 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
447 CPAN::Shell->o (conf => pushy_https => "0");
423 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 448 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
424 CPAN::Shell->o (conf => q<init>); 449 CPAN::Shell->o (conf => q<init>);
425 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 450 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
426 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 451 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
427 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 452 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
428 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 453 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
429 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 454 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
430 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl"); 455 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
456 CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make");
431 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); 457 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
432 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 458 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
433 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>); 459 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
460 CPAN::Shell->o (conf => q<recommends_policy>, q<0>);
461 CPAN::Shell->o (conf => q<suggests_policy>, q<0>);
434 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); 462 CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>);
435 CPAN::Shell->o (conf => q<commit>); 463 CPAN::Shell->o (conf => q<commit>);
436 ' || fatal "error while initialising CPAN" 464 ' || fatal "error while initialising CPAN"
437 465
466 postcpanconfig
467
438 : > "$PERL_PREFIX/staticstamp.install" 468 : > "$PERL_PREFIX/staticstamp.install"
439 fi 469 fi
440 470
441 _postinstall 471 _postinstall
472) || exit
442} 473}
443 474
444import() { 475import() {
476(
445 IMPORT="$1" 477 IMPORT="$1"
446 478
447 rcd "$STATICPERL" 479 rcd "$STATICPERL"
448 480
449 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 481 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
460 492
461 : > "$PERL_PREFIX/staticstamp.install" 493 : > "$PERL_PREFIX/staticstamp.install"
462 fi 494 fi
463 495
464 _postinstall 496 _postinstall
497) || exit
465} 498}
466 499
467############################################################################# 500#############################################################################
468# install a module from CPAN 501# install a module from CPAN
469 502
470instcpan() { 503instcpan() {
471 [ $NOCHECK_INSTALL ] || install 504 [ $NOCHECK_INSTALL ] || install
472 505
473 verblock <<EOF 506 verblock <<EOF
474installing modules from CPAN 507installing modules from CPAN
475$@ 508$*
476EOF 509EOF
477 510
478 MYCONFIG= 511 MYCONFIG=
479 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig 512 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
480 513
481 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" 514 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
482 515
483 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then 516 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
484 fatal "failure while installing modules from CPAN ($@)" 517 fatal "failure while installing modules from CPAN ($*)"
485 fi 518 fi
486 rm -f "$STATICPERL/instcpan.log" 519 rm -f "$STATICPERL/instcpan.log"
487} 520}
488 521
489############################################################################# 522#############################################################################
492instsrc() { 525instsrc() {
493 [ $NOCHECK_INSTALL ] || install 526 [ $NOCHECK_INSTALL ] || install
494 527
495 verblock <<EOF 528 verblock <<EOF
496installing modules from source 529installing modules from source
497$@ 530$*
498EOF 531EOF
499 532
500 for mod in "$@"; do 533 for mod in "$@"; do
501 echo 534 echo
502 echo $mod 535 echo $mod
540catmkbundle() { 573catmkbundle() {
541 { 574 {
542 read dummy 575 read dummy
543 echo "#!$PERL_PREFIX/bin/perl" 576 echo "#!$PERL_PREFIX/bin/perl"
544 cat 577 cat
545 } <<'MKBUNDLE' 578 } <<'end_of_mkbundle'
546#CAT mkbundle 579#CAT mkbundle
547MKBUNDLE 580end_of_mkbundle
548} 581}
549 582
550bundle() { 583bundle() {
551 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" 584 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
552 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 585 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines