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 | |
9 | DLCACHE= |
10 | |
10 | |
11 | # perl build variables |
11 | # perl build variables |
|
|
12 | MAKE=make |
12 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
13 | PERL_VERSION=5.12.4 # 5.8.9 is also a good choice |
|
|
14 | PERL_CC=cc |
13 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CONFIGURE="" # additional Configure arguments |
14 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
16 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
15 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
16 | |
18 | |
17 | ARCH="$(uname -m)" |
19 | ARCH="$(uname -m)" |
18 | |
20 | |
19 | case "$ARCH" in |
21 | case "$ARCH" in |
… | |
… | |
27 | ;; |
29 | ;; |
28 | esac |
30 | esac |
29 | |
31 | |
30 | # -Wl,--gc-sections makes it impossible to check for undefined references |
32 | # -Wl,--gc-sections makes it impossible to check for undefined references |
31 | # 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 :/ |
32 | # -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 |
33 | PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" |
35 | #PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
|
|
36 | PERL_LDFLAGS= |
34 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
35 | |
38 | |
36 | # some configuration options for modules |
39 | # some configuration options for modules |
37 | export PERL_MM_USE_DEFAULT=1 |
40 | PERL_MM_USE_DEFAULT=1 |
|
|
41 | PERL_MM_OPT="MAN1PODS= MAN3PODS=" |
38 | #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 |
39 | export 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' |
|
|
44 | export PERL_MM_USE_DEFAULT PERL_MM_OPT |
40 | |
45 | |
41 | # which extra modules to install by default from CPAN that are |
46 | # which extra modules to install by default from CPAN that are |
42 | # required by mkbundle |
47 | # required by mkbundle |
43 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
48 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
44 | |
49 | |
45 | # which extra modules you might want to install |
50 | # which extra modules you might want to install |
46 | EXTRA_MODULES="" |
51 | EXTRA_MODULES="" |
47 | |
52 | |
48 | # overridable functions |
53 | # overridable functions |
49 | preconfigure() { : ; } |
54 | preconfigure() { : ; } |
|
|
55 | patchconfig() { : ; } |
50 | postconfigure() { : ; } |
56 | postconfigure() { : ; } |
51 | postbuild() { : ; } |
57 | postbuild() { : ; } |
52 | postinstall() { : ; } |
58 | postinstall() { : ; } |
53 | |
59 | |
54 | # now source user config, if any |
60 | # now source user config, if any |
… | |
… | |
61 | fi |
67 | fi |
62 | |
68 | |
63 | ############################################################################# |
69 | ############################################################################# |
64 | # support |
70 | # support |
65 | |
71 | |
66 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
|
|
67 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
72 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
68 | |
73 | |
69 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
74 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
|
|
75 | unset PERL_MB_OPT |
70 | export LC_ALL=C # just to be on the safe side |
76 | LC_ALL=C; export LC_ALL # just to be on the safe side |
|
|
77 | |
|
|
78 | # prepend PATH - not required by staticperl itself, but might make |
|
|
79 | # life easier when working in e.g. "staticperl cpan / look" |
|
|
80 | PATH="$PERL_PREFIX/perl/bin:$PATH" |
71 | |
81 | |
72 | # set version in a way that Makefile.PL can extract |
82 | # set version in a way that Makefile.PL can extract |
73 | VERSION=VERSION; eval \ |
83 | VERSION=VERSION; eval \ |
74 | $VERSION=0.9 |
84 | $VERSION="1.31" |
75 | |
85 | |
76 | BZ2=bz2 |
86 | BZ2=bz2 |
77 | BZIP2=bzip2 |
87 | BZIP2=bzip2 |
78 | |
88 | |
79 | fatal() { |
89 | fatal() { |
… | |
… | |
122 | |
132 | |
123 | ############################################################################# |
133 | ############################################################################# |
124 | # download/configure/compile/install perl |
134 | # download/configure/compile/install perl |
125 | |
135 | |
126 | clean() { |
136 | clean() { |
127 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
137 | rm -rf "$STATICPERL/src" |
|
|
138 | } |
|
|
139 | |
|
|
140 | realclean() { |
|
|
141 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
|
|
142 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
143 | rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
128 | } |
144 | } |
129 | |
145 | |
130 | fetch() { |
146 | fetch() { |
131 | rcd "$STATICPERL" |
147 | rcd "$STATICPERL" |
132 | |
148 | |
133 | mkdir -p src |
149 | mkdir -p src |
134 | rcd src |
150 | rcd src |
135 | |
151 | |
136 | if ! [ -d "perl-$PERL_VERSION" ]; then |
152 | if ! [ -d "perl-$PERL_VERSION" ]; then |
137 | if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then |
153 | PERLTAR=perl-$PERL_VERSION.tar.$BZ2 |
138 | |
154 | |
|
|
155 | if ! [ -e $PERLTAR ]; then |
139 | URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" |
156 | URL="$CPAN/src/5.0/$PERLTAR" |
140 | |
157 | |
141 | verblock <<EOF |
158 | verblock <<EOF |
142 | downloading perl |
159 | downloading perl |
143 | to manually download perl yourself, place |
160 | to manually download perl yourself, place |
144 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
161 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
145 | trying $URL |
162 | trying $URL |
146 | EOF |
|
|
147 | |
163 | |
|
|
164 | either curl or wget is required for automatic download. |
|
|
165 | curl is tried first, then wget. |
|
|
166 | |
|
|
167 | you can configure a download cache directory via DLCACHE |
|
|
168 | in your .staticperlrc to avoid repeated downloads. |
|
|
169 | EOF |
|
|
170 | |
148 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
171 | rm -f $PERLTAR~ # just to be on the safe side |
149 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
172 | { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
150 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
173 | || wget -O $PERLTAR~ "$URL" \ |
|
|
174 | || curl -f >$PERLTAR~ "$URL" \ |
151 | || fatal "$URL: unable to download" |
175 | || fatal "$URL: unable to download" |
152 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
176 | rm -f $PERLTAR |
|
|
177 | mv $PERLTAR~ $PERLTAR |
|
|
178 | if [ "$DLCACHE" ]; then |
|
|
179 | mkdir -p "$DLCACHE" |
|
|
180 | cp $PERLTAR "$DLCACHE"/$PERLTAR~ && \ |
|
|
181 | mv "$DLCACHE"/$PERLTAR~ "$DLCACHE"/$PERLTAR |
|
|
182 | fi |
153 | fi |
183 | fi |
154 | |
184 | |
155 | verblock <<EOF |
185 | verblock <<EOF |
156 | unpacking perl |
186 | unpacking perl |
157 | EOF |
187 | EOF |
158 | |
188 | |
159 | mkdir -p unpack |
189 | mkdir -p unpack |
160 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
190 | rm -rf unpack/perl-$PERL_VERSION |
|
|
191 | $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \ |
161 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
192 | || fatal "$PERLTAR: error during unpacking" |
162 | chmod -R u+w unpack/perl-$PERL_VERSION |
193 | chmod -R u+w unpack/perl-$PERL_VERSION |
163 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
194 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
164 | rmdir -p unpack |
195 | rmdir -p unpack |
165 | fi |
196 | fi |
166 | } |
197 | } |
167 | |
198 | |
168 | # similar to GNU-sed -i or perl -pi |
199 | # similar to GNU-sed -i or perl -pi |
169 | sedreplace() { |
200 | sedreplace() { |
170 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
201 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
|
|
202 | rm -f "$2" |
171 | mv "$2~" "$2" |
203 | mv "$2~" "$2" |
|
|
204 | } |
|
|
205 | |
|
|
206 | configure_failure() { |
|
|
207 | cat <<EOF |
|
|
208 | |
|
|
209 | |
|
|
210 | *** |
|
|
211 | *** Configure failed - see above for the exact error message(s). |
|
|
212 | *** |
|
|
213 | *** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE |
|
|
214 | *** flags are not supported by your compiler. Less often, this is because |
|
|
215 | *** PERL_LIBS either contains a library not available on your system (such as |
|
|
216 | *** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl). |
|
|
217 | *** |
|
|
218 | *** You can provide your own flags by creating a ~/.staticperlrc file with |
|
|
219 | *** variable assignments. For example (these are the actual values used): |
|
|
220 | *** |
|
|
221 | |
|
|
222 | PERL_CC="$PERL_CC" |
|
|
223 | PERL_CCFLAGS="$PERL_CCFLAGS" |
|
|
224 | PERL_OPTIMIZE="$PERL_OPTIMIZE" |
|
|
225 | PERL_LDFLAGS="$PERL_LDFLAGS" |
|
|
226 | PERL_LIBS="$PERL_LIBS" |
|
|
227 | |
|
|
228 | EOF |
|
|
229 | exit 1 |
172 | } |
230 | } |
173 | |
231 | |
174 | configure() { |
232 | configure() { |
175 | fetch |
233 | fetch |
176 | |
234 | |
… | |
… | |
182 | configuring $STATICPERL/src/perl-$PERL_VERSION |
240 | configuring $STATICPERL/src/perl-$PERL_VERSION |
183 | EOF |
241 | EOF |
184 | |
242 | |
185 | rm -f "$PERL_PREFIX/staticstamp.install" |
243 | rm -f "$PERL_PREFIX/staticstamp.install" |
186 | |
244 | |
187 | make distclean >/dev/null 2>&1 |
245 | "$MAKE" distclean >/dev/null 2>&1 |
188 | |
246 | |
|
|
247 | sedreplace '/^#define SITELIB/d' config_h.SH |
|
|
248 | |
189 | # I hate them |
249 | # I hate them for this |
190 | grep -q -- -fstack-protector Configure && \ |
250 | grep -q -- -fstack-protector Configure && \ |
191 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
251 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
192 | |
252 | |
193 | preconfigure |
253 | # what did that bloke think |
|
|
254 | grep -q -- usedl=.define hints/darwin.sh && \ |
|
|
255 | sedreplace '/^usedl=.define.;$/d' hints/darwin.sh |
|
|
256 | |
|
|
257 | preconfigure || fatal "preconfigure hook failed" |
194 | |
258 | |
195 | # trace configure \ |
259 | # trace configure \ |
196 | sh Configure -Duselargefiles \ |
260 | sh Configure -Duselargefiles \ |
197 | -Uuse64bitint \ |
261 | -Uuse64bitint \ |
198 | -Dusemymalloc=n \ |
262 | -Dusemymalloc=n \ |
199 | -Uusedl \ |
263 | -Uusedl \ |
200 | -Uusethreads \ |
264 | -Uusethreads \ |
201 | -Uuseithreads \ |
265 | -Uuseithreads \ |
202 | -Uusemultiplicity \ |
266 | -Uusemultiplicity \ |
203 | -Duseperlio \ |
|
|
204 | -Uusesfio \ |
267 | -Uusesfio \ |
205 | -Uuseshrplib \ |
268 | -Uuseshrplib \ |
|
|
269 | -Uinstallusrbinperl \ |
206 | -Dcppflags="$PERL_CPPFLAGS" \ |
270 | -A ccflags=" $PERL_CCFLAGS" \ |
207 | -Dccflags="-g2 -fno-strict-aliasing" \ |
271 | -Dcc="$PERL_CC" \ |
208 | -Doptimize="$PERL_OPTIMIZE" \ |
272 | -Doptimize="$PERL_OPTIMIZE" \ |
209 | -Dldflags="$PERL_LDFLAGS" \ |
273 | -Dldflags="$PERL_LDFLAGS" \ |
210 | -Dlibs="$PERL_LIBS" \ |
274 | -Dlibs="$PERL_LIBS" \ |
211 | -Dprefix="$PERL_PREFIX" \ |
275 | -Dprefix="$PERL_PREFIX" \ |
212 | -Dbin="$PERL_PREFIX/bin" \ |
276 | -Dbin="$PERL_PREFIX/bin" \ |
213 | -Dprivlib="$PERL_PREFIX/lib" \ |
277 | -Dprivlib="$PERL_PREFIX/lib" \ |
214 | -Darchlib="$PERL_PREFIX/lib" \ |
278 | -Darchlib="$PERL_PREFIX/lib" \ |
215 | -Uusevendorprefix \ |
279 | -Uusevendorprefix \ |
216 | -Dsitelib="$PERL_PREFIX/lib" \ |
280 | -Dsitelib="$PERL_PREFIX/lib" \ |
217 | -Dsitearch="$PERL_PREFIX/lib" \ |
281 | -Dsitearch="$PERL_PREFIX/lib" \ |
218 | -Usitelibexp \ |
|
|
219 | -Uman1dir \ |
282 | -Uman1dir \ |
220 | -Uman3dir \ |
283 | -Uman3dir \ |
221 | -Usiteman1dir \ |
284 | -Usiteman1dir \ |
222 | -Usiteman3dir \ |
285 | -Usiteman3dir \ |
223 | -Dpager=/usr/bin/less \ |
286 | -Dpager=/usr/bin/less \ |
224 | -Demail="$EMAIL" \ |
287 | -Demail="$EMAIL" \ |
225 | -Dcf_email="$EMAIL" \ |
288 | -Dcf_email="$EMAIL" \ |
226 | -Dcf_by="$EMAIL" \ |
289 | -Dcf_by="$EMAIL" \ |
227 | $PERL_CONFIGURE \ |
290 | $PERL_CONFIGURE \ |
|
|
291 | -Duseperlio \ |
228 | -dE || fatal "Configure failed" |
292 | -dE || configure_failure |
229 | |
293 | |
230 | sedreplace ' |
294 | sedreplace ' |
231 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
295 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
232 | s/ *-fno-stack-protector */ /g |
296 | s/ *-fno-stack-protector */ /g |
233 | ' config.sh |
297 | ' config.sh |
234 | |
298 | |
|
|
299 | patchconfig || fatal "patchconfig hook failed" |
|
|
300 | |
235 | sh Configure -S || fatal "Configure -S failed" |
301 | sh Configure -S || fatal "Configure -S failed" |
236 | |
302 | |
237 | postconfigure || fatal "postconfigure hook failed" |
303 | postconfigure || fatal "postconfigure hook failed" |
238 | |
304 | |
239 | touch staticstamp.configure |
305 | : > staticstamp.configure |
|
|
306 | } |
|
|
307 | |
|
|
308 | write_shellscript() { |
|
|
309 | { |
|
|
310 | echo "#!/bin/sh" |
|
|
311 | echo "STATICPERL=\"$STATICPERL\"" |
|
|
312 | echo "PERL_PREFIX=\"$PERL_PREFIX\"" |
|
|
313 | echo "MAKE=\"$MAKE\"" |
|
|
314 | cat |
|
|
315 | } >"$PERL_PREFIX/bin/$1" |
|
|
316 | chmod 755 "$PERL_PREFIX/bin/$1" |
240 | } |
317 | } |
241 | |
318 | |
242 | build() { |
319 | build() { |
243 | configure |
320 | configure |
244 | |
321 | |
… | |
… | |
248 | building $STATICPERL/src/perl-$PERL_VERSION |
325 | building $STATICPERL/src/perl-$PERL_VERSION |
249 | EOF |
326 | EOF |
250 | |
327 | |
251 | rm -f "$PERL_PREFIX/staticstamp.install" |
328 | rm -f "$PERL_PREFIX/staticstamp.install" |
252 | |
329 | |
253 | make || fatal "make: error while building perl" |
330 | "$MAKE" || fatal "make: error while building perl" |
254 | |
331 | |
255 | postbuild || fatal "postbuild hook failed" |
332 | postbuild || fatal "postbuild hook failed" |
|
|
333 | } |
|
|
334 | |
|
|
335 | _postinstall() { |
|
|
336 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
|
|
337 | NOCHECK_INSTALL=+ |
|
|
338 | instcpan $STATICPERL_MODULES |
|
|
339 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
|
|
340 | |
|
|
341 | postinstall || fatal "postinstall hook failed" |
|
|
342 | |
|
|
343 | : > "$PERL_PREFIX/staticstamp.postinstall" |
|
|
344 | fi |
256 | } |
345 | } |
257 | |
346 | |
258 | install() { |
347 | install() { |
259 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
348 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
260 | build |
349 | build |
… | |
… | |
265 | EOF |
354 | EOF |
266 | |
355 | |
267 | ln -sf "perl/bin/" "$STATICPERL/bin" |
356 | ln -sf "perl/bin/" "$STATICPERL/bin" |
268 | ln -sf "perl/lib/" "$STATICPERL/lib" |
357 | ln -sf "perl/lib/" "$STATICPERL/lib" |
269 | |
358 | |
|
|
359 | mkdir "$STATICPERL/patched" |
|
|
360 | |
270 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
361 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
271 | rm -rf "$PERL_PREFIX" # by this rm -rf |
362 | rm -rf "$PERL_PREFIX" # by this rm -rf |
272 | |
363 | |
273 | make install || fatal "make install: error while installing" |
364 | "$MAKE" install || fatal "make install: error while installing" |
274 | |
365 | |
275 | rcd "$PERL_PREFIX" |
366 | rcd "$PERL_PREFIX" |
276 | |
367 | |
277 | # create a "make install" replacement for CPAN |
368 | # create a "make install" replacement for CPAN |
278 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
369 | write_shellscript SP-make-install-make <<'EOF' |
279 | make || exit |
370 | #CAT make-install-make.sh |
280 | |
|
|
281 | if find blib/arch/auto -type f | grep -q -v .exists; then |
|
|
282 | echo Probably an XS module, rebuilding perl |
|
|
283 | if make perl; then |
|
|
284 | mv perl "$PERL_PREFIX"/bin/perl |
|
|
285 | make -f Makefile.aperl map_clean |
|
|
286 | else |
|
|
287 | make -f Makefile.aperl map_clean |
|
|
288 | exit 1 |
|
|
289 | fi |
|
|
290 | fi |
|
|
291 | |
|
|
292 | make install UNINST=1 |
|
|
293 | EOF |
371 | EOF |
294 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
|
|
295 | |
372 | |
|
|
373 | # create a "patch modules" helper |
|
|
374 | write_shellscript SP-patch-postinstall <<'EOF' |
|
|
375 | #CAT patch-postinstall.sh |
|
|
376 | EOF |
|
|
377 | |
|
|
378 | "$PERL_PREFIX/bin/SP-patch-postinstall" |
|
|
379 | |
296 | # trick CPAN into avoiding ~/.cpan completely |
380 | # help to trick CPAN into avoiding ~/.cpan completely |
297 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
381 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
298 | |
382 | |
|
|
383 | # we call cpan with -MCPAN::MyConfig in this script, which |
|
|
384 | # is strictly unnecssary as we have to patch CPAN anyway, |
|
|
385 | # so consider it "for good measure". |
299 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
386 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
300 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
387 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
301 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
388 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
302 | CPAN::Shell->o (conf => q<init>); |
389 | CPAN::Shell->o (conf => q<init>); |
303 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
390 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
304 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
391 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
305 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
392 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
306 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
393 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
307 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
394 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
308 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
395 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
309 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
396 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
310 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
397 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
|
|
398 | CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); |
311 | CPAN::Shell->o (conf => q<commit>); |
399 | CPAN::Shell->o (conf => q<commit>); |
312 | ' || fatal "error while initialising CPAN" |
400 | ' || fatal "error while initialising CPAN" |
313 | |
401 | |
314 | touch "$PERL_PREFIX/staticstamp.install" |
402 | : > "$PERL_PREFIX/staticstamp.install" |
315 | fi |
403 | fi |
316 | |
404 | |
|
|
405 | _postinstall |
|
|
406 | } |
|
|
407 | |
|
|
408 | import() { |
|
|
409 | IMPORT="$1" |
|
|
410 | |
|
|
411 | rcd "$STATICPERL" |
|
|
412 | |
317 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
413 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
318 | NOCHECK_INSTALL=+ |
414 | verblock <<EOF |
319 | instcpan $STATICPERL_MODULES |
415 | import perl from $IMPORT to $STATICPERL |
320 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
416 | EOF |
321 | |
417 | |
322 | postinstall || fatal "postinstall hook failed" |
418 | rm -rf bin cpan lib patched perl src |
|
|
419 | mkdir -m 755 perl perl/bin |
|
|
420 | ln -s perl/bin/ bin |
|
|
421 | ln -s "$IMPORT" perl/bin/ |
323 | |
422 | |
324 | touch "$PERL_PREFIX/staticstamp.postinstall" |
423 | : > "$PERL_PREFIX/staticstamp.install" |
325 | fi |
424 | fi |
|
|
425 | |
|
|
426 | _postinstall |
326 | } |
427 | } |
327 | |
428 | |
328 | ############################################################################# |
429 | ############################################################################# |
329 | # install a module from CPAN |
430 | # install a module from CPAN |
330 | |
431 | |
… | |
… | |
334 | verblock <<EOF |
435 | verblock <<EOF |
335 | installing modules from CPAN |
436 | installing modules from CPAN |
336 | $@ |
437 | $@ |
337 | EOF |
438 | EOF |
338 | |
439 | |
339 | for mod in "$@"; do |
440 | #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
340 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
441 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
341 | || fatal "$mod: unable to install from CPAN" |
442 | |
342 | done |
443 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
|
|
444 | fatal "failure while installing modules from CPAN ($@)" |
|
|
445 | fi |
343 | rm -rf "$STATICPERL/build" |
446 | rm -f "$STATICPERL/instcpan.log" |
344 | } |
447 | } |
345 | |
448 | |
346 | ############################################################################# |
449 | ############################################################################# |
347 | # install a module from unpacked sources |
450 | # install a module from unpacked sources |
348 | |
451 | |
… | |
… | |
357 | for mod in "$@"; do |
460 | for mod in "$@"; do |
358 | echo |
461 | echo |
359 | echo $mod |
462 | echo $mod |
360 | ( |
463 | ( |
361 | rcd $mod |
464 | rcd $mod |
362 | make -f Makefile.aperl map_clean >/dev/null 2>&1 |
465 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
363 | make distclean >/dev/null 2>&1 |
466 | "$MAKE" distclean >/dev/null 2>&1 |
364 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
467 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
365 | make || fatal "$mod: error building module" |
468 | "$MAKE" || fatal "$mod: error building module" |
366 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
469 | "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
367 | make distclean >/dev/null 2>&1 |
470 | "$MAKE" distclean >/dev/null 2>&1 |
368 | exit 0 |
471 | exit 0 |
369 | ) || exit $? |
472 | ) || exit $? |
370 | done |
473 | done |
371 | } |
474 | } |
372 | |
475 | |
373 | ############################################################################# |
476 | ############################################################################# |
374 | # main |
477 | # main |
375 | |
478 | |
376 | podusage() { |
479 | podusage() { |
377 | echo |
480 | echo |
|
|
481 | |
378 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
482 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
379 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
483 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
380 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
484 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
381 | 2>/dev/null && exit |
485 | 2>/dev/null && exit |
382 | fi |
486 | fi |
|
|
487 | |
383 | # try whatever perl we can find |
488 | # try whatever perl we can find |
384 | perl -MPod::Usage -e \ |
489 | perl -MPod::Usage -e \ |
385 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
490 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
386 | 2>/dev/null && exit |
491 | 2>/dev/null && exit |
387 | |
492 | |
388 | fatal "displaying documentation requires a working perl - try '$0 install' first" |
493 | fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" |
389 | } |
494 | } |
390 | |
495 | |
391 | usage() { |
496 | usage() { |
392 | podusage 0 |
497 | podusage 0 |
393 | } |
498 | } |
… | |
… | |
401 | #CAT mkbundle |
506 | #CAT mkbundle |
402 | MKBUNDLE |
507 | MKBUNDLE |
403 | } |
508 | } |
404 | |
509 | |
405 | bundle() { |
510 | bundle() { |
|
|
511 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
406 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
512 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
407 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
513 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
408 | CACHE="$STATICPERL/cache" |
514 | CACHE="$STATICPERL/cache" |
409 | mkdir -p "$CACHE" |
515 | mkdir -p "$CACHE" |
410 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
516 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
… | |
… | |
418 | command="${1#--}"; shift |
524 | command="${1#--}"; shift |
419 | case "$command" in |
525 | case "$command" in |
420 | version ) |
526 | version ) |
421 | echo "staticperl version $VERSION" |
527 | echo "staticperl version $VERSION" |
422 | ;; |
528 | ;; |
423 | fetch | configure | build | install | clean | distclean) |
529 | fetch | configure | build | install | clean | realclean | distclean ) |
424 | ( "$command" ) |
530 | ( "$command" ) || exit |
|
|
531 | ;; |
|
|
532 | import ) |
|
|
533 | ( import "$1" ) || exit |
|
|
534 | shift |
425 | ;; |
535 | ;; |
426 | instsrc ) |
536 | instsrc ) |
427 | ( instsrc "$@" ) |
537 | ( instsrc "$@" ) || exit |
428 | exit |
538 | exit |
429 | ;; |
539 | ;; |
430 | instcpan ) |
540 | instcpan ) |
431 | ( instcpan "$@" ) |
541 | ( instcpan "$@" ) || exit |
|
|
542 | exit |
|
|
543 | ;; |
|
|
544 | perl ) |
|
|
545 | ( install ) || exit |
|
|
546 | exec "$PERL_PREFIX/bin/perl" "$@" |
432 | exit |
547 | exit |
433 | ;; |
548 | ;; |
434 | cpan ) |
549 | cpan ) |
435 | ( install ) |
550 | ( install ) || exit |
|
|
551 | PERL="$PERL_PREFIX/bin/perl" |
|
|
552 | export PERL |
436 | "$PERL_PREFIX/bin/cpan" "$@" |
553 | exec "$PERL_PREFIX/bin/cpan" "$@" |
437 | exit |
554 | exit |
438 | ;; |
555 | ;; |
439 | mkbundle ) |
556 | mkbundle ) |
440 | ( install ) |
557 | ( install ) || exit |
441 | bundle "$@" |
558 | bundle "$@" |
442 | exit |
559 | exit |
443 | ;; |
560 | ;; |
444 | mkperl ) |
561 | mkperl ) |
445 | ( install ) |
562 | ( install ) || exit |
446 | bundle --perl "$@" |
563 | bundle --perl "$@" |
447 | exit |
564 | exit |
448 | ;; |
565 | ;; |
449 | mkapp ) |
566 | mkapp ) |
450 | ( install ) |
567 | ( install ) || exit |
451 | bundle --app "$@" |
568 | bundle --app "$@" |
452 | exit |
569 | exit |
453 | ;; |
570 | ;; |
454 | help ) |
571 | help ) |
455 | podusage 2 |
572 | podusage 2 |