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.20 by root, Mon Dec 13 17:35:51 2010 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
11PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 15MAKE=make
16PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds
12PERL_CC=cc 17PERL_CC=cc
13PERL_CONFIGURE="" # additional Configure arguments 18PERL_CONFIGURE="" # additional Configure arguments
14PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 19PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG"
15PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 20PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
16 21
17ARCH="$(uname -m)" 22ARCH="$(uname -m)"
18 23
19case "$ARCH" in 24#case "$ARCH" in
20 i*86 | x86_64 | amd64 ) 25# i*86 | x86_64 | amd64 )
21 #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
22 PERL_OPTIMIZE="$PERL_OPTIMIZE" # 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
38export PERL_MM_USE_DEFAULT=1 43PERL_MM_USE_DEFAULT=1
44PERL_MM_OPT="MAN1PODS= MAN3PODS="
39#export 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
40export 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' 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'
47export PERL_MM_USE_DEFAULT PERL_MM_OPT
41 48
42# which extra modules to install by default from CPAN that are 49# which extra modules to install by default from CPAN that are
43# required by mkbundle 50# required by mkbundle
44STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 51STATICPERL_MODULES="ExtUtils::MakeMaker ExtUtils::CBuilder common::sense Pod::Strip PPI PPI::XS Pod::Usage"
45 52
46# which extra modules you might want to install 53# which extra modules you might want to install
47EXTRA_MODULES="" 54EXTRA_MODULES=""
48 55
49# overridable functions 56# overridable functions
50preconfigure() { : ; } 57preconfigure() { : ; }
58patchconfig() { : ; }
51postconfigure() { : ; } 59postconfigure() { : ; }
52postbuild() { : ; } 60postbuild() { : ; }
61postcpanconfig() { : ; }
53postinstall() { : ; } 62postinstall() { : ; }
54 63
55# now source user config, if any 64# now source user config, if any
56if [ "$STATICPERLRC" ]; then 65if [ "$STATICPERLRC" ]; then
57 . "$STATICPERLRC" 66 . "$STATICPERLRC"
58else 67else
62fi 71fi
63 72
64############################################################################# 73#############################################################################
65# support 74# support
66 75
67MKBUNDLE="${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
68PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed 83PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
69 84
70unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 85unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
86unset PERL_MB_OPT
71export LC_ALL=C # 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"
72 92
73# set version in a way that Makefile.PL can extract 93# set version in a way that Makefile.PL can extract
74VERSION=VERSION; eval \ 94VERSION=VERSION; eval \
75$VERSION=0.911 95$VERSION="1.46"
76
77BZ2=bz2
78BZIP2=bzip2
79 96
80fatal() { 97fatal() {
81 printf -- "\nFATAL: %s\n\n" "$*" >&2 98 printf -- "\nFATAL: %s\n\n" "$*" >&2
82 exit 1 99 exit 1
83} 100}
123 140
124############################################################################# 141#############################################################################
125# download/configure/compile/install perl 142# download/configure/compile/install perl
126 143
127clean() { 144clean() {
128 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 145 rm -rf "$STATICPERL/src"
146}
147
148realclean() {
149 rm -f "$PERL_PREFIX/staticstamp.postinstall"
150 rm -f "$PERL_PREFIX/staticstamp.install"
151 rm -f "$STATICPERL/src/perl/staticstamp.configure"
129} 152}
130 153
131fetch() { 154fetch() {
155(
132 rcd "$STATICPERL" 156 rcd "$STATICPERL"
133 157
134 mkdir -p src 158 mkdir -p src
135 rcd src 159 rcd src
136 160
137 if ! [ -d "perl-$PERL_VERSION" ]; then 161 if ! [ -d "perl" ]; then
138 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 162 rm -rf unpack
163 mkdir -p unpack
139 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 * )
140 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
141 184
185 if ! [ -e "$PERLTAR" ]; then
142 verblock <<EOF 186 verblock <<EOF
143downloading 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
144to manually download perl yourself, place 194to manually download perl yourself, place a suitable tarball in
145perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 195$DLCACHE/$PERLTAR
146trying $URL
147EOF
148 196
197either curl or wget is required for automatic download.
198curl is tried first, then wget.
199EOF
200
149 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
150 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 202 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
151 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 203 || wget -O $PERLTAR~ "$PERLURL" \
204 || curl -f >$PERLTAR~ "$PERLURL" \
152 || fatal "$URL: unable to download" 205 || fatal "$URL: unable to download"
153 rm -f perl-$PERL_VERSION.tar.$BZ2 206 rm -f $PERLTAR
154 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
155 fi 213 fi
156 214
157 verblock <<EOF 215 verblock <<EOF
158unpacking perl 216unpacking perl
159EOF 217EOF
160 218
161 mkdir -p unpack 219 case "$PERLTAR" in
162 rm -rf unpack/perl-$PERL_VERSION 220 *.xz ) UNCOMPRESS="xz -d" ;;
163 $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 - ) \
164 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 232 || fatal "$PERLTAR: error during unpacking"
165 chmod -R u+w unpack/perl-$PERL_VERSION 233
166 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 234 if [ -d unpack/*/ ]; then
235 chmod -R u+w unpack/*/
236 mv unpack/*/ perl
167 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"
168 fi 243 fi
244) || exit
169} 245}
170 246
171# similar to GNU-sed -i or perl -pi 247# similar to GNU-sed -i or perl -pi
172sedreplace() { 248sedreplace() {
173 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 249 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
174 rm -f "$2" 250 rm -f "$2"
175 mv "$2~" "$2" 251 mv "$2~" "$2"
176} 252}
177 253
254configure_failure() {
255 cat <<EOF
256
257
258***
259*** Configure failed - see above for the exact error message(s).
260***
261*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
262*** flags are not supported by your compiler. Less often, this is because
263*** PERL_LIBS either contains a library not available on your system (such as
264*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
265***
266*** You can provide your own flags by creating a ~/.staticperlrc file with
267*** variable assignments. For example (these are the actual values used):
268***
269
270PERL_CC="$PERL_CC"
271PERL_CCFLAGS="$PERL_CCFLAGS"
272PERL_OPTIMIZE="$PERL_OPTIMIZE"
273PERL_LDFLAGS="$PERL_LDFLAGS"
274PERL_LIBS="$PERL_LIBS"
275
276EOF
277 exit 1
278}
279
178configure() { 280configure() {
281(
179 fetch 282 fetch
180 283
181 rcd "$STATICPERL/src/perl-$PERL_VERSION" 284 rcd "$STATICPERL/src/perl"
182 285
183 [ -e staticstamp.configure ] && return 286 [ -e staticstamp.configure ] && return
184 287
185 verblock <<EOF 288 verblock <<EOF
186configuring $STATICPERL/src/perl-$PERL_VERSION 289configuring $STATICPERL/src/perl
187EOF 290EOF
188 291
189 rm -f "$PERL_PREFIX/staticstamp.install" 292 rm -f "$PERL_PREFIX/staticstamp.install"
190 293
191 make distclean >/dev/null 2>&1 294 "$MAKE" distclean >/dev/null 2>&1
192 295
296 sedreplace '/^#define SITELIB/d' config_h.SH
297
193 # I hate them 298 # I hate them for this
194 grep -q -- -fstack-protector Configure && \ 299 grep -q -- -fstack-protector Configure && \
195 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 300 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
196 301
197 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"
198 307
199# trace configure \ 308# trace configure \
200 sh Configure -Duselargefiles \ 309 sh Configure -Duselargefiles \
201 -Uuse64bitint \ 310 -Uuse64bitint \
202 -Dusemymalloc=n \ 311 -Dusemymalloc=n \
204 -Uusethreads \ 313 -Uusethreads \
205 -Uuseithreads \ 314 -Uuseithreads \
206 -Uusemultiplicity \ 315 -Uusemultiplicity \
207 -Uusesfio \ 316 -Uusesfio \
208 -Uuseshrplib \ 317 -Uuseshrplib \
318 -Uinstallusrbinperl \
319 -A ccflags=" $PERL_CCFLAGS" \
209 -Dcc="$PERL_CC" \ 320 -Dcc="$PERL_CC" \
210 -Dcppflags="$PERL_CPPFLAGS" \
211 -Dccflags="-g2 -fno-strict-aliasing" \
212 -Doptimize="$PERL_OPTIMIZE" \ 321 -Doptimize="$PERL_OPTIMIZE" \
213 -Dldflags="$PERL_LDFLAGS" \ 322 -Dldflags="$PERL_LDFLAGS" \
214 -Dlibs="$PERL_LIBS" \ 323 -Dlibs="$PERL_LIBS" \
215 -Dprefix="$PERL_PREFIX" \ 324 -Dprefix="$PERL_PREFIX" \
216 -Dbin="$PERL_PREFIX/bin" \ 325 -Dbin="$PERL_PREFIX/bin" \
217 -Dprivlib="$PERL_PREFIX/lib" \ 326 -Dprivlib="$PERL_PREFIX/lib" \
218 -Darchlib="$PERL_PREFIX/lib" \ 327 -Darchlib="$PERL_PREFIX/lib" \
219 -Uusevendorprefix \ 328 -Uusevendorprefix \
220 -Dsitelib="$PERL_PREFIX/lib" \ 329 -Dsitelib="$PERL_PREFIX/lib" \
221 -Dsitearch="$PERL_PREFIX/lib" \ 330 -Dsitearch="$PERL_PREFIX/lib" \
222 -Usitelibexp \
223 -Uman1dir \ 331 -Uman1dir \
224 -Uman3dir \ 332 -Uman3dir \
225 -Usiteman1dir \ 333 -Usiteman1dir \
226 -Usiteman3dir \ 334 -Usiteman3dir \
227 -Dpager=/usr/bin/less \ 335 -Dpager=/usr/bin/less \
228 -Demail="$EMAIL" \ 336 -Demail="$EMAIL" \
229 -Dcf_email="$EMAIL" \ 337 -Dcf_email="$EMAIL" \
230 -Dcf_by="$EMAIL" \ 338 -Dcf_by="$EMAIL" \
231 $PERL_CONFIGURE \ 339 $PERL_CONFIGURE \
232 -Duseperlio \ 340 -Duseperlio \
341 -Uversiononly \
233 -dE || fatal "Configure failed" 342 -dE || configure_failure
234 343
235 sedreplace ' 344 sedreplace '
236 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 345 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
237 s/ *-fno-stack-protector */ /g 346 s/ *-fno-stack-protector */ /g
238 ' config.sh 347 ' config.sh
239 348
349 patchconfig || fatal "patchconfig hook failed"
350
240 sh Configure -S || fatal "Configure -S failed" 351 sh Configure -S || fatal "Configure -S failed"
241 352
242 postconfigure || fatal "postconfigure hook failed" 353 postconfigure || fatal "postconfigure hook failed"
243 354
244 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"
245} 368}
246 369
247build() { 370build() {
371(
248 configure 372 configure
249 373
250 rcd "$STATICPERL/src/perl-$PERL_VERSION" 374 rcd "$STATICPERL/src/perl"
251 375
252 verblock <<EOF 376 verblock <<EOF
253building $STATICPERL/src/perl-$PERL_VERSION 377building $STATICPERL/src/perl
254EOF 378EOF
255 379
256 rm -f "$PERL_PREFIX/staticstamp.install" 380 rm -f "$PERL_PREFIX/staticstamp.install"
257 381
258 make || fatal "make: error while building perl" 382 "$MAKE" || fatal "make: error while building perl"
259 383
260 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
261} 398}
262 399
263install() { 400install() {
401(
264 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 402 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
265 build 403 build
266 404
267 verblock <<EOF 405 verblock <<EOF
268installing $STATICPERL/src/perl-$PERL_VERSION 406installing $STATICPERL/src/perl
269to $PERL_PREFIX 407to $PERL_PREFIX
270EOF 408EOF
271 409
272 ln -sf "perl/bin/" "$STATICPERL/bin" 410 ln -sf "perl/bin/" "$STATICPERL/bin"
273 ln -sf "perl/lib/" "$STATICPERL/lib" 411 ln -sf "perl/lib/" "$STATICPERL/lib"
274 412
413 mkdir "$STATICPERL/patched"
414
275 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 415 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
276 rm -rf "$PERL_PREFIX" # by this rm -rf 416 rm -rf "$PERL_PREFIX" # by this rm -rf
277 417
418 rcd "$STATICPERL/src/perl"
419
278 make install || fatal "make install: error while installing" 420 "$MAKE" install || fatal "make install: error while installing"
279 421
280 rcd "$PERL_PREFIX" 422 rcd "$PERL_PREFIX"
281 423
282 # create a "make install" replacement for CPAN 424 # create a "make install" replacement for CPAN
283 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 425 write_shellscript SP-make-make <<'end_of_make'
284make || exit 426#CAT make-make.sh
427end_of_make
285 428
286if find blib/arch/auto -type f | grep -q -v .exists; then 429 # create a "make install" replacement for CPAN
287 echo Probably an XS module, rebuilding perl 430 write_shellscript SP-make-install-make <<'end_of_make_install_make'
288 if make perl; then 431#CAT make-install-make.sh
289 mv perl "$PERL_PREFIX"/bin/perl~ \ 432end_of_make_install_make
290 && rm -f "$PERL_PREFIX"/bin/perl \
291 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
292 make -f Makefile.aperl map_clean
293 else
294 make -f Makefile.aperl map_clean
295 exit 1
296 fi
297fi
298 433
299make install UNINST=1 434 # create a "patch modules" helper
300EOF 435 write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall'
301 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install 436#CAT patch-postinstall.sh
437end_of_patch_postinstall
302 438
439 # immediately use it
440 "$PERL_PREFIX/bin/SP-patch-postinstall"
441
303 # trick CPAN into avoiding ~/.cpan completely 442 # help to trick CPAN into avoiding ~/.cpan completely
304 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 443 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
305 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".
306 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 448 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
307 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 449 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
450 CPAN::Shell->o (conf => pushy_https => "0");
308 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 451 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
309 CPAN::Shell->o (conf => q<init>); 452 CPAN::Shell->o (conf => q<init>);
310 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 453 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
311 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 454 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
312 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 455 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
313 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 456 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
314 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");
315 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");
316 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 461 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
317 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>);
318 CPAN::Shell->o (conf => q<commit>); 466 CPAN::Shell->o (conf => q<commit>);
319 ' || fatal "error while initialising CPAN" 467 ' || fatal "error while initialising CPAN"
320 468
469 postcpanconfig
470
321 touch "$PERL_PREFIX/staticstamp.install" 471 : > "$PERL_PREFIX/staticstamp.install"
322 fi 472 fi
323 473
474 _postinstall
475) || exit
476}
477
478import() {
479(
480 IMPORT="$1"
481
482 rcd "$STATICPERL"
483
324 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 484 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
325 NOCHECK_INSTALL=+ 485 verblock <<EOF
326 instcpan $STATICPERL_MODULES 486import perl from $IMPORT to $STATICPERL
327 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 487EOF
328 488
329 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/
330 493
494 echo "$IMPORT" > "$PERL_PREFIX/.import"
495
331 touch "$PERL_PREFIX/staticstamp.postinstall" 496 : > "$PERL_PREFIX/staticstamp.install"
332 fi 497 fi
498
499 _postinstall
500) || exit
333} 501}
334 502
335############################################################################# 503#############################################################################
336# install a module from CPAN 504# install a module from CPAN
337 505
338instcpan() { 506instcpan() {
339 [ $NOCHECK_INSTALL ] || install 507 [ $NOCHECK_INSTALL ] || install
340 508
341 verblock <<EOF 509 verblock <<EOF
342installing modules from CPAN 510installing modules from CPAN
343$@ 511$*
344EOF 512EOF
345 513
346 for mod in "$@"; do 514 MYCONFIG=
347 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 515 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
348 || fatal "$mod: unable to install from CPAN" 516
349 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
350 rm -rf "$STATICPERL/build" 522 rm -f "$STATICPERL/instcpan.log"
351} 523}
352 524
353############################################################################# 525#############################################################################
354# install a module from unpacked sources 526# install a module from unpacked sources
355 527
356instsrc() { 528instsrc() {
357 [ $NOCHECK_INSTALL ] || install 529 [ $NOCHECK_INSTALL ] || install
358 530
359 verblock <<EOF 531 verblock <<EOF
360installing modules from source 532installing modules from source
361$@ 533$*
362EOF 534EOF
363 535
364 for mod in "$@"; do 536 for mod in "$@"; do
365 echo 537 echo
366 echo $mod 538 echo $mod
367 ( 539 (
368 rcd $mod 540 rcd $mod
369 make -f Makefile.aperl map_clean >/dev/null 2>&1 541 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
370 make distclean >/dev/null 2>&1 542 "$MAKE" distclean >/dev/null 2>&1
371 "$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"
372 make || fatal "$mod: error building module" 544 "$MAKE" || fatal "$mod: error building module"
373 "$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"
374 make distclean >/dev/null 2>&1 546 "$MAKE" distclean >/dev/null 2>&1
375 exit 0 547 exit 0
376 ) || exit $? 548 ) || exit $?
377 done 549 done
378} 550}
379 551
404catmkbundle() { 576catmkbundle() {
405 { 577 {
406 read dummy 578 read dummy
407 echo "#!$PERL_PREFIX/bin/perl" 579 echo "#!$PERL_PREFIX/bin/perl"
408 cat 580 cat
409 } <<'MKBUNDLE' 581 } <<'end_of_mkbundle'
410#CAT mkbundle 582#CAT mkbundle
411MKBUNDLE 583end_of_mkbundle
412} 584}
413 585
414bundle() { 586bundle() {
587 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
415 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 588 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
416 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 589 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
417 CACHE="$STATICPERL/cache" 590 CACHE="$STATICPERL/cache"
418 mkdir -p "$CACHE" 591 mkdir -p "$CACHE"
419 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" 592 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
427 command="${1#--}"; shift 600 command="${1#--}"; shift
428 case "$command" in 601 case "$command" in
429 version ) 602 version )
430 echo "staticperl version $VERSION" 603 echo "staticperl version $VERSION"
431 ;; 604 ;;
432 fetch | configure | build | install | clean | distclean) 605 fetch | configure | build | install | clean | realclean | distclean )
433 ( "$command" ) 606 ( "$command" ) || exit
607 ;;
608 import )
609 ( import "$1" ) || exit
610 shift
434 ;; 611 ;;
435 instsrc ) 612 instsrc )
436 ( instsrc "$@" ) 613 ( instsrc "$@" ) || exit
437 exit 614 exit
438 ;; 615 ;;
439 instcpan ) 616 instcpan )
440 ( instcpan "$@" ) 617 ( instcpan "$@" ) || exit
441 exit 618 exit
442 ;; 619 ;;
620 perl )
621 ( install ) || exit
622 exec "$PERL_PREFIX/bin/perl" "$@"
623 exit
624 ;;
443 cpan ) 625 cpan )
444 ( install ) 626 ( install ) || exit
627 PERL="$PERL_PREFIX/bin/perl"
628 export PERL
445 "$PERL_PREFIX/bin/cpan" "$@" 629 exec "$PERL_PREFIX/bin/cpan" "$@"
446 exit 630 exit
447 ;; 631 ;;
448 mkbundle ) 632 mkbundle )
449 ( install ) 633 ( install ) || exit
450 bundle "$@" 634 bundle "$@"
451 exit 635 exit
452 ;; 636 ;;
453 mkperl ) 637 mkperl )
454 ( install ) 638 ( install ) || exit
455 bundle --perl "$@" 639 bundle --perl "$@"
456 exit 640 exit
457 ;; 641 ;;
458 mkapp ) 642 mkapp )
459 ( install ) 643 ( install ) || exit
460 bundle --app "$@" 644 bundle --app "$@"
461 exit 645 exit
462 ;; 646 ;;
463 help ) 647 help )
464 podusage 2 648 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines