1 |
root |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
############################################################################# |
4 |
root |
1.45 |
# configuration to fill in (or to replace in your .staticperlrc) |
5 |
root |
1.1 |
|
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 |
root |
1.45 |
DLCACHE= |
10 |
root |
1.1 |
|
11 |
|
|
# perl build variables |
12 |
root |
1.21 |
MAKE=make |
13 |
root |
1.49 |
PERL_VERSION=5.12.4 # 5.8.9 is also a good choice |
14 |
root |
1.19 |
PERL_CC=cc |
15 |
root |
1.4 |
PERL_CONFIGURE="" # additional Configure arguments |
16 |
root |
1.32 |
PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
17 |
root |
1.31 |
PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
18 |
root |
1.1 |
|
19 |
|
|
ARCH="$(uname -m)" |
20 |
|
|
|
21 |
|
|
case "$ARCH" in |
22 |
|
|
i*86 | x86_64 | amd64 ) |
23 |
root |
1.22 |
PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64 |
24 |
root |
1.1 |
case "$ARCH" in |
25 |
|
|
i*86 ) |
26 |
|
|
PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only |
27 |
|
|
;; |
28 |
|
|
esac |
29 |
|
|
;; |
30 |
|
|
esac |
31 |
|
|
|
32 |
|
|
# -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 :/ |
34 |
root |
1.16 |
# --allow-multiple-definition exists to work around uclibc's pthread static linking bug |
35 |
root |
1.37 |
#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" |
36 |
|
|
PERL_LDFLAGS= |
37 |
root |
1.1 |
PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself |
38 |
|
|
|
39 |
|
|
# some configuration options for modules |
40 |
root |
1.24 |
PERL_MM_USE_DEFAULT=1 |
41 |
root |
1.39 |
PERL_MM_OPT="MAN1PODS= MAN3PODS=" |
42 |
root |
1.24 |
#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow |
43 |
root |
1.47 |
#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' |
44 |
|
|
export PERL_MM_USE_DEFAULT PERL_MM_OPT |
45 |
root |
1.1 |
|
46 |
|
|
# which extra modules to install by default from CPAN that are |
47 |
|
|
# required by mkbundle |
48 |
root |
1.2 |
STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
49 |
|
|
|
50 |
|
|
# which extra modules you might want to install |
51 |
|
|
EXTRA_MODULES="" |
52 |
root |
1.1 |
|
53 |
|
|
# overridable functions |
54 |
root |
1.7 |
preconfigure() { : ; } |
55 |
root |
1.37 |
patchconfig() { : ; } |
56 |
root |
1.1 |
postconfigure() { : ; } |
57 |
|
|
postbuild() { : ; } |
58 |
|
|
postinstall() { : ; } |
59 |
|
|
|
60 |
|
|
# now source user config, if any |
61 |
root |
1.14 |
if [ "$STATICPERLRC" ]; then |
62 |
|
|
. "$STATICPERLRC" |
63 |
|
|
else |
64 |
|
|
[ -r /etc/staticperlrc ] && . /etc/staticperlrc |
65 |
|
|
[ -r ~/.staticperlrc ] && . ~/.staticperlrc |
66 |
|
|
[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" |
67 |
|
|
fi |
68 |
root |
1.1 |
|
69 |
|
|
############################################################################# |
70 |
|
|
# support |
71 |
|
|
|
72 |
root |
1.14 |
PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
73 |
|
|
|
74 |
root |
1.38 |
unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG |
75 |
root |
1.39 |
unset PERL_MB_OPT |
76 |
root |
1.24 |
LC_ALL=C; export LC_ALL # just to be on the safe side |
77 |
root |
1.12 |
|
78 |
root |
1.38 |
# prepend PATH - not required by staticperl itself, but might make |
79 |
|
|
# life easier when working in e.g. "staticperl cpan / look" |
80 |
|
|
PATH="$PERL_PREFIX/perl/bin:$PATH" |
81 |
|
|
|
82 |
root |
1.1 |
# set version in a way that Makefile.PL can extract |
83 |
|
|
VERSION=VERSION; eval \ |
84 |
root |
1.44 |
$VERSION="1.31" |
85 |
root |
1.1 |
|
86 |
|
|
BZ2=bz2 |
87 |
|
|
BZIP2=bzip2 |
88 |
|
|
|
89 |
|
|
fatal() { |
90 |
|
|
printf -- "\nFATAL: %s\n\n" "$*" >&2 |
91 |
|
|
exit 1 |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
verbose() { |
95 |
|
|
printf -- "%s\n" "$*" |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
verblock() { |
99 |
|
|
verbose |
100 |
|
|
verbose "***" |
101 |
|
|
while read line; do |
102 |
|
|
verbose "*** $line" |
103 |
|
|
done |
104 |
|
|
verbose "***" |
105 |
|
|
verbose |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
rcd() { |
109 |
|
|
cd "$1" || fatal "$1: cannot enter" |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
trace() { |
113 |
|
|
prefix="$1"; shift |
114 |
|
|
# "$@" 2>&1 | while read line; do |
115 |
|
|
# echo "$prefix: $line" |
116 |
|
|
# done |
117 |
|
|
"$@" |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
trap wait 0 |
121 |
|
|
|
122 |
|
|
############################################################################# |
123 |
|
|
# clean |
124 |
|
|
|
125 |
|
|
distclean() { |
126 |
|
|
verblock <<EOF |
127 |
root |
1.14 |
deleting everything installed by this script (rm -rf $STATICPERL) |
128 |
root |
1.1 |
EOF |
129 |
|
|
|
130 |
|
|
rm -rf "$STATICPERL" |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
############################################################################# |
134 |
|
|
# download/configure/compile/install perl |
135 |
|
|
|
136 |
|
|
clean() { |
137 |
root |
1.48 |
rm -rf "$STATICPERL/src" |
138 |
root |
1.1 |
} |
139 |
|
|
|
140 |
root |
1.23 |
realclean() { |
141 |
|
|
rm -f "$PERL_PREFIX/staticstamp.postinstall" |
142 |
|
|
rm -f "$PERL_PREFIX/staticstamp.install" |
143 |
|
|
rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure" |
144 |
|
|
} |
145 |
|
|
|
146 |
root |
1.1 |
fetch() { |
147 |
|
|
rcd "$STATICPERL" |
148 |
|
|
|
149 |
|
|
mkdir -p src |
150 |
|
|
rcd src |
151 |
|
|
|
152 |
root |
1.6 |
if ! [ -d "perl-$PERL_VERSION" ]; then |
153 |
root |
1.45 |
PERLTAR=perl-$PERL_VERSION.tar.$BZ2 |
154 |
root |
1.1 |
|
155 |
root |
1.45 |
if ! [ -e $PERLTAR ]; then |
156 |
|
|
URL="$CPAN/src/5.0/$PERLTAR" |
157 |
root |
1.1 |
|
158 |
|
|
verblock <<EOF |
159 |
|
|
downloading perl |
160 |
|
|
to manually download perl yourself, place |
161 |
root |
1.6 |
perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
162 |
root |
1.1 |
trying $URL |
163 |
root |
1.42 |
|
164 |
|
|
either curl or wget is required for automatic download. |
165 |
|
|
curl is tried first, then wget. |
166 |
root |
1.45 |
|
167 |
|
|
you can configure a download cache directory via DLCACHE |
168 |
|
|
in your .staticperlrc to avoid repeated downloads. |
169 |
root |
1.1 |
EOF |
170 |
|
|
|
171 |
root |
1.45 |
rm -f $PERLTAR~ # just to be on the safe side |
172 |
root |
1.48 |
{ [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ |
173 |
root |
1.45 |
|| wget -O $PERLTAR~ "$URL" \ |
174 |
|
|
|| curl -f >$PERLTAR~ "$URL" \ |
175 |
root |
1.5 |
|| fatal "$URL: unable to download" |
176 |
root |
1.45 |
rm -f $PERLTAR |
177 |
|
|
mv $PERLTAR~ $PERLTAR |
178 |
|
|
if [ "$DLCACHE" ]; then |
179 |
|
|
mkdir -p "$DLCACHE" |
180 |
root |
1.46 |
cp $PERLTAR "$DLCACHE"/$PERLTAR~ && \ |
181 |
root |
1.45 |
mv "$DLCACHE"/$PERLTAR~ "$DLCACHE"/$PERLTAR |
182 |
|
|
fi |
183 |
root |
1.1 |
fi |
184 |
|
|
|
185 |
|
|
verblock <<EOF |
186 |
|
|
unpacking perl |
187 |
|
|
EOF |
188 |
|
|
|
189 |
|
|
mkdir -p unpack |
190 |
root |
1.20 |
rm -rf unpack/perl-$PERL_VERSION |
191 |
root |
1.45 |
$BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \ |
192 |
|
|
|| fatal "$PERLTAR: error during unpacking" |
193 |
root |
1.8 |
chmod -R u+w unpack/perl-$PERL_VERSION |
194 |
root |
1.6 |
mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION |
195 |
root |
1.1 |
rmdir -p unpack |
196 |
|
|
fi |
197 |
|
|
} |
198 |
|
|
|
199 |
|
|
# similar to GNU-sed -i or perl -pi |
200 |
|
|
sedreplace() { |
201 |
|
|
sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
202 |
root |
1.20 |
rm -f "$2" |
203 |
root |
1.1 |
mv "$2~" "$2" |
204 |
|
|
} |
205 |
|
|
|
206 |
root |
1.22 |
configure_failure() { |
207 |
|
|
cat <<EOF |
208 |
|
|
|
209 |
|
|
|
210 |
|
|
*** |
211 |
|
|
*** Configure failed - see above for the exact error message(s). |
212 |
|
|
*** |
213 |
|
|
*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE |
214 |
|
|
*** flags are not supported by your compiler. Less often, this is because |
215 |
|
|
*** PERL_LIBS either contains a library not available on your system (such as |
216 |
|
|
*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl). |
217 |
|
|
*** |
218 |
|
|
*** You can provide your own flags by creating a ~/.staticperlrc file with |
219 |
|
|
*** variable assignments. For example (these are the actual values used): |
220 |
|
|
*** |
221 |
|
|
|
222 |
|
|
PERL_CC="$PERL_CC" |
223 |
|
|
PERL_CCFLAGS="$PERL_CCFLAGS" |
224 |
|
|
PERL_OPTIMIZE="$PERL_OPTIMIZE" |
225 |
|
|
PERL_LDFLAGS="$PERL_LDFLAGS" |
226 |
|
|
PERL_LIBS="$PERL_LIBS" |
227 |
|
|
|
228 |
|
|
EOF |
229 |
|
|
exit 1 |
230 |
|
|
} |
231 |
|
|
|
232 |
root |
1.1 |
configure() { |
233 |
|
|
fetch |
234 |
|
|
|
235 |
root |
1.6 |
rcd "$STATICPERL/src/perl-$PERL_VERSION" |
236 |
root |
1.1 |
|
237 |
|
|
[ -e staticstamp.configure ] && return |
238 |
|
|
|
239 |
|
|
verblock <<EOF |
240 |
root |
1.6 |
configuring $STATICPERL/src/perl-$PERL_VERSION |
241 |
root |
1.1 |
EOF |
242 |
|
|
|
243 |
root |
1.8 |
rm -f "$PERL_PREFIX/staticstamp.install" |
244 |
root |
1.1 |
|
245 |
root |
1.21 |
"$MAKE" distclean >/dev/null 2>&1 |
246 |
root |
1.1 |
|
247 |
root |
1.23 |
sedreplace '/^#define SITELIB/d' config_h.SH |
248 |
|
|
|
249 |
|
|
# I hate them for this |
250 |
root |
1.1 |
grep -q -- -fstack-protector Configure && \ |
251 |
|
|
sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure |
252 |
|
|
|
253 |
root |
1.37 |
# what did that bloke think |
254 |
|
|
grep -q -- usedl=.define hints/darwin.sh && \ |
255 |
|
|
sedreplace '/^usedl=.define.;$/d' hints/darwin.sh |
256 |
|
|
|
257 |
|
|
preconfigure || fatal "preconfigure hook failed" |
258 |
root |
1.7 |
|
259 |
root |
1.1 |
# trace configure \ |
260 |
|
|
sh Configure -Duselargefiles \ |
261 |
|
|
-Uuse64bitint \ |
262 |
|
|
-Dusemymalloc=n \ |
263 |
|
|
-Uusedl \ |
264 |
|
|
-Uusethreads \ |
265 |
|
|
-Uuseithreads \ |
266 |
|
|
-Uusemultiplicity \ |
267 |
|
|
-Uusesfio \ |
268 |
|
|
-Uuseshrplib \ |
269 |
root |
1.26 |
-Uinstallusrbinperl \ |
270 |
root |
1.22 |
-A ccflags=" $PERL_CCFLAGS" \ |
271 |
root |
1.19 |
-Dcc="$PERL_CC" \ |
272 |
root |
1.1 |
-Doptimize="$PERL_OPTIMIZE" \ |
273 |
|
|
-Dldflags="$PERL_LDFLAGS" \ |
274 |
|
|
-Dlibs="$PERL_LIBS" \ |
275 |
root |
1.6 |
-Dprefix="$PERL_PREFIX" \ |
276 |
|
|
-Dbin="$PERL_PREFIX/bin" \ |
277 |
|
|
-Dprivlib="$PERL_PREFIX/lib" \ |
278 |
|
|
-Darchlib="$PERL_PREFIX/lib" \ |
279 |
root |
1.1 |
-Uusevendorprefix \ |
280 |
root |
1.6 |
-Dsitelib="$PERL_PREFIX/lib" \ |
281 |
|
|
-Dsitearch="$PERL_PREFIX/lib" \ |
282 |
root |
1.1 |
-Uman1dir \ |
283 |
|
|
-Uman3dir \ |
284 |
|
|
-Usiteman1dir \ |
285 |
|
|
-Usiteman3dir \ |
286 |
|
|
-Dpager=/usr/bin/less \ |
287 |
|
|
-Demail="$EMAIL" \ |
288 |
|
|
-Dcf_email="$EMAIL" \ |
289 |
|
|
-Dcf_by="$EMAIL" \ |
290 |
root |
1.4 |
$PERL_CONFIGURE \ |
291 |
root |
1.19 |
-Duseperlio \ |
292 |
root |
1.22 |
-dE || configure_failure |
293 |
root |
1.1 |
|
294 |
|
|
sedreplace ' |
295 |
|
|
s/-Wl,--no-gc-sections/-Wl,--gc-sections/g |
296 |
|
|
s/ *-fno-stack-protector */ /g |
297 |
|
|
' config.sh |
298 |
|
|
|
299 |
root |
1.37 |
patchconfig || fatal "patchconfig hook failed" |
300 |
|
|
|
301 |
root |
1.1 |
sh Configure -S || fatal "Configure -S failed" |
302 |
|
|
|
303 |
|
|
postconfigure || fatal "postconfigure hook failed" |
304 |
|
|
|
305 |
root |
1.48 |
: > staticstamp.configure |
306 |
root |
1.1 |
} |
307 |
|
|
|
308 |
root |
1.39 |
write_shellscript() { |
309 |
|
|
{ |
310 |
|
|
echo "#!/bin/sh" |
311 |
|
|
echo "STATICPERL=\"$STATICPERL\"" |
312 |
|
|
echo "PERL_PREFIX=\"$PERL_PREFIX\"" |
313 |
|
|
echo "MAKE=\"$MAKE\"" |
314 |
|
|
cat |
315 |
|
|
} >"$PERL_PREFIX/bin/$1" |
316 |
|
|
chmod 755 "$PERL_PREFIX/bin/$1" |
317 |
|
|
} |
318 |
|
|
|
319 |
root |
1.1 |
build() { |
320 |
|
|
configure |
321 |
|
|
|
322 |
root |
1.6 |
rcd "$STATICPERL/src/perl-$PERL_VERSION" |
323 |
root |
1.1 |
|
324 |
|
|
verblock <<EOF |
325 |
root |
1.6 |
building $STATICPERL/src/perl-$PERL_VERSION |
326 |
root |
1.1 |
EOF |
327 |
|
|
|
328 |
root |
1.6 |
rm -f "$PERL_PREFIX/staticstamp.install" |
329 |
root |
1.1 |
|
330 |
root |
1.21 |
"$MAKE" || fatal "make: error while building perl" |
331 |
root |
1.1 |
|
332 |
|
|
postbuild || fatal "postbuild hook failed" |
333 |
|
|
} |
334 |
|
|
|
335 |
root |
1.48 |
_postinstall() { |
336 |
|
|
if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
337 |
|
|
NOCHECK_INSTALL=+ |
338 |
|
|
instcpan $STATICPERL_MODULES |
339 |
|
|
[ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
340 |
|
|
|
341 |
|
|
postinstall || fatal "postinstall hook failed" |
342 |
|
|
|
343 |
|
|
: > "$PERL_PREFIX/staticstamp.postinstall" |
344 |
|
|
fi |
345 |
|
|
} |
346 |
|
|
|
347 |
root |
1.1 |
install() { |
348 |
root |
1.9 |
if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
349 |
|
|
build |
350 |
root |
1.1 |
|
351 |
root |
1.9 |
verblock <<EOF |
352 |
root |
1.6 |
installing $STATICPERL/src/perl-$PERL_VERSION |
353 |
|
|
to $PERL_PREFIX |
354 |
root |
1.1 |
EOF |
355 |
|
|
|
356 |
root |
1.14 |
ln -sf "perl/bin/" "$STATICPERL/bin" |
357 |
|
|
ln -sf "perl/lib/" "$STATICPERL/lib" |
358 |
|
|
|
359 |
root |
1.39 |
mkdir "$STATICPERL/patched" |
360 |
|
|
|
361 |
root |
1.14 |
ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
362 |
|
|
rm -rf "$PERL_PREFIX" # by this rm -rf |
363 |
|
|
|
364 |
root |
1.21 |
"$MAKE" install || fatal "make install: error while installing" |
365 |
root |
1.1 |
|
366 |
root |
1.9 |
rcd "$PERL_PREFIX" |
367 |
root |
1.2 |
|
368 |
root |
1.9 |
# create a "make install" replacement for CPAN |
369 |
root |
1.39 |
write_shellscript SP-make-install-make <<'EOF' |
370 |
|
|
#CAT make-install-make.sh |
371 |
|
|
EOF |
372 |
root |
1.10 |
|
373 |
root |
1.39 |
# create a "patch modules" helper |
374 |
|
|
write_shellscript SP-patch-postinstall <<'EOF' |
375 |
|
|
#CAT patch-postinstall.sh |
376 |
|
|
EOF |
377 |
root |
1.10 |
|
378 |
root |
1.39 |
"$PERL_PREFIX/bin/SP-patch-postinstall" |
379 |
root |
1.9 |
|
380 |
root |
1.39 |
# help to trick CPAN into avoiding ~/.cpan completely |
381 |
root |
1.9 |
echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
382 |
root |
1.1 |
|
383 |
root |
1.39 |
# we call cpan with -MCPAN::MyConfig in this script, which |
384 |
|
|
# is strictly unnecssary as we have to patch CPAN anyway, |
385 |
|
|
# so consider it "for good measure". |
386 |
root |
1.36 |
"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
387 |
root |
1.9 |
CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
388 |
|
|
CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
389 |
|
|
CPAN::Shell->o (conf => q<init>); |
390 |
|
|
CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
391 |
|
|
CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
392 |
|
|
CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
393 |
|
|
CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
394 |
|
|
CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
395 |
root |
1.39 |
CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
396 |
root |
1.9 |
CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
397 |
|
|
CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); |
398 |
root |
1.36 |
CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); |
399 |
root |
1.9 |
CPAN::Shell->o (conf => q<commit>); |
400 |
|
|
' || fatal "error while initialising CPAN" |
401 |
root |
1.2 |
|
402 |
root |
1.48 |
: > "$PERL_PREFIX/staticstamp.install" |
403 |
root |
1.9 |
fi |
404 |
|
|
|
405 |
root |
1.48 |
_postinstall |
406 |
|
|
} |
407 |
|
|
|
408 |
|
|
import() { |
409 |
|
|
IMPORT="$1" |
410 |
|
|
|
411 |
|
|
rcd "$STATICPERL" |
412 |
|
|
|
413 |
|
|
if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
414 |
|
|
verblock <<EOF |
415 |
|
|
import perl from $IMPORT to $STATICPERL |
416 |
|
|
EOF |
417 |
root |
1.1 |
|
418 |
root |
1.48 |
rm -rf bin cpan lib patched perl src |
419 |
|
|
mkdir -m 755 perl perl/bin |
420 |
|
|
ln -s perl/bin/ bin |
421 |
|
|
ln -s "$IMPORT" perl/bin/ |
422 |
root |
1.1 |
|
423 |
root |
1.48 |
: > "$PERL_PREFIX/staticstamp.install" |
424 |
root |
1.9 |
fi |
425 |
root |
1.48 |
|
426 |
|
|
_postinstall |
427 |
root |
1.1 |
} |
428 |
|
|
|
429 |
|
|
############################################################################# |
430 |
|
|
# install a module from CPAN |
431 |
|
|
|
432 |
|
|
instcpan() { |
433 |
|
|
[ $NOCHECK_INSTALL ] || install |
434 |
|
|
|
435 |
|
|
verblock <<EOF |
436 |
|
|
installing modules from CPAN |
437 |
|
|
$@ |
438 |
|
|
EOF |
439 |
|
|
|
440 |
root |
1.50 |
"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
441 |
|
|
#"$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
442 |
root |
1.48 |
|
443 |
|
|
if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
444 |
|
|
fatal "failure while installing modules from CPAN ($@)" |
445 |
|
|
fi |
446 |
|
|
rm -f "$STATICPERL/instcpan.log" |
447 |
root |
1.1 |
} |
448 |
|
|
|
449 |
|
|
############################################################################# |
450 |
|
|
# install a module from unpacked sources |
451 |
|
|
|
452 |
|
|
instsrc() { |
453 |
|
|
[ $NOCHECK_INSTALL ] || install |
454 |
|
|
|
455 |
|
|
verblock <<EOF |
456 |
|
|
installing modules from source |
457 |
|
|
$@ |
458 |
|
|
EOF |
459 |
|
|
|
460 |
|
|
for mod in "$@"; do |
461 |
|
|
echo |
462 |
|
|
echo $mod |
463 |
|
|
( |
464 |
|
|
rcd $mod |
465 |
root |
1.21 |
"$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 |
466 |
|
|
"$MAKE" distclean >/dev/null 2>&1 |
467 |
root |
1.6 |
"$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" |
468 |
root |
1.21 |
"$MAKE" || fatal "$mod: error building module" |
469 |
root |
1.39 |
"$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" |
470 |
root |
1.21 |
"$MAKE" distclean >/dev/null 2>&1 |
471 |
root |
1.1 |
exit 0 |
472 |
|
|
) || exit $? |
473 |
|
|
done |
474 |
|
|
} |
475 |
|
|
|
476 |
|
|
############################################################################# |
477 |
|
|
# main |
478 |
|
|
|
479 |
|
|
podusage() { |
480 |
|
|
echo |
481 |
root |
1.17 |
|
482 |
root |
1.6 |
if [ -e "$PERL_PREFIX/bin/perl" ]; then |
483 |
|
|
"$PERL_PREFIX/bin/perl" -MPod::Usage -e \ |
484 |
root |
1.1 |
'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
485 |
|
|
2>/dev/null && exit |
486 |
|
|
fi |
487 |
root |
1.17 |
|
488 |
root |
1.1 |
# try whatever perl we can find |
489 |
|
|
perl -MPod::Usage -e \ |
490 |
|
|
'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ |
491 |
|
|
2>/dev/null && exit |
492 |
|
|
|
493 |
root |
1.17 |
fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location" |
494 |
root |
1.1 |
} |
495 |
|
|
|
496 |
|
|
usage() { |
497 |
|
|
podusage 0 |
498 |
|
|
} |
499 |
|
|
|
500 |
|
|
catmkbundle() { |
501 |
|
|
{ |
502 |
|
|
read dummy |
503 |
root |
1.6 |
echo "#!$PERL_PREFIX/bin/perl" |
504 |
root |
1.1 |
cat |
505 |
|
|
} <<'MKBUNDLE' |
506 |
|
|
#CAT mkbundle |
507 |
|
|
MKBUNDLE |
508 |
|
|
} |
509 |
|
|
|
510 |
|
|
bundle() { |
511 |
root |
1.39 |
MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
512 |
root |
1.1 |
catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
513 |
|
|
chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" |
514 |
root |
1.12 |
CACHE="$STATICPERL/cache" |
515 |
|
|
mkdir -p "$CACHE" |
516 |
|
|
"$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" |
517 |
root |
1.1 |
} |
518 |
|
|
|
519 |
|
|
if [ $# -gt 0 ]; then |
520 |
|
|
while [ $# -gt 0 ]; do |
521 |
|
|
mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" |
522 |
root |
1.6 |
mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" |
523 |
root |
1.1 |
|
524 |
|
|
command="${1#--}"; shift |
525 |
|
|
case "$command" in |
526 |
root |
1.14 |
version ) |
527 |
|
|
echo "staticperl version $VERSION" |
528 |
|
|
;; |
529 |
root |
1.48 |
fetch | configure | build | install | clean | realclean | distclean ) |
530 |
root |
1.22 |
( "$command" ) || exit |
531 |
root |
1.1 |
;; |
532 |
root |
1.48 |
import ) |
533 |
|
|
( import "$1" ) || exit |
534 |
|
|
shift |
535 |
|
|
;; |
536 |
root |
1.1 |
instsrc ) |
537 |
root |
1.22 |
( instsrc "$@" ) || exit |
538 |
root |
1.1 |
exit |
539 |
|
|
;; |
540 |
|
|
instcpan ) |
541 |
root |
1.22 |
( instcpan "$@" ) || exit |
542 |
root |
1.1 |
exit |
543 |
|
|
;; |
544 |
root |
1.39 |
perl ) |
545 |
|
|
( install ) || exit |
546 |
|
|
exec "$PERL_PREFIX/bin/perl" "$@" |
547 |
|
|
exit |
548 |
|
|
;; |
549 |
root |
1.1 |
cpan ) |
550 |
root |
1.22 |
( install ) || exit |
551 |
root |
1.48 |
PERL="$PERL_PREFIX/bin/perl" |
552 |
|
|
export PERL |
553 |
root |
1.39 |
exec "$PERL_PREFIX/bin/cpan" "$@" |
554 |
root |
1.1 |
exit |
555 |
|
|
;; |
556 |
|
|
mkbundle ) |
557 |
root |
1.22 |
( install ) || exit |
558 |
root |
1.40 |
bundle "$@" |
559 |
root |
1.1 |
exit |
560 |
|
|
;; |
561 |
|
|
mkperl ) |
562 |
root |
1.22 |
( install ) || exit |
563 |
root |
1.40 |
bundle --perl "$@" |
564 |
root |
1.1 |
exit |
565 |
|
|
;; |
566 |
root |
1.11 |
mkapp ) |
567 |
root |
1.22 |
( install ) || exit |
568 |
root |
1.40 |
bundle --app "$@" |
569 |
root |
1.11 |
exit |
570 |
|
|
;; |
571 |
root |
1.1 |
help ) |
572 |
|
|
podusage 2 |
573 |
|
|
;; |
574 |
|
|
* ) |
575 |
|
|
exec 1>&2 |
576 |
|
|
echo |
577 |
|
|
echo "Unknown command: $command" |
578 |
|
|
podusage 0 |
579 |
|
|
;; |
580 |
|
|
esac |
581 |
|
|
done |
582 |
|
|
else |
583 |
|
|
usage |
584 |
|
|
fi |
585 |
|
|
|
586 |
|
|
exit 0 |
587 |
|
|
|
588 |
|
|
#CAT staticperl.pod |
589 |
|
|
|