ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.sh
(Generate patch)

Comparing App-Staticperl/staticperl.sh (file contents):
Revision 1.1 by root, Mon Dec 6 19:33:58 2010 UTC vs.
Revision 1.6 by root, Tue Dec 7 10:40:39 2010 UTC

1#!/bin/sh 1#!/bin/sh
2 2
3############################################################################# 3#############################################################################
4# configuration to fill in 4# configuration to fill in
5 5
6PERLVER=5.12.2 # 5.8.9 is also a good choice
7STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
8CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use
9EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
10 9
11MKBUNDLE="$STATICPERL/mkbundle" 10MKBUNDLE="$STATICPERL/mkbundle"
12 11
13# perl build variables 12# perl build variables
14PREFIX="$STATICPERL/perl" # where the perl gets installed 13PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed
14PERL_VERSION=5.12.2 # 5.8.9 is also a good choice
15PERL_CONFIGURE="" # additional Configure arguments
15PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 16PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP"
16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
17 18
18ARCH="$(uname -m)" 19ARCH="$(uname -m)"
19 20
39#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow 40#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
40export 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' 41export EV_EXTRA_DEFS='-DEV_FEATURES=4+8+16+64 -DEV_USE_SELECT=0 -DEV_USE_POLL=1 -DEV_USE_EPOLL=1 -DEV_NO_LOOPS -DEV_COMPAT3=0'
41 42
42# which extra modules to install by default from CPAN that are 43# which extra modules to install by default from CPAN that are
43# required by mkbundle 44# required by mkbundle
44EXTRA_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 45STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage"
46
47# which extra modules you might want to install
48EXTRA_MODULES=""
45 49
46# overridable functions 50# overridable functions
47postconfigure() { : ; } 51postconfigure() { : ; }
48postbuild() { : ; } 52postbuild() { : ; }
49postinstall() { : ; } 53postinstall() { : ; }
109 113
110############################################################################# 114#############################################################################
111# download/configure/compile/install perl 115# download/configure/compile/install perl
112 116
113clean() { 117clean() {
114 cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return 118 cd "$STATICPERL/src/perl-$PERL_VERSION" 2>/dev/null || return
115 119
116 rm -f staticstamp.configure 120 rm -f staticstamp.configure
117 make distclean >/dev/null 2>&1 121 make distclean >/dev/null 2>&1
118} 122}
119 123
121 rcd "$STATICPERL" 125 rcd "$STATICPERL"
122 126
123 mkdir -p src 127 mkdir -p src
124 rcd src 128 rcd src
125 129
126 if ! [ -d "perl-$PERLVER" ]; then 130 if ! [ -d "perl-$PERL_VERSION" ]; then
127 if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then 131 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then
128 132
129 URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" 133 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2"
130 134
131 verblock <<EOF 135 verblock <<EOF
132downloading perl 136downloading perl
133to manually download perl yourself, place 137to manually download perl yourself, place
134perl-$PERLVER.tar.$BZ2 in $STATICPERL 138perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
135trying $URL 139trying $URL
136EOF 140EOF
137 141
138 curl >perl-$PERLVER.tar.$BZ2~ "$URL" \ 142 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side
139 || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ 143 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
144 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
140 || fatal "$URL: error during downloading" 145 || fatal "$URL: unable to download"
141 mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.tar.$BZ2 146 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2
142 fi 147 fi
143 148
144 verblock <<EOF 149 verblock <<EOF
145unpacking perl 150unpacking perl
146EOF 151EOF
147 152
148 mkdir -p unpack 153 mkdir -p unpack
149 $BZIP2 -d <perl-$PERLVER.tar.bz2 | tar xpC unpack \ 154 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xpC unpack \
150 || fatal "perl-$PERLVER.tar.bz2: error during unpacking" 155 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking"
151 mv unpack/perl-$PERLVER perl-$PERLVER 156 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
152 rmdir -p unpack 157 rmdir -p unpack
153 fi 158 fi
154} 159}
155 160
156# similar to GNU-sed -i or perl -pi 161# similar to GNU-sed -i or perl -pi
160} 165}
161 166
162configure() { 167configure() {
163 fetch 168 fetch
164 169
165 rcd "$STATICPERL/src/perl-$PERLVER" 170 rcd "$STATICPERL/src/perl-$PERL_VERSION"
166 171
167 [ -e staticstamp.configure ] && return 172 [ -e staticstamp.configure ] && return
168 173
169 verblock <<EOF 174 verblock <<EOF
170configuring $STATICPERL/src/perl-$PERLVER 175configuring $STATICPERL/src/perl-$PERL_VERSION
171EOF 176EOF
172 177
173 clean 178 clean
174 179
175 rm -f "$PREFIX/staticstamp.install" 180 rm -f "$PERL_PREFIX/staticstamp.install"
176 181
177 # I hate them 182 # I hate them
178 grep -q -- -fstack-protector Configure && \ 183 grep -q -- -fstack-protector Configure && \
179 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 184 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
180 185
192 -Dcppflags="$PERL_CPPFLAGS" \ 197 -Dcppflags="$PERL_CPPFLAGS" \
193 -Dccflags="-g2 -fno-strict-aliasing" \ 198 -Dccflags="-g2 -fno-strict-aliasing" \
194 -Doptimize="$PERL_OPTIMIZE" \ 199 -Doptimize="$PERL_OPTIMIZE" \
195 -Dldflags="$PERL_LDFLAGS" \ 200 -Dldflags="$PERL_LDFLAGS" \
196 -Dlibs="$PERL_LIBS" \ 201 -Dlibs="$PERL_LIBS" \
197 -Dprefix="$PREFIX" \ 202 -Dprefix="$PERL_PREFIX" \
198 -Dbin="$PREFIX/bin" \ 203 -Dbin="$PERL_PREFIX/bin" \
199 -Dprivlib="$PREFIX/plib" \ 204 -Dprivlib="$PERL_PREFIX/lib" \
200 -Darchlib="$PREFIX/plib" \ 205 -Darchlib="$PERL_PREFIX/lib" \
201 -Uusevendorprefix \ 206 -Uusevendorprefix \
202 -Dsitelib="$PREFIX/plib" \ 207 -Dsitelib="$PERL_PREFIX/lib" \
203 -Dsitearch="$PREFIX/plib" \ 208 -Dsitearch="$PERL_PREFIX/lib" \
204 -Usitelibexp \ 209 -Usitelibexp \
205 -Uman1dir \ 210 -Uman1dir \
206 -Uman3dir \ 211 -Uman3dir \
207 -Usiteman1dir \ 212 -Usiteman1dir \
208 -Usiteman3dir \ 213 -Usiteman3dir \
209 -Dpager=/usr/bin/less \ 214 -Dpager=/usr/bin/less \
210 -Demail="$EMAIL" \ 215 -Demail="$EMAIL" \
211 -Dcf_email="$EMAIL" \ 216 -Dcf_email="$EMAIL" \
212 -Dcf_by="$EMAIL" \ 217 -Dcf_by="$EMAIL" \
218 $PERL_CONFIGURE \
213 -dE || fatal "Configure failed" 219 -dE || fatal "Configure failed"
214 220
215 sedreplace ' 221 sedreplace '
216 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 222 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
217 s/ *-fno-stack-protector */ /g 223 s/ *-fno-stack-protector */ /g
225} 231}
226 232
227build() { 233build() {
228 configure 234 configure
229 235
230 rcd "$STATICPERL/src/perl-$PERLVER" 236 rcd "$STATICPERL/src/perl-$PERL_VERSION"
231 237
232 verblock <<EOF 238 verblock <<EOF
233building $STATICPERL/src/perl-$PERLVER 239building $STATICPERL/src/perl-$PERL_VERSION
234EOF 240EOF
235 241
236 rm -f "$PREFIX/staticstamp.install" 242 rm -f "$PERL_PREFIX/staticstamp.install"
237 243
238 make || fatal "make: error while building perl" 244 make || fatal "make: error while building perl"
239 245
240 postbuild || fatal "postbuild hook failed" 246 postbuild || fatal "postbuild hook failed"
241} 247}
242 248
243install() { 249install() {
244 [ -e "$PREFIX/staticstamp.install" ] && return 250 [ -e "$PERL_PREFIX/staticstamp.install" ] && return
245 251
246 build 252 build
247 253
248 verblock <<EOF 254 verblock <<EOF
249installing $STATICPERL/src/perl-$PERLVER 255installing $STATICPERL/src/perl-$PERL_VERSION
250to $PREFIX 256to $PERL_PREFIX
251EOF 257EOF
252 258
253 rm -rf "$PREFIX" 259 rm -rf "$PERL_PREFIX"
254 260
255 make install || fatal "make install: error while installing" 261 make install || fatal "make install: error while installing"
256 262
263 rcd "$PERL_PREFIX"
264
257 # create a "make install" replacement for CPAN 265 # create a "make install" replacement for CPAN
258 cat >"$PREFIX"/bin/cpan-make-install <<EOF 266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
259make install UNINST=1 267make install UNINST=1
260if find blib/arch/auto -type f | grep -q -v .exists; then 268if find blib/arch/auto -type f | grep -q -v .exists; then
261 echo Probably an XS module, rebuilding perl 269 echo Probably an XS module, rebuilding perl
262 make perl 270 make perl
263 rm -f "$PREFIX"/bin/perl 271 rm -f "$PERL_PREFIX"/bin/perl
264 make -f Makefile.aperl inst_perl 272 make -f Makefile.aperl inst_perl
265 make -f Makefile.aperl map_clean 273 make -f Makefile.aperl map_clean
266fi 274fi
267EOF 275EOF
268 chmod 755 "$PREFIX"/bin/cpan-make-install 276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
269 277
278 # trick CPAN into avoiding ~/.cpan completely
279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
280
270 "$PREFIX"/bin/perl -MCPAN -e ' 281 "$PERL_PREFIX"/bin/perl -MCPAN -e '
271 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 282 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
283 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
272 CPAN::Shell->o (conf => q<init>); 284 CPAN::Shell->o (conf => q<init>);
273 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 285 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
274 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 286 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
275 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 287 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
276 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 288 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
277 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 289 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
278 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PREFIX"'/bin/cpan-make-install"); 290 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install");
279 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 291 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
280 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 292 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
281 CPAN::Shell->o (conf => q<commit>); 293 CPAN::Shell->o (conf => q<commit>);
282 ' || fatal "error while initialising CPAN" 294 ' || fatal "error while initialising CPAN"
283 295
284 NOCHECK_INSTALL=+ 296 NOCHECK_INSTALL=+
285 instcpan $EXTRA_MODULES 297 instcpan $STATICPERL_MODULES
298 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
286 299
287 postinstall || fatal "postinstall hook failed" 300 postinstall || fatal "postinstall hook failed"
288 301
289 touch "$PREFIX/staticstamp.install" 302 touch "$PERL_PREFIX/staticstamp.install"
290} 303}
291 304
292############################################################################# 305#############################################################################
293# install a module from CPAN 306# install a module from CPAN
294 307
299installing modules from CPAN 312installing modules from CPAN
300$@ 313$@
301EOF 314EOF
302 315
303 for mod in "$@"; do 316 for mod in "$@"; do
304 "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 317 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \
305 || fatal "$mod: unable to install from CPAN" 318 || fatal "$mod: unable to install from CPAN"
306 done 319 done
307 rm -rf "$STATICPERL/build" 320 rm -rf "$STATICPERL/build"
308} 321}
309 322
323 echo $mod 336 echo $mod
324 ( 337 (
325 rcd $mod 338 rcd $mod
326 make -f Makefile.aperl map_clean >/dev/null 2>&1 339 make -f Makefile.aperl map_clean >/dev/null 2>&1
327 make distclean >/dev/null 2>&1 340 make distclean >/dev/null 2>&1
328 "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 341 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
329 make || fatal "$mod: error building module" 342 make || fatal "$mod: error building module"
330 "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 343 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module"
331 make distclean >/dev/null 2>&1 344 make distclean >/dev/null 2>&1
332 exit 0 345 exit 0
333 ) || exit $? 346 ) || exit $?
334 done 347 done
335} 348}
336 349
337############################################################################# 350#############################################################################
338# do schmorpy stuff
339
340MODSRCDIR=~/src
341
342instmodsrc() {
343 for mod in "$@"; do
344 instmod_src "$MODSRCDIR/$mod"
345 done
346}
347
348install_schmorp() {
349 install
350
351 instcpan Data::Dump Term::ReadLine::Perl Term::ANSIColor Term::ReadKey
352 instcpan Digest::SHA Digest::MD6 Digest::SHA256 Digest::MD4 Digest::HMAC_MD5 Digest::HMAC_MD6 Digest::FNV
353 #instcpan Net::SSLeay # requires static -ldl
354
355 instmodsrc common-sense Crypt-Twofish2 Array-Heap Convert-Scalar Compress-LZF JSON-XS
356 instmodsrc EV Guard Async-Interrupt IO-AIO
357 instmodsrc AnyEvent AnyEvent-AIO Coro AnyEvent-HTTP
358 instmodsrc Linux-Inotify2 EV-Loop-Async
359
360 instcpan AnyEvent::HTTPD
361}
362
363#############################################################################
364# main 351# main
365 352
366podusage() { 353podusage() {
367 echo 354 echo
368 if [ -e "$PREFIX/bin/perl" ]; then 355 if [ -e "$PERL_PREFIX/bin/perl" ]; then
369 "$PREFIX/bin/perl" -MPod::Usage -e \ 356 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
370 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 357 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
371 2>/dev/null && exit 358 2>/dev/null && exit
372 fi 359 fi
373 # try whatever perl we can find 360 # try whatever perl we can find
374 perl -MPod::Usage -e \ 361 perl -MPod::Usage -e \
383} 370}
384 371
385catmkbundle() { 372catmkbundle() {
386 { 373 {
387 read dummy 374 read dummy
388 echo "#!$PREFIX/bin/perl" 375 echo "#!$PERL_PREFIX/bin/perl"
389 cat 376 cat
390 } <<'MKBUNDLE' 377 } <<'MKBUNDLE'
391#CAT mkbundle 378#CAT mkbundle
392MKBUNDLE 379MKBUNDLE
393} 380}
394 381
395bundle() { 382bundle() {
396 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 383 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
397 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 384 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
398 "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 385 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@"
399} 386}
400 387
401if [ $# -gt 0 ]; then 388if [ $# -gt 0 ]; then
402 while [ $# -gt 0 ]; do 389 while [ $# -gt 0 ]; do
403 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 390 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
404 mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" 391 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
405 392
406 command="${1#--}"; shift 393 command="${1#--}"; shift
407 case "$command" in 394 case "$command" in
408 fetch | configure | build | install | clean | distclean) 395 fetch | configure | build | install | clean | distclean)
409 verblock <<EOF 396 verblock <<EOF
410$command 397$command
411EOF 398EOF
412 "$command" 399 ( "$command" )
413 ;; 400 ;;
414 instsrc ) 401 instsrc )
415 instsrc "$@" 402 ( instsrc "$@" )
416 exit 403 exit
417 ;; 404 ;;
418 instcpan ) 405 instcpan )
419 instcpan "$@" 406 ( instcpan "$@" )
420 exit 407 exit
421 ;; 408 ;;
422 instschmorp )
423 install_schmorp
424 ;;
425 cpan ) 409 cpan )
426 install 410 ( install )
427 "$PREFIX/bin/cpan" "$@" 411 "$PERL_PREFIX/bin/cpan" "$@"
428 exit 412 exit
429 ;; 413 ;;
430 mkbundle ) 414 mkbundle )
431 install 415 ( install )
432 bundle "$@" 416 bundle "$@"
433 exit 417 exit
434 ;; 418 ;;
435 mkperl ) 419 mkperl )
436 install 420 ( install )
437 bundle --perl "$@" 421 bundle --perl "$@"
438 exit 422 exit
439 ;; 423 ;;
440 help ) 424 help )
441 podusage 2 425 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines