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