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.52 by root, Mon Mar 5 07:14:32 2012 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=5.12.4 # 5.8.9 is also a good choice
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="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
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
71
72PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
73
74unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
75unset PERL_MB_OPT
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"
62 81
63# set version in a way that Makefile.PL can extract 82# set version in a way that Makefile.PL can extract
64VERSION=VERSION; eval \ 83VERSION=VERSION; eval \
65$VERSION=0.1 84$VERSION="1.41"
66 85
67BZ2=bz2 86BZ2=bz2
68BZIP2=bzip2 87BZIP2=bzip2
69 88
70fatal() { 89fatal() {
103############################################################################# 122#############################################################################
104# clean 123# clean
105 124
106distclean() { 125distclean() {
107 verblock <<EOF 126 verblock <<EOF
108deleting everything installed by this script 127 deleting everything installed by this script (rm -rf $STATICPERL)
109EOF 128EOF
110 129
111 rm -rf "$STATICPERL" 130 rm -rf "$STATICPERL"
112} 131}
113 132
114############################################################################# 133#############################################################################
115# download/configure/compile/install perl 134# download/configure/compile/install perl
116 135
117clean() { 136clean() {
118 cd "$STATICPERL/src/perl-$PERL_VERSION" 2>/dev/null || return 137 rm -rf "$STATICPERL/src"
138}
119 139
120 rm -f staticstamp.configure 140realclean() {
121 make distclean >/dev/null 2>&1 141 rm -f "$PERL_PREFIX/staticstamp.postinstall"
142 rm -f "$PERL_PREFIX/staticstamp.install"
143 rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure"
122} 144}
123 145
124fetch() { 146fetch() {
125 rcd "$STATICPERL" 147 rcd "$STATICPERL"
126 148
127 mkdir -p src 149 mkdir -p src
128 rcd src 150 rcd src
129 151
130 if ! [ -d "perl-$PERL_VERSION" ]; then 152 if ! [ -d "perl-$PERL_VERSION" ]; then
131 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 153 PERLTAR=perl-$PERL_VERSION.tar.$BZ2
132 154
155 if ! [ -e $PERLTAR ]; then
133 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 156 URL="$CPAN/src/5.0/$PERLTAR"
134 157
135 verblock <<EOF 158 verblock <<EOF
136downloading perl 159downloading perl
137to manually download perl yourself, place 160to manually download perl yourself, place
138perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 161perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
139trying $URL 162trying $URL
140EOF
141 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
142 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
143 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 172 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
144 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
145 || fatal "$URL: unable to download" 175 || fatal "$URL: unable to download"
146 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 176 rm -f $PERLTAR
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
147 fi 183 fi
148 184
149 verblock <<EOF 185 verblock <<EOF
150unpacking perl 186unpacking perl
151EOF 187EOF
152 188
153 mkdir -p unpack 189 mkdir -p unpack
154 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xpC unpack \ 190 rm -rf unpack/perl-$PERL_VERSION
191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
155 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
193 chmod -R u+w unpack/perl-$PERL_VERSION
156 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
157 rmdir -p unpack 195 rmdir -p unpack
158 fi 196 fi
159} 197}
160 198
161# similar to GNU-sed -i or perl -pi 199# similar to GNU-sed -i or perl -pi
162sedreplace() { 200sedreplace() {
163 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 201 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
202 rm -f "$2"
164 mv "$2~" "$2" 203 mv "$2~" "$2"
204}
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
165} 230}
166 231
167configure() { 232configure() {
168 fetch 233 fetch
169 234
173 238
174 verblock <<EOF 239 verblock <<EOF
175configuring $STATICPERL/src/perl-$PERL_VERSION 240configuring $STATICPERL/src/perl-$PERL_VERSION
176EOF 241EOF
177 242
178 clean
179
180 rm -f "$PERL_PREFIX/staticstamp.install" 243 rm -f "$PERL_PREFIX/staticstamp.install"
181 244
245 "$MAKE" distclean >/dev/null 2>&1
246
247 sedreplace '/^#define SITELIB/d' config_h.SH
248
182 # I hate them 249 # I hate them for this
183 grep -q -- -fstack-protector Configure && \ 250 grep -q -- -fstack-protector Configure && \
184 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 251 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
252
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"
185 258
186# trace configure \ 259# trace configure \
187 sh Configure -Duselargefiles \ 260 sh Configure -Duselargefiles \
188 -Uuse64bitint \ 261 -Uuse64bitint \
189 -Dusemymalloc=n \ 262 -Dusemymalloc=n \
190 -Uusedl \ 263 -Uusedl \
191 -Uusethreads \ 264 -Uusethreads \
192 -Uuseithreads \ 265 -Uuseithreads \
193 -Uusemultiplicity \ 266 -Uusemultiplicity \
194 -Duseperlio \
195 -Uusesfio \ 267 -Uusesfio \
196 -Uuseshrplib \ 268 -Uuseshrplib \
269 -Uinstallusrbinperl \
197 -Dcppflags="$PERL_CPPFLAGS" \ 270 -A ccflags=" $PERL_CCFLAGS" \
198 -Dccflags="-g2 -fno-strict-aliasing" \ 271 -Dcc="$PERL_CC" \
199 -Doptimize="$PERL_OPTIMIZE" \ 272 -Doptimize="$PERL_OPTIMIZE" \
200 -Dldflags="$PERL_LDFLAGS" \ 273 -Dldflags="$PERL_LDFLAGS" \
201 -Dlibs="$PERL_LIBS" \ 274 -Dlibs="$PERL_LIBS" \
202 -Dprefix="$PERL_PREFIX" \ 275 -Dprefix="$PERL_PREFIX" \
203 -Dbin="$PERL_PREFIX/bin" \ 276 -Dbin="$PERL_PREFIX/bin" \
204 -Dprivlib="$PERL_PREFIX/lib" \ 277 -Dprivlib="$PERL_PREFIX/lib" \
205 -Darchlib="$PERL_PREFIX/lib" \ 278 -Darchlib="$PERL_PREFIX/lib" \
206 -Uusevendorprefix \ 279 -Uusevendorprefix \
207 -Dsitelib="$PERL_PREFIX/lib" \ 280 -Dsitelib="$PERL_PREFIX/lib" \
208 -Dsitearch="$PERL_PREFIX/lib" \ 281 -Dsitearch="$PERL_PREFIX/lib" \
209 -Usitelibexp \
210 -Uman1dir \ 282 -Uman1dir \
211 -Uman3dir \ 283 -Uman3dir \
212 -Usiteman1dir \ 284 -Usiteman1dir \
213 -Usiteman3dir \ 285 -Usiteman3dir \
214 -Dpager=/usr/bin/less \ 286 -Dpager=/usr/bin/less \
215 -Demail="$EMAIL" \ 287 -Demail="$EMAIL" \
216 -Dcf_email="$EMAIL" \ 288 -Dcf_email="$EMAIL" \
217 -Dcf_by="$EMAIL" \ 289 -Dcf_by="$EMAIL" \
218 $PERL_CONFIGURE \ 290 $PERL_CONFIGURE \
291 -Duseperlio \
219 -dE || fatal "Configure failed" 292 -dE || configure_failure
220 293
221 sedreplace ' 294 sedreplace '
222 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 295 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
223 s/ *-fno-stack-protector */ /g 296 s/ *-fno-stack-protector */ /g
224 ' config.sh 297 ' config.sh
225 298
299 patchconfig || fatal "patchconfig hook failed"
300
226 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
227 302
228 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
229 304
230 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"
231} 317}
232 318
233build() { 319build() {
234 configure 320 configure
235 321
239building $STATICPERL/src/perl-$PERL_VERSION 325building $STATICPERL/src/perl-$PERL_VERSION
240EOF 326EOF
241 327
242 rm -f "$PERL_PREFIX/staticstamp.install" 328 rm -f "$PERL_PREFIX/staticstamp.install"
243 329
244 make || fatal "make: error while building perl" 330 "$MAKE" || fatal "make: error while building perl"
245 331
246 postbuild || fatal "postbuild hook failed" 332 postbuild || fatal "postbuild hook failed"
247} 333}
248 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
345}
346
249install() { 347install() {
250 [ -e "$PERL_PREFIX/staticstamp.install" ] && return 348 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
251
252 build 349 build
253 350
254 verblock <<EOF 351 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 352installing $STATICPERL/src/perl-$PERL_VERSION
256to $PERL_PREFIX 353to $PERL_PREFIX
257EOF 354EOF
258 355
259 rm -rf "$PERL_PREFIX" 356 ln -sf "perl/bin/" "$STATICPERL/bin"
260 357 ln -sf "perl/lib/" "$STATICPERL/lib"
358
359 mkdir "$STATICPERL/patched"
360
361 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
362 rm -rf "$PERL_PREFIX" # by this rm -rf
363
261 make install || fatal "make install: error while installing" 364 "$MAKE" install || fatal "make install: error while installing"
262 365
263 rcd "$PERL_PREFIX" 366 rcd "$PERL_PREFIX"
264 367
265 # create a "make install" replacement for CPAN 368 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 369 write_shellscript SP-make-install-make <<'EOF'
267make install UNINST=1 370#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 371EOF
276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
277 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
278 # trick CPAN into avoiding ~/.cpan completely 380 # help to trick CPAN into avoiding ~/.cpan completely
279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 381 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
280 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".
281 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 386 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
282 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 387 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
283 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 388 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
284 CPAN::Shell->o (conf => q<init>); 389 CPAN::Shell->o (conf => q<init>);
285 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 390 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
286 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 391 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
287 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 392 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
288 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 393 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
289 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 394 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
290 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");
291 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 396 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
292 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");
293 CPAN::Shell->o (conf => q<commit>); 399 CPAN::Shell->o (conf => q<commit>);
294 ' || fatal "error while initialising CPAN" 400 ' || fatal "error while initialising CPAN"
295 401
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" 402 : > "$PERL_PREFIX/staticstamp.install"
403 fi
404
405 _postinstall
406}
407
408import() {
409 IMPORT="$1"
410
411 rcd "$STATICPERL"
412
413 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
414 verblock <<EOF
415import perl from $IMPORT to $STATICPERL
416EOF
417
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/
422
423 echo "$IMPORT" > "$PERL_PREFIX/.import"
424
425 : > "$PERL_PREFIX/staticstamp.install"
426 fi
427
428 _postinstall
303} 429}
304 430
305############################################################################# 431#############################################################################
306# install a module from CPAN 432# install a module from CPAN
307 433
311 verblock <<EOF 437 verblock <<EOF
312installing modules from CPAN 438installing modules from CPAN
313$@ 439$@
314EOF 440EOF
315 441
316 for mod in "$@"; do 442 MYCONFIG=
317 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 443 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
318 || fatal "$mod: unable to install from CPAN" 444
319 done 445 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
446
447 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
448 fatal "failure while installing modules from CPAN ($@)"
449 fi
320 rm -rf "$STATICPERL/build" 450 rm -f "$STATICPERL/instcpan.log"
321} 451}
322 452
323############################################################################# 453#############################################################################
324# install a module from unpacked sources 454# install a module from unpacked sources
325 455
334 for mod in "$@"; do 464 for mod in "$@"; do
335 echo 465 echo
336 echo $mod 466 echo $mod
337 ( 467 (
338 rcd $mod 468 rcd $mod
339 make -f Makefile.aperl map_clean >/dev/null 2>&1 469 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
340 make distclean >/dev/null 2>&1 470 "$MAKE" distclean >/dev/null 2>&1
341 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 471 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
342 make || fatal "$mod: error building module" 472 "$MAKE" || fatal "$mod: error building module"
343 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 473 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
344 make distclean >/dev/null 2>&1 474 "$MAKE" distclean >/dev/null 2>&1
345 exit 0 475 exit 0
346 ) || exit $? 476 ) || exit $?
347 done 477 done
348} 478}
349 479
350############################################################################# 480#############################################################################
351# main 481# main
352 482
353podusage() { 483podusage() {
354 echo 484 echo
485
355 if [ -e "$PERL_PREFIX/bin/perl" ]; then 486 if [ -e "$PERL_PREFIX/bin/perl" ]; then
356 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 487 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
357 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 488 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
358 2>/dev/null && exit 489 2>/dev/null && exit
359 fi 490 fi
491
360 # try whatever perl we can find 492 # try whatever perl we can find
361 perl -MPod::Usage -e \ 493 perl -MPod::Usage -e \
362 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 494 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
363 2>/dev/null && exit 495 2>/dev/null && exit
364 496
365 fatal "displaying documentation requires a working perl - try '$0 install' first" 497 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
366} 498}
367 499
368usage() { 500usage() {
369 podusage 0 501 podusage 0
370} 502}
378#CAT mkbundle 510#CAT mkbundle
379MKBUNDLE 511MKBUNDLE
380} 512}
381 513
382bundle() { 514bundle() {
515 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
383 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 516 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
384 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 517 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
518 CACHE="$STATICPERL/cache"
519 mkdir -p "$CACHE"
385 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 520 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
386} 521}
387 522
388if [ $# -gt 0 ]; then 523if [ $# -gt 0 ]; then
389 while [ $# -gt 0 ]; do 524 while [ $# -gt 0 ]; do
390 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 525 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
391 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 526 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
392 527
393 command="${1#--}"; shift 528 command="${1#--}"; shift
394 case "$command" in 529 case "$command" in
530 version )
531 echo "staticperl version $VERSION"
532 ;;
395 fetch | configure | build | install | clean | distclean) 533 fetch | configure | build | install | clean | realclean | distclean )
396 verblock <<EOF
397$command
398EOF
399 ( "$command" ) 534 ( "$command" ) || exit
535 ;;
536 import )
537 ( import "$1" ) || exit
538 shift
400 ;; 539 ;;
401 instsrc ) 540 instsrc )
402 ( instsrc "$@" ) 541 ( instsrc "$@" ) || exit
403 exit 542 exit
404 ;; 543 ;;
405 instcpan ) 544 instcpan )
406 ( instcpan "$@" ) 545 ( instcpan "$@" ) || exit
546 exit
547 ;;
548 perl )
549 ( install ) || exit
550 exec "$PERL_PREFIX/bin/perl" "$@"
407 exit 551 exit
408 ;; 552 ;;
409 cpan ) 553 cpan )
410 ( install ) 554 ( install ) || exit
555 PERL="$PERL_PREFIX/bin/perl"
556 export PERL
411 "$PERL_PREFIX/bin/cpan" "$@" 557 exec "$PERL_PREFIX/bin/cpan" "$@"
412 exit 558 exit
413 ;; 559 ;;
414 mkbundle ) 560 mkbundle )
415 ( install ) 561 ( install ) || exit
416 bundle "$@" 562 bundle "$@"
417 exit 563 exit
418 ;; 564 ;;
419 mkperl ) 565 mkperl )
420 ( install ) 566 ( install ) || exit
421 bundle --perl "$@" 567 bundle --perl "$@"
568 exit
569 ;;
570 mkapp )
571 ( install ) || exit
572 bundle --app "$@"
422 exit 573 exit
423 ;; 574 ;;
424 help ) 575 help )
425 podusage 2 576 podusage 2
426 ;; 577 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines