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.11 by root, Wed Dec 8 22:27:35 2010 UTC vs.
Revision 1.63 by root, Fri Oct 16 02:43:37 2015 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_CFLASGS"
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.9 91$VERSION="1.44"
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() {
123 rcd "$STATICPERL" 151 rcd "$STATICPERL"
124 152
125 mkdir -p src 153 mkdir -p src
126 rcd src 154 rcd src
127 155
128 if ! [ -d "perl-$PERL_VERSION" ]; then 156 if ! [ -d "perl" ]; then
129 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 157 rm -rf unpack
158 mkdir -p unpack
130 159
160 case "$PERL_VERSION" in
161 *:* )
162 # url
163 PERLURL="$PERL_VERSION"
164 PERLTAR="$(basename "$PERL_VERSION")"
165 ;;
166 /* )
167 # directory
168 verbose "copying $PERL_VERSION"
169 cp -Rp "$PERL_VERSION/." unpack/.
170 chmod -R u+w unpack
171 mv unpack perl
172 return
173 ;;
174 * )
131 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 175 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
176 PERLTAR=perl-$PERL_VERSION.tar.bz2
177 ;;
178 esac
132 179
180 if ! [ -e "$PERLTAR" ]; then
133 verblock <<EOF 181 verblock <<EOF
134downloading perl 182downloading perl
183
184trying to download from $PERLURL
185
186you can configure a download cache directory via DLCACHE
187in your .staticperlrc to avoid repeated downloads.
188
135to manually download perl yourself, place 189to manually download perl yourself, place a suitable tarball in
136perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 190$DLCACHE/$PERLTAR
137trying $URL
138EOF
139 191
192either curl or wget is required for automatic download.
193curl is tried first, then wget.
194EOF
195
140 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 196 rm -f $PERLTAR~ # just to be on the safe side
141 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 197 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
142 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 198 || wget -O $PERLTAR~ "$PERLURL" \
199 || curl -f >$PERLTAR~ "$PERLURL" \
143 || fatal "$URL: unable to download" 200 || fatal "$URL: unable to download"
144 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 201 rm -f $PERLTAR
202 mv $PERLTAR~ $PERLTAR
203 if [ "$DLCACHE" ]; then
204 mkdir -p "$DLCACHE"
205 cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \
206 mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR
207 fi
145 fi 208 fi
146 209
147 verblock <<EOF 210 verblock <<EOF
148unpacking perl 211unpacking perl
149EOF 212EOF
150 213
151 mkdir -p unpack 214 case "$PERLTAR" in
152 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ 215 *.xz ) UNCOMPRESS="xz -d" ;;
216 *.lzma ) UNCOMPRESS="lzma -d" ;;
217 *.bz2 ) UNCOMPRESS="bzip2 -d" ;;
218 *.gz ) UNCOMPRESS="gzip -d" ;;
219 *.tar ) UNCOMPRESS="cat" ;;
220 * )
221 fatal "don't know hot to uncompress $PERL_TAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported."
222 exit 1
223 ;;
224 esac
225
226 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
153 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 227 || fatal "$PERLTAR: error during unpacking"
154 chmod -R u+w unpack/perl-$PERL_VERSION 228
155 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 229 if [ -d unpack/*/ ]; then
230 chmod -R u+w unpack/*/
231 mv unpack/*/ perl
156 rmdir -p unpack 232 rmdir -p unpack
233 else
234 fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this"
235 fi
236
237 rm "$PERLTAR"
157 fi 238 fi
158} 239}
159 240
160# similar to GNU-sed -i or perl -pi 241# similar to GNU-sed -i or perl -pi
161sedreplace() { 242sedreplace() {
162 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 243 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
244 rm -f "$2"
163 mv "$2~" "$2" 245 mv "$2~" "$2"
246}
247
248configure_failure() {
249 cat <<EOF
250
251
252***
253*** Configure failed - see above for the exact error message(s).
254***
255*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
256*** flags are not supported by your compiler. Less often, this is because
257*** PERL_LIBS either contains a library not available on your system (such as
258*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
259***
260*** You can provide your own flags by creating a ~/.staticperlrc file with
261*** variable assignments. For example (these are the actual values used):
262***
263
264PERL_CC="$PERL_CC"
265PERL_CCFLAGS="$PERL_CCFLAGS"
266PERL_OPTIMIZE="$PERL_OPTIMIZE"
267PERL_LDFLAGS="$PERL_LDFLAGS"
268PERL_LIBS="$PERL_LIBS"
269
270EOF
271 exit 1
164} 272}
165 273
166configure() { 274configure() {
167 fetch 275 fetch
168 276
169 rcd "$STATICPERL/src/perl-$PERL_VERSION" 277 rcd "$STATICPERL/src/perl"
170 278
171 [ -e staticstamp.configure ] && return 279 [ -e staticstamp.configure ] && return
172 280
173 verblock <<EOF 281 verblock <<EOF
174configuring $STATICPERL/src/perl-$PERL_VERSION 282configuring $STATICPERL/src/perl
175EOF 283EOF
176 284
177 rm -f "$PERL_PREFIX/staticstamp.install" 285 rm -f "$PERL_PREFIX/staticstamp.install"
178 286
179 make distclean >/dev/null 2>&1 287 "$MAKE" distclean >/dev/null 2>&1
180 288
289 sedreplace '/^#define SITELIB/d' config_h.SH
290
181 # I hate them 291 # I hate them for this
182 grep -q -- -fstack-protector Configure && \ 292 grep -q -- -fstack-protector Configure && \
183 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 293 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
184 294
185 preconfigure 295 # what did that bloke think
296 grep -q -- usedl=.define hints/darwin.sh && \
297 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
298
299 preconfigure || fatal "preconfigure hook failed"
186 300
187# trace configure \ 301# trace configure \
188 sh Configure -Duselargefiles \ 302 sh Configure -Duselargefiles \
189 -Uuse64bitint \ 303 -Uuse64bitint \
190 -Dusemymalloc=n \ 304 -Dusemymalloc=n \
191 -Uusedl \ 305 -Uusedl \
192 -Uusethreads \ 306 -Uusethreads \
193 -Uuseithreads \ 307 -Uuseithreads \
194 -Uusemultiplicity \ 308 -Uusemultiplicity \
195 -Duseperlio \
196 -Uusesfio \ 309 -Uusesfio \
197 -Uuseshrplib \ 310 -Uuseshrplib \
311 -Uinstallusrbinperl \
198 -Dcppflags="$PERL_CPPFLAGS" \ 312 -A ccflags=" $PERL_CCFLAGS" \
199 -Dccflags="-g2 -fno-strict-aliasing" \ 313 -Dcc="$PERL_CC" \
200 -Doptimize="$PERL_OPTIMIZE" \ 314 -Doptimize="$PERL_OPTIMIZE" \
201 -Dldflags="$PERL_LDFLAGS" \ 315 -Dldflags="$PERL_LDFLAGS" \
202 -Dlibs="$PERL_LIBS" \ 316 -Dlibs="$PERL_LIBS" \
203 -Dprefix="$PERL_PREFIX" \ 317 -Dprefix="$PERL_PREFIX" \
204 -Dbin="$PERL_PREFIX/bin" \ 318 -Dbin="$PERL_PREFIX/bin" \
205 -Dprivlib="$PERL_PREFIX/lib" \ 319 -Dprivlib="$PERL_PREFIX/lib" \
206 -Darchlib="$PERL_PREFIX/lib" \ 320 -Darchlib="$PERL_PREFIX/lib" \
207 -Uusevendorprefix \ 321 -Uusevendorprefix \
208 -Dsitelib="$PERL_PREFIX/lib" \ 322 -Dsitelib="$PERL_PREFIX/lib" \
209 -Dsitearch="$PERL_PREFIX/lib" \ 323 -Dsitearch="$PERL_PREFIX/lib" \
210 -Usitelibexp \
211 -Uman1dir \ 324 -Uman1dir \
212 -Uman3dir \ 325 -Uman3dir \
213 -Usiteman1dir \ 326 -Usiteman1dir \
214 -Usiteman3dir \ 327 -Usiteman3dir \
215 -Dpager=/usr/bin/less \ 328 -Dpager=/usr/bin/less \
216 -Demail="$EMAIL" \ 329 -Demail="$EMAIL" \
217 -Dcf_email="$EMAIL" \ 330 -Dcf_email="$EMAIL" \
218 -Dcf_by="$EMAIL" \ 331 -Dcf_by="$EMAIL" \
219 $PERL_CONFIGURE \ 332 $PERL_CONFIGURE \
333 -Duseperlio \
220 -dE || fatal "Configure failed" 334 -dE || configure_failure
221 335
222 sedreplace ' 336 sedreplace '
223 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 337 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
224 s/ *-fno-stack-protector */ /g 338 s/ *-fno-stack-protector */ /g
225 ' config.sh 339 ' config.sh
226 340
341 patchconfig || fatal "patchconfig hook failed"
342
227 sh Configure -S || fatal "Configure -S failed" 343 sh Configure -S || fatal "Configure -S failed"
228 344
229 postconfigure || fatal "postconfigure hook failed" 345 postconfigure || fatal "postconfigure hook failed"
230 346
231 touch staticstamp.configure 347 : > staticstamp.configure
348}
349
350write_shellscript() {
351 {
352 echo "#!/bin/sh"
353 echo "STATICPERL=\"$STATICPERL\""
354 echo "PERL_PREFIX=\"$PERL_PREFIX\""
355 echo "MAKE=\"$MAKE\""
356 cat
357 } >"$PERL_PREFIX/bin/$1"
358 chmod 755 "$PERL_PREFIX/bin/$1"
232} 359}
233 360
234build() { 361build() {
235 configure 362 configure
236 363
237 rcd "$STATICPERL/src/perl-$PERL_VERSION" 364 rcd "$STATICPERL/src/perl"
238 365
239 verblock <<EOF 366 verblock <<EOF
240building $STATICPERL/src/perl-$PERL_VERSION 367building $STATICPERL/src/perl
241EOF 368EOF
242 369
243 rm -f "$PERL_PREFIX/staticstamp.install" 370 rm -f "$PERL_PREFIX/staticstamp.install"
244 371
245 make || fatal "make: error while building perl" 372 "$MAKE" || fatal "make: error while building perl"
246 373
247 postbuild || fatal "postbuild hook failed" 374 postbuild || fatal "postbuild hook failed"
375}
376
377_postinstall() {
378 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
379 NOCHECK_INSTALL=+
380 instcpan $STATICPERL_MODULES
381 [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES
382
383 postinstall || fatal "postinstall hook failed"
384
385 : > "$PERL_PREFIX/staticstamp.postinstall"
386 fi
248} 387}
249 388
250install() { 389install() {
251 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 390 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
252 build 391 build
253 392
254 verblock <<EOF 393 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 394installing $STATICPERL/src/perl
256to $PERL_PREFIX 395to $PERL_PREFIX
257EOF 396EOF
258 397
259 rm -rf "$PERL_PREFIX" 398 ln -sf "perl/bin/" "$STATICPERL/bin"
260 399 ln -sf "perl/lib/" "$STATICPERL/lib"
400
401 mkdir "$STATICPERL/patched"
402
403 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
404 rm -rf "$PERL_PREFIX" # by this rm -rf
405
261 make install || fatal "make install: error while installing" 406 "$MAKE" install || fatal "make install: error while installing"
262 407
263 rcd "$PERL_PREFIX" 408 rcd "$PERL_PREFIX"
264 409
265 # create a "make install" replacement for CPAN 410 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 411 write_shellscript SP-make-install-make <<'EOF'
267make || exit 412#CAT make-install-make.sh
268
269if find blib/arch/auto -type f | grep -q -v .exists; then
270 echo Probably an XS module, rebuilding perl
271 if make perl; then
272 mv perl "$PERL_PREFIX"/bin/perl
273 make -f Makefile.aperl map_clean
274 else
275 make -f Makefile.aperl map_clean
276 exit 1
277 fi
278fi
279
280make install UNINST=1
281EOF 413EOF
282 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
283 414
415 # create a "patch modules" helper
416 write_shellscript SP-patch-postinstall <<'EOF'
417#CAT patch-postinstall.sh
418EOF
419
420 # immediately use it
421 "$PERL_PREFIX/bin/SP-patch-postinstall"
422
284 # trick CPAN into avoiding ~/.cpan completely 423 # help to trick CPAN into avoiding ~/.cpan completely
285 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 424 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
286 425
426 # we call cpan with -MCPAN::MyConfig in this script, which
427 # is strictly unnecssary as we have to patch CPAN anyway,
428 # so consider it "for good measure".
287 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 429 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
288 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 430 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
289 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 431 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
290 CPAN::Shell->o (conf => q<init>); 432 CPAN::Shell->o (conf => q<init>);
291 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 433 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
292 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 434 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
293 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 435 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
294 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 436 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
295 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 437 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
438 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
296 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 439 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
297 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 440 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
298 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 441 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
442 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
299 CPAN::Shell->o (conf => q<commit>); 443 CPAN::Shell->o (conf => q<commit>);
300 ' || fatal "error while initialising CPAN" 444 ' || fatal "error while initialising CPAN"
301 445
302 touch "$PERL_PREFIX/staticstamp.install" 446 : > "$PERL_PREFIX/staticstamp.install"
303 fi 447 fi
304 448
449 _postinstall
450}
451
452import() {
453 IMPORT="$1"
454
455 rcd "$STATICPERL"
456
305 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 457 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
306 NOCHECK_INSTALL=+ 458 verblock <<EOF
307 instcpan $STATICPERL_MODULES 459import perl from $IMPORT to $STATICPERL
308 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 460EOF
309 461
310 postinstall || fatal "postinstall hook failed" 462 rm -rf bin cpan lib patched perl src
463 mkdir -m 755 perl perl/bin
464 ln -s perl/bin/ bin
465 ln -s "$IMPORT" perl/bin/
311 466
467 echo "$IMPORT" > "$PERL_PREFIX/.import"
468
312 touch "$PERL_PREFIX/staticstamp.postinstall" 469 : > "$PERL_PREFIX/staticstamp.install"
313 fi 470 fi
471
472 _postinstall
314} 473}
315 474
316############################################################################# 475#############################################################################
317# install a module from CPAN 476# install a module from CPAN
318 477
322 verblock <<EOF 481 verblock <<EOF
323installing modules from CPAN 482installing modules from CPAN
324$@ 483$@
325EOF 484EOF
326 485
327 for mod in "$@"; do 486 MYCONFIG=
328 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 487 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
329 || fatal "$mod: unable to install from CPAN" 488
330 done 489 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
490
491 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
492 fatal "failure while installing modules from CPAN ($@)"
493 fi
331 rm -rf "$STATICPERL/build" 494 rm -f "$STATICPERL/instcpan.log"
332} 495}
333 496
334############################################################################# 497#############################################################################
335# install a module from unpacked sources 498# install a module from unpacked sources
336 499
345 for mod in "$@"; do 508 for mod in "$@"; do
346 echo 509 echo
347 echo $mod 510 echo $mod
348 ( 511 (
349 rcd $mod 512 rcd $mod
350 make -f Makefile.aperl map_clean >/dev/null 2>&1 513 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
351 make distclean >/dev/null 2>&1 514 "$MAKE" distclean >/dev/null 2>&1
352 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 515 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
353 make || fatal "$mod: error building module" 516 "$MAKE" || fatal "$mod: error building module"
354 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 517 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
355 make distclean >/dev/null 2>&1 518 "$MAKE" distclean >/dev/null 2>&1
356 exit 0 519 exit 0
357 ) || exit $? 520 ) || exit $?
358 done 521 done
359} 522}
360 523
361############################################################################# 524#############################################################################
362# main 525# main
363 526
364podusage() { 527podusage() {
365 echo 528 echo
529
366 if [ -e "$PERL_PREFIX/bin/perl" ]; then 530 if [ -e "$PERL_PREFIX/bin/perl" ]; then
367 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 531 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
368 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 532 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
369 2>/dev/null && exit 533 2>/dev/null && exit
370 fi 534 fi
535
371 # try whatever perl we can find 536 # try whatever perl we can find
372 perl -MPod::Usage -e \ 537 perl -MPod::Usage -e \
373 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 538 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
374 2>/dev/null && exit 539 2>/dev/null && exit
375 540
376 fatal "displaying documentation requires a working perl - try '$0 install' first" 541 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
377} 542}
378 543
379usage() { 544usage() {
380 podusage 0 545 podusage 0
381} 546}
389#CAT mkbundle 554#CAT mkbundle
390MKBUNDLE 555MKBUNDLE
391} 556}
392 557
393bundle() { 558bundle() {
559 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
394 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 560 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
395 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 561 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
562 CACHE="$STATICPERL/cache"
563 mkdir -p "$CACHE"
396 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 564 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
397} 565}
398 566
399if [ $# -gt 0 ]; then 567if [ $# -gt 0 ]; then
400 while [ $# -gt 0 ]; do 568 while [ $# -gt 0 ]; do
401 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 569 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
402 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 570 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
403 571
404 command="${1#--}"; shift 572 command="${1#--}"; shift
405 case "$command" in 573 case "$command" in
574 version )
575 echo "staticperl version $VERSION"
576 ;;
406 fetch | configure | build | install | clean | distclean) 577 fetch | configure | build | install | clean | realclean | distclean )
407 verblock <<EOF
408$command
409EOF
410 ( "$command" ) 578 ( "$command" ) || exit
579 ;;
580 import )
581 ( import "$1" ) || exit
582 shift
411 ;; 583 ;;
412 instsrc ) 584 instsrc )
413 ( instsrc "$@" ) 585 ( instsrc "$@" ) || exit
414 exit 586 exit
415 ;; 587 ;;
416 instcpan ) 588 instcpan )
417 ( instcpan "$@" ) 589 ( instcpan "$@" ) || exit
418 exit 590 exit
419 ;; 591 ;;
592 perl )
593 ( install ) || exit
594 exec "$PERL_PREFIX/bin/perl" "$@"
595 exit
596 ;;
420 cpan ) 597 cpan )
421 ( install ) 598 ( install ) || exit
599 PERL="$PERL_PREFIX/bin/perl"
600 export PERL
422 "$PERL_PREFIX/bin/cpan" "$@" 601 exec "$PERL_PREFIX/bin/cpan" "$@"
423 exit 602 exit
424 ;; 603 ;;
425 mkbundle ) 604 mkbundle )
426 ( install ) 605 ( install ) || exit
427 bundle "$@" 606 bundle "$@"
428 exit 607 exit
429 ;; 608 ;;
430 mkperl ) 609 mkperl )
431 ( install ) 610 ( install ) || exit
432 bundle --perl "$@" 611 bundle --perl "$@"
433 exit 612 exit
434 ;; 613 ;;
435 mkapp ) 614 mkapp )
436 ( install ) 615 ( install ) || exit
437 bundle --app "$@" 616 bundle --app "$@"
438 exit 617 exit
439 ;; 618 ;;
440 help ) 619 help )
441 podusage 2 620 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines