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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines