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.60 by root, Fri Jul 31 09:36:54 2015 UTC vs.
Revision 1.75 by root, Tue Aug 1 03:48:59 2023 UTC

8EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
9DLCACHE= 9DLCACHE=
10 10
11# perl build variables 11# perl build variables
12MAKE=make 12MAKE=make
13PERL_DIST=perl 13PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds
14PERL_VERSION=5.22.0 # 5.12.4 and 5.8.9 are good choices for small builds
15PERL_CC=cc 14PERL_CC=cc
16PERL_CONFIGURE="" # additional Configure arguments 15PERL_CONFIGURE="" # additional Configure arguments
17PERL_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"
18PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
19 18
50 49
51# which extra modules you might want to install 50# which extra modules you might want to install
52EXTRA_MODULES="" 51EXTRA_MODULES=""
53 52
54# overridable functions 53# overridable functions
55preconfigure() { : ; } 54preconfigure() { : ; }
56patchconfig() { : ; } 55patchconfig() { : ; }
57postconfigure() { : ; } 56postconfigure() { : ; }
58postbuild() { : ; } 57postbuild() { : ; }
58postcpanconfig() { : ; }
59postinstall() { : ; } 59postinstall() { : ; }
60 60
61# now source user config, if any 61# now source user config, if any
62if [ "$STATICPERLRC" ]; then 62if [ "$STATICPERLRC" ]; then
63 . "$STATICPERLRC" 63 . "$STATICPERLRC"
64else 64else
70############################################################################# 70#############################################################################
71# support 71# support
72 72
73# work around ExtUtils::CBuilder and others 73# work around ExtUtils::CBuilder and others
74export CC="$PERL_CC" 74export CC="$PERL_CC"
75export CFLAGS="$PERL_CFLASGS" 75export CFLAGS="$PERL_CFLAGS"
76export LD="$PERL_CC" 76export LD="$PERL_CC"
77export LDFLAGS="$PERL_LDFLAGS" 77export LDFLAGS="$PERL_LDFLAGS"
78unset LIBS 78unset LIBS
79 79
80PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed 80PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
87# life easier when working in e.g. "staticperl cpan / look" 87# life easier when working in e.g. "staticperl cpan / look"
88PATH="$PERL_PREFIX/perl/bin:$PATH" 88PATH="$PERL_PREFIX/perl/bin:$PATH"
89 89
90# set version in a way that Makefile.PL can extract 90# set version in a way that Makefile.PL can extract
91VERSION=VERSION; eval \ 91VERSION=VERSION; eval \
92$VERSION="1.44" 92$VERSION="1.46"
93
94BZ2=bz2
95BZIP2=bzip2
96 93
97fatal() { 94fatal() {
98 printf -- "\nFATAL: %s\n\n" "$*" >&2 95 printf -- "\nFATAL: %s\n\n" "$*" >&2
99 exit 1 96 exit 1
100} 97}
146} 143}
147 144
148realclean() { 145realclean() {
149 rm -f "$PERL_PREFIX/staticstamp.postinstall" 146 rm -f "$PERL_PREFIX/staticstamp.postinstall"
150 rm -f "$PERL_PREFIX/staticstamp.install" 147 rm -f "$PERL_PREFIX/staticstamp.install"
151 rm -f "$STATICPERL/src/$PERL_DIST-"*"/staticstamp.configure" 148 rm -f "$STATICPERL/src/perl/staticstamp.configure"
152} 149}
153 150
154fetch() { 151fetch() {
152(
155 rcd "$STATICPERL" 153 rcd "$STATICPERL"
156 154
157 mkdir -p src 155 mkdir -p src
158 rcd src 156 rcd src
159 157
160 if ! [ -d "perl-$PERL_VERSION" ]; then 158 if ! [ -d "perl" ]; then
161 PERLTAR=$PERL_DIST-$PERL_VERSION.tar.$BZ2 159 rm -rf unpack
160 mkdir -p unpack
162 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 * )
177 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
178 PERLTAR=perl-$PERL_VERSION.tar.bz2
179 ;;
180 esac
181
163 if ! [ -e $PERLTAR ]; then 182 if ! [ -e "$PERLTAR" ]; then
164 URL="$CPAN/src/5.0/$PERLTAR"
165 [ "$PERL_URL" ] && URL="$PERL_URL"
166
167 verblock <<EOF 183 verblock <<EOF
168downloading 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
169to manually download perl yourself, place 191to manually download perl yourself, place a suitable tarball in
170perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 192$DLCACHE/$PERLTAR
171trying $URL
172 193
173either curl or wget is required for automatic download. 194either curl or wget is required for automatic download.
174curl is tried first, then wget. 195curl is tried first, then wget.
175
176you can configure a download cache directory via DLCACHE
177in your .staticperlrc to avoid repeated downloads.
178EOF 196EOF
179 197
180 rm -f $PERLTAR~ # just to be on the safe side 198 rm -f $PERLTAR~ # just to be on the safe side
181 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ 199 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
182 || wget -O $PERLTAR~ "$URL" \ 200 || wget -O $PERLTAR~ "$PERLURL" \
183 || curl -f >$PERLTAR~ "$URL" \ 201 || curl -f >$PERLTAR~ "$PERLURL" \
184 || fatal "$URL: unable to download" 202 || fatal "$URL: unable to download"
185 rm -f $PERLTAR 203 rm -f $PERLTAR
186 mv $PERLTAR~ $PERLTAR 204 mv $PERLTAR~ $PERLTAR
187 if [ "$DLCACHE" ]; then 205 if [ "$DLCACHE" ]; then
188 mkdir -p "$DLCACHE" 206 mkdir -p "$DLCACHE"
193 211
194 verblock <<EOF 212 verblock <<EOF
195unpacking perl 213unpacking perl
196EOF 214EOF
197 215
198 mkdir -p unpack 216 case "$PERLTAR" in
199 rm -rf unpack/perl-$PERL_VERSION 217 *.xz ) UNCOMPRESS="xz -d" ;;
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
200 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \ 228 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
201 || fatal "$PERLTAR: error during unpacking" 229 || fatal "$PERLTAR: error during unpacking"
202 chmod -R u+w unpack/$PERL_DIST-$PERL_VERSION 230
203 mv unpack/$PERL_DIST-$PERL_VERSION perl-$PERL_VERSION 231 if [ -d unpack/*/ ]; then
232 chmod -R u+w unpack/*/
233 mv unpack/*/ perl
204 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"
205 fi 240 fi
241) || exit
206} 242}
207 243
208# similar to GNU-sed -i or perl -pi 244# similar to GNU-sed -i or perl -pi
209sedreplace() { 245sedreplace() {
210 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 246 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
237EOF 273EOF
238 exit 1 274 exit 1
239} 275}
240 276
241configure() { 277configure() {
278(
242 fetch 279 fetch
243 280
244 rcd "$STATICPERL/src/perl-$PERL_VERSION" 281 rcd "$STATICPERL/src/perl"
245 282
246 [ -e staticstamp.configure ] && return 283 [ -e staticstamp.configure ] && return
247 284
248 verblock <<EOF 285 verblock <<EOF
249configuring $STATICPERL/src/perl-$PERL_VERSION 286configuring $STATICPERL/src/perl
250EOF 287EOF
251 288
252 rm -f "$PERL_PREFIX/staticstamp.install" 289 rm -f "$PERL_PREFIX/staticstamp.install"
253 290
254 "$MAKE" distclean >/dev/null 2>&1 291 "$MAKE" distclean >/dev/null 2>&1
296 -Demail="$EMAIL" \ 333 -Demail="$EMAIL" \
297 -Dcf_email="$EMAIL" \ 334 -Dcf_email="$EMAIL" \
298 -Dcf_by="$EMAIL" \ 335 -Dcf_by="$EMAIL" \
299 $PERL_CONFIGURE \ 336 $PERL_CONFIGURE \
300 -Duseperlio \ 337 -Duseperlio \
338 -Uversiononly \
301 -dE || configure_failure 339 -dE || configure_failure
302 340
303 sedreplace ' 341 sedreplace '
304 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 342 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
305 s/ *-fno-stack-protector */ /g 343 s/ *-fno-stack-protector */ /g
310 sh Configure -S || fatal "Configure -S failed" 348 sh Configure -S || fatal "Configure -S failed"
311 349
312 postconfigure || fatal "postconfigure hook failed" 350 postconfigure || fatal "postconfigure hook failed"
313 351
314 : > staticstamp.configure 352 : > staticstamp.configure
353) || exit
315} 354}
316 355
317write_shellscript() { 356write_shellscript() {
318 { 357 {
319 echo "#!/bin/sh" 358 echo "#!/bin/sh"
324 } >"$PERL_PREFIX/bin/$1" 363 } >"$PERL_PREFIX/bin/$1"
325 chmod 755 "$PERL_PREFIX/bin/$1" 364 chmod 755 "$PERL_PREFIX/bin/$1"
326} 365}
327 366
328build() { 367build() {
368(
329 configure 369 configure
330 370
331 rcd "$STATICPERL/src/perl-$PERL_VERSION" 371 rcd "$STATICPERL/src/perl"
332 372
333 verblock <<EOF 373 verblock <<EOF
334building $STATICPERL/src/perl-$PERL_VERSION 374building $STATICPERL/src/perl
335EOF 375EOF
336 376
337 rm -f "$PERL_PREFIX/staticstamp.install" 377 rm -f "$PERL_PREFIX/staticstamp.install"
338 378
339 "$MAKE" || fatal "make: error while building perl" 379 "$MAKE" || fatal "make: error while building perl"
340 380
341 postbuild || fatal "postbuild hook failed" 381 postbuild || fatal "postbuild hook failed"
382) || exit
342} 383}
343 384
344_postinstall() { 385_postinstall() {
345 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 386 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
346 NOCHECK_INSTALL=+ 387 NOCHECK_INSTALL=+
352 : > "$PERL_PREFIX/staticstamp.postinstall" 393 : > "$PERL_PREFIX/staticstamp.postinstall"
353 fi 394 fi
354} 395}
355 396
356install() { 397install() {
398(
357 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 399 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
358 build 400 build
359 401
360 verblock <<EOF 402 verblock <<EOF
361installing $STATICPERL/src/perl-$PERL_VERSION 403installing $STATICPERL/src/perl
362to $PERL_PREFIX 404to $PERL_PREFIX
363EOF 405EOF
364 406
365 ln -sf "perl/bin/" "$STATICPERL/bin" 407 ln -sf "perl/bin/" "$STATICPERL/bin"
366 ln -sf "perl/lib/" "$STATICPERL/lib" 408 ln -sf "perl/lib/" "$STATICPERL/lib"
368 mkdir "$STATICPERL/patched" 410 mkdir "$STATICPERL/patched"
369 411
370 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 412 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
371 rm -rf "$PERL_PREFIX" # by this rm -rf 413 rm -rf "$PERL_PREFIX" # by this rm -rf
372 414
415 rcd "$STATICPERL/src/perl"
416
373 "$MAKE" install || fatal "make install: error while installing" 417 "$MAKE" install || fatal "make install: error while installing"
374 418
375 rcd "$PERL_PREFIX" 419 rcd "$PERL_PREFIX"
376 420
377 # create a "make install" replacement for CPAN 421 # create a "make install" replacement for CPAN
378 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'
379#CAT make-install-make.sh 428#CAT make-install-make.sh
380EOF 429end_of_make_install_make
381 430
382 # create a "patch modules" helper 431 # create a "patch modules" helper
383 write_shellscript SP-patch-postinstall <<'EOF' 432 write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall'
384#CAT patch-postinstall.sh 433#CAT patch-postinstall.sh
385EOF 434end_of_patch_postinstall
386 435
387 # immediately use it 436 # immediately use it
388 "$PERL_PREFIX/bin/SP-patch-postinstall" 437 "$PERL_PREFIX/bin/SP-patch-postinstall"
389 438
390 # help to trick CPAN into avoiding ~/.cpan completely 439 # help to trick CPAN into avoiding ~/.cpan completely
391 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 440 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
392 441
393 # we call cpan with -MCPAN::MyConfig in this script, which 442 # we call cpan with -MCPAN::MyConfig in this script, which
394 # is strictly unnecssary as we have to patch CPAN anyway, 443 # is strictly unnecessary as we have to patch CPAN anyway,
395 # so consider it "for good measure". 444 # so consider it "for good measure".
396 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' 445 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
397 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 446 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
447 CPAN::Shell->o (conf => pushy_https => "0");
398 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 448 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
399 CPAN::Shell->o (conf => q<init>); 449 CPAN::Shell->o (conf => q<init>);
400 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 450 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
401 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 451 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
402 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 452 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
403 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 453 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
404 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 454 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
405 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");
406 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");
407 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 458 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
408 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>);
409 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); 462 CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>);
410 CPAN::Shell->o (conf => q<commit>); 463 CPAN::Shell->o (conf => q<commit>);
411 ' || fatal "error while initialising CPAN" 464 ' || fatal "error while initialising CPAN"
412 465
466 postcpanconfig
467
413 : > "$PERL_PREFIX/staticstamp.install" 468 : > "$PERL_PREFIX/staticstamp.install"
414 fi 469 fi
415 470
416 _postinstall 471 _postinstall
472) || exit
417} 473}
418 474
419import() { 475import() {
476(
420 IMPORT="$1" 477 IMPORT="$1"
421 478
422 rcd "$STATICPERL" 479 rcd "$STATICPERL"
423 480
424 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 481 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
435 492
436 : > "$PERL_PREFIX/staticstamp.install" 493 : > "$PERL_PREFIX/staticstamp.install"
437 fi 494 fi
438 495
439 _postinstall 496 _postinstall
497) || exit
440} 498}
441 499
442############################################################################# 500#############################################################################
443# install a module from CPAN 501# install a module from CPAN
444 502
445instcpan() { 503instcpan() {
446 [ $NOCHECK_INSTALL ] || install 504 [ $NOCHECK_INSTALL ] || install
447 505
448 verblock <<EOF 506 verblock <<EOF
449installing modules from CPAN 507installing modules from CPAN
450$@ 508$*
451EOF 509EOF
452 510
453 MYCONFIG= 511 MYCONFIG=
454 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig 512 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
455 513
456 "$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"
457 515
458 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then 516 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
459 fatal "failure while installing modules from CPAN ($@)" 517 fatal "failure while installing modules from CPAN ($*)"
460 fi 518 fi
461 rm -f "$STATICPERL/instcpan.log" 519 rm -f "$STATICPERL/instcpan.log"
462} 520}
463 521
464############################################################################# 522#############################################################################
467instsrc() { 525instsrc() {
468 [ $NOCHECK_INSTALL ] || install 526 [ $NOCHECK_INSTALL ] || install
469 527
470 verblock <<EOF 528 verblock <<EOF
471installing modules from source 529installing modules from source
472$@ 530$*
473EOF 531EOF
474 532
475 for mod in "$@"; do 533 for mod in "$@"; do
476 echo 534 echo
477 echo $mod 535 echo $mod
515catmkbundle() { 573catmkbundle() {
516 { 574 {
517 read dummy 575 read dummy
518 echo "#!$PERL_PREFIX/bin/perl" 576 echo "#!$PERL_PREFIX/bin/perl"
519 cat 577 cat
520 } <<'MKBUNDLE' 578 } <<'end_of_mkbundle'
521#CAT mkbundle 579#CAT mkbundle
522MKBUNDLE 580end_of_mkbundle
523} 581}
524 582
525bundle() { 583bundle() {
526 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" 584 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
527 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 585 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines