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