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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines