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