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