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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines