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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines