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.3 by root, Mon Dec 6 21:10:41 2010 UTC vs.
Revision 1.75 by root, Tue Aug 1 03:48:59 2023 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=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds
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" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
17 18
18ARCH="$(uname -m)" 19ARCH="$(uname -m)"
19 20
20case "$ARCH" in 21#case "$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 case "$ARCH" in 24# case "$ARCH" in
24 i*86 ) 25# i*86 )
25 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
26 ;; 27# ;;
27 esac 28# esac
28 ;; 29# ;;
29esac 30#esac
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="ExtUtils::MakeMaker ExtUtils::CBuilder common::sense Pod::Strip PPI 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() { : ; }
58postcpanconfig() { : ; }
52postinstall() { : ; } 59postinstall() { : ; }
53 60
54# now source user config, if any 61# now source user config, if any
62if [ "$STATICPERLRC" ]; then
63 . "$STATICPERLRC"
64else
55[ -r /etc/staticperlrc ] && . /etc/staticperlrc 65 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
56[ -r ~/.staticperlrc ] && . ~/.staticperlrc 66 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
57[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 67 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
68fi
58 69
59############################################################################# 70#############################################################################
60# support 71# support
61 72
73# work around ExtUtils::CBuilder and others
74export CC="$PERL_CC"
75export CFLAGS="$PERL_CFLAGS"
76export LD="$PERL_CC"
77export LDFLAGS="$PERL_LDFLAGS"
78unset LIBS
79
80PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
81
82unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
83unset PERL_MB_OPT
84LC_ALL=C; export LC_ALL # just to be on the safe side
85
86# prepend PATH - not required by staticperl itself, but might make
87# life easier when working in e.g. "staticperl cpan / look"
88PATH="$PERL_PREFIX/perl/bin:$PATH"
89
62# set version in a way that Makefile.PL can extract 90# set version in a way that Makefile.PL can extract
63VERSION=VERSION; eval \ 91VERSION=VERSION; eval \
64$VERSION=0.1 92$VERSION="1.46"
65
66BZ2=bz2
67BZIP2=bzip2
68 93
69fatal() { 94fatal() {
70 printf -- "\nFATAL: %s\n\n" "$*" >&2 95 printf -- "\nFATAL: %s\n\n" "$*" >&2
71 exit 1 96 exit 1
72} 97}
102############################################################################# 127#############################################################################
103# clean 128# clean
104 129
105distclean() { 130distclean() {
106 verblock <<EOF 131 verblock <<EOF
107deleting everything installed by this script 132 deleting everything installed by this script (rm -rf $STATICPERL)
108EOF 133EOF
109 134
110 rm -rf "$STATICPERL" 135 rm -rf "$STATICPERL"
111} 136}
112 137
113############################################################################# 138#############################################################################
114# download/configure/compile/install perl 139# download/configure/compile/install perl
115 140
116clean() { 141clean() {
117 cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return 142 rm -rf "$STATICPERL/src"
143}
118 144
119 rm -f staticstamp.configure 145realclean() {
120 make distclean >/dev/null 2>&1 146 rm -f "$PERL_PREFIX/staticstamp.postinstall"
147 rm -f "$PERL_PREFIX/staticstamp.install"
148 rm -f "$STATICPERL/src/perl/staticstamp.configure"
121} 149}
122 150
123fetch() { 151fetch() {
152(
124 rcd "$STATICPERL" 153 rcd "$STATICPERL"
125 154
126 mkdir -p src 155 mkdir -p src
127 rcd src 156 rcd src
128 157
129 if ! [ -d "perl-$PERLVER" ]; then 158 if ! [ -d "perl" ]; then
130 if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then 159 rm -rf unpack
160 mkdir -p unpack
131 161
162 case "$PERL_VERSION" in
163 *:* )
164 # url
165 PERLURL="$PERL_VERSION"
166 PERLTAR="$(basename "$PERL_VERSION")"
167 ;;
168 /* )
169 # directory
170 verbose "copying $PERL_VERSION"
171 cp -Rp "$PERL_VERSION/." unpack/.
172 chmod -R u+w unpack
173 mv unpack perl
174 return
175 ;;
176 * )
132 URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" 177 PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
178 PERLTAR=perl-$PERL_VERSION.tar.bz2
179 ;;
180 esac
133 181
182 if ! [ -e "$PERLTAR" ]; then
134 verblock <<EOF 183 verblock <<EOF
135downloading perl 184downloading perl
185
186trying to download from $PERLURL
187
188you can configure a download cache directory via DLCACHE
189in your .staticperlrc to avoid repeated downloads.
190
136to manually download perl yourself, place 191to manually download perl yourself, place a suitable tarball in
137perl-$PERLVER.tar.$BZ2 in $STATICPERL 192$DLCACHE/$PERLTAR
138trying $URL
139EOF
140 193
141 curl >perl-$PERLVER.tar.$BZ2~ "$URL" \ 194either curl or wget is required for automatic download.
142 || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ 195curl is tried first, then wget.
196EOF
197
198 rm -f $PERLTAR~ # just to be on the safe side
199 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
200 || wget -O $PERLTAR~ "$PERLURL" \
201 || curl -f >$PERLTAR~ "$PERLURL" \
143 || fatal "$URL: error during downloading" 202 || fatal "$URL: unable to download"
144 mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.tar.$BZ2 203 rm -f $PERLTAR
204 mv $PERLTAR~ $PERLTAR
205 if [ "$DLCACHE" ]; then
206 mkdir -p "$DLCACHE"
207 cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \
208 mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR
209 fi
145 fi 210 fi
146 211
147 verblock <<EOF 212 verblock <<EOF
148unpacking perl 213unpacking perl
149EOF 214EOF
150 215
151 mkdir -p unpack 216 case "$PERLTAR" in
152 $BZIP2 -d <perl-$PERLVER.tar.bz2 | tar xpC unpack \ 217 *.xz ) UNCOMPRESS="xz -d" ;;
218 *.lzma ) UNCOMPRESS="lzma -d" ;;
219 *.bz2 ) UNCOMPRESS="bzip2 -d" ;;
220 *.gz ) UNCOMPRESS="gzip -d" ;;
221 *.tar ) UNCOMPRESS="cat" ;;
222 * )
223 fatal "don't know hot to uncompress $PERLTAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported."
224 exit 1
225 ;;
226 esac
227
228 <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
153 || fatal "perl-$PERLVER.tar.bz2: error during unpacking" 229 || fatal "$PERLTAR: error during unpacking"
154 mv unpack/perl-$PERLVER perl-$PERLVER 230
231 if [ -d unpack/*/ ]; then
232 chmod -R u+w unpack/*/
233 mv unpack/*/ perl
155 rmdir -p unpack 234 rmdir -p unpack
235 else
236 fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this"
237 fi
238
239 rm "$PERLTAR"
156 fi 240 fi
241) || exit
157} 242}
158 243
159# similar to GNU-sed -i or perl -pi 244# similar to GNU-sed -i or perl -pi
160sedreplace() { 245sedreplace() {
161 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 246 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
247 rm -f "$2"
162 mv "$2~" "$2" 248 mv "$2~" "$2"
163} 249}
164 250
251configure_failure() {
252 cat <<EOF
253
254
255***
256*** Configure failed - see above for the exact error message(s).
257***
258*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
259*** flags are not supported by your compiler. Less often, this is because
260*** PERL_LIBS either contains a library not available on your system (such as
261*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
262***
263*** You can provide your own flags by creating a ~/.staticperlrc file with
264*** variable assignments. For example (these are the actual values used):
265***
266
267PERL_CC="$PERL_CC"
268PERL_CCFLAGS="$PERL_CCFLAGS"
269PERL_OPTIMIZE="$PERL_OPTIMIZE"
270PERL_LDFLAGS="$PERL_LDFLAGS"
271PERL_LIBS="$PERL_LIBS"
272
273EOF
274 exit 1
275}
276
165configure() { 277configure() {
278(
166 fetch 279 fetch
167 280
168 rcd "$STATICPERL/src/perl-$PERLVER" 281 rcd "$STATICPERL/src/perl"
169 282
170 [ -e staticstamp.configure ] && return 283 [ -e staticstamp.configure ] && return
171 284
172 verblock <<EOF 285 verblock <<EOF
173configuring $STATICPERL/src/perl-$PERLVER 286configuring $STATICPERL/src/perl
174EOF 287EOF
175 288
176 clean
177
178 rm -f "$PREFIX/staticstamp.install" 289 rm -f "$PERL_PREFIX/staticstamp.install"
179 290
291 "$MAKE" distclean >/dev/null 2>&1
292
293 sedreplace '/^#define SITELIB/d' config_h.SH
294
180 # I hate them 295 # I hate them for this
181 grep -q -- -fstack-protector Configure && \ 296 grep -q -- -fstack-protector Configure && \
182 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 297 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
298
299 # what did that bloke think
300 grep -q -- usedl=.define hints/darwin.sh && \
301 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
302
303 preconfigure || fatal "preconfigure hook failed"
183 304
184# trace configure \ 305# trace configure \
185 sh Configure -Duselargefiles \ 306 sh Configure -Duselargefiles \
186 -Uuse64bitint \ 307 -Uuse64bitint \
187 -Dusemymalloc=n \ 308 -Dusemymalloc=n \
188 -Uusedl \ 309 -Uusedl \
189 -Uusethreads \ 310 -Uusethreads \
190 -Uuseithreads \ 311 -Uuseithreads \
191 -Uusemultiplicity \ 312 -Uusemultiplicity \
192 -Duseperlio \
193 -Uusesfio \ 313 -Uusesfio \
194 -Uuseshrplib \ 314 -Uuseshrplib \
315 -Uinstallusrbinperl \
195 -Dcppflags="$PERL_CPPFLAGS" \ 316 -A ccflags=" $PERL_CCFLAGS" \
196 -Dccflags="-g2 -fno-strict-aliasing" \ 317 -Dcc="$PERL_CC" \
197 -Doptimize="$PERL_OPTIMIZE" \ 318 -Doptimize="$PERL_OPTIMIZE" \
198 -Dldflags="$PERL_LDFLAGS" \ 319 -Dldflags="$PERL_LDFLAGS" \
199 -Dlibs="$PERL_LIBS" \ 320 -Dlibs="$PERL_LIBS" \
200 -Dprefix="$PREFIX" \ 321 -Dprefix="$PERL_PREFIX" \
201 -Dbin="$PREFIX/bin" \ 322 -Dbin="$PERL_PREFIX/bin" \
202 -Dprivlib="$PREFIX/lib" \ 323 -Dprivlib="$PERL_PREFIX/lib" \
203 -Darchlib="$PREFIX/lib" \ 324 -Darchlib="$PERL_PREFIX/lib" \
204 -Uusevendorprefix \ 325 -Uusevendorprefix \
205 -Dsitelib="$PREFIX/lib" \ 326 -Dsitelib="$PERL_PREFIX/lib" \
206 -Dsitearch="$PREFIX/lib" \ 327 -Dsitearch="$PERL_PREFIX/lib" \
207 -Usitelibexp \
208 -Uman1dir \ 328 -Uman1dir \
209 -Uman3dir \ 329 -Uman3dir \
210 -Usiteman1dir \ 330 -Usiteman1dir \
211 -Usiteman3dir \ 331 -Usiteman3dir \
212 -Dpager=/usr/bin/less \ 332 -Dpager=/usr/bin/less \
213 -Demail="$EMAIL" \ 333 -Demail="$EMAIL" \
214 -Dcf_email="$EMAIL" \ 334 -Dcf_email="$EMAIL" \
215 -Dcf_by="$EMAIL" \ 335 -Dcf_by="$EMAIL" \
336 $PERL_CONFIGURE \
337 -Duseperlio \
338 -Uversiononly \
216 -dE || fatal "Configure failed" 339 -dE || configure_failure
217 340
218 sedreplace ' 341 sedreplace '
219 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 342 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
220 s/ *-fno-stack-protector */ /g 343 s/ *-fno-stack-protector */ /g
221 ' config.sh 344 ' config.sh
222 345
346 patchconfig || fatal "patchconfig hook failed"
347
223 sh Configure -S || fatal "Configure -S failed" 348 sh Configure -S || fatal "Configure -S failed"
224 349
225 postconfigure || fatal "postconfigure hook failed" 350 postconfigure || fatal "postconfigure hook failed"
226 351
227 touch staticstamp.configure 352 : > staticstamp.configure
353) || exit
354}
355
356write_shellscript() {
357 {
358 echo "#!/bin/sh"
359 echo "STATICPERL=\"$STATICPERL\""
360 echo "PERL_PREFIX=\"$PERL_PREFIX\""
361 echo "MAKE=\"$MAKE\""
362 cat
363 } >"$PERL_PREFIX/bin/$1"
364 chmod 755 "$PERL_PREFIX/bin/$1"
228} 365}
229 366
230build() { 367build() {
368(
231 configure 369 configure
232 370
233 rcd "$STATICPERL/src/perl-$PERLVER" 371 rcd "$STATICPERL/src/perl"
234 372
235 verblock <<EOF 373 verblock <<EOF
236building $STATICPERL/src/perl-$PERLVER 374building $STATICPERL/src/perl
237EOF 375EOF
238 376
239 rm -f "$PREFIX/staticstamp.install" 377 rm -f "$PERL_PREFIX/staticstamp.install"
240 378
241 make || fatal "make: error while building perl" 379 "$MAKE" || fatal "make: error while building perl"
242 380
243 postbuild || fatal "postbuild hook failed" 381 postbuild || fatal "postbuild hook failed"
382) || exit
383}
384
385_postinstall() {
386 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
387 NOCHECK_INSTALL=+
388 instcpan $STATICPERL_MODULES
389 [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES
390
391 postinstall || fatal "postinstall hook failed"
392
393 : > "$PERL_PREFIX/staticstamp.postinstall"
394 fi
244} 395}
245 396
246install() { 397install() {
398(
247 [ -e "$PREFIX/staticstamp.install" ] && return 399 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
248
249 build 400 build
250 401
251 verblock <<EOF 402 verblock <<EOF
252installing $STATICPERL/src/perl-$PERLVER 403installing $STATICPERL/src/perl
253to $PREFIX 404to $PERL_PREFIX
254EOF 405EOF
255 406
256 rm -rf "$PREFIX" 407 ln -sf "perl/bin/" "$STATICPERL/bin"
257 408 ln -sf "perl/lib/" "$STATICPERL/lib"
409
410 mkdir "$STATICPERL/patched"
411
412 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
413 rm -rf "$PERL_PREFIX" # by this rm -rf
414
415 rcd "$STATICPERL/src/perl"
416
258 make install || fatal "make install: error while installing" 417 "$MAKE" install || fatal "make install: error while installing"
259 418
260 rcd "$PREFIX" 419 rcd "$PERL_PREFIX"
261 420
262 # create a "make install" replacement for CPAN 421 # create a "make install" replacement for CPAN
263 cat >"$PREFIX"/bin/cpan-make-install <<EOF 422 write_shellscript SP-make-make <<'end_of_make'
264make install UNINST=1 423#CAT make-make.sh
265if find blib/arch/auto -type f | grep -q -v .exists; then 424end_of_make
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
273 chmod 755 "$PREFIX"/bin/cpan-make-install
274 425
426 # create a "make install" replacement for CPAN
427 write_shellscript SP-make-install-make <<'end_of_make_install_make'
428#CAT make-install-make.sh
429end_of_make_install_make
430
431 # create a "patch modules" helper
432 write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall'
433#CAT patch-postinstall.sh
434end_of_patch_postinstall
435
436 # immediately use it
437 "$PERL_PREFIX/bin/SP-patch-postinstall"
438
275 # trick CPAN into avoiding ~/.cpan completely 439 # help to trick CPAN into avoiding ~/.cpan completely
276 echo 1 >"$PREFIX/lib/CPAN/MyConfig.pm" 440 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
277 441
278 "$PREFIX"/bin/perl -MCPAN -e ' 442 # we call cpan with -MCPAN::MyConfig in this script, which
443 # is strictly unnecessary as we have to patch CPAN anyway,
444 # so consider it "for good measure".
445 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
279 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 446 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
447 CPAN::Shell->o (conf => pushy_https => "0");
280 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 448 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
281 CPAN::Shell->o (conf => q<init>); 449 CPAN::Shell->o (conf => q<init>);
282 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 450 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
283 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 451 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
284 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 452 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
285 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 453 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
286 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 454 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
455 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
456 CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make");
287 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PREFIX"'/bin/cpan-make-install"); 457 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>); 458 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
289 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 459 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
460 CPAN::Shell->o (conf => q<recommends_policy>, q<0>);
461 CPAN::Shell->o (conf => q<suggests_policy>, q<0>);
462 CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>);
290 CPAN::Shell->o (conf => q<commit>); 463 CPAN::Shell->o (conf => q<commit>);
291 ' || fatal "error while initialising CPAN" 464 ' || fatal "error while initialising CPAN"
292 465
293 NOCHECK_INSTALL=+ 466 postcpanconfig
294 instcpan $STATICPERL_MODULES
295 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
296 467
297 postinstall || fatal "postinstall hook failed"
298
299 touch "$PREFIX/staticstamp.install" 468 : > "$PERL_PREFIX/staticstamp.install"
469 fi
470
471 _postinstall
472) || exit
473}
474
475import() {
476(
477 IMPORT="$1"
478
479 rcd "$STATICPERL"
480
481 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
482 verblock <<EOF
483import perl from $IMPORT to $STATICPERL
484EOF
485
486 rm -rf bin cpan lib patched perl src
487 mkdir -m 755 perl perl/bin
488 ln -s perl/bin/ bin
489 ln -s "$IMPORT" perl/bin/
490
491 echo "$IMPORT" > "$PERL_PREFIX/.import"
492
493 : > "$PERL_PREFIX/staticstamp.install"
494 fi
495
496 _postinstall
497) || exit
300} 498}
301 499
302############################################################################# 500#############################################################################
303# install a module from CPAN 501# install a module from CPAN
304 502
305instcpan() { 503instcpan() {
306 [ $NOCHECK_INSTALL ] || install 504 [ $NOCHECK_INSTALL ] || install
307 505
308 verblock <<EOF 506 verblock <<EOF
309installing modules from CPAN 507installing modules from CPAN
310$@ 508$*
311EOF 509EOF
312 510
313 for mod in "$@"; do 511 MYCONFIG=
314 "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 512 [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
315 || fatal "$mod: unable to install from CPAN" 513
316 done 514 "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
515
516 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
517 fatal "failure while installing modules from CPAN ($*)"
518 fi
317 rm -rf "$STATICPERL/build" 519 rm -f "$STATICPERL/instcpan.log"
318} 520}
319 521
320############################################################################# 522#############################################################################
321# install a module from unpacked sources 523# install a module from unpacked sources
322 524
323instsrc() { 525instsrc() {
324 [ $NOCHECK_INSTALL ] || install 526 [ $NOCHECK_INSTALL ] || install
325 527
326 verblock <<EOF 528 verblock <<EOF
327installing modules from source 529installing modules from source
328$@ 530$*
329EOF 531EOF
330 532
331 for mod in "$@"; do 533 for mod in "$@"; do
332 echo 534 echo
333 echo $mod 535 echo $mod
334 ( 536 (
335 rcd $mod 537 rcd $mod
336 make -f Makefile.aperl map_clean >/dev/null 2>&1 538 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
337 make distclean >/dev/null 2>&1 539 "$MAKE" distclean >/dev/null 2>&1
338 "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 540 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
339 make || fatal "$mod: error building module" 541 "$MAKE" || fatal "$mod: error building module"
340 "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 542 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
341 make distclean >/dev/null 2>&1 543 "$MAKE" distclean >/dev/null 2>&1
342 exit 0 544 exit 0
343 ) || exit $? 545 ) || exit $?
344 done 546 done
345} 547}
346 548
347############################################################################# 549#############################################################################
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 550# main
375 551
376podusage() { 552podusage() {
377 echo 553 echo
554
378 if [ -e "$PREFIX/bin/perl" ]; then 555 if [ -e "$PERL_PREFIX/bin/perl" ]; then
379 "$PREFIX/bin/perl" -MPod::Usage -e \ 556 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
380 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 557 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
381 2>/dev/null && exit 558 2>/dev/null && exit
382 fi 559 fi
560
383 # try whatever perl we can find 561 # try whatever perl we can find
384 perl -MPod::Usage -e \ 562 perl -MPod::Usage -e \
385 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 563 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
386 2>/dev/null && exit 564 2>/dev/null && exit
387 565
388 fatal "displaying documentation requires a working perl - try '$0 install' first" 566 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
389} 567}
390 568
391usage() { 569usage() {
392 podusage 0 570 podusage 0
393} 571}
394 572
395catmkbundle() { 573catmkbundle() {
396 { 574 {
397 read dummy 575 read dummy
398 echo "#!$PREFIX/bin/perl" 576 echo "#!$PERL_PREFIX/bin/perl"
399 cat 577 cat
400 } <<'MKBUNDLE' 578 } <<'end_of_mkbundle'
401#CAT mkbundle 579#CAT mkbundle
402MKBUNDLE 580end_of_mkbundle
403} 581}
404 582
405bundle() { 583bundle() {
584 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
406 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 585 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
407 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 586 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
587 CACHE="$STATICPERL/cache"
588 mkdir -p "$CACHE"
408 "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 589 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
409} 590}
410 591
411if [ $# -gt 0 ]; then 592if [ $# -gt 0 ]; then
412 while [ $# -gt 0 ]; do 593 while [ $# -gt 0 ]; do
413 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 594 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
414 mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" 595 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
415 596
416 command="${1#--}"; shift 597 command="${1#--}"; shift
417 case "$command" in 598 case "$command" in
599 version )
600 echo "staticperl version $VERSION"
601 ;;
418 fetch | configure | build | install | clean | distclean) 602 fetch | configure | build | install | clean | realclean | distclean )
419 verblock <<EOF
420$command
421EOF
422 "$command" 603 ( "$command" ) || exit
604 ;;
605 import )
606 ( import "$1" ) || exit
607 shift
423 ;; 608 ;;
424 instsrc ) 609 instsrc )
425 instsrc "$@" 610 ( instsrc "$@" ) || exit
426 exit 611 exit
427 ;; 612 ;;
428 instcpan ) 613 instcpan )
429 instcpan "$@" 614 ( instcpan "$@" ) || exit
430 exit 615 exit
431 ;; 616 ;;
432 instschmorp ) 617 perl )
433 install_schmorp 618 ( install ) || exit
619 exec "$PERL_PREFIX/bin/perl" "$@"
620 exit
434 ;; 621 ;;
435 cpan ) 622 cpan )
436 install 623 ( install ) || exit
624 PERL="$PERL_PREFIX/bin/perl"
625 export PERL
437 "$PREFIX/bin/cpan" "$@" 626 exec "$PERL_PREFIX/bin/cpan" "$@"
438 exit 627 exit
439 ;; 628 ;;
440 mkbundle ) 629 mkbundle )
441 install 630 ( install ) || exit
442 bundle "$@" 631 bundle "$@"
443 exit 632 exit
444 ;; 633 ;;
445 mkperl ) 634 mkperl )
446 install 635 ( install ) || exit
447 bundle --perl "$@" 636 bundle --perl "$@"
637 exit
638 ;;
639 mkapp )
640 ( install ) || exit
641 bundle --app "$@"
448 exit 642 exit
449 ;; 643 ;;
450 help ) 644 help )
451 podusage 2 645 podusage 2
452 ;; 646 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines