1 |
root |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
############################################################################# |
4 |
|
|
# configuration to fill in |
5 |
|
|
|
6 |
|
|
STATICPERL=~/.staticperl |
7 |
root |
1.14 |
CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
8 |
root |
1.1 |
EMAIL="read the documentation <rtfm@example.org>" |
9 |
|
|
|
10 |
|
|
# perl build variables |
11 |
root |
1.21 |
MAKE=make |
12 |
root |
1.29 |
PERL_VERSION=5.12.3 # 5.8.9 is also a good choice |
13 |
root |
1.19 |
PERL_CC=cc |
14 |
root |
1.4 |
PERL_CONFIGURE="" # additional Configure arguments |
15 |
root |
1.31 |
PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -D_GNU_SOURCE -DNDEBUG" |
16 |
|
|
PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 |
root |
1.1 |
|
18 |
|
|
ARCH="$(uname -m)" |
19 |
|
|
|
20 |
|
|
case "$ARCH" in |
21 |
|
|
i*86 | x86_64 | amd64 ) |
22 |
root |
1.22 |
PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 |
23 |
root |
1.1 |
case "$ARCH" in |
24 |
|
|
i*86 ) |
25 |
|
|
PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only |
26 |
|
|
;; |
27 |
|
|
esac |
28 |
|
|
;; |
29 |
|
|
esac |
30 |
|
|
|
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 :/ |
33 |
root |
1.16 |
# --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
34 |
|
|
PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
35 |
root |
1.1 |
PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
36 |
|
|
|
37 |
|
|
# some configuration options for modules |
38 |
root |
1.24 |
PERL_MM_USE_DEFAULT=1 |
39 |
|
|
#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
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 |
root |
1.1 |
|
43 |
|
|
# which extra modules to install by default from CPAN that are |
44 |
|
|
# required by mkbundle |
45 |
root |
1.2 |
STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
46 |
|
|
|
47 |
|
|
# which extra modules you might want to install |
48 |
|
|
EXTRA_MODULES="" |
49 |
root |
1.1 |
|
50 |
|
|
# overridable functions |
51 |
root |
1.7 |
preconfigure() { : ; } |
52 |
root |
1.1 |
postconfigure() { : ; } |
53 |
|
|
postbuild() { : ; } |
54 |
|
|
postinstall() { : ; } |
55 |
|
|
|
56 |
|
|
# now source user config, if any |
57 |
root |
1.14 |
if [ "$STATICPERLRC" ]; then |
58 |
|
|
. "$STATICPERLRC" |
59 |
|
|
else |
60 |
|
|
[ -r /etc/staticperlrc ] && . /etc/staticperlrc |
61 |
|
|
[ -r ~/.staticperlrc ] && . ~/.staticperlrc |
62 |
|
|
[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
63 |
|
|
fi |
64 |
root |
1.1 |
|
65 |
|
|
############################################################################# |
66 |
|
|
# support |
67 |
|
|
|
68 |
root |
1.14 |
MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" |
69 |
|
|
PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
70 |
|
|
|
71 |
root |
1.12 |
unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
72 |
root |
1.24 |
LC_ALL=C; export LC_ALL # just to be on the safe side |
73 |
root |
1.12 |
|
74 |
root |
1.1 |
# set version in a way that Makefile.PL can extract |
75 |
|
|
VERSION=VERSION; eval \ |
76 |
root |
1.27 |
$VERSION="1.0" |
77 |
root |
1.1 |
|
78 |
|
|
BZ2=bz2 |
79 |
|
|
BZIP2=bzip2 |
80 |
|
|
|
81 |
|
|
fatal() { |
82 |
|
|
printf -- "\nFATAL: %s\n\n" "$*" >&2 |
83 |
|
|
exit 1 |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
verbose() { |
87 |
|
|
printf -- "%s\n" "$*" |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
verblock() { |
91 |
|
|
verbose |
92 |
|
|
verbose "***" |
93 |
|
|
while read line; do |
94 |
|
|
verbose "*** $line" |
95 |
|
|
done |
96 |
|
|
verbose "***" |
97 |
|
|
verbose |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
rcd() { |
101 |
|
|
cd "$1" || fatal "$1: cannot enter" |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
trace() { |
105 |
|
|
prefix="$1"; shift |
106 |
|
|
# "$@" 2>&1 | while read line; do |
107 |
|
|
# echo "$prefix: $line" |
108 |
|
|
# done |
109 |
|
|
"$@" |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
trap wait 0 |
113 |
|
|
|
114 |
|
|
############################################################################# |
115 |
|
|
# clean |
116 |
|
|
|
117 |
|
|
distclean() { |
118 |
|
|
verblock <<EOF |
119 |
root |
1.14 |
deleting everything installed by this script (rm -rf $STATICPERL) |
120 |
root |
1.1 |
EOF |
121 |
|
|
|
122 |
|
|
rm -rf "$STATICPERL" |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
############################################################################# |
126 |
|
|
# download/configure/compile/install perl |
127 |
|
|
|
128 |
|
|
clean() { |
129 |
root |
1.7 |
rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
130 |
root |
1.1 |
} |
131 |
|
|
|
132 |
root |
1.23 |
realclean() { |
133 |
|
|
rm -f "$PERL_PREFIX/staticstamp.postinstall" |
134 |
|
|
rm -f "$PERL_PREFIX/staticstamp.install" |
135 |
|
|
rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
136 |
|
|
} |
137 |
|
|
|
138 |
root |
1.1 |
fetch() { |
139 |
|
|
rcd "$STATICPERL" |
140 |
|
|
|
141 |
|
|
mkdir -p src |
142 |
|
|
rcd src |
143 |
|
|
|
144 |
root |
1.6 |
if ! [ -d "perl-$PERL_VERSION" ]; then |
145 |
|
|
if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then |
146 |
root |
1.1 |
|
147 |
root |
1.6 |
URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" |
148 |
root |
1.1 |
|
149 |
|
|
verblock <<EOF |
150 |
|
|
downloading perl |
151 |
|
|
to manually download perl yourself, place |
152 |
root |
1.6 |
perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
153 |
root |
1.1 |
trying $URL |
154 |
|
|
EOF |
155 |
|
|
|
156 |
root |
1.6 |
rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side |
157 |
root |
1.25 |
curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
158 |
|
|
|| wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ |
159 |
root |
1.5 |
|| fatal "$URL: unable to download" |
160 |
root |
1.20 |
rm -f perl-$PERL_VERSION.tar.$BZ2 |
161 |
root |
1.6 |
mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 |
162 |
root |
1.1 |
fi |
163 |
|
|
|
164 |
|
|
verblock <<EOF |
165 |
|
|
unpacking perl |
166 |
|
|
EOF |
167 |
|
|
|
168 |
|
|
mkdir -p unpack |
169 |
root |
1.20 |
rm -rf unpack/perl-$PERL_VERSION |
170 |
root |
1.28 |
$BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | tar xfC - unpack \ |
171 |
|
|
|| fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" |
172 |
root |
1.8 |
chmod -R u+w unpack/perl-$PERL_VERSION |
173 |
root |
1.6 |
mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
174 |
root |
1.1 |
rmdir -p unpack |
175 |
|
|
fi |
176 |
|
|
} |
177 |
|
|
|
178 |
|
|
# similar to GNU-sed -i or perl -pi |
179 |
|
|
sedreplace() { |
180 |
|
|
sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
181 |
root |
1.20 |
rm -f "$2" |
182 |
root |
1.1 |
mv "$2~" "$2" |
183 |
|
|
} |
184 |
|
|
|
185 |
root |
1.22 |
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 |
209 |
|
|
} |
210 |
|
|
|
211 |
root |
1.1 |
configure() { |
212 |
|
|
fetch |
213 |
|
|
|
214 |
root |
1.6 |
rcd "$STATICPERL/src/perl-$PERL_VERSION" |
215 |
root |
1.1 |
|
216 |
|
|
[ -e staticstamp.configure ] && return |
217 |
|
|
|
218 |
|
|
verblock <<EOF |
219 |
root |
1.6 |
configuring $STATICPERL/src/perl-$PERL_VERSION |
220 |
root |
1.1 |
EOF |
221 |
|
|
|
222 |
root |
1.8 |
rm -f "$PERL_PREFIX/staticstamp.install" |
223 |
root |
1.1 |
|
224 |
root |
1.21 |
"$MAKE" distclean >/dev/null 2>&1 |
225 |
root |
1.1 |
|
226 |
root |
1.23 |
sedreplace '/^#define SITELIB/d' config_h.SH |
227 |
|
|
|
228 |
|
|
# I hate them for this |
229 |
root |
1.1 |
grep -q -- -fstack-protector Configure && \ |
230 |
|
|
sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
231 |
|
|
|
232 |
root |
1.7 |
preconfigure |
233 |
|
|
|
234 |
root |
1.1 |
# trace configure \ |
235 |
|
|
sh Configure -Duselargefiles \ |
236 |
|
|
-Uuse64bitint \ |
237 |
|
|
-Dusemymalloc=n \ |
238 |
|
|
-Uusedl \ |
239 |
|
|
-Uusethreads \ |
240 |
|
|
-Uuseithreads \ |
241 |
|
|
-Uusemultiplicity \ |
242 |
|
|
-Uusesfio \ |
243 |
|
|
-Uuseshrplib \ |
244 |
root |
1.26 |
-Uinstallusrbinperl \ |
245 |
root |
1.22 |
-A ccflags=" $PERL_CCFLAGS" \ |
246 |
root |
1.19 |
-Dcc="$PERL_CC" \ |
247 |
root |
1.1 |
-Doptimize="$PERL_OPTIMIZE" \ |
248 |
|
|
-Dldflags="$PERL_LDFLAGS" \ |
249 |
|
|
-Dlibs="$PERL_LIBS" \ |
250 |
root |
1.6 |
-Dprefix="$PERL_PREFIX" \ |
251 |
|
|
-Dbin="$PERL_PREFIX/bin" \ |
252 |
|
|
-Dprivlib="$PERL_PREFIX/lib" \ |
253 |
|
|
-Darchlib="$PERL_PREFIX/lib" \ |
254 |
root |
1.1 |
-Uusevendorprefix \ |
255 |
root |
1.6 |
-Dsitelib="$PERL_PREFIX/lib" \ |
256 |
|
|
-Dsitearch="$PERL_PREFIX/lib" \ |
257 |
root |
1.1 |
-Uman1dir \ |
258 |
|
|
-Uman3dir \ |
259 |
|
|
-Usiteman1dir \ |
260 |
|
|
-Usiteman3dir \ |
261 |
|
|
-Dpager=/usr/bin/less \ |
262 |
|
|
-Demail="$EMAIL" \ |
263 |
|
|
-Dcf_email="$EMAIL" \ |
264 |
|
|
-Dcf_by="$EMAIL" \ |
265 |
root |
1.4 |
$PERL_CONFIGURE \ |
266 |
root |
1.19 |
-Duseperlio \ |
267 |
root |
1.22 |
-dE || configure_failure |
268 |
root |
1.1 |
|
269 |
|
|
sedreplace ' |
270 |
|
|
s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
271 |
|
|
s/ *-fno-stack-protector */ /g |
272 |
|
|
' config.sh |
273 |
|
|
|
274 |
|
|
sh Configure -S || fatal "Configure -S failed" |
275 |
|
|
|
276 |
|
|
postconfigure || fatal "postconfigure hook failed" |
277 |
|
|
|
278 |
|
|
touch staticstamp.configure |
279 |
|
|
} |
280 |
|
|
|
281 |
|
|
build() { |
282 |
|
|
configure |
283 |
|
|
|
284 |
root |
1.6 |
rcd "$STATICPERL/src/perl-$PERL_VERSION" |
285 |
root |
1.1 |
|
286 |
|
|
verblock <<EOF |
287 |
root |
1.6 |
building $STATICPERL/src/perl-$PERL_VERSION |
288 |
root |
1.1 |
EOF |
289 |
|
|
|
290 |
root |
1.6 |
rm -f "$PERL_PREFIX/staticstamp.install" |
291 |
root |
1.1 |
|
292 |
root |
1.21 |
"$MAKE" || fatal "make: error while building perl" |
293 |
root |
1.1 |
|
294 |
|
|
postbuild || fatal "postbuild hook failed" |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
install() { |
298 |
root |
1.9 |
if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
299 |
|
|
build |
300 |
root |
1.1 |
|
301 |
root |
1.9 |
verblock <<EOF |
302 |
root |
1.6 |
installing $STATICPERL/src/perl-$PERL_VERSION |
303 |
|
|
to $PERL_PREFIX |
304 |
root |
1.1 |
EOF |
305 |
|
|
|
306 |
root |
1.14 |
ln -sf "perl/bin/" "$STATICPERL/bin" |
307 |
|
|
ln -sf "perl/lib/" "$STATICPERL/lib" |
308 |
|
|
|
309 |
|
|
ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
310 |
|
|
rm -rf "$PERL_PREFIX" # by this rm -rf |
311 |
|
|
|
312 |
root |
1.21 |
"$MAKE" install || fatal "make install: error while installing" |
313 |
root |
1.1 |
|
314 |
root |
1.9 |
rcd "$PERL_PREFIX" |
315 |
root |
1.2 |
|
316 |
root |
1.9 |
# create a "make install" replacement for CPAN |
317 |
|
|
cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF |
318 |
root |
1.21 |
"$MAKE" || exit |
319 |
root |
1.10 |
|
320 |
root |
1.1 |
if find blib/arch/auto -type f | grep -q -v .exists; then |
321 |
|
|
echo Probably an XS module, rebuilding perl |
322 |
root |
1.21 |
if "$MAKE" perl; then |
323 |
root |
1.20 |
mv perl "$PERL_PREFIX"/bin/perl~ \ |
324 |
|
|
&& rm -f "$PERL_PREFIX"/bin/perl \ |
325 |
|
|
&& mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl |
326 |
root |
1.21 |
"$MAKE" -f Makefile.aperl map_clean |
327 |
root |
1.10 |
else |
328 |
root |
1.21 |
"$MAKE" -f Makefile.aperl map_clean |
329 |
root |
1.10 |
exit 1 |
330 |
|
|
fi |
331 |
root |
1.1 |
fi |
332 |
root |
1.10 |
|
333 |
root |
1.21 |
"$MAKE" install UNINST=1 |
334 |
root |
1.1 |
EOF |
335 |
root |
1.9 |
chmod 755 "$PERL_PREFIX"/bin/cpan-make-install |
336 |
|
|
|
337 |
|
|
# trick CPAN into avoiding ~/.cpan completely |
338 |
|
|
echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
339 |
root |
1.1 |
|
340 |
root |
1.9 |
"$PERL_PREFIX"/bin/perl -MCPAN -e ' |
341 |
|
|
CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
342 |
|
|
CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
343 |
|
|
CPAN::Shell->o (conf => q<init>); |
344 |
|
|
CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
345 |
|
|
CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
346 |
|
|
CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
347 |
|
|
CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
348 |
|
|
CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
349 |
|
|
CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); |
350 |
|
|
CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
351 |
|
|
CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
352 |
|
|
CPAN::Shell->o (conf => q<commit>); |
353 |
|
|
' || fatal "error while initialising CPAN" |
354 |
root |
1.2 |
|
355 |
root |
1.9 |
touch "$PERL_PREFIX/staticstamp.install" |
356 |
|
|
fi |
357 |
|
|
|
358 |
root |
1.10 |
if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
359 |
root |
1.9 |
NOCHECK_INSTALL=+ |
360 |
|
|
instcpan $STATICPERL_MODULES |
361 |
|
|
[ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
362 |
root |
1.1 |
|
363 |
root |
1.9 |
postinstall || fatal "postinstall hook failed" |
364 |
root |
1.1 |
|
365 |
root |
1.9 |
touch "$PERL_PREFIX/staticstamp.postinstall" |
366 |
|
|
fi |
367 |
root |
1.1 |
} |
368 |
|
|
|
369 |
|
|
############################################################################# |
370 |
|
|
# install a module from CPAN |
371 |
|
|
|
372 |
|
|
instcpan() { |
373 |
|
|
[ $NOCHECK_INSTALL ] || install |
374 |
|
|
|
375 |
|
|
verblock <<EOF |
376 |
|
|
installing modules from CPAN |
377 |
|
|
$@ |
378 |
|
|
EOF |
379 |
|
|
|
380 |
|
|
for mod in "$@"; do |
381 |
root |
1.6 |
"$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ |
382 |
root |
1.1 |
|| fatal "$mod: unable to install from CPAN" |
383 |
|
|
done |
384 |
|
|
rm -rf "$STATICPERL/build" |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
############################################################################# |
388 |
|
|
# install a module from unpacked sources |
389 |
|
|
|
390 |
|
|
instsrc() { |
391 |
|
|
[ $NOCHECK_INSTALL ] || install |
392 |
|
|
|
393 |
|
|
verblock <<EOF |
394 |
|
|
installing modules from source |
395 |
|
|
$@ |
396 |
|
|
EOF |
397 |
|
|
|
398 |
|
|
for mod in "$@"; do |
399 |
|
|
echo |
400 |
|
|
echo $mod |
401 |
|
|
( |
402 |
|
|
rcd $mod |
403 |
root |
1.21 |
"$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
404 |
|
|
"$MAKE" distclean >/dev/null 2>&1 |
405 |
root |
1.6 |
"$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
406 |
root |
1.21 |
"$MAKE" || fatal "$mod: error building module" |
407 |
root |
1.6 |
"$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" |
408 |
root |
1.21 |
"$MAKE" distclean >/dev/null 2>&1 |
409 |
root |
1.1 |
exit 0 |
410 |
|
|
) || exit $? |
411 |
|
|
done |
412 |
|
|
} |
413 |
|
|
|
414 |
|
|
############################################################################# |
415 |
|
|
# main |
416 |
|
|
|
417 |
|
|
podusage() { |
418 |
|
|
echo |
419 |
root |
1.17 |
|
420 |
root |
1.6 |
if [ -e "$PERL_PREFIX/bin/perl" ]; then |
421 |
|
|
"$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
422 |
root |
1.1 |
'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
423 |
|
|
2>/dev/null && exit |
424 |
|
|
fi |
425 |
root |
1.17 |
|
426 |
root |
1.1 |
# try whatever perl we can find |
427 |
|
|
perl -MPod::Usage -e \ |
428 |
|
|
'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
429 |
|
|
2>/dev/null && exit |
430 |
|
|
|
431 |
root |
1.17 |
fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" |
432 |
root |
1.1 |
} |
433 |
|
|
|
434 |
|
|
usage() { |
435 |
|
|
podusage 0 |
436 |
|
|
} |
437 |
|
|
|
438 |
|
|
catmkbundle() { |
439 |
|
|
{ |
440 |
|
|
read dummy |
441 |
root |
1.6 |
echo "#!$PERL_PREFIX/bin/perl" |
442 |
root |
1.1 |
cat |
443 |
|
|
} <<'MKBUNDLE' |
444 |
|
|
#CAT mkbundle |
445 |
|
|
MKBUNDLE |
446 |
|
|
} |
447 |
|
|
|
448 |
|
|
bundle() { |
449 |
|
|
catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
450 |
|
|
chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
451 |
root |
1.12 |
CACHE="$STATICPERL/cache" |
452 |
|
|
mkdir -p "$CACHE" |
453 |
|
|
"$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
454 |
root |
1.1 |
} |
455 |
|
|
|
456 |
|
|
if [ $# -gt 0 ]; then |
457 |
|
|
while [ $# -gt 0 ]; do |
458 |
|
|
mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
459 |
root |
1.6 |
mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
460 |
root |
1.1 |
|
461 |
|
|
command="${1#--}"; shift |
462 |
|
|
case "$command" in |
463 |
root |
1.14 |
version ) |
464 |
|
|
echo "staticperl version $VERSION" |
465 |
|
|
;; |
466 |
root |
1.23 |
fetch | configure | build | install | clean | realclean | distclean) |
467 |
root |
1.22 |
( "$command" ) || exit |
468 |
root |
1.1 |
;; |
469 |
|
|
instsrc ) |
470 |
root |
1.22 |
( instsrc "$@" ) || exit |
471 |
root |
1.1 |
exit |
472 |
|
|
;; |
473 |
|
|
instcpan ) |
474 |
root |
1.22 |
( instcpan "$@" ) || exit |
475 |
root |
1.1 |
exit |
476 |
|
|
;; |
477 |
|
|
cpan ) |
478 |
root |
1.22 |
( install ) || exit |
479 |
root |
1.6 |
"$PERL_PREFIX/bin/cpan" "$@" |
480 |
root |
1.1 |
exit |
481 |
|
|
;; |
482 |
|
|
mkbundle ) |
483 |
root |
1.22 |
( install ) || exit |
484 |
root |
1.1 |
bundle "$@" |
485 |
|
|
exit |
486 |
|
|
;; |
487 |
|
|
mkperl ) |
488 |
root |
1.22 |
( install ) || exit |
489 |
root |
1.1 |
bundle --perl "$@" |
490 |
|
|
exit |
491 |
|
|
;; |
492 |
root |
1.11 |
mkapp ) |
493 |
root |
1.22 |
( install ) || exit |
494 |
root |
1.11 |
bundle --app "$@" |
495 |
|
|
exit |
496 |
|
|
;; |
497 |
root |
1.1 |
help ) |
498 |
|
|
podusage 2 |
499 |
|
|
;; |
500 |
|
|
* ) |
501 |
|
|
exec 1>&2 |
502 |
|
|
echo |
503 |
|
|
echo "Unknown command: $command" |
504 |
|
|
podusage 0 |
505 |
|
|
;; |
506 |
|
|
esac |
507 |
|
|
done |
508 |
|
|
else |
509 |
|
|
usage |
510 |
|
|
fi |
511 |
|
|
|
512 |
|
|
exit 0 |
513 |
|
|
|
514 |
|
|
#CAT staticperl.pod |
515 |
|
|
|