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.21 by root, Mon Dec 13 18:08:01 2010 UTC vs.
Revision 1.49 by root, Sun Jul 10 01:37:56 2011 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>"
9DLCACHE=
9 10
10# perl build variables 11# perl build variables
11MAKE=make 12MAKE=make
12PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 13PERL_VERSION=5.12.4 # 5.8.9 is also a good choice
13PERL_CC=cc 14PERL_CC=cc
14PERL_CONFIGURE="" # additional Configure arguments 15PERL_CONFIGURE="" # additional Configure arguments
15PERL_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"
16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
17 18
18ARCH="$(uname -m)" 19ARCH="$(uname -m)"
19 20
20case "$ARCH" in 21case "$ARCH" in
21 i*86 | x86_64 | amd64 ) 22 i*86 | x86_64 | amd64 )
22 #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
23 PERL_OPTIMIZE="$PERL_OPTIMIZE" # 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
30esac 30esac
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# --allow-multiple-definition exists 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 -Wl,--allow-multiple-definition" 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="common::sense Pod::Strip 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
63fi 67fi
64 68
65############################################################################# 69#############################################################################
66# support 70# support
67 71
68MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}"
69PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed 72PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
70 73
71unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 74unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
75unset PERL_MB_OPT
72export LC_ALL=C # just to be on the safe side 76LC_ALL=C; export LC_ALL # just to be on the safe side
77
78# prepend PATH - not required by staticperl itself, but might make
79# life easier when working in e.g. "staticperl cpan / look"
80PATH="$PERL_PREFIX/perl/bin:$PATH"
73 81
74# set version in a way that Makefile.PL can extract 82# set version in a way that Makefile.PL can extract
75VERSION=VERSION; eval \ 83VERSION=VERSION; eval \
76$VERSION=0.911 84$VERSION="1.31"
77 85
78BZ2=bz2 86BZ2=bz2
79BZIP2=bzip2 87BZIP2=bzip2
80 88
81fatal() { 89fatal() {
124 132
125############################################################################# 133#############################################################################
126# download/configure/compile/install perl 134# download/configure/compile/install perl
127 135
128clean() { 136clean() {
129 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 137 rm -rf "$STATICPERL/src"
138}
139
140realclean() {
141 rm -f "$PERL_PREFIX/staticstamp.postinstall"
142 rm -f "$PERL_PREFIX/staticstamp.install"
143 rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure"
130} 144}
131 145
132fetch() { 146fetch() {
133 rcd "$STATICPERL" 147 rcd "$STATICPERL"
134 148
135 mkdir -p src 149 mkdir -p src
136 rcd src 150 rcd src
137 151
138 if ! [ -d "perl-$PERL_VERSION" ]; then 152 if ! [ -d "perl-$PERL_VERSION" ]; then
139 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 153 PERLTAR=perl-$PERL_VERSION.tar.$BZ2
140 154
155 if ! [ -e $PERLTAR ]; then
141 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 156 URL="$CPAN/src/5.0/$PERLTAR"
142 157
143 verblock <<EOF 158 verblock <<EOF
144downloading perl 159downloading perl
145to manually download perl yourself, place 160to manually download perl yourself, place
146perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 161perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
147trying $URL 162trying $URL
148EOF
149 163
164either curl or wget is required for automatic download.
165curl is tried first, then wget.
166
167you can configure a download cache directory via DLCACHE
168in your .staticperlrc to avoid repeated downloads.
169EOF
170
150 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 171 rm -f $PERLTAR~ # just to be on the safe side
151 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 172 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
152 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
153 || fatal "$URL: unable to download" 175 || fatal "$URL: unable to download"
154 rm -f perl-$PERL_VERSION.tar.$BZ2 176 rm -f $PERLTAR
155 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 177 mv $PERLTAR~ $PERLTAR
178 if [ "$DLCACHE" ]; then
179 mkdir -p "$DLCACHE"
180 cp $PERLTAR "$DLCACHE"/$PERLTAR~ && \
181 mv "$DLCACHE"/$PERLTAR~ "$DLCACHE"/$PERLTAR
182 fi
156 fi 183 fi
157 184
158 verblock <<EOF 185 verblock <<EOF
159unpacking perl 186unpacking perl
160EOF 187EOF
161 188
162 mkdir -p unpack 189 mkdir -p unpack
163 rm -rf unpack/perl-$PERL_VERSION 190 rm -rf unpack/perl-$PERL_VERSION
164 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ 191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
165 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
166 chmod -R u+w unpack/perl-$PERL_VERSION 193 chmod -R u+w unpack/perl-$PERL_VERSION
167 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
168 rmdir -p unpack 195 rmdir -p unpack
169 fi 196 fi
170} 197}
174 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 201 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
175 rm -f "$2" 202 rm -f "$2"
176 mv "$2~" "$2" 203 mv "$2~" "$2"
177} 204}
178 205
206configure_failure() {
207 cat <<EOF
208
209
210***
211*** Configure failed - see above for the exact error message(s).
212***
213*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
214*** flags are not supported by your compiler. Less often, this is because
215*** PERL_LIBS either contains a library not available on your system (such as
216*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
217***
218*** You can provide your own flags by creating a ~/.staticperlrc file with
219*** variable assignments. For example (these are the actual values used):
220***
221
222PERL_CC="$PERL_CC"
223PERL_CCFLAGS="$PERL_CCFLAGS"
224PERL_OPTIMIZE="$PERL_OPTIMIZE"
225PERL_LDFLAGS="$PERL_LDFLAGS"
226PERL_LIBS="$PERL_LIBS"
227
228EOF
229 exit 1
230}
231
179configure() { 232configure() {
180 fetch 233 fetch
181 234
182 rcd "$STATICPERL/src/perl-$PERL_VERSION" 235 rcd "$STATICPERL/src/perl-$PERL_VERSION"
183 236
189 242
190 rm -f "$PERL_PREFIX/staticstamp.install" 243 rm -f "$PERL_PREFIX/staticstamp.install"
191 244
192 "$MAKE" distclean >/dev/null 2>&1 245 "$MAKE" distclean >/dev/null 2>&1
193 246
247 sedreplace '/^#define SITELIB/d' config_h.SH
248
194 # I hate them 249 # I hate them for this
195 grep -q -- -fstack-protector Configure && \ 250 grep -q -- -fstack-protector Configure && \
196 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 251 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
197 252
198 preconfigure 253 # what did that bloke think
254 grep -q -- usedl=.define hints/darwin.sh && \
255 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
256
257 preconfigure || fatal "preconfigure hook failed"
199 258
200# trace configure \ 259# trace configure \
201 sh Configure -Duselargefiles \ 260 sh Configure -Duselargefiles \
202 -Uuse64bitint \ 261 -Uuse64bitint \
203 -Dusemymalloc=n \ 262 -Dusemymalloc=n \
205 -Uusethreads \ 264 -Uusethreads \
206 -Uuseithreads \ 265 -Uuseithreads \
207 -Uusemultiplicity \ 266 -Uusemultiplicity \
208 -Uusesfio \ 267 -Uusesfio \
209 -Uuseshrplib \ 268 -Uuseshrplib \
269 -Uinstallusrbinperl \
270 -A ccflags=" $PERL_CCFLAGS" \
210 -Dcc="$PERL_CC" \ 271 -Dcc="$PERL_CC" \
211 -Dcppflags="$PERL_CPPFLAGS" \
212 -Dccflags="-g2 -fno-strict-aliasing" \
213 -Doptimize="$PERL_OPTIMIZE" \ 272 -Doptimize="$PERL_OPTIMIZE" \
214 -Dldflags="$PERL_LDFLAGS" \ 273 -Dldflags="$PERL_LDFLAGS" \
215 -Dlibs="$PERL_LIBS" \ 274 -Dlibs="$PERL_LIBS" \
216 -Dprefix="$PERL_PREFIX" \ 275 -Dprefix="$PERL_PREFIX" \
217 -Dbin="$PERL_PREFIX/bin" \ 276 -Dbin="$PERL_PREFIX/bin" \
218 -Dprivlib="$PERL_PREFIX/lib" \ 277 -Dprivlib="$PERL_PREFIX/lib" \
219 -Darchlib="$PERL_PREFIX/lib" \ 278 -Darchlib="$PERL_PREFIX/lib" \
220 -Uusevendorprefix \ 279 -Uusevendorprefix \
221 -Dsitelib="$PERL_PREFIX/lib" \ 280 -Dsitelib="$PERL_PREFIX/lib" \
222 -Dsitearch="$PERL_PREFIX/lib" \ 281 -Dsitearch="$PERL_PREFIX/lib" \
223 -Usitelibexp \
224 -Uman1dir \ 282 -Uman1dir \
225 -Uman3dir \ 283 -Uman3dir \
226 -Usiteman1dir \ 284 -Usiteman1dir \
227 -Usiteman3dir \ 285 -Usiteman3dir \
228 -Dpager=/usr/bin/less \ 286 -Dpager=/usr/bin/less \
229 -Demail="$EMAIL" \ 287 -Demail="$EMAIL" \
230 -Dcf_email="$EMAIL" \ 288 -Dcf_email="$EMAIL" \
231 -Dcf_by="$EMAIL" \ 289 -Dcf_by="$EMAIL" \
232 $PERL_CONFIGURE \ 290 $PERL_CONFIGURE \
233 -Duseperlio \ 291 -Duseperlio \
234 -dE || fatal "Configure failed" 292 -dE || configure_failure
235 293
236 sedreplace ' 294 sedreplace '
237 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 295 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
238 s/ *-fno-stack-protector */ /g 296 s/ *-fno-stack-protector */ /g
239 ' config.sh 297 ' config.sh
240 298
299 patchconfig || fatal "patchconfig hook failed"
300
241 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
242 302
243 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
244 304
245 touch staticstamp.configure 305 : > staticstamp.configure
306}
307
308write_shellscript() {
309 {
310 echo "#!/bin/sh"
311 echo "STATICPERL=\"$STATICPERL\""
312 echo "PERL_PREFIX=\"$PERL_PREFIX\""
313 echo "MAKE=\"$MAKE\""
314 cat
315 } >"$PERL_PREFIX/bin/$1"
316 chmod 755 "$PERL_PREFIX/bin/$1"
246} 317}
247 318
248build() { 319build() {
249 configure 320 configure
250 321
257 rm -f "$PERL_PREFIX/staticstamp.install" 328 rm -f "$PERL_PREFIX/staticstamp.install"
258 329
259 "$MAKE" || fatal "make: error while building perl" 330 "$MAKE" || fatal "make: error while building perl"
260 331
261 postbuild || fatal "postbuild hook failed" 332 postbuild || fatal "postbuild hook failed"
333}
334
335_postinstall() {
336 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
337 NOCHECK_INSTALL=+
338 instcpan $STATICPERL_MODULES
339 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
340
341 postinstall || fatal "postinstall hook failed"
342
343 : > "$PERL_PREFIX/staticstamp.postinstall"
344 fi
262} 345}
263 346
264install() { 347install() {
265 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 348 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
266 build 349 build
271EOF 354EOF
272 355
273 ln -sf "perl/bin/" "$STATICPERL/bin" 356 ln -sf "perl/bin/" "$STATICPERL/bin"
274 ln -sf "perl/lib/" "$STATICPERL/lib" 357 ln -sf "perl/lib/" "$STATICPERL/lib"
275 358
359 mkdir "$STATICPERL/patched"
360
276 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 361 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
277 rm -rf "$PERL_PREFIX" # by this rm -rf 362 rm -rf "$PERL_PREFIX" # by this rm -rf
278 363
279 "$MAKE" install || fatal "make install: error while installing" 364 "$MAKE" install || fatal "make install: error while installing"
280 365
281 rcd "$PERL_PREFIX" 366 rcd "$PERL_PREFIX"
282 367
283 # create a "make install" replacement for CPAN 368 # create a "make install" replacement for CPAN
284 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 369 write_shellscript SP-make-install-make <<'EOF'
285"$MAKE" || exit 370#CAT make-install-make.sh
286
287if find blib/arch/auto -type f | grep -q -v .exists; then
288 echo Probably an XS module, rebuilding perl
289 if "$MAKE" perl; then
290 mv perl "$PERL_PREFIX"/bin/perl~ \
291 && rm -f "$PERL_PREFIX"/bin/perl \
292 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
293 "$MAKE" -f Makefile.aperl map_clean
294 else
295 "$MAKE" -f Makefile.aperl map_clean
296 exit 1
297 fi
298fi
299
300"$MAKE" install UNINST=1
301EOF 371EOF
302 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
303 372
373 # create a "patch modules" helper
374 write_shellscript SP-patch-postinstall <<'EOF'
375#CAT patch-postinstall.sh
376EOF
377
378 "$PERL_PREFIX/bin/SP-patch-postinstall"
379
304 # trick CPAN into avoiding ~/.cpan completely 380 # help to trick CPAN into avoiding ~/.cpan completely
305 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 381 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
306 382
383 # we call cpan with -MCPAN::MyConfig in this script, which
384 # is strictly unnecssary as we have to patch CPAN anyway,
385 # so consider it "for good measure".
307 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 386 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
308 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 387 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
309 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 388 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
310 CPAN::Shell->o (conf => q<init>); 389 CPAN::Shell->o (conf => q<init>);
311 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 390 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
312 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 391 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
313 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 392 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
314 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 393 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
315 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 394 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
316 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 395 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
317 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 396 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
318 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 397 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
398 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
319 CPAN::Shell->o (conf => q<commit>); 399 CPAN::Shell->o (conf => q<commit>);
320 ' || fatal "error while initialising CPAN" 400 ' || fatal "error while initialising CPAN"
321 401
322 touch "$PERL_PREFIX/staticstamp.install" 402 : > "$PERL_PREFIX/staticstamp.install"
323 fi 403 fi
324 404
405 _postinstall
406}
407
408import() {
409 IMPORT="$1"
410
411 rcd "$STATICPERL"
412
325 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 413 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
326 NOCHECK_INSTALL=+ 414 verblock <<EOF
327 instcpan $STATICPERL_MODULES 415import perl from $IMPORT to $STATICPERL
328 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 416EOF
329 417
330 postinstall || fatal "postinstall hook failed" 418 rm -rf bin cpan lib patched perl src
419 mkdir -m 755 perl perl/bin
420 ln -s perl/bin/ bin
421 ln -s "$IMPORT" perl/bin/
331 422
332 touch "$PERL_PREFIX/staticstamp.postinstall" 423 : > "$PERL_PREFIX/staticstamp.install"
333 fi 424 fi
425
426 _postinstall
334} 427}
335 428
336############################################################################# 429#############################################################################
337# install a module from CPAN 430# install a module from CPAN
338 431
342 verblock <<EOF 435 verblock <<EOF
343installing modules from CPAN 436installing modules from CPAN
344$@ 437$@
345EOF 438EOF
346 439
347 for mod in "$@"; do 440 #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
348 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 441 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
349 || fatal "$mod: unable to install from CPAN" 442
350 done 443 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
444 fatal "failure while installing modules from CPAN ($@)"
445 fi
351 rm -rf "$STATICPERL/build" 446 rm -f "$STATICPERL/instcpan.log"
352} 447}
353 448
354############################################################################# 449#############################################################################
355# install a module from unpacked sources 450# install a module from unpacked sources
356 451
369 rcd $mod 464 rcd $mod
370 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 465 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
371 "$MAKE" distclean >/dev/null 2>&1 466 "$MAKE" distclean >/dev/null 2>&1
372 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 467 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
373 "$MAKE" || fatal "$mod: error building module" 468 "$MAKE" || fatal "$mod: error building module"
374 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 469 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
375 "$MAKE" distclean >/dev/null 2>&1 470 "$MAKE" distclean >/dev/null 2>&1
376 exit 0 471 exit 0
377 ) || exit $? 472 ) || exit $?
378 done 473 done
379} 474}
411#CAT mkbundle 506#CAT mkbundle
412MKBUNDLE 507MKBUNDLE
413} 508}
414 509
415bundle() { 510bundle() {
511 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
416 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 512 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
417 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 513 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
418 CACHE="$STATICPERL/cache" 514 CACHE="$STATICPERL/cache"
419 mkdir -p "$CACHE" 515 mkdir -p "$CACHE"
420 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" 516 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
428 command="${1#--}"; shift 524 command="${1#--}"; shift
429 case "$command" in 525 case "$command" in
430 version ) 526 version )
431 echo "staticperl version $VERSION" 527 echo "staticperl version $VERSION"
432 ;; 528 ;;
433 fetch | configure | build | install | clean | distclean) 529 fetch | configure | build | install | clean | realclean | distclean )
434 ( "$command" ) 530 ( "$command" ) || exit
531 ;;
532 import )
533 ( import "$1" ) || exit
534 shift
435 ;; 535 ;;
436 instsrc ) 536 instsrc )
437 ( instsrc "$@" ) 537 ( instsrc "$@" ) || exit
438 exit 538 exit
439 ;; 539 ;;
440 instcpan ) 540 instcpan )
441 ( instcpan "$@" ) 541 ( instcpan "$@" ) || exit
542 exit
543 ;;
544 perl )
545 ( install ) || exit
546 exec "$PERL_PREFIX/bin/perl" "$@"
442 exit 547 exit
443 ;; 548 ;;
444 cpan ) 549 cpan )
445 ( install ) 550 ( install ) || exit
551 PERL="$PERL_PREFIX/bin/perl"
552 export PERL
446 "$PERL_PREFIX/bin/cpan" "$@" 553 exec "$PERL_PREFIX/bin/cpan" "$@"
447 exit 554 exit
448 ;; 555 ;;
449 mkbundle ) 556 mkbundle )
450 ( install ) 557 ( install ) || exit
451 bundle "$@" 558 bundle "$@"
452 exit 559 exit
453 ;; 560 ;;
454 mkperl ) 561 mkperl )
455 ( install ) 562 ( install ) || exit
456 bundle --perl "$@" 563 bundle --perl "$@"
457 exit 564 exit
458 ;; 565 ;;
459 mkapp ) 566 mkapp )
460 ( install ) 567 ( install ) || exit
461 bundle --app "$@" 568 bundle --app "$@"
462 exit 569 exit
463 ;; 570 ;;
464 help ) 571 help )
465 podusage 2 572 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines