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