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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines