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 | |
6 | STATICPERL=~/.staticperl |
6 | STATICPERL=~/.staticperl |
7 | CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
7 | CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
8 | EMAIL="read the documentation <rtfm@example.org>" |
8 | EMAIL="read the documentation <rtfm@example.org>" |
|
|
9 | DLCACHE= |
9 | |
10 | |
10 | # perl build variables |
11 | # perl build variables |
11 | MAKE=make |
12 | MAKE=make |
12 | PERL_VERSION=5.12.3 # 5.8.9 is also a good choice |
13 | PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds |
13 | PERL_CC=cc |
14 | PERL_CC=cc |
14 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
16 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
16 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | |
18 | |
18 | ARCH="$(uname -m)" |
19 | ARCH="$(uname -m)" |
19 | |
20 | |
20 | case "$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 | # ;; |
29 | esac |
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 | # --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
34 | # --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
34 | PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
35 | #PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
|
|
36 | PERL_LDFLAGS= |
35 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
36 | |
38 | |
37 | # some configuration options for modules |
39 | # some configuration options for modules |
38 | PERL_MM_USE_DEFAULT=1 |
40 | PERL_MM_USE_DEFAULT=1 |
|
|
41 | PERL_MM_OPT="MAN1PODS= MAN3PODS=" |
39 | #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 |
40 | 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' |
41 | export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS |
44 | export 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 |
45 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
48 | STATICPERL_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 |
48 | EXTRA_MODULES="" |
51 | EXTRA_MODULES="" |
49 | |
52 | |
50 | # overridable functions |
53 | # overridable functions |
51 | preconfigure() { : ; } |
54 | preconfigure() { : ; } |
|
|
55 | patchconfig() { : ; } |
52 | postconfigure() { : ; } |
56 | postconfigure() { : ; } |
53 | postbuild() { : ; } |
57 | postbuild() { : ; } |
54 | postinstall() { : ; } |
58 | postinstall() { : ; } |
55 | |
59 | |
56 | # now source user config, if any |
60 | # now source user config, if any |
… | |
… | |
63 | fi |
67 | fi |
64 | |
68 | |
65 | ############################################################################# |
69 | ############################################################################# |
66 | # support |
70 | # support |
67 | |
71 | |
68 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
72 | # work around ExtUtils::CBuilder and others |
|
|
73 | export CC="$PERL_CC" |
|
|
74 | export CFLAGS="$PERL_CFLAGS" |
|
|
75 | export LD="$PERL_CC" |
|
|
76 | export LDFLAGS="$PERL_LDFLAGS" |
|
|
77 | unset LIBS |
|
|
78 | |
69 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
79 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
70 | |
80 | |
71 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
81 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
|
|
82 | unset PERL_MB_OPT |
72 | LC_ALL=C; export LC_ALL # just to be on the safe side |
83 | LC_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" |
|
|
87 | PATH="$PERL_PREFIX/perl/bin:$PATH" |
73 | |
88 | |
74 | # set version in a way that Makefile.PL can extract |
89 | # set version in a way that Makefile.PL can extract |
75 | VERSION=VERSION; eval \ |
90 | VERSION=VERSION; eval \ |
76 | $VERSION="1.1" |
91 | $VERSION="1.45" |
77 | |
|
|
78 | BZ2=bz2 |
|
|
79 | BZIP2=bzip2 |
|
|
80 | |
92 | |
81 | fatal() { |
93 | fatal() { |
82 | printf -- "\nFATAL: %s\n\n" "$*" >&2 |
94 | printf -- "\nFATAL: %s\n\n" "$*" >&2 |
83 | exit 1 |
95 | exit 1 |
84 | } |
96 | } |
… | |
… | |
124 | |
136 | |
125 | ############################################################################# |
137 | ############################################################################# |
126 | # download/configure/compile/install perl |
138 | # download/configure/compile/install perl |
127 | |
139 | |
128 | clean() { |
140 | clean() { |
129 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
141 | rm -rf "$STATICPERL/src" |
130 | } |
142 | } |
131 | |
143 | |
132 | realclean() { |
144 | realclean() { |
133 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
145 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
134 | rm -f "$PERL_PREFIX/staticstamp.install" |
146 | rm -f "$PERL_PREFIX/staticstamp.install" |
135 | rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
147 | rm -f "$STATICPERL/src/perl/staticstamp.configure" |
136 | } |
148 | } |
137 | |
149 | |
138 | fetch() { |
150 | fetch() { |
|
|
151 | ( |
139 | rcd "$STATICPERL" |
152 | rcd "$STATICPERL" |
140 | |
153 | |
141 | mkdir -p src |
154 | mkdir -p src |
142 | rcd src |
155 | rcd src |
143 | |
156 | |
144 | if ! [ -d "perl-$PERL_VERSION" ]; then |
157 | if ! [ -d "perl" ]; then |
145 | if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then |
158 | rm -rf unpack |
|
|
159 | mkdir -p unpack |
146 | |
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 | * ) |
147 | 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 |
148 | |
180 | |
|
|
181 | if ! [ -e "$PERLTAR" ]; then |
149 | verblock <<EOF |
182 | verblock <<EOF |
150 | downloading perl |
183 | downloading perl |
|
|
184 | |
|
|
185 | trying to download from $PERLURL |
|
|
186 | |
|
|
187 | you can configure a download cache directory via DLCACHE |
|
|
188 | in your .staticperlrc to avoid repeated downloads. |
|
|
189 | |
151 | to manually download perl yourself, place |
190 | to manually download perl yourself, place a suitable tarball in |
152 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
191 | $DLCACHE/$PERLTAR |
153 | trying $URL |
|
|
154 | EOF |
|
|
155 | |
192 | |
|
|
193 | either curl or wget is required for automatic download. |
|
|
194 | curl is tried first, then wget. |
|
|
195 | EOF |
|
|
196 | |
156 | 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 |
157 | curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
198 | { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
158 | || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
199 | || wget -O $PERLTAR~ "$PERLURL" \ |
|
|
200 | || curl -f >$PERLTAR~ "$PERLURL" \ |
159 | || fatal "$URL: unable to download" |
201 | || fatal "$URL: unable to download" |
160 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
202 | rm -f $PERLTAR |
161 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
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 |
162 | fi |
209 | fi |
163 | |
210 | |
164 | verblock <<EOF |
211 | verblock <<EOF |
165 | unpacking perl |
212 | unpacking perl |
166 | EOF |
213 | EOF |
167 | |
214 | |
168 | mkdir -p unpack |
215 | case "$PERLTAR" in |
169 | rm -rf unpack/perl-$PERL_VERSION |
216 | *.xz ) UNCOMPRESS="xz -d" ;; |
170 | $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | tar xfC - unpack \ |
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 - ) \ |
171 | || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" |
228 | || fatal "$PERLTAR: error during unpacking" |
172 | chmod -R u+w unpack/perl-$PERL_VERSION |
229 | |
173 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
230 | if [ -d unpack/*/ ]; then |
|
|
231 | chmod -R u+w unpack/*/ |
|
|
232 | mv unpack/*/ perl |
174 | 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" |
175 | fi |
239 | fi |
|
|
240 | ) || exit |
176 | } |
241 | } |
177 | |
242 | |
178 | # similar to GNU-sed -i or perl -pi |
243 | # similar to GNU-sed -i or perl -pi |
179 | sedreplace() { |
244 | sedreplace() { |
180 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
245 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
… | |
… | |
207 | EOF |
272 | EOF |
208 | exit 1 |
273 | exit 1 |
209 | } |
274 | } |
210 | |
275 | |
211 | configure() { |
276 | configure() { |
|
|
277 | ( |
212 | fetch |
278 | fetch |
213 | |
279 | |
214 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
280 | rcd "$STATICPERL/src/perl" |
215 | |
281 | |
216 | [ -e staticstamp.configure ] && return |
282 | [ -e staticstamp.configure ] && return |
217 | |
283 | |
218 | verblock <<EOF |
284 | verblock <<EOF |
219 | configuring $STATICPERL/src/perl-$PERL_VERSION |
285 | configuring $STATICPERL/src/perl |
220 | EOF |
286 | EOF |
221 | |
287 | |
222 | rm -f "$PERL_PREFIX/staticstamp.install" |
288 | rm -f "$PERL_PREFIX/staticstamp.install" |
223 | |
289 | |
224 | "$MAKE" distclean >/dev/null 2>&1 |
290 | "$MAKE" distclean >/dev/null 2>&1 |
… | |
… | |
227 | |
293 | |
228 | # I hate them for this |
294 | # I hate them for this |
229 | grep -q -- -fstack-protector Configure && \ |
295 | grep -q -- -fstack-protector Configure && \ |
230 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
296 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
231 | |
297 | |
232 | 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" |
233 | |
303 | |
234 | # trace configure \ |
304 | # trace configure \ |
235 | sh Configure -Duselargefiles \ |
305 | sh Configure -Duselargefiles \ |
236 | -Uuse64bitint \ |
306 | -Uuse64bitint \ |
237 | -Dusemymalloc=n \ |
307 | -Dusemymalloc=n \ |
… | |
… | |
262 | -Demail="$EMAIL" \ |
332 | -Demail="$EMAIL" \ |
263 | -Dcf_email="$EMAIL" \ |
333 | -Dcf_email="$EMAIL" \ |
264 | -Dcf_by="$EMAIL" \ |
334 | -Dcf_by="$EMAIL" \ |
265 | $PERL_CONFIGURE \ |
335 | $PERL_CONFIGURE \ |
266 | -Duseperlio \ |
336 | -Duseperlio \ |
|
|
337 | -Uversiononly \ |
267 | -dE || configure_failure |
338 | -dE || configure_failure |
268 | |
339 | |
269 | sedreplace ' |
340 | sedreplace ' |
270 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
341 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
271 | s/ *-fno-stack-protector */ /g |
342 | s/ *-fno-stack-protector */ /g |
272 | ' config.sh |
343 | ' config.sh |
273 | |
344 | |
|
|
345 | patchconfig || fatal "patchconfig hook failed" |
|
|
346 | |
274 | sh Configure -S || fatal "Configure -S failed" |
347 | sh Configure -S || fatal "Configure -S failed" |
275 | |
348 | |
276 | postconfigure || fatal "postconfigure hook failed" |
349 | postconfigure || fatal "postconfigure hook failed" |
277 | |
350 | |
278 | touch staticstamp.configure |
351 | : > staticstamp.configure |
|
|
352 | ) || exit |
|
|
353 | } |
|
|
354 | |
|
|
355 | write_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" |
279 | } |
364 | } |
280 | |
365 | |
281 | build() { |
366 | build() { |
|
|
367 | ( |
282 | configure |
368 | configure |
283 | |
369 | |
284 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
370 | rcd "$STATICPERL/src/perl" |
285 | |
371 | |
286 | verblock <<EOF |
372 | verblock <<EOF |
287 | building $STATICPERL/src/perl-$PERL_VERSION |
373 | building $STATICPERL/src/perl |
288 | EOF |
374 | EOF |
289 | |
375 | |
290 | rm -f "$PERL_PREFIX/staticstamp.install" |
376 | rm -f "$PERL_PREFIX/staticstamp.install" |
291 | |
377 | |
292 | "$MAKE" || fatal "make: error while building perl" |
378 | "$MAKE" || fatal "make: error while building perl" |
293 | |
379 | |
294 | 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 |
295 | } |
394 | } |
296 | |
395 | |
297 | install() { |
396 | install() { |
|
|
397 | ( |
298 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
398 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
299 | build |
399 | build |
300 | |
400 | |
301 | verblock <<EOF |
401 | verblock <<EOF |
302 | installing $STATICPERL/src/perl-$PERL_VERSION |
402 | installing $STATICPERL/src/perl |
303 | to $PERL_PREFIX |
403 | to $PERL_PREFIX |
304 | EOF |
404 | EOF |
305 | |
405 | |
306 | ln -sf "perl/bin/" "$STATICPERL/bin" |
406 | ln -sf "perl/bin/" "$STATICPERL/bin" |
307 | ln -sf "perl/lib/" "$STATICPERL/lib" |
407 | ln -sf "perl/lib/" "$STATICPERL/lib" |
308 | |
408 | |
|
|
409 | mkdir "$STATICPERL/patched" |
|
|
410 | |
309 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
411 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
310 | rm -rf "$PERL_PREFIX" # by this rm -rf |
412 | rm -rf "$PERL_PREFIX" # by this rm -rf |
311 | |
413 | |
|
|
414 | rcd "$STATICPERL/src/perl" |
|
|
415 | |
312 | "$MAKE" install || fatal "make install: error while installing" |
416 | "$MAKE" install || fatal "make install: error while installing" |
313 | |
417 | |
314 | rcd "$PERL_PREFIX" |
418 | rcd "$PERL_PREFIX" |
315 | |
419 | |
316 | # create a "make install" replacement for CPAN |
420 | # create a "make install" replacement for CPAN |
317 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
421 | write_shellscript SP-make-make <<'end_of_make' |
318 | "$MAKE" || exit |
422 | #CAT make-make.sh |
|
|
423 | end_of_make |
319 | |
424 | |
320 | if find blib/arch/auto -type f | grep -q -v .exists; then |
425 | # create a "make install" replacement for CPAN |
321 | echo Probably an XS module, rebuilding perl |
426 | write_shellscript SP-make-install-make <<'end_of_make_install_make' |
322 | if "$MAKE" perl; then |
427 | #CAT make-install-make.sh |
323 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
428 | end_of_make_install_make |
324 | && rm -f "$PERL_PREFIX"/bin/perl \ |
|
|
325 | && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl |
|
|
326 | "$MAKE" -f Makefile.aperl map_clean |
|
|
327 | else |
|
|
328 | "$MAKE" -f Makefile.aperl map_clean |
|
|
329 | exit 1 |
|
|
330 | fi |
|
|
331 | fi |
|
|
332 | |
429 | |
333 | "$MAKE" install UNINST=1 |
430 | # create a "patch modules" helper |
334 | EOF |
431 | write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall' |
335 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
432 | #CAT patch-postinstall.sh |
|
|
433 | end_of_patch_postinstall |
336 | |
434 | |
|
|
435 | # immediately use it |
|
|
436 | "$PERL_PREFIX/bin/SP-patch-postinstall" |
|
|
437 | |
337 | # trick CPAN into avoiding ~/.cpan completely |
438 | # help to trick CPAN into avoiding ~/.cpan completely |
338 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
439 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
339 | |
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". |
340 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
444 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
341 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
445 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
342 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
446 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
343 | CPAN::Shell->o (conf => q<init>); |
447 | CPAN::Shell->o (conf => q<init>); |
344 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
448 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
345 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
449 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
346 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
450 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
347 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
451 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
348 | 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"); |
349 | 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"); |
350 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
456 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
351 | 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<rfecommends_policy>, q<no>); |
|
|
459 | CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>); |
352 | CPAN::Shell->o (conf => q<commit>); |
460 | CPAN::Shell->o (conf => q<commit>); |
353 | ' || fatal "error while initialising CPAN" |
461 | ' || fatal "error while initialising CPAN" |
354 | |
462 | |
355 | touch "$PERL_PREFIX/staticstamp.install" |
463 | : > "$PERL_PREFIX/staticstamp.install" |
356 | fi |
464 | fi |
357 | |
465 | |
|
|
466 | _postinstall |
|
|
467 | ) || exit |
|
|
468 | } |
|
|
469 | |
|
|
470 | import() { |
|
|
471 | ( |
|
|
472 | IMPORT="$1" |
|
|
473 | |
|
|
474 | rcd "$STATICPERL" |
|
|
475 | |
358 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
476 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
359 | NOCHECK_INSTALL=+ |
477 | verblock <<EOF |
360 | instcpan $STATICPERL_MODULES |
478 | import perl from $IMPORT to $STATICPERL |
361 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
479 | EOF |
362 | |
480 | |
363 | postinstall || fatal "postinstall hook failed" |
481 | rm -rf bin cpan lib patched perl src |
|
|
482 | mkdir -m 755 perl perl/bin |
|
|
483 | ln -s perl/bin/ bin |
|
|
484 | ln -s "$IMPORT" perl/bin/ |
364 | |
485 | |
|
|
486 | echo "$IMPORT" > "$PERL_PREFIX/.import" |
|
|
487 | |
365 | touch "$PERL_PREFIX/staticstamp.postinstall" |
488 | : > "$PERL_PREFIX/staticstamp.install" |
366 | fi |
489 | fi |
|
|
490 | |
|
|
491 | _postinstall |
|
|
492 | ) || exit |
367 | } |
493 | } |
368 | |
494 | |
369 | ############################################################################# |
495 | ############################################################################# |
370 | # install a module from CPAN |
496 | # install a module from CPAN |
371 | |
497 | |
372 | instcpan() { |
498 | instcpan() { |
373 | [ $NOCHECK_INSTALL ] || install |
499 | [ $NOCHECK_INSTALL ] || install |
374 | |
500 | |
375 | verblock <<EOF |
501 | verblock <<EOF |
376 | installing modules from CPAN |
502 | installing modules from CPAN |
377 | $@ |
503 | $* |
378 | EOF |
504 | EOF |
379 | |
505 | |
380 | for mod in "$@"; do |
506 | MYCONFIG= |
381 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
507 | [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig |
382 | || fatal "$mod: unable to install from CPAN" |
508 | |
383 | done |
509 | "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
|
|
510 | |
|
|
511 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
|
|
512 | fatal "failure while installing modules from CPAN ($*)" |
|
|
513 | fi |
384 | rm -rf "$STATICPERL/build" |
514 | rm -f "$STATICPERL/instcpan.log" |
385 | } |
515 | } |
386 | |
516 | |
387 | ############################################################################# |
517 | ############################################################################# |
388 | # install a module from unpacked sources |
518 | # install a module from unpacked sources |
389 | |
519 | |
390 | instsrc() { |
520 | instsrc() { |
391 | [ $NOCHECK_INSTALL ] || install |
521 | [ $NOCHECK_INSTALL ] || install |
392 | |
522 | |
393 | verblock <<EOF |
523 | verblock <<EOF |
394 | installing modules from source |
524 | installing modules from source |
395 | $@ |
525 | $* |
396 | EOF |
526 | EOF |
397 | |
527 | |
398 | for mod in "$@"; do |
528 | for mod in "$@"; do |
399 | echo |
529 | echo |
400 | echo $mod |
530 | echo $mod |
… | |
… | |
402 | rcd $mod |
532 | rcd $mod |
403 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
533 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
404 | "$MAKE" distclean >/dev/null 2>&1 |
534 | "$MAKE" distclean >/dev/null 2>&1 |
405 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
535 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
406 | "$MAKE" || fatal "$mod: error building module" |
536 | "$MAKE" || fatal "$mod: error building module" |
407 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
537 | "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
408 | "$MAKE" distclean >/dev/null 2>&1 |
538 | "$MAKE" distclean >/dev/null 2>&1 |
409 | exit 0 |
539 | exit 0 |
410 | ) || exit $? |
540 | ) || exit $? |
411 | done |
541 | done |
412 | } |
542 | } |
… | |
… | |
438 | catmkbundle() { |
568 | catmkbundle() { |
439 | { |
569 | { |
440 | read dummy |
570 | read dummy |
441 | echo "#!$PERL_PREFIX/bin/perl" |
571 | echo "#!$PERL_PREFIX/bin/perl" |
442 | cat |
572 | cat |
443 | } <<'MKBUNDLE' |
573 | } <<'end_of_mkbundle' |
444 | #CAT mkbundle |
574 | #CAT mkbundle |
445 | MKBUNDLE |
575 | end_of_mkbundle |
446 | } |
576 | } |
447 | |
577 | |
448 | bundle() { |
578 | bundle() { |
|
|
579 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
449 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
580 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
450 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
581 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
451 | CACHE="$STATICPERL/cache" |
582 | CACHE="$STATICPERL/cache" |
452 | mkdir -p "$CACHE" |
583 | mkdir -p "$CACHE" |
453 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
584 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
… | |
… | |
461 | command="${1#--}"; shift |
592 | command="${1#--}"; shift |
462 | case "$command" in |
593 | case "$command" in |
463 | version ) |
594 | version ) |
464 | echo "staticperl version $VERSION" |
595 | echo "staticperl version $VERSION" |
465 | ;; |
596 | ;; |
466 | fetch | configure | build | install | clean | realclean | distclean) |
597 | fetch | configure | build | install | clean | realclean | distclean ) |
467 | ( "$command" ) || exit |
598 | ( "$command" ) || exit |
|
|
599 | ;; |
|
|
600 | import ) |
|
|
601 | ( import "$1" ) || exit |
|
|
602 | shift |
468 | ;; |
603 | ;; |
469 | instsrc ) |
604 | instsrc ) |
470 | ( instsrc "$@" ) || exit |
605 | ( instsrc "$@" ) || exit |
471 | exit |
606 | exit |
472 | ;; |
607 | ;; |
473 | instcpan ) |
608 | instcpan ) |
474 | ( instcpan "$@" ) || exit |
609 | ( instcpan "$@" ) || exit |
475 | exit |
610 | exit |
476 | ;; |
611 | ;; |
|
|
612 | perl ) |
|
|
613 | ( install ) || exit |
|
|
614 | exec "$PERL_PREFIX/bin/perl" "$@" |
|
|
615 | exit |
|
|
616 | ;; |
477 | cpan ) |
617 | cpan ) |
478 | ( install ) || exit |
618 | ( install ) || exit |
|
|
619 | PERL="$PERL_PREFIX/bin/perl" |
|
|
620 | export PERL |
479 | "$PERL_PREFIX/bin/cpan" "$@" |
621 | exec "$PERL_PREFIX/bin/cpan" "$@" |
480 | exit |
622 | exit |
481 | ;; |
623 | ;; |
482 | mkbundle ) |
624 | mkbundle ) |
483 | ( install ) || exit |
625 | ( install ) || exit |
484 | bundle "$@" |
626 | bundle "$@" |