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 | |
10 | |
13 | # perl build variables |
11 | # perl build variables |
14 | PREFIX="$STATICPERL/perl" # where the perl gets installed |
12 | PERL_VERSION=5.12.2 # 5.8.9 is also a good choice |
|
|
13 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
14 | PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" |
16 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
15 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | |
16 | |
18 | ARCH="$(uname -m)" |
17 | ARCH="$(uname -m)" |
19 | |
18 | |
… | |
… | |
45 | |
44 | |
46 | # which extra modules you might want to install |
45 | # which extra modules you might want to install |
47 | EXTRA_MODULES="" |
46 | EXTRA_MODULES="" |
48 | |
47 | |
49 | # overridable functions |
48 | # overridable functions |
|
|
49 | preconfigure() { : ; } |
50 | postconfigure() { : ; } |
50 | postconfigure() { : ; } |
51 | postbuild() { : ; } |
51 | postbuild() { : ; } |
52 | postinstall() { : ; } |
52 | postinstall() { : ; } |
53 | |
53 | |
54 | # now source user config, if any |
54 | # now source user config, if any |
|
|
55 | if [ "$STATICPERLRC" ]; then |
|
|
56 | . "$STATICPERLRC" |
|
|
57 | else |
55 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
58 | [ -r /etc/staticperlrc ] && . /etc/staticperlrc |
56 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
59 | [ -r ~/.staticperlrc ] && . ~/.staticperlrc |
57 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
60 | [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
|
|
61 | fi |
58 | |
62 | |
59 | ############################################################################# |
63 | ############################################################################# |
60 | # support |
64 | # support |
|
|
65 | |
|
|
66 | MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
|
|
67 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
|
|
68 | |
|
|
69 | unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
|
|
70 | export LC_ALL=C # just to be on the safe side |
61 | |
71 | |
62 | # set version in a way that Makefile.PL can extract |
72 | # set version in a way that Makefile.PL can extract |
63 | VERSION=VERSION; eval \ |
73 | VERSION=VERSION; eval \ |
64 | $VERSION=0.1 |
74 | $VERSION=0.9 |
65 | |
75 | |
66 | BZ2=bz2 |
76 | BZ2=bz2 |
67 | BZIP2=bzip2 |
77 | BZIP2=bzip2 |
68 | |
78 | |
69 | fatal() { |
79 | fatal() { |
… | |
… | |
102 | ############################################################################# |
112 | ############################################################################# |
103 | # clean |
113 | # clean |
104 | |
114 | |
105 | distclean() { |
115 | distclean() { |
106 | verblock <<EOF |
116 | verblock <<EOF |
107 | deleting everything installed by this script |
117 | deleting everything installed by this script (rm -rf $STATICPERL) |
108 | EOF |
118 | EOF |
109 | |
119 | |
110 | rm -rf "$STATICPERL" |
120 | rm -rf "$STATICPERL" |
111 | } |
121 | } |
112 | |
122 | |
113 | ############################################################################# |
123 | ############################################################################# |
114 | # download/configure/compile/install perl |
124 | # download/configure/compile/install perl |
115 | |
125 | |
116 | clean() { |
126 | clean() { |
117 | cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return |
127 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
118 | |
|
|
119 | rm -f staticstamp.configure |
|
|
120 | make distclean >/dev/null 2>&1 |
|
|
121 | } |
128 | } |
122 | |
129 | |
123 | fetch() { |
130 | fetch() { |
124 | rcd "$STATICPERL" |
131 | rcd "$STATICPERL" |
125 | |
132 | |
126 | mkdir -p src |
133 | mkdir -p src |
127 | rcd src |
134 | rcd src |
128 | |
135 | |
129 | if ! [ -d "perl-$PERLVER" ]; then |
136 | if ! [ -d "perl-$PERL_VERSION" ]; then |
130 | if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then |
137 | if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then |
131 | |
138 | |
132 | URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" |
139 | URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" |
133 | |
140 | |
134 | verblock <<EOF |
141 | verblock <<EOF |
135 | downloading perl |
142 | downloading perl |
136 | to manually download perl yourself, place |
143 | to manually download perl yourself, place |
137 | perl-$PERLVER.tar.$BZ2 in $STATICPERL |
144 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
138 | trying $URL |
145 | trying $URL |
139 | EOF |
146 | EOF |
140 | |
147 | |
141 | curl >perl-$PERLVER.tar.$BZ2~ "$URL" \ |
148 | rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
142 | || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ |
149 | wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
|
|
150 | || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
143 | || fatal "$URL: error during downloading" |
151 | || fatal "$URL: unable to download" |
144 | mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.tar.$BZ2 |
152 | mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
145 | fi |
153 | fi |
146 | |
154 | |
147 | verblock <<EOF |
155 | verblock <<EOF |
148 | unpacking perl |
156 | unpacking perl |
149 | EOF |
157 | EOF |
150 | |
158 | |
151 | mkdir -p unpack |
159 | mkdir -p unpack |
152 | $BZIP2 -d <perl-$PERLVER.tar.bz2 | tar xpC unpack \ |
160 | $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \ |
153 | || fatal "perl-$PERLVER.tar.bz2: error during unpacking" |
161 | || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" |
|
|
162 | chmod -R u+w unpack/perl-$PERL_VERSION |
154 | mv unpack/perl-$PERLVER perl-$PERLVER |
163 | mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
155 | rmdir -p unpack |
164 | rmdir -p unpack |
156 | fi |
165 | fi |
157 | } |
166 | } |
158 | |
167 | |
159 | # similar to GNU-sed -i or perl -pi |
168 | # similar to GNU-sed -i or perl -pi |
… | |
… | |
163 | } |
172 | } |
164 | |
173 | |
165 | configure() { |
174 | configure() { |
166 | fetch |
175 | fetch |
167 | |
176 | |
168 | rcd "$STATICPERL/src/perl-$PERLVER" |
177 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
169 | |
178 | |
170 | [ -e staticstamp.configure ] && return |
179 | [ -e staticstamp.configure ] && return |
171 | |
180 | |
172 | verblock <<EOF |
181 | verblock <<EOF |
173 | configuring $STATICPERL/src/perl-$PERLVER |
182 | configuring $STATICPERL/src/perl-$PERL_VERSION |
174 | EOF |
183 | EOF |
175 | |
184 | |
176 | clean |
|
|
177 | |
|
|
178 | rm -f "$PREFIX/staticstamp.install" |
185 | rm -f "$PERL_PREFIX/staticstamp.install" |
|
|
186 | |
|
|
187 | make distclean >/dev/null 2>&1 |
179 | |
188 | |
180 | # I hate them |
189 | # I hate them |
181 | grep -q -- -fstack-protector Configure && \ |
190 | grep -q -- -fstack-protector Configure && \ |
182 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
191 | sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
|
|
192 | |
|
|
193 | preconfigure |
183 | |
194 | |
184 | # trace configure \ |
195 | # trace configure \ |
185 | sh Configure -Duselargefiles \ |
196 | sh Configure -Duselargefiles \ |
186 | -Uuse64bitint \ |
197 | -Uuse64bitint \ |
187 | -Dusemymalloc=n \ |
198 | -Dusemymalloc=n \ |
… | |
… | |
195 | -Dcppflags="$PERL_CPPFLAGS" \ |
206 | -Dcppflags="$PERL_CPPFLAGS" \ |
196 | -Dccflags="-g2 -fno-strict-aliasing" \ |
207 | -Dccflags="-g2 -fno-strict-aliasing" \ |
197 | -Doptimize="$PERL_OPTIMIZE" \ |
208 | -Doptimize="$PERL_OPTIMIZE" \ |
198 | -Dldflags="$PERL_LDFLAGS" \ |
209 | -Dldflags="$PERL_LDFLAGS" \ |
199 | -Dlibs="$PERL_LIBS" \ |
210 | -Dlibs="$PERL_LIBS" \ |
200 | -Dprefix="$PREFIX" \ |
211 | -Dprefix="$PERL_PREFIX" \ |
201 | -Dbin="$PREFIX/bin" \ |
212 | -Dbin="$PERL_PREFIX/bin" \ |
202 | -Dprivlib="$PREFIX/lib" \ |
213 | -Dprivlib="$PERL_PREFIX/lib" \ |
203 | -Darchlib="$PREFIX/lib" \ |
214 | -Darchlib="$PERL_PREFIX/lib" \ |
204 | -Uusevendorprefix \ |
215 | -Uusevendorprefix \ |
205 | -Dsitelib="$PREFIX/lib" \ |
216 | -Dsitelib="$PERL_PREFIX/lib" \ |
206 | -Dsitearch="$PREFIX/lib" \ |
217 | -Dsitearch="$PERL_PREFIX/lib" \ |
207 | -Usitelibexp \ |
218 | -Usitelibexp \ |
208 | -Uman1dir \ |
219 | -Uman1dir \ |
209 | -Uman3dir \ |
220 | -Uman3dir \ |
210 | -Usiteman1dir \ |
221 | -Usiteman1dir \ |
211 | -Usiteman3dir \ |
222 | -Usiteman3dir \ |
212 | -Dpager=/usr/bin/less \ |
223 | -Dpager=/usr/bin/less \ |
213 | -Demail="$EMAIL" \ |
224 | -Demail="$EMAIL" \ |
214 | -Dcf_email="$EMAIL" \ |
225 | -Dcf_email="$EMAIL" \ |
215 | -Dcf_by="$EMAIL" \ |
226 | -Dcf_by="$EMAIL" \ |
|
|
227 | $PERL_CONFIGURE \ |
216 | -dE || fatal "Configure failed" |
228 | -dE || fatal "Configure failed" |
217 | |
229 | |
218 | sedreplace ' |
230 | sedreplace ' |
219 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
231 | s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
220 | s/ *-fno-stack-protector */ /g |
232 | s/ *-fno-stack-protector */ /g |
… | |
… | |
228 | } |
240 | } |
229 | |
241 | |
230 | build() { |
242 | build() { |
231 | configure |
243 | configure |
232 | |
244 | |
233 | rcd "$STATICPERL/src/perl-$PERLVER" |
245 | rcd "$STATICPERL/src/perl-$PERL_VERSION" |
234 | |
246 | |
235 | verblock <<EOF |
247 | verblock <<EOF |
236 | building $STATICPERL/src/perl-$PERLVER |
248 | building $STATICPERL/src/perl-$PERL_VERSION |
237 | EOF |
249 | EOF |
238 | |
250 | |
239 | rm -f "$PREFIX/staticstamp.install" |
251 | rm -f "$PERL_PREFIX/staticstamp.install" |
240 | |
252 | |
241 | make || fatal "make: error while building perl" |
253 | make || fatal "make: error while building perl" |
242 | |
254 | |
243 | postbuild || fatal "postbuild hook failed" |
255 | postbuild || fatal "postbuild hook failed" |
244 | } |
256 | } |
245 | |
257 | |
246 | install() { |
258 | install() { |
247 | [ -e "$PREFIX/staticstamp.install" ] && return |
259 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
248 | |
|
|
249 | build |
260 | build |
250 | |
261 | |
251 | verblock <<EOF |
262 | verblock <<EOF |
252 | installing $STATICPERL/src/perl-$PERLVER |
263 | installing $STATICPERL/src/perl-$PERL_VERSION |
253 | to $PREFIX |
264 | to $PERL_PREFIX |
254 | EOF |
265 | EOF |
255 | |
266 | |
256 | rm -rf "$PREFIX" |
267 | ln -sf "perl/bin/" "$STATICPERL/bin" |
257 | |
268 | ln -sf "perl/lib/" "$STATICPERL/lib" |
|
|
269 | |
|
|
270 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
|
|
271 | rm -rf "$PERL_PREFIX" # by this rm -rf |
|
|
272 | |
258 | make install || fatal "make install: error while installing" |
273 | make install || fatal "make install: error while installing" |
259 | |
274 | |
260 | rcd "$PREFIX" |
275 | rcd "$PERL_PREFIX" |
261 | |
276 | |
262 | # create a "make install" replacement for CPAN |
277 | # create a "make install" replacement for CPAN |
263 | cat >"$PREFIX"/bin/cpan-make-install <<EOF |
278 | cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
264 | make install UNINST=1 |
279 | make || exit |
|
|
280 | |
265 | if find blib/arch/auto -type f | grep -q -v .exists; then |
281 | if find blib/arch/auto -type f | grep -q -v .exists; then |
266 | echo Probably an XS module, rebuilding perl |
282 | echo Probably an XS module, rebuilding perl |
267 | make perl |
283 | if make perl; then |
268 | rm -f "$PREFIX"/bin/perl |
284 | mv perl "$PERL_PREFIX"/bin/perl |
269 | make -f Makefile.aperl inst_perl |
|
|
270 | make -f Makefile.aperl map_clean |
285 | make -f Makefile.aperl map_clean |
|
|
286 | else |
|
|
287 | make -f Makefile.aperl map_clean |
|
|
288 | exit 1 |
|
|
289 | fi |
271 | fi |
290 | fi |
|
|
291 | |
|
|
292 | make install UNINST=1 |
272 | EOF |
293 | EOF |
273 | chmod 755 "$PREFIX"/bin/cpan-make-install |
294 | chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
274 | |
295 | |
275 | # trick CPAN into avoiding ~/.cpan completely |
296 | # trick CPAN into avoiding ~/.cpan completely |
276 | echo 1 >"$PREFIX/lib/CPAN/MyConfig.pm" |
297 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
277 | |
298 | |
278 | "$PREFIX"/bin/perl -MCPAN -e ' |
299 | "$PERL_PREFIX"/bin/perl -MCPAN -e ' |
279 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
300 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
280 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
301 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
281 | CPAN::Shell->o (conf => q<init>); |
302 | CPAN::Shell->o (conf => q<init>); |
282 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
303 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
283 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
304 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
284 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
305 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
285 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
306 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
286 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
307 | 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"); |
308 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
288 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
309 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
289 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
310 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
290 | CPAN::Shell->o (conf => q<commit>); |
311 | CPAN::Shell->o (conf => q<commit>); |
291 | ' || fatal "error while initialising CPAN" |
312 | ' || fatal "error while initialising CPAN" |
292 | |
313 | |
|
|
314 | touch "$PERL_PREFIX/staticstamp.install" |
|
|
315 | fi |
|
|
316 | |
|
|
317 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
293 | NOCHECK_INSTALL=+ |
318 | NOCHECK_INSTALL=+ |
294 | instcpan $STATICPERL_MODULES |
319 | instcpan $STATICPERL_MODULES |
295 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
320 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
296 | |
321 | |
297 | postinstall || fatal "postinstall hook failed" |
322 | postinstall || fatal "postinstall hook failed" |
298 | |
323 | |
299 | touch "$PREFIX/staticstamp.install" |
324 | touch "$PERL_PREFIX/staticstamp.postinstall" |
|
|
325 | fi |
300 | } |
326 | } |
301 | |
327 | |
302 | ############################################################################# |
328 | ############################################################################# |
303 | # install a module from CPAN |
329 | # install a module from CPAN |
304 | |
330 | |
… | |
… | |
309 | installing modules from CPAN |
335 | installing modules from CPAN |
310 | $@ |
336 | $@ |
311 | EOF |
337 | EOF |
312 | |
338 | |
313 | for mod in "$@"; do |
339 | for mod in "$@"; do |
314 | "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
340 | "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
315 | || fatal "$mod: unable to install from CPAN" |
341 | || fatal "$mod: unable to install from CPAN" |
316 | done |
342 | done |
317 | rm -rf "$STATICPERL/build" |
343 | rm -rf "$STATICPERL/build" |
318 | } |
344 | } |
319 | |
345 | |
… | |
… | |
333 | echo $mod |
359 | echo $mod |
334 | ( |
360 | ( |
335 | rcd $mod |
361 | rcd $mod |
336 | make -f Makefile.aperl map_clean >/dev/null 2>&1 |
362 | make -f Makefile.aperl map_clean >/dev/null 2>&1 |
337 | make distclean >/dev/null 2>&1 |
363 | make distclean >/dev/null 2>&1 |
338 | "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
364 | "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
339 | make || fatal "$mod: error building module" |
365 | make || fatal "$mod: error building module" |
340 | "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
366 | "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
341 | make distclean >/dev/null 2>&1 |
367 | make distclean >/dev/null 2>&1 |
342 | exit 0 |
368 | exit 0 |
343 | ) || exit $? |
369 | ) || exit $? |
344 | done |
370 | done |
345 | } |
371 | } |
346 | |
372 | |
347 | ############################################################################# |
373 | ############################################################################# |
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 |
374 | # main |
375 | |
375 | |
376 | podusage() { |
376 | podusage() { |
377 | echo |
377 | echo |
378 | if [ -e "$PREFIX/bin/perl" ]; then |
378 | if [ -e "$PERL_PREFIX/bin/perl" ]; then |
379 | "$PREFIX/bin/perl" -MPod::Usage -e \ |
379 | "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
380 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
380 | 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
381 | 2>/dev/null && exit |
381 | 2>/dev/null && exit |
382 | fi |
382 | fi |
383 | # try whatever perl we can find |
383 | # try whatever perl we can find |
384 | perl -MPod::Usage -e \ |
384 | perl -MPod::Usage -e \ |
… | |
… | |
393 | } |
393 | } |
394 | |
394 | |
395 | catmkbundle() { |
395 | catmkbundle() { |
396 | { |
396 | { |
397 | read dummy |
397 | read dummy |
398 | echo "#!$PREFIX/bin/perl" |
398 | echo "#!$PERL_PREFIX/bin/perl" |
399 | cat |
399 | cat |
400 | } <<'MKBUNDLE' |
400 | } <<'MKBUNDLE' |
401 | #CAT mkbundle |
401 | #CAT mkbundle |
402 | MKBUNDLE |
402 | MKBUNDLE |
403 | } |
403 | } |
404 | |
404 | |
405 | bundle() { |
405 | bundle() { |
406 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
406 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
407 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
407 | chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
|
|
408 | CACHE="$STATICPERL/cache" |
|
|
409 | mkdir -p "$CACHE" |
408 | "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" |
410 | "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
409 | } |
411 | } |
410 | |
412 | |
411 | if [ $# -gt 0 ]; then |
413 | if [ $# -gt 0 ]; then |
412 | while [ $# -gt 0 ]; do |
414 | while [ $# -gt 0 ]; do |
413 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
415 | mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
414 | mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" |
416 | mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
415 | |
417 | |
416 | command="${1#--}"; shift |
418 | command="${1#--}"; shift |
417 | case "$command" in |
419 | case "$command" in |
|
|
420 | version ) |
|
|
421 | echo "staticperl version $VERSION" |
|
|
422 | ;; |
418 | fetch | configure | build | install | clean | distclean) |
423 | fetch | configure | build | install | clean | distclean) |
419 | verblock <<EOF |
|
|
420 | $command |
|
|
421 | EOF |
|
|
422 | "$command" |
424 | ( "$command" ) |
423 | ;; |
425 | ;; |
424 | instsrc ) |
426 | instsrc ) |
425 | instsrc "$@" |
427 | ( instsrc "$@" ) |
426 | exit |
428 | exit |
427 | ;; |
429 | ;; |
428 | instcpan ) |
430 | instcpan ) |
429 | instcpan "$@" |
431 | ( instcpan "$@" ) |
430 | exit |
|
|
431 | ;; |
432 | exit |
432 | instschmorp ) |
|
|
433 | install_schmorp |
|
|
434 | ;; |
433 | ;; |
435 | cpan ) |
434 | cpan ) |
436 | install |
435 | ( install ) |
437 | "$PREFIX/bin/cpan" "$@" |
436 | "$PERL_PREFIX/bin/cpan" "$@" |
438 | exit |
437 | exit |
439 | ;; |
438 | ;; |
440 | mkbundle ) |
439 | mkbundle ) |
441 | install |
440 | ( install ) |
442 | bundle "$@" |
441 | bundle "$@" |
443 | exit |
442 | exit |
444 | ;; |
443 | ;; |
445 | mkperl ) |
444 | mkperl ) |
446 | install |
445 | ( install ) |
447 | bundle --perl "$@" |
446 | bundle --perl "$@" |
|
|
447 | exit |
|
|
448 | ;; |
|
|
449 | mkapp ) |
|
|
450 | ( install ) |
|
|
451 | bundle --app "$@" |
448 | exit |
452 | exit |
449 | ;; |
453 | ;; |
450 | help ) |
454 | help ) |
451 | podusage 2 |
455 | podusage 2 |
452 | ;; |
456 | ;; |