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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines