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.1 by root, Mon Dec 6 19:33:58 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
6PERLVER=5.12.2 # 5.8.9 is also a good choice
7STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
8CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan # which mirror to use
9EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
10 9DLCACHE=
11MKBUNDLE="$STATICPERL/mkbundle"
12 10
13# perl build variables 11# perl build variables
14PREFIX="$STATICPERL/perl" # where the perl gets installed 12MAKE=make
15PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 13PERL_VERSION=5.12.4 # 5.8.9 is also a good choice
14PERL_CC=cc
15PERL_CONFIGURE="" # additional Configure arguments
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
28 ;; 29 ;;
29esac 30esac
30 31
31# -Wl,--gc-sections makes it impossible to check for undefined references 32# -Wl,--gc-sections makes it impossible to check for undefined references
32# 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 :/
33# -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
34PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" 35#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36PERL_LDFLAGS=
35PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 37PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
36 38
37# some configuration options for modules 39# some configuration options for modules
38export PERL_MM_USE_DEFAULT=1 40PERL_MM_USE_DEFAULT=1
41PERL_MM_OPT="MAN1PODS= MAN3PODS="
39#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
40export 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
41 45
42# which extra modules to install by default from CPAN that are 46# which extra modules to install by default from CPAN that are
43# required by mkbundle 47# required by mkbundle
44EXTRA_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 48STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage"
49
50# which extra modules you might want to install
51EXTRA_MODULES=""
45 52
46# overridable functions 53# overridable functions
54preconfigure() { : ; }
55patchconfig() { : ; }
47postconfigure() { : ; } 56postconfigure() { : ; }
48postbuild() { : ; } 57postbuild() { : ; }
49postinstall() { : ; } 58postinstall() { : ; }
50 59
51# now source user config, if any 60# now source user config, if any
61if [ "$STATICPERLRC" ]; then
62 . "$STATICPERLRC"
63else
52[ -r /etc/staticperlrc ] && . /etc/staticperlrc 64 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
53[ -r ~/.staticperlrc ] && . ~/.staticperlrc 65 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
54[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 66 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
67fi
55 68
56############################################################################# 69#############################################################################
57# 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"
58 81
59# set version in a way that Makefile.PL can extract 82# set version in a way that Makefile.PL can extract
60VERSION=VERSION; eval \ 83VERSION=VERSION; eval \
61$VERSION=0.1 84$VERSION="1.31"
62 85
63BZ2=bz2 86BZ2=bz2
64BZIP2=bzip2 87BZIP2=bzip2
65 88
66fatal() { 89fatal() {
99############################################################################# 122#############################################################################
100# clean 123# clean
101 124
102distclean() { 125distclean() {
103 verblock <<EOF 126 verblock <<EOF
104deleting everything installed by this script 127 deleting everything installed by this script (rm -rf $STATICPERL)
105EOF 128EOF
106 129
107 rm -rf "$STATICPERL" 130 rm -rf "$STATICPERL"
108} 131}
109 132
110############################################################################# 133#############################################################################
111# download/configure/compile/install perl 134# download/configure/compile/install perl
112 135
113clean() { 136clean() {
114 cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return 137 rm -rf "$STATICPERL/src"
138}
115 139
116 rm -f staticstamp.configure 140realclean() {
117 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"
118} 144}
119 145
120fetch() { 146fetch() {
121 rcd "$STATICPERL" 147 rcd "$STATICPERL"
122 148
123 mkdir -p src 149 mkdir -p src
124 rcd src 150 rcd src
125 151
126 if ! [ -d "perl-$PERLVER" ]; then 152 if ! [ -d "perl-$PERL_VERSION" ]; then
153 PERLTAR=perl-$PERL_VERSION.tar.$BZ2
154
127 if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then 155 if ! [ -e $PERLTAR ]; then
128
129 URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" 156 URL="$CPAN/src/5.0/$PERLTAR"
130 157
131 verblock <<EOF 158 verblock <<EOF
132downloading perl 159downloading perl
133to manually download perl yourself, place 160to manually download perl yourself, place
134perl-$PERLVER.tar.$BZ2 in $STATICPERL 161perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
135trying $URL 162trying $URL
136EOF
137 163
138 curl >perl-$PERLVER.tar.$BZ2~ "$URL" \ 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
171 rm -f $PERLTAR~ # just to be on the safe side
172 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
139 || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
140 || fatal "$URL: error during downloading" 175 || fatal "$URL: unable to download"
141 mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.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
142 fi 183 fi
143 184
144 verblock <<EOF 185 verblock <<EOF
145unpacking perl 186unpacking perl
146EOF 187EOF
147 188
148 mkdir -p unpack 189 mkdir -p unpack
149 $BZIP2 -d <perl-$PERLVER.tar.bz2 | tar xpC unpack \ 190 rm -rf unpack/perl-$PERL_VERSION
191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
150 || fatal "perl-$PERLVER.tar.bz2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
193 chmod -R u+w unpack/perl-$PERL_VERSION
151 mv unpack/perl-$PERLVER perl-$PERLVER 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
152 rmdir -p unpack 195 rmdir -p unpack
153 fi 196 fi
154} 197}
155 198
156# similar to GNU-sed -i or perl -pi 199# similar to GNU-sed -i or perl -pi
157sedreplace() { 200sedreplace() {
158 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"
159 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
160} 230}
161 231
162configure() { 232configure() {
163 fetch 233 fetch
164 234
165 rcd "$STATICPERL/src/perl-$PERLVER" 235 rcd "$STATICPERL/src/perl-$PERL_VERSION"
166 236
167 [ -e staticstamp.configure ] && return 237 [ -e staticstamp.configure ] && return
168 238
169 verblock <<EOF 239 verblock <<EOF
170configuring $STATICPERL/src/perl-$PERLVER 240configuring $STATICPERL/src/perl-$PERL_VERSION
171EOF 241EOF
172 242
173 clean
174
175 rm -f "$PREFIX/staticstamp.install" 243 rm -f "$PERL_PREFIX/staticstamp.install"
176 244
245 "$MAKE" distclean >/dev/null 2>&1
246
247 sedreplace '/^#define SITELIB/d' config_h.SH
248
177 # I hate them 249 # I hate them for this
178 grep -q -- -fstack-protector Configure && \ 250 grep -q -- -fstack-protector Configure && \
179 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"
180 258
181# trace configure \ 259# trace configure \
182 sh Configure -Duselargefiles \ 260 sh Configure -Duselargefiles \
183 -Uuse64bitint \ 261 -Uuse64bitint \
184 -Dusemymalloc=n \ 262 -Dusemymalloc=n \
185 -Uusedl \ 263 -Uusedl \
186 -Uusethreads \ 264 -Uusethreads \
187 -Uuseithreads \ 265 -Uuseithreads \
188 -Uusemultiplicity \ 266 -Uusemultiplicity \
189 -Duseperlio \
190 -Uusesfio \ 267 -Uusesfio \
191 -Uuseshrplib \ 268 -Uuseshrplib \
269 -Uinstallusrbinperl \
192 -Dcppflags="$PERL_CPPFLAGS" \ 270 -A ccflags=" $PERL_CCFLAGS" \
193 -Dccflags="-g2 -fno-strict-aliasing" \ 271 -Dcc="$PERL_CC" \
194 -Doptimize="$PERL_OPTIMIZE" \ 272 -Doptimize="$PERL_OPTIMIZE" \
195 -Dldflags="$PERL_LDFLAGS" \ 273 -Dldflags="$PERL_LDFLAGS" \
196 -Dlibs="$PERL_LIBS" \ 274 -Dlibs="$PERL_LIBS" \
197 -Dprefix="$PREFIX" \ 275 -Dprefix="$PERL_PREFIX" \
198 -Dbin="$PREFIX/bin" \ 276 -Dbin="$PERL_PREFIX/bin" \
199 -Dprivlib="$PREFIX/plib" \ 277 -Dprivlib="$PERL_PREFIX/lib" \
200 -Darchlib="$PREFIX/plib" \ 278 -Darchlib="$PERL_PREFIX/lib" \
201 -Uusevendorprefix \ 279 -Uusevendorprefix \
202 -Dsitelib="$PREFIX/plib" \ 280 -Dsitelib="$PERL_PREFIX/lib" \
203 -Dsitearch="$PREFIX/plib" \ 281 -Dsitearch="$PERL_PREFIX/lib" \
204 -Usitelibexp \
205 -Uman1dir \ 282 -Uman1dir \
206 -Uman3dir \ 283 -Uman3dir \
207 -Usiteman1dir \ 284 -Usiteman1dir \
208 -Usiteman3dir \ 285 -Usiteman3dir \
209 -Dpager=/usr/bin/less \ 286 -Dpager=/usr/bin/less \
210 -Demail="$EMAIL" \ 287 -Demail="$EMAIL" \
211 -Dcf_email="$EMAIL" \ 288 -Dcf_email="$EMAIL" \
212 -Dcf_by="$EMAIL" \ 289 -Dcf_by="$EMAIL" \
290 $PERL_CONFIGURE \
291 -Duseperlio \
213 -dE || fatal "Configure failed" 292 -dE || configure_failure
214 293
215 sedreplace ' 294 sedreplace '
216 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 295 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
217 s/ *-fno-stack-protector */ /g 296 s/ *-fno-stack-protector */ /g
218 ' config.sh 297 ' config.sh
219 298
299 patchconfig || fatal "patchconfig hook failed"
300
220 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
221 302
222 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
223 304
224 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"
225} 317}
226 318
227build() { 319build() {
228 configure 320 configure
229 321
230 rcd "$STATICPERL/src/perl-$PERLVER" 322 rcd "$STATICPERL/src/perl-$PERL_VERSION"
231 323
232 verblock <<EOF 324 verblock <<EOF
233building $STATICPERL/src/perl-$PERLVER 325building $STATICPERL/src/perl-$PERL_VERSION
234EOF 326EOF
235 327
236 rm -f "$PREFIX/staticstamp.install" 328 rm -f "$PERL_PREFIX/staticstamp.install"
237 329
238 make || fatal "make: error while building perl" 330 "$MAKE" || fatal "make: error while building perl"
239 331
240 postbuild || fatal "postbuild hook failed" 332 postbuild || fatal "postbuild hook failed"
241} 333}
242 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
243install() { 347install() {
244 [ -e "$PREFIX/staticstamp.install" ] && return 348 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
245
246 build 349 build
247 350
248 verblock <<EOF 351 verblock <<EOF
249installing $STATICPERL/src/perl-$PERLVER 352installing $STATICPERL/src/perl-$PERL_VERSION
250to $PREFIX 353to $PERL_PREFIX
251EOF 354EOF
252 355
253 rm -rf "$PREFIX" 356 ln -sf "perl/bin/" "$STATICPERL/bin"
254 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
255 make install || fatal "make install: error while installing" 364 "$MAKE" install || fatal "make install: error while installing"
256 365
366 rcd "$PERL_PREFIX"
367
257 # create a "make install" replacement for CPAN 368 # create a "make install" replacement for CPAN
258 cat >"$PREFIX"/bin/cpan-make-install <<EOF 369 write_shellscript SP-make-install-make <<'EOF'
259make install UNINST=1 370#CAT make-install-make.sh
260if find blib/arch/auto -type f | grep -q -v .exists; then
261 echo Probably an XS module, rebuilding perl
262 make perl
263 rm -f "$PREFIX"/bin/perl
264 make -f Makefile.aperl inst_perl
265 make -f Makefile.aperl map_clean
266fi
267EOF 371EOF
268 chmod 755 "$PREFIX"/bin/cpan-make-install
269 372
270 "$PREFIX"/bin/perl -MCPAN -e ' 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
380 # help to trick CPAN into avoiding ~/.cpan completely
381 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
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".
386 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
271 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 387 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
272 CPAN::Shell->o (conf => q<init>);
273 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 388 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
389 CPAN::Shell->o (conf => q<init>);
390 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
274 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 391 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
275 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 392 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
276 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 393 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
277 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 394 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
278 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PREFIX"'/bin/cpan-make-install"); 395 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
279 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 396 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
280 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");
281 CPAN::Shell->o (conf => q<commit>); 399 CPAN::Shell->o (conf => q<commit>);
282 ' || fatal "error while initialising CPAN" 400 ' || fatal "error while initialising CPAN"
283 401
284 NOCHECK_INSTALL=+
285 instcpan $EXTRA_MODULES
286
287 postinstall || fatal "postinstall hook failed"
288
289 touch "$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 : > "$PERL_PREFIX/staticstamp.install"
424 fi
425
426 _postinstall
290} 427}
291 428
292############################################################################# 429#############################################################################
293# install a module from CPAN 430# install a module from CPAN
294 431
298 verblock <<EOF 435 verblock <<EOF
299installing modules from CPAN 436installing modules from CPAN
300$@ 437$@
301EOF 438EOF
302 439
303 for mod in "$@"; do 440 #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
304 "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 441 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
305 || fatal "$mod: unable to install from CPAN" 442
306 done 443 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
444 fatal "failure while installing modules from CPAN ($@)"
445 fi
307 rm -rf "$STATICPERL/build" 446 rm -f "$STATICPERL/instcpan.log"
308} 447}
309 448
310############################################################################# 449#############################################################################
311# install a module from unpacked sources 450# install a module from unpacked sources
312 451
321 for mod in "$@"; do 460 for mod in "$@"; do
322 echo 461 echo
323 echo $mod 462 echo $mod
324 ( 463 (
325 rcd $mod 464 rcd $mod
326 make -f Makefile.aperl map_clean >/dev/null 2>&1 465 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
327 make distclean >/dev/null 2>&1 466 "$MAKE" distclean >/dev/null 2>&1
328 "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 467 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
329 make || fatal "$mod: error building module" 468 "$MAKE" || fatal "$mod: error building module"
330 "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 469 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
331 make distclean >/dev/null 2>&1 470 "$MAKE" distclean >/dev/null 2>&1
332 exit 0 471 exit 0
333 ) || exit $? 472 ) || exit $?
334 done 473 done
335} 474}
336 475
337############################################################################# 476#############################################################################
338# do schmorpy stuff
339
340MODSRCDIR=~/src
341
342instmodsrc() {
343 for mod in "$@"; do
344 instmod_src "$MODSRCDIR/$mod"
345 done
346}
347
348install_schmorp() {
349 install
350
351 instcpan Data::Dump Term::ReadLine::Perl Term::ANSIColor Term::ReadKey
352 instcpan Digest::SHA Digest::MD6 Digest::SHA256 Digest::MD4 Digest::HMAC_MD5 Digest::HMAC_MD6 Digest::FNV
353 #instcpan Net::SSLeay # requires static -ldl
354
355 instmodsrc common-sense Crypt-Twofish2 Array-Heap Convert-Scalar Compress-LZF JSON-XS
356 instmodsrc EV Guard Async-Interrupt IO-AIO
357 instmodsrc AnyEvent AnyEvent-AIO Coro AnyEvent-HTTP
358 instmodsrc Linux-Inotify2 EV-Loop-Async
359
360 instcpan AnyEvent::HTTPD
361}
362
363#############################################################################
364# main 477# main
365 478
366podusage() { 479podusage() {
367 echo 480 echo
481
368 if [ -e "$PREFIX/bin/perl" ]; then 482 if [ -e "$PERL_PREFIX/bin/perl" ]; then
369 "$PREFIX/bin/perl" -MPod::Usage -e \ 483 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
370 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 484 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
371 2>/dev/null && exit 485 2>/dev/null && exit
372 fi 486 fi
487
373 # try whatever perl we can find 488 # try whatever perl we can find
374 perl -MPod::Usage -e \ 489 perl -MPod::Usage -e \
375 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 490 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
376 2>/dev/null && exit 491 2>/dev/null && exit
377 492
378 fatal "displaying documentation requires a working perl - try '$0 install' first" 493 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
379} 494}
380 495
381usage() { 496usage() {
382 podusage 0 497 podusage 0
383} 498}
384 499
385catmkbundle() { 500catmkbundle() {
386 { 501 {
387 read dummy 502 read dummy
388 echo "#!$PREFIX/bin/perl" 503 echo "#!$PERL_PREFIX/bin/perl"
389 cat 504 cat
390 } <<'MKBUNDLE' 505 } <<'MKBUNDLE'
391#CAT mkbundle 506#CAT mkbundle
392MKBUNDLE 507MKBUNDLE
393} 508}
394 509
395bundle() { 510bundle() {
511 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
396 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 512 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
397 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 513 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
514 CACHE="$STATICPERL/cache"
515 mkdir -p "$CACHE"
398 "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 516 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
399} 517}
400 518
401if [ $# -gt 0 ]; then 519if [ $# -gt 0 ]; then
402 while [ $# -gt 0 ]; do 520 while [ $# -gt 0 ]; do
403 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 521 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
404 mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" 522 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
405 523
406 command="${1#--}"; shift 524 command="${1#--}"; shift
407 case "$command" in 525 case "$command" in
526 version )
527 echo "staticperl version $VERSION"
528 ;;
408 fetch | configure | build | install | clean | distclean) 529 fetch | configure | build | install | clean | realclean | distclean )
409 verblock <<EOF
410$command
411EOF
412 "$command" 530 ( "$command" ) || exit
531 ;;
532 import )
533 ( import "$1" ) || exit
534 shift
413 ;; 535 ;;
414 instsrc ) 536 instsrc )
415 instsrc "$@" 537 ( instsrc "$@" ) || exit
416 exit 538 exit
417 ;; 539 ;;
418 instcpan ) 540 instcpan )
419 instcpan "$@" 541 ( instcpan "$@" ) || exit
420 exit
421 ;; 542 exit
422 instschmorp ) 543 ;;
423 install_schmorp 544 perl )
545 ( install ) || exit
546 exec "$PERL_PREFIX/bin/perl" "$@"
547 exit
424 ;; 548 ;;
425 cpan ) 549 cpan )
426 install 550 ( install ) || exit
551 PERL="$PERL_PREFIX/bin/perl"
552 export PERL
427 "$PREFIX/bin/cpan" "$@" 553 exec "$PERL_PREFIX/bin/cpan" "$@"
428 exit 554 exit
429 ;; 555 ;;
430 mkbundle ) 556 mkbundle )
431 install 557 ( install ) || exit
432 bundle "$@" 558 bundle "$@"
433 exit 559 exit
434 ;; 560 ;;
435 mkperl ) 561 mkperl )
436 install 562 ( install ) || exit
437 bundle --perl "$@" 563 bundle --perl "$@"
564 exit
565 ;;
566 mkapp )
567 ( install ) || exit
568 bundle --app "$@"
438 exit 569 exit
439 ;; 570 ;;
440 help ) 571 help )
441 podusage 2 572 podusage 2
442 ;; 573 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines