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