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