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