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_CFLASGS" |
|
|
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.44" |
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() { |
139 | rcd "$STATICPERL" |
151 | rcd "$STATICPERL" |
140 | |
152 | |
141 | mkdir -p src |
153 | mkdir -p src |
142 | rcd src |
154 | rcd src |
143 | |
155 | |
144 | if ! [ -d "perl-$PERL_VERSION" ]; then |
156 | if ! [ -d "perl" ]; then |
145 | if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then |
157 | rm -rf unpack |
|
|
158 | mkdir -p unpack |
146 | |
159 | |
|
|
160 | case "$PERL_VERSION" in |
|
|
161 | *:* ) |
|
|
162 | # url |
|
|
163 | PERLURL="$PERL_VERSION" |
|
|
164 | PERLTAR="$(basename "$PERL_VERSION")" |
|
|
165 | ;; |
|
|
166 | /* ) |
|
|
167 | # directory |
|
|
168 | verbose "copying $PERL_VERSION" |
|
|
169 | cp -Rp "$PERL_VERSION/." unpack/. |
|
|
170 | chmod -R u+w unpack |
|
|
171 | mv unpack perl |
|
|
172 | return |
|
|
173 | ;; |
|
|
174 | * ) |
147 | URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" |
175 | PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2" |
|
|
176 | PERLTAR=perl-$PERL_VERSION.tar.bz2 |
|
|
177 | ;; |
|
|
178 | esac |
148 | |
179 | |
|
|
180 | if ! [ -e "$PERLTAR" ]; then |
149 | verblock <<EOF |
181 | verblock <<EOF |
150 | downloading perl |
182 | downloading perl |
|
|
183 | |
|
|
184 | trying to download from $PERLURL |
|
|
185 | |
|
|
186 | you can configure a download cache directory via DLCACHE |
|
|
187 | in your .staticperlrc to avoid repeated downloads. |
|
|
188 | |
151 | to manually download perl yourself, place |
189 | to manually download perl yourself, place a suitable tarball in |
152 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
190 | $DLCACHE/$PERLTAR |
153 | trying $URL |
|
|
154 | EOF |
|
|
155 | |
191 | |
|
|
192 | either curl or wget is required for automatic download. |
|
|
193 | curl is tried first, then wget. |
|
|
194 | EOF |
|
|
195 | |
156 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
196 | rm -f $PERLTAR~ # just to be on the safe side |
157 | curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
197 | { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
158 | || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
198 | || wget -O $PERLTAR~ "$PERLURL" \ |
|
|
199 | || curl -f >$PERLTAR~ "$PERLURL" \ |
159 | || fatal "$URL: unable to download" |
200 | || fatal "$URL: unable to download" |
160 | rm -f perl-$PERL_VERSION.tar.$BZ2 |
201 | rm -f $PERLTAR |
161 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
202 | mv $PERLTAR~ $PERLTAR |
|
|
203 | if [ "$DLCACHE" ]; then |
|
|
204 | mkdir -p "$DLCACHE" |
|
|
205 | cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \ |
|
|
206 | mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR |
|
|
207 | fi |
162 | fi |
208 | fi |
163 | |
209 | |
164 | verblock <<EOF |
210 | verblock <<EOF |
165 | unpacking perl |
211 | unpacking perl |
166 | EOF |
212 | EOF |
167 | |
213 | |
168 | mkdir -p unpack |
214 | case "$PERLTAR" in |
169 | rm -rf unpack/perl-$PERL_VERSION |
215 | *.xz ) UNCOMPRESS="xz -d" ;; |
170 | $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | tar xfC - unpack \ |
216 | *.lzma ) UNCOMPRESS="lzma -d" ;; |
|
|
217 | *.bz2 ) UNCOMPRESS="bzip2 -d" ;; |
|
|
218 | *.gz ) UNCOMPRESS="gzip -d" ;; |
|
|
219 | *.tar ) UNCOMPRESS="cat" ;; |
|
|
220 | * ) |
|
|
221 | fatal "don't know hot to uncompress $PERL_TAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported." |
|
|
222 | exit 1 |
|
|
223 | ;; |
|
|
224 | esac |
|
|
225 | |
|
|
226 | <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \ |
171 | || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" |
227 | || fatal "$PERLTAR: error during unpacking" |
172 | chmod -R u+w unpack/perl-$PERL_VERSION |
228 | |
173 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
229 | if [ -d unpack/*/ ]; then |
|
|
230 | chmod -R u+w unpack/*/ |
|
|
231 | mv unpack/*/ perl |
174 | rmdir -p unpack |
232 | rmdir -p unpack |
|
|
233 | else |
|
|
234 | fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this" |
|
|
235 | fi |
|
|
236 | |
|
|
237 | rm "$PERLTAR" |
175 | fi |
238 | fi |
176 | } |
239 | } |
177 | |
240 | |
178 | # similar to GNU-sed -i or perl -pi |
241 | # similar to GNU-sed -i or perl -pi |
179 | sedreplace() { |
242 | sedreplace() { |
… | |
… | |
209 | } |
272 | } |
210 | |
273 | |
211 | configure() { |
274 | configure() { |
212 | fetch |
275 | fetch |
213 | |
276 | |
214 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
277 | rcd "$STATICPERL/src/perl" |
215 | |
278 | |
216 | [ -e staticstamp.configure ] && return |
279 | [ -e staticstamp.configure ] && return |
217 | |
280 | |
218 | verblock <<EOF |
281 | verblock <<EOF |
219 | configuring $STATICPERL/src/perl-$PERL_VERSION |
282 | configuring $STATICPERL/src/perl |
220 | EOF |
283 | EOF |
221 | |
284 | |
222 | rm -f "$PERL_PREFIX/staticstamp.install" |
285 | rm -f "$PERL_PREFIX/staticstamp.install" |
223 | |
286 | |
224 | "$MAKE" distclean >/dev/null 2>&1 |
287 | "$MAKE" distclean >/dev/null 2>&1 |
… | |
… | |
227 | |
290 | |
228 | # I hate them for this |
291 | # I hate them for this |
229 | grep -q -- -fstack-protector Configure && \ |
292 | grep -q -- -fstack-protector Configure && \ |
230 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
293 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
231 | |
294 | |
232 | preconfigure |
295 | # what did that bloke think |
|
|
296 | grep -q -- usedl=.define hints/darwin.sh && \ |
|
|
297 | sedreplace '/^usedl=.define.;$/d' hints/darwin.sh |
|
|
298 | |
|
|
299 | preconfigure || fatal "preconfigure hook failed" |
233 | |
300 | |
234 | # trace configure \ |
301 | # trace configure \ |
235 | sh Configure -Duselargefiles \ |
302 | sh Configure -Duselargefiles \ |
236 | -Uuse64bitint \ |
303 | -Uuse64bitint \ |
237 | -Dusemymalloc=n \ |
304 | -Dusemymalloc=n \ |
… | |
… | |
262 | -Demail="$EMAIL" \ |
329 | -Demail="$EMAIL" \ |
263 | -Dcf_email="$EMAIL" \ |
330 | -Dcf_email="$EMAIL" \ |
264 | -Dcf_by="$EMAIL" \ |
331 | -Dcf_by="$EMAIL" \ |
265 | $PERL_CONFIGURE \ |
332 | $PERL_CONFIGURE \ |
266 | -Duseperlio \ |
333 | -Duseperlio \ |
|
|
334 | -Uversiononly \ |
267 | -dE || configure_failure |
335 | -dE || configure_failure |
268 | |
336 | |
269 | sedreplace ' |
337 | sedreplace ' |
270 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
338 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
271 | s/ *-fno-stack-protector */ /g |
339 | s/ *-fno-stack-protector */ /g |
272 | ' config.sh |
340 | ' config.sh |
273 | |
341 | |
|
|
342 | patchconfig || fatal "patchconfig hook failed" |
|
|
343 | |
274 | sh Configure -S || fatal "Configure -S failed" |
344 | sh Configure -S || fatal "Configure -S failed" |
275 | |
345 | |
276 | postconfigure || fatal "postconfigure hook failed" |
346 | postconfigure || fatal "postconfigure hook failed" |
277 | |
347 | |
278 | touch staticstamp.configure |
348 | : > staticstamp.configure |
|
|
349 | } |
|
|
350 | |
|
|
351 | write_shellscript() { |
|
|
352 | { |
|
|
353 | echo "#!/bin/sh" |
|
|
354 | echo "STATICPERL=\"$STATICPERL\"" |
|
|
355 | echo "PERL_PREFIX=\"$PERL_PREFIX\"" |
|
|
356 | echo "MAKE=\"$MAKE\"" |
|
|
357 | cat |
|
|
358 | } >"$PERL_PREFIX/bin/$1" |
|
|
359 | chmod 755 "$PERL_PREFIX/bin/$1" |
279 | } |
360 | } |
280 | |
361 | |
281 | build() { |
362 | build() { |
282 | configure |
363 | configure |
283 | |
364 | |
284 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
365 | rcd "$STATICPERL/src/perl" |
285 | |
366 | |
286 | verblock <<EOF |
367 | verblock <<EOF |
287 | building $STATICPERL/src/perl-$PERL_VERSION |
368 | building $STATICPERL/src/perl |
288 | EOF |
369 | EOF |
289 | |
370 | |
290 | rm -f "$PERL_PREFIX/staticstamp.install" |
371 | rm -f "$PERL_PREFIX/staticstamp.install" |
291 | |
372 | |
292 | "$MAKE" || fatal "make: error while building perl" |
373 | "$MAKE" || fatal "make: error while building perl" |
293 | |
374 | |
294 | postbuild || fatal "postbuild hook failed" |
375 | postbuild || fatal "postbuild hook failed" |
|
|
376 | } |
|
|
377 | |
|
|
378 | _postinstall() { |
|
|
379 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
|
|
380 | NOCHECK_INSTALL=+ |
|
|
381 | instcpan $STATICPERL_MODULES |
|
|
382 | [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES |
|
|
383 | |
|
|
384 | postinstall || fatal "postinstall hook failed" |
|
|
385 | |
|
|
386 | : > "$PERL_PREFIX/staticstamp.postinstall" |
|
|
387 | fi |
295 | } |
388 | } |
296 | |
389 | |
297 | install() { |
390 | install() { |
298 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
391 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
299 | build |
392 | build |
300 | |
393 | |
301 | verblock <<EOF |
394 | verblock <<EOF |
302 | installing $STATICPERL/src/perl-$PERL_VERSION |
395 | installing $STATICPERL/src/perl |
303 | to $PERL_PREFIX |
396 | to $PERL_PREFIX |
304 | EOF |
397 | EOF |
305 | |
398 | |
306 | ln -sf "perl/bin/" "$STATICPERL/bin" |
399 | ln -sf "perl/bin/" "$STATICPERL/bin" |
307 | ln -sf "perl/lib/" "$STATICPERL/lib" |
400 | ln -sf "perl/lib/" "$STATICPERL/lib" |
308 | |
401 | |
|
|
402 | mkdir "$STATICPERL/patched" |
|
|
403 | |
309 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
404 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
310 | rm -rf "$PERL_PREFIX" # by this rm -rf |
405 | rm -rf "$PERL_PREFIX" # by this rm -rf |
311 | |
406 | |
312 | "$MAKE" install || fatal "make install: error while installing" |
407 | "$MAKE" install || fatal "make install: error while installing" |
313 | |
408 | |
314 | rcd "$PERL_PREFIX" |
409 | rcd "$PERL_PREFIX" |
315 | |
410 | |
316 | # create a "make install" replacement for CPAN |
411 | # create a "make install" replacement for CPAN |
317 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
412 | write_shellscript SP-make-install-make <<'EOF' |
318 | "$MAKE" || exit |
413 | #CAT make-install-make.sh |
319 | |
|
|
320 | if find blib/arch/auto -type f | grep -q -v .exists; then |
|
|
321 | echo Probably an XS module, rebuilding perl |
|
|
322 | if "$MAKE" perl; then |
|
|
323 | mv perl "$PERL_PREFIX"/bin/perl~ \ |
|
|
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 | |
|
|
333 | "$MAKE" install UNINST=1 |
|
|
334 | EOF |
414 | EOF |
335 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
|
|
336 | |
415 | |
|
|
416 | # create a "patch modules" helper |
|
|
417 | write_shellscript SP-patch-postinstall <<'EOF' |
|
|
418 | #CAT patch-postinstall.sh |
|
|
419 | EOF |
|
|
420 | |
|
|
421 | # immediately use it |
|
|
422 | "$PERL_PREFIX/bin/SP-patch-postinstall" |
|
|
423 | |
337 | # trick CPAN into avoiding ~/.cpan completely |
424 | # help to trick CPAN into avoiding ~/.cpan completely |
338 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
425 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
339 | |
426 | |
|
|
427 | # we call cpan with -MCPAN::MyConfig in this script, which |
|
|
428 | # is strictly unnecssary as we have to patch CPAN anyway, |
|
|
429 | # so consider it "for good measure". |
340 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
430 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
341 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
431 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
342 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
432 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
343 | CPAN::Shell->o (conf => q<init>); |
433 | CPAN::Shell->o (conf => q<init>); |
344 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
434 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
345 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
435 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
346 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
436 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
347 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
437 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
348 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
438 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
|
|
439 | CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl"); |
349 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
440 | 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>); |
441 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
351 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
442 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>); |
|
|
443 | CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); |
352 | CPAN::Shell->o (conf => q<commit>); |
444 | CPAN::Shell->o (conf => q<commit>); |
353 | ' || fatal "error while initialising CPAN" |
445 | ' || fatal "error while initialising CPAN" |
354 | |
446 | |
355 | touch "$PERL_PREFIX/staticstamp.install" |
447 | : > "$PERL_PREFIX/staticstamp.install" |
356 | fi |
448 | fi |
357 | |
449 | |
|
|
450 | _postinstall |
|
|
451 | } |
|
|
452 | |
|
|
453 | import() { |
|
|
454 | IMPORT="$1" |
|
|
455 | |
|
|
456 | rcd "$STATICPERL" |
|
|
457 | |
358 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
458 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
359 | NOCHECK_INSTALL=+ |
459 | verblock <<EOF |
360 | instcpan $STATICPERL_MODULES |
460 | import perl from $IMPORT to $STATICPERL |
361 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
461 | EOF |
362 | |
462 | |
363 | postinstall || fatal "postinstall hook failed" |
463 | rm -rf bin cpan lib patched perl src |
|
|
464 | mkdir -m 755 perl perl/bin |
|
|
465 | ln -s perl/bin/ bin |
|
|
466 | ln -s "$IMPORT" perl/bin/ |
364 | |
467 | |
|
|
468 | echo "$IMPORT" > "$PERL_PREFIX/.import" |
|
|
469 | |
365 | touch "$PERL_PREFIX/staticstamp.postinstall" |
470 | : > "$PERL_PREFIX/staticstamp.install" |
366 | fi |
471 | fi |
|
|
472 | |
|
|
473 | _postinstall |
367 | } |
474 | } |
368 | |
475 | |
369 | ############################################################################# |
476 | ############################################################################# |
370 | # install a module from CPAN |
477 | # install a module from CPAN |
371 | |
478 | |
… | |
… | |
375 | verblock <<EOF |
482 | verblock <<EOF |
376 | installing modules from CPAN |
483 | installing modules from CPAN |
377 | $@ |
484 | $@ |
378 | EOF |
485 | EOF |
379 | |
486 | |
380 | for mod in "$@"; do |
487 | MYCONFIG= |
381 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
488 | [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig |
382 | || fatal "$mod: unable to install from CPAN" |
489 | |
383 | done |
490 | "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
|
|
491 | |
|
|
492 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
|
|
493 | fatal "failure while installing modules from CPAN ($@)" |
|
|
494 | fi |
384 | rm -rf "$STATICPERL/build" |
495 | rm -f "$STATICPERL/instcpan.log" |
385 | } |
496 | } |
386 | |
497 | |
387 | ############################################################################# |
498 | ############################################################################# |
388 | # install a module from unpacked sources |
499 | # install a module from unpacked sources |
389 | |
500 | |
… | |
… | |
402 | rcd $mod |
513 | rcd $mod |
403 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
514 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
404 | "$MAKE" distclean >/dev/null 2>&1 |
515 | "$MAKE" distclean >/dev/null 2>&1 |
405 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
516 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
406 | "$MAKE" || fatal "$mod: error building module" |
517 | "$MAKE" || fatal "$mod: error building module" |
407 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
518 | "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
408 | "$MAKE" distclean >/dev/null 2>&1 |
519 | "$MAKE" distclean >/dev/null 2>&1 |
409 | exit 0 |
520 | exit 0 |
410 | ) || exit $? |
521 | ) || exit $? |
411 | done |
522 | done |
412 | } |
523 | } |
… | |
… | |
444 | #CAT mkbundle |
555 | #CAT mkbundle |
445 | MKBUNDLE |
556 | MKBUNDLE |
446 | } |
557 | } |
447 | |
558 | |
448 | bundle() { |
559 | bundle() { |
|
|
560 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
449 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
561 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
450 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
562 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
451 | CACHE="$STATICPERL/cache" |
563 | CACHE="$STATICPERL/cache" |
452 | mkdir -p "$CACHE" |
564 | mkdir -p "$CACHE" |
453 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
565 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
… | |
… | |
461 | command="${1#--}"; shift |
573 | command="${1#--}"; shift |
462 | case "$command" in |
574 | case "$command" in |
463 | version ) |
575 | version ) |
464 | echo "staticperl version $VERSION" |
576 | echo "staticperl version $VERSION" |
465 | ;; |
577 | ;; |
466 | fetch | configure | build | install | clean | realclean | distclean) |
578 | fetch | configure | build | install | clean | realclean | distclean ) |
467 | ( "$command" ) || exit |
579 | ( "$command" ) || exit |
|
|
580 | ;; |
|
|
581 | import ) |
|
|
582 | ( import "$1" ) || exit |
|
|
583 | shift |
468 | ;; |
584 | ;; |
469 | instsrc ) |
585 | instsrc ) |
470 | ( instsrc "$@" ) || exit |
586 | ( instsrc "$@" ) || exit |
471 | exit |
587 | exit |
472 | ;; |
588 | ;; |
473 | instcpan ) |
589 | instcpan ) |
474 | ( instcpan "$@" ) || exit |
590 | ( instcpan "$@" ) || exit |
475 | exit |
591 | exit |
476 | ;; |
592 | ;; |
|
|
593 | perl ) |
|
|
594 | ( install ) || exit |
|
|
595 | exec "$PERL_PREFIX/bin/perl" "$@" |
|
|
596 | exit |
|
|
597 | ;; |
477 | cpan ) |
598 | cpan ) |
478 | ( install ) || exit |
599 | ( install ) || exit |
|
|
600 | PERL="$PERL_PREFIX/bin/perl" |
|
|
601 | export PERL |
479 | "$PERL_PREFIX/bin/cpan" "$@" |
602 | exec "$PERL_PREFIX/bin/cpan" "$@" |
480 | exit |
603 | exit |
481 | ;; |
604 | ;; |
482 | mkbundle ) |
605 | mkbundle ) |
483 | ( install ) || exit |
606 | ( install ) || exit |
484 | bundle "$@" |
607 | bundle "$@" |