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