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 | PERLVER=5.12.2 # 5.8.9 is also a good choice |
|
|
7 | STATICPERL=~/.staticperl |
6 | STATICPERL=~/.staticperl |
8 | CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use |
7 | CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
9 | EMAIL="read the documentation <rtfm@example.org>" |
8 | EMAIL="read the documentation <rtfm@example.org>" |
10 | |
9 | DLCACHE= |
11 | MKBUNDLE="$STATICPERL/mkbundle" |
|
|
12 | |
10 | |
13 | # perl build variables |
11 | # perl build variables |
14 | PREFIX="$STATICPERL/perl" # where the perl gets installed |
12 | MAKE=make |
|
|
13 | PERL_VERSION=5.12.4 # 5.8.9 is also a good choice |
|
|
14 | PERL_CC=cc |
15 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CONFIGURE="" # additional Configure arguments |
16 | 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" |
17 | 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" |
18 | |
18 | |
19 | ARCH="$(uname -m)" |
19 | ARCH="$(uname -m)" |
20 | |
20 | |
21 | case "$ARCH" in |
21 | case "$ARCH" in |
… | |
… | |
29 | ;; |
29 | ;; |
30 | esac |
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 |
35 | PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" |
35 | #PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
|
|
36 | PERL_LDFLAGS= |
36 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
37 | |
38 | |
38 | # some configuration options for modules |
39 | # some configuration options for modules |
39 | export PERL_MM_USE_DEFAULT=1 |
40 | PERL_MM_USE_DEFAULT=1 |
|
|
41 | PERL_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 |
41 | 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 |
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="common::sense Pod::Strip 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 |
|
|
54 | preconfigure() { : ; } |
|
|
55 | patchconfig() { : ; } |
51 | postconfigure() { : ; } |
56 | postconfigure() { : ; } |
52 | postbuild() { : ; } |
57 | postbuild() { : ; } |
53 | postinstall() { : ; } |
58 | postinstall() { : ; } |
54 | |
59 | |
55 | # now source user config, if any |
60 | # now source user config, if any |
|
|
61 | if [ "$STATICPERLRC" ]; then |
|
|
62 | . "$STATICPERLRC" |
|
|
63 | else |
56 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
64 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
57 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
65 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
58 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
66 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
|
|
67 | fi |
59 | |
68 | |
60 | ############################################################################# |
69 | ############################################################################# |
61 | # support |
70 | # support |
|
|
71 | |
|
|
72 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
|
|
73 | |
|
|
74 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
|
|
75 | unset PERL_MB_OPT |
|
|
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" |
62 | |
81 | |
63 | # set version in a way that Makefile.PL can extract |
82 | # set version in a way that Makefile.PL can extract |
64 | VERSION=VERSION; eval \ |
83 | VERSION=VERSION; eval \ |
65 | $VERSION=0.1 |
84 | $VERSION="1.31" |
66 | |
85 | |
67 | BZ2=bz2 |
86 | BZ2=bz2 |
68 | BZIP2=bzip2 |
87 | BZIP2=bzip2 |
69 | |
88 | |
70 | fatal() { |
89 | fatal() { |
… | |
… | |
103 | ############################################################################# |
122 | ############################################################################# |
104 | # clean |
123 | # clean |
105 | |
124 | |
106 | distclean() { |
125 | distclean() { |
107 | verblock <<EOF |
126 | verblock <<EOF |
108 | deleting everything installed by this script |
127 | deleting everything installed by this script (rm -rf $STATICPERL) |
109 | EOF |
128 | EOF |
110 | |
129 | |
111 | rm -rf "$STATICPERL" |
130 | rm -rf "$STATICPERL" |
112 | } |
131 | } |
113 | |
132 | |
114 | ############################################################################# |
133 | ############################################################################# |
115 | # download/configure/compile/install perl |
134 | # download/configure/compile/install perl |
116 | |
135 | |
117 | clean() { |
136 | clean() { |
118 | cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return |
137 | rm -rf "$STATICPERL/src" |
|
|
138 | } |
119 | |
139 | |
120 | rm -f staticstamp.configure |
140 | realclean() { |
121 | make distclean >/dev/null 2>&1 |
141 | rm -f "$PERL_PREFIX/staticstamp.postinstall" |
|
|
142 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
143 | rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
122 | } |
144 | } |
123 | |
145 | |
124 | fetch() { |
146 | fetch() { |
125 | rcd "$STATICPERL" |
147 | rcd "$STATICPERL" |
126 | |
148 | |
127 | mkdir -p src |
149 | mkdir -p src |
128 | rcd src |
150 | rcd src |
129 | |
151 | |
130 | if ! [ -d "perl-$PERLVER" ]; then |
152 | if ! [ -d "perl-$PERL_VERSION" ]; then |
|
|
153 | PERLTAR=perl-$PERL_VERSION.tar.$BZ2 |
|
|
154 | |
131 | if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then |
155 | if ! [ -e $PERLTAR ]; then |
132 | |
|
|
133 | URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" |
156 | URL="$CPAN/src/5.0/$PERLTAR" |
134 | |
157 | |
135 | verblock <<EOF |
158 | verblock <<EOF |
136 | downloading perl |
159 | downloading perl |
137 | to manually download perl yourself, place |
160 | to manually download perl yourself, place |
138 | perl-$PERLVER.tar.$BZ2 in $STATICPERL |
161 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
139 | trying $URL |
162 | trying $URL |
140 | EOF |
|
|
141 | |
163 | |
142 | curl >perl-$PERLVER.tar.$BZ2~ "$URL" \ |
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 | |
|
|
171 | rm -f $PERLTAR~ # just to be on the safe side |
|
|
172 | { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
143 | || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ |
173 | || wget -O $PERLTAR~ "$URL" \ |
|
|
174 | || curl -f >$PERLTAR~ "$URL" \ |
144 | || fatal "$URL: unable to download" |
175 | || fatal "$URL: unable to download" |
145 | mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.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 |
146 | fi |
183 | fi |
147 | |
184 | |
148 | verblock <<EOF |
185 | verblock <<EOF |
149 | unpacking perl |
186 | unpacking perl |
150 | EOF |
187 | EOF |
151 | |
188 | |
152 | mkdir -p unpack |
189 | mkdir -p unpack |
153 | $BZIP2 -d <perl-$PERLVER.tar.bz2 | tar xpC unpack \ |
190 | rm -rf unpack/perl-$PERL_VERSION |
|
|
191 | $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \ |
154 | || fatal "perl-$PERLVER.tar.bz2: error during unpacking" |
192 | || fatal "$PERLTAR: error during unpacking" |
|
|
193 | chmod -R u+w unpack/perl-$PERL_VERSION |
155 | mv unpack/perl-$PERLVER perl-$PERLVER |
194 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
156 | rmdir -p unpack |
195 | rmdir -p unpack |
157 | fi |
196 | fi |
158 | } |
197 | } |
159 | |
198 | |
160 | # similar to GNU-sed -i or perl -pi |
199 | # similar to GNU-sed -i or perl -pi |
161 | sedreplace() { |
200 | sedreplace() { |
162 | 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" |
163 | 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 |
164 | } |
230 | } |
165 | |
231 | |
166 | configure() { |
232 | configure() { |
167 | fetch |
233 | fetch |
168 | |
234 | |
169 | rcd "$STATICPERL/src/perl-$PERLVER" |
235 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
170 | |
236 | |
171 | [ -e staticstamp.configure ] && return |
237 | [ -e staticstamp.configure ] && return |
172 | |
238 | |
173 | verblock <<EOF |
239 | verblock <<EOF |
174 | configuring $STATICPERL/src/perl-$PERLVER |
240 | configuring $STATICPERL/src/perl-$PERL_VERSION |
175 | EOF |
241 | EOF |
176 | |
242 | |
177 | clean |
|
|
178 | |
|
|
179 | rm -f "$PREFIX/staticstamp.install" |
243 | rm -f "$PERL_PREFIX/staticstamp.install" |
180 | |
244 | |
|
|
245 | "$MAKE" distclean >/dev/null 2>&1 |
|
|
246 | |
|
|
247 | sedreplace '/^#define SITELIB/d' config_h.SH |
|
|
248 | |
181 | # I hate them |
249 | # I hate them for this |
182 | grep -q -- -fstack-protector Configure && \ |
250 | grep -q -- -fstack-protector Configure && \ |
183 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
251 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
|
|
252 | |
|
|
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" |
184 | |
258 | |
185 | # trace configure \ |
259 | # trace configure \ |
186 | sh Configure -Duselargefiles \ |
260 | sh Configure -Duselargefiles \ |
187 | -Uuse64bitint \ |
261 | -Uuse64bitint \ |
188 | -Dusemymalloc=n \ |
262 | -Dusemymalloc=n \ |
189 | -Uusedl \ |
263 | -Uusedl \ |
190 | -Uusethreads \ |
264 | -Uusethreads \ |
191 | -Uuseithreads \ |
265 | -Uuseithreads \ |
192 | -Uusemultiplicity \ |
266 | -Uusemultiplicity \ |
193 | -Duseperlio \ |
|
|
194 | -Uusesfio \ |
267 | -Uusesfio \ |
195 | -Uuseshrplib \ |
268 | -Uuseshrplib \ |
|
|
269 | -Uinstallusrbinperl \ |
196 | -Dcppflags="$PERL_CPPFLAGS" \ |
270 | -A ccflags=" $PERL_CCFLAGS" \ |
197 | -Dccflags="-g2 -fno-strict-aliasing" \ |
271 | -Dcc="$PERL_CC" \ |
198 | -Doptimize="$PERL_OPTIMIZE" \ |
272 | -Doptimize="$PERL_OPTIMIZE" \ |
199 | -Dldflags="$PERL_LDFLAGS" \ |
273 | -Dldflags="$PERL_LDFLAGS" \ |
200 | -Dlibs="$PERL_LIBS" \ |
274 | -Dlibs="$PERL_LIBS" \ |
201 | -Dprefix="$PREFIX" \ |
275 | -Dprefix="$PERL_PREFIX" \ |
202 | -Dbin="$PREFIX/bin" \ |
276 | -Dbin="$PERL_PREFIX/bin" \ |
203 | -Dprivlib="$PREFIX/lib" \ |
277 | -Dprivlib="$PERL_PREFIX/lib" \ |
204 | -Darchlib="$PREFIX/lib" \ |
278 | -Darchlib="$PERL_PREFIX/lib" \ |
205 | -Uusevendorprefix \ |
279 | -Uusevendorprefix \ |
206 | -Dsitelib="$PREFIX/lib" \ |
280 | -Dsitelib="$PERL_PREFIX/lib" \ |
207 | -Dsitearch="$PREFIX/lib" \ |
281 | -Dsitearch="$PERL_PREFIX/lib" \ |
208 | -Usitelibexp \ |
|
|
209 | -Uman1dir \ |
282 | -Uman1dir \ |
210 | -Uman3dir \ |
283 | -Uman3dir \ |
211 | -Usiteman1dir \ |
284 | -Usiteman1dir \ |
212 | -Usiteman3dir \ |
285 | -Usiteman3dir \ |
213 | -Dpager=/usr/bin/less \ |
286 | -Dpager=/usr/bin/less \ |
214 | -Demail="$EMAIL" \ |
287 | -Demail="$EMAIL" \ |
215 | -Dcf_email="$EMAIL" \ |
288 | -Dcf_email="$EMAIL" \ |
216 | -Dcf_by="$EMAIL" \ |
289 | -Dcf_by="$EMAIL" \ |
217 | $PERL_CONFIGURE \ |
290 | $PERL_CONFIGURE \ |
|
|
291 | -Duseperlio \ |
218 | -dE || fatal "Configure failed" |
292 | -dE || configure_failure |
219 | |
293 | |
220 | sedreplace ' |
294 | sedreplace ' |
221 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
295 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
222 | s/ *-fno-stack-protector */ /g |
296 | s/ *-fno-stack-protector */ /g |
223 | ' config.sh |
297 | ' config.sh |
224 | |
298 | |
|
|
299 | patchconfig || fatal "patchconfig hook failed" |
|
|
300 | |
225 | sh Configure -S || fatal "Configure -S failed" |
301 | sh Configure -S || fatal "Configure -S failed" |
226 | |
302 | |
227 | postconfigure || fatal "postconfigure hook failed" |
303 | postconfigure || fatal "postconfigure hook failed" |
228 | |
304 | |
229 | 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" |
230 | } |
317 | } |
231 | |
318 | |
232 | build() { |
319 | build() { |
233 | configure |
320 | configure |
234 | |
321 | |
235 | rcd "$STATICPERL/src/perl-$PERLVER" |
322 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
236 | |
323 | |
237 | verblock <<EOF |
324 | verblock <<EOF |
238 | building $STATICPERL/src/perl-$PERLVER |
325 | building $STATICPERL/src/perl-$PERL_VERSION |
239 | EOF |
326 | EOF |
240 | |
327 | |
241 | rm -f "$PREFIX/staticstamp.install" |
328 | rm -f "$PERL_PREFIX/staticstamp.install" |
242 | |
329 | |
243 | make || fatal "make: error while building perl" |
330 | "$MAKE" || fatal "make: error while building perl" |
244 | |
331 | |
245 | postbuild || fatal "postbuild hook failed" |
332 | postbuild || fatal "postbuild hook failed" |
246 | } |
333 | } |
247 | |
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 |
|
|
345 | } |
|
|
346 | |
248 | install() { |
347 | install() { |
249 | [ -e "$PREFIX/staticstamp.install" ] && return |
348 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
250 | |
|
|
251 | build |
349 | build |
252 | |
350 | |
253 | verblock <<EOF |
351 | verblock <<EOF |
254 | installing $STATICPERL/src/perl-$PERLVER |
352 | installing $STATICPERL/src/perl-$PERL_VERSION |
255 | to $PREFIX |
353 | to $PERL_PREFIX |
256 | EOF |
354 | EOF |
257 | |
355 | |
258 | rm -rf "$PREFIX" |
356 | ln -sf "perl/bin/" "$STATICPERL/bin" |
259 | |
357 | ln -sf "perl/lib/" "$STATICPERL/lib" |
|
|
358 | |
|
|
359 | mkdir "$STATICPERL/patched" |
|
|
360 | |
|
|
361 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
|
|
362 | rm -rf "$PERL_PREFIX" # by this rm -rf |
|
|
363 | |
260 | make install || fatal "make install: error while installing" |
364 | "$MAKE" install || fatal "make install: error while installing" |
261 | |
365 | |
262 | rcd "$PREFIX" |
366 | rcd "$PERL_PREFIX" |
263 | |
367 | |
264 | # create a "make install" replacement for CPAN |
368 | # create a "make install" replacement for CPAN |
265 | cat >"$PREFIX"/bin/cpan-make-install <<EOF |
369 | write_shellscript SP-make-install-make <<'EOF' |
266 | make install UNINST=1 |
370 | #CAT make-install-make.sh |
267 | if find blib/arch/auto -type f | grep -q -v .exists; then |
|
|
268 | echo Probably an XS module, rebuilding perl |
|
|
269 | make perl |
|
|
270 | rm -f "$PREFIX"/bin/perl |
|
|
271 | make -f Makefile.aperl inst_perl |
|
|
272 | make -f Makefile.aperl map_clean |
|
|
273 | fi |
|
|
274 | EOF |
371 | EOF |
275 | chmod 755 "$PREFIX"/bin/cpan-make-install |
|
|
276 | |
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 | |
277 | # trick CPAN into avoiding ~/.cpan completely |
380 | # help to trick CPAN into avoiding ~/.cpan completely |
278 | echo 1 >"$PREFIX/lib/CPAN/MyConfig.pm" |
381 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
279 | |
382 | |
280 | "$PREFIX"/bin/perl -MCPAN -e ' |
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". |
|
|
386 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
281 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
387 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
282 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
388 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
283 | CPAN::Shell->o (conf => q<init>); |
389 | CPAN::Shell->o (conf => q<init>); |
284 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
390 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
285 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
391 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
286 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
392 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
287 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
393 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
288 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
394 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
289 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PREFIX"'/bin/cpan-make-install"); |
395 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
290 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
396 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
291 | 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"); |
292 | CPAN::Shell->o (conf => q<commit>); |
399 | CPAN::Shell->o (conf => q<commit>); |
293 | ' || fatal "error while initialising CPAN" |
400 | ' || fatal "error while initialising CPAN" |
294 | |
401 | |
295 | NOCHECK_INSTALL=+ |
|
|
296 | instcpan $STATICPERL_MODULES |
|
|
297 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
|
|
298 | |
|
|
299 | postinstall || fatal "postinstall hook failed" |
|
|
300 | |
|
|
301 | touch "$PREFIX/staticstamp.install" |
402 | : > "$PERL_PREFIX/staticstamp.install" |
|
|
403 | fi |
|
|
404 | |
|
|
405 | _postinstall |
|
|
406 | } |
|
|
407 | |
|
|
408 | import() { |
|
|
409 | IMPORT="$1" |
|
|
410 | |
|
|
411 | rcd "$STATICPERL" |
|
|
412 | |
|
|
413 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
|
|
414 | verblock <<EOF |
|
|
415 | import perl from $IMPORT to $STATICPERL |
|
|
416 | EOF |
|
|
417 | |
|
|
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/ |
|
|
422 | |
|
|
423 | : > "$PERL_PREFIX/staticstamp.install" |
|
|
424 | fi |
|
|
425 | |
|
|
426 | _postinstall |
302 | } |
427 | } |
303 | |
428 | |
304 | ############################################################################# |
429 | ############################################################################# |
305 | # install a module from CPAN |
430 | # install a module from CPAN |
306 | |
431 | |
… | |
… | |
310 | verblock <<EOF |
435 | verblock <<EOF |
311 | installing modules from CPAN |
436 | installing modules from CPAN |
312 | $@ |
437 | $@ |
313 | EOF |
438 | EOF |
314 | |
439 | |
315 | for mod in "$@"; do |
440 | #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
316 | "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
441 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
317 | || fatal "$mod: unable to install from CPAN" |
442 | |
318 | done |
443 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
|
|
444 | fatal "failure while installing modules from CPAN ($@)" |
|
|
445 | fi |
319 | rm -rf "$STATICPERL/build" |
446 | rm -f "$STATICPERL/instcpan.log" |
320 | } |
447 | } |
321 | |
448 | |
322 | ############################################################################# |
449 | ############################################################################# |
323 | # install a module from unpacked sources |
450 | # install a module from unpacked sources |
324 | |
451 | |
… | |
… | |
333 | for mod in "$@"; do |
460 | for mod in "$@"; do |
334 | echo |
461 | echo |
335 | echo $mod |
462 | echo $mod |
336 | ( |
463 | ( |
337 | rcd $mod |
464 | rcd $mod |
338 | make -f Makefile.aperl map_clean >/dev/null 2>&1 |
465 | "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
339 | make distclean >/dev/null 2>&1 |
466 | "$MAKE" distclean >/dev/null 2>&1 |
340 | "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
467 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
341 | make || fatal "$mod: error building module" |
468 | "$MAKE" || fatal "$mod: error building module" |
342 | "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
469 | "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
343 | make distclean >/dev/null 2>&1 |
470 | "$MAKE" distclean >/dev/null 2>&1 |
344 | exit 0 |
471 | exit 0 |
345 | ) || exit $? |
472 | ) || exit $? |
346 | done |
473 | done |
347 | } |
474 | } |
348 | |
475 | |
349 | ############################################################################# |
476 | ############################################################################# |
350 | # main |
477 | # main |
351 | |
478 | |
352 | podusage() { |
479 | podusage() { |
353 | echo |
480 | echo |
|
|
481 | |
354 | if [ -e "$PREFIX/bin/perl" ]; then |
482 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
355 | "$PREFIX/bin/perl" -MPod::Usage -e \ |
483 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
356 | '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" \ |
357 | 2>/dev/null && exit |
485 | 2>/dev/null && exit |
358 | fi |
486 | fi |
|
|
487 | |
359 | # try whatever perl we can find |
488 | # try whatever perl we can find |
360 | perl -MPod::Usage -e \ |
489 | perl -MPod::Usage -e \ |
361 | '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" \ |
362 | 2>/dev/null && exit |
491 | 2>/dev/null && exit |
363 | |
492 | |
364 | 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" |
365 | } |
494 | } |
366 | |
495 | |
367 | usage() { |
496 | usage() { |
368 | podusage 0 |
497 | podusage 0 |
369 | } |
498 | } |
370 | |
499 | |
371 | catmkbundle() { |
500 | catmkbundle() { |
372 | { |
501 | { |
373 | read dummy |
502 | read dummy |
374 | echo "#!$PREFIX/bin/perl" |
503 | echo "#!$PERL_PREFIX/bin/perl" |
375 | cat |
504 | cat |
376 | } <<'MKBUNDLE' |
505 | } <<'MKBUNDLE' |
377 | #CAT mkbundle |
506 | #CAT mkbundle |
378 | MKBUNDLE |
507 | MKBUNDLE |
379 | } |
508 | } |
380 | |
509 | |
381 | bundle() { |
510 | bundle() { |
|
|
511 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
382 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
512 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
383 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
513 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
|
|
514 | CACHE="$STATICPERL/cache" |
|
|
515 | mkdir -p "$CACHE" |
384 | "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" |
516 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
385 | } |
517 | } |
386 | |
518 | |
387 | if [ $# -gt 0 ]; then |
519 | if [ $# -gt 0 ]; then |
388 | while [ $# -gt 0 ]; do |
520 | while [ $# -gt 0 ]; do |
389 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
521 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
390 | mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" |
522 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
391 | |
523 | |
392 | command="${1#--}"; shift |
524 | command="${1#--}"; shift |
393 | case "$command" in |
525 | case "$command" in |
|
|
526 | version ) |
|
|
527 | echo "staticperl version $VERSION" |
|
|
528 | ;; |
394 | fetch | configure | build | install | clean | distclean) |
529 | fetch | configure | build | install | clean | realclean | distclean ) |
395 | verblock <<EOF |
|
|
396 | $command |
|
|
397 | EOF |
|
|
398 | "$command" |
530 | ( "$command" ) || exit |
|
|
531 | ;; |
|
|
532 | import ) |
|
|
533 | ( import "$1" ) || exit |
|
|
534 | shift |
399 | ;; |
535 | ;; |
400 | instsrc ) |
536 | instsrc ) |
401 | instsrc "$@" |
537 | ( instsrc "$@" ) || exit |
402 | exit |
538 | exit |
403 | ;; |
539 | ;; |
404 | instcpan ) |
540 | instcpan ) |
405 | instcpan "$@" |
541 | ( instcpan "$@" ) || exit |
|
|
542 | exit |
|
|
543 | ;; |
|
|
544 | perl ) |
|
|
545 | ( install ) || exit |
|
|
546 | exec "$PERL_PREFIX/bin/perl" "$@" |
406 | exit |
547 | exit |
407 | ;; |
548 | ;; |
408 | cpan ) |
549 | cpan ) |
409 | install |
550 | ( install ) || exit |
|
|
551 | PERL="$PERL_PREFIX/bin/perl" |
|
|
552 | export PERL |
410 | "$PREFIX/bin/cpan" "$@" |
553 | exec "$PERL_PREFIX/bin/cpan" "$@" |
411 | exit |
554 | exit |
412 | ;; |
555 | ;; |
413 | mkbundle ) |
556 | mkbundle ) |
414 | install |
557 | ( install ) || exit |
415 | bundle "$@" |
558 | bundle "$@" |
416 | exit |
559 | exit |
417 | ;; |
560 | ;; |
418 | mkperl ) |
561 | mkperl ) |
419 | install |
562 | ( install ) || exit |
420 | bundle --perl "$@" |
563 | bundle --perl "$@" |
|
|
564 | exit |
|
|
565 | ;; |
|
|
566 | mkapp ) |
|
|
567 | ( install ) || exit |
|
|
568 | bundle --app "$@" |
421 | exit |
569 | exit |
422 | ;; |
570 | ;; |
423 | help ) |
571 | help ) |
424 | podusage 2 |
572 | podusage 2 |
425 | ;; |
573 | ;; |