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.4 by root, Tue Dec 7 09:27:54 2010 UTC vs.
Revision 1.9 by root, Tue Dec 7 20:03:15 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_CONFIGURE="" # additional Configure arguments
16PERL_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"
17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 18
19ARCH="$(uname -m)" 19ARCH="$(uname -m)"
46 46
47# which extra modules you might want to install 47# which extra modules you might want to install
48EXTRA_MODULES="" 48EXTRA_MODULES=""
49 49
50# overridable functions 50# overridable functions
51preconfigure() { : ; }
51postconfigure() { : ; } 52postconfigure() { : ; }
52postbuild() { : ; } 53postbuild() { : ; }
53postinstall() { : ; } 54postinstall() { : ; }
54 55
55# now source user config, if any 56# now source user config, if any
113 114
114############################################################################# 115#############################################################################
115# download/configure/compile/install perl 116# download/configure/compile/install perl
116 117
117clean() { 118clean() {
118 cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return 119 rm -rf "$STATICPERL/src/perl-$PERL_VERSION"
119
120 rm -f staticstamp.configure
121 make distclean >/dev/null 2>&1
122} 120}
123 121
124fetch() { 122fetch() {
125 rcd "$STATICPERL" 123 rcd "$STATICPERL"
126 124
127 mkdir -p src 125 mkdir -p src
128 rcd src 126 rcd src
129 127
130 if ! [ -d "perl-$PERLVER" ]; then 128 if ! [ -d "perl-$PERL_VERSION" ]; then
131 if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then 129 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then
132 130
133 URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" 131 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2"
134 132
135 verblock <<EOF 133 verblock <<EOF
136downloading perl 134downloading perl
137to manually download perl yourself, place 135to manually download perl yourself, place
138perl-$PERLVER.tar.$BZ2 in $STATICPERL 136perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
139trying $URL 137trying $URL
140EOF 138EOF
141 139
142 curl >perl-$PERLVER.tar.$BZ2~ "$URL" \ 140 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side
143 || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ 141 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
142 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
144 || fatal "$URL: error during downloading" 143 || fatal "$URL: unable to download"
145 mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.tar.$BZ2 144 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2
146 fi 145 fi
147 146
148 verblock <<EOF 147 verblock <<EOF
149unpacking perl 148unpacking perl
150EOF 149EOF
151 150
152 mkdir -p unpack 151 mkdir -p unpack
153 $BZIP2 -d <perl-$PERLVER.tar.bz2 | tar xpC unpack \ 152 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \
154 || fatal "perl-$PERLVER.tar.bz2: error during unpacking" 153 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking"
154 chmod -R u+w unpack/perl-$PERL_VERSION
155 mv unpack/perl-$PERLVER perl-$PERLVER 155 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
156 rmdir -p unpack 156 rmdir -p unpack
157 fi 157 fi
158} 158}
159 159
160# similar to GNU-sed -i or perl -pi 160# similar to GNU-sed -i or perl -pi
164} 164}
165 165
166configure() { 166configure() {
167 fetch 167 fetch
168 168
169 rcd "$STATICPERL/src/perl-$PERLVER" 169 rcd "$STATICPERL/src/perl-$PERL_VERSION"
170 170
171 [ -e staticstamp.configure ] && return 171 [ -e staticstamp.configure ] && return
172 172
173 verblock <<EOF 173 verblock <<EOF
174configuring $STATICPERL/src/perl-$PERLVER 174configuring $STATICPERL/src/perl-$PERL_VERSION
175EOF 175EOF
176 176
177 clean
178
179 rm -f "$PREFIX/staticstamp.install" 177 rm -f "$PERL_PREFIX/staticstamp.install"
178
179 make distclean >/dev/null 2>&1
180 180
181 # I hate them 181 # I hate them
182 grep -q -- -fstack-protector Configure && \ 182 grep -q -- -fstack-protector Configure && \
183 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 183 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
184
185 preconfigure
184 186
185# trace configure \ 187# trace configure \
186 sh Configure -Duselargefiles \ 188 sh Configure -Duselargefiles \
187 -Uuse64bitint \ 189 -Uuse64bitint \
188 -Dusemymalloc=n \ 190 -Dusemymalloc=n \
196 -Dcppflags="$PERL_CPPFLAGS" \ 198 -Dcppflags="$PERL_CPPFLAGS" \
197 -Dccflags="-g2 -fno-strict-aliasing" \ 199 -Dccflags="-g2 -fno-strict-aliasing" \
198 -Doptimize="$PERL_OPTIMIZE" \ 200 -Doptimize="$PERL_OPTIMIZE" \
199 -Dldflags="$PERL_LDFLAGS" \ 201 -Dldflags="$PERL_LDFLAGS" \
200 -Dlibs="$PERL_LIBS" \ 202 -Dlibs="$PERL_LIBS" \
201 -Dprefix="$PREFIX" \ 203 -Dprefix="$PERL_PREFIX" \
202 -Dbin="$PREFIX/bin" \ 204 -Dbin="$PERL_PREFIX/bin" \
203 -Dprivlib="$PREFIX/lib" \ 205 -Dprivlib="$PERL_PREFIX/lib" \
204 -Darchlib="$PREFIX/lib" \ 206 -Darchlib="$PERL_PREFIX/lib" \
205 -Uusevendorprefix \ 207 -Uusevendorprefix \
206 -Dsitelib="$PREFIX/lib" \ 208 -Dsitelib="$PERL_PREFIX/lib" \
207 -Dsitearch="$PREFIX/lib" \ 209 -Dsitearch="$PERL_PREFIX/lib" \
208 -Usitelibexp \ 210 -Usitelibexp \
209 -Uman1dir \ 211 -Uman1dir \
210 -Uman3dir \ 212 -Uman3dir \
211 -Usiteman1dir \ 213 -Usiteman1dir \
212 -Usiteman3dir \ 214 -Usiteman3dir \
230} 232}
231 233
232build() { 234build() {
233 configure 235 configure
234 236
235 rcd "$STATICPERL/src/perl-$PERLVER" 237 rcd "$STATICPERL/src/perl-$PERL_VERSION"
236 238
237 verblock <<EOF 239 verblock <<EOF
238building $STATICPERL/src/perl-$PERLVER 240building $STATICPERL/src/perl-$PERL_VERSION
239EOF 241EOF
240 242
241 rm -f "$PREFIX/staticstamp.install" 243 rm -f "$PERL_PREFIX/staticstamp.install"
242 244
243 make || fatal "make: error while building perl" 245 make || fatal "make: error while building perl"
244 246
245 postbuild || fatal "postbuild hook failed" 247 postbuild || fatal "postbuild hook failed"
246} 248}
247 249
248install() { 250install() {
249 [ -e "$PREFIX/staticstamp.install" ] && return 251 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
250
251 build 252 build
252 253
253 verblock <<EOF 254 verblock <<EOF
254installing $STATICPERL/src/perl-$PERLVER 255installing $STATICPERL/src/perl-$PERL_VERSION
255to $PREFIX 256to $PERL_PREFIX
256EOF 257EOF
257 258
258 rm -rf "$PREFIX" 259 rm -rf "$PERL_PREFIX"
259 260
260 make install || fatal "make install: error while installing" 261 make install || fatal "make install: error while installing"
261 262
262 rcd "$PREFIX" 263 rcd "$PERL_PREFIX"
263 264
264 # create a "make install" replacement for CPAN 265 # create a "make install" replacement for CPAN
265 cat >"$PREFIX"/bin/cpan-make-install <<EOF 266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
266make install UNINST=1 267make install UNINST=1
267if find blib/arch/auto -type f | grep -q -v .exists; then 268if find blib/arch/auto -type f | grep -q -v .exists; then
268 echo Probably an XS module, rebuilding perl 269 echo Probably an XS module, rebuilding perl
269 make perl 270 make perl
270 rm -f "$PREFIX"/bin/perl 271 rm -f "$PERL_PREFIX"/bin/perl
271 make -f Makefile.aperl inst_perl 272 make -f Makefile.aperl inst_perl
272 make -f Makefile.aperl map_clean 273 make -f Makefile.aperl map_clean
273fi 274fi
274EOF 275EOF
275 chmod 755 "$PREFIX"/bin/cpan-make-install 276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
276 277
277 # trick CPAN into avoiding ~/.cpan completely 278 # trick CPAN into avoiding ~/.cpan completely
278 echo 1 >"$PREFIX/lib/CPAN/MyConfig.pm" 279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
279 280
280 "$PREFIX"/bin/perl -MCPAN -e ' 281 "$PERL_PREFIX"/bin/perl -MCPAN -e '
281 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 282 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
282 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 283 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
283 CPAN::Shell->o (conf => q<init>); 284 CPAN::Shell->o (conf => q<init>);
284 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 285 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
285 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 286 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
286 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 287 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
287 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 288 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
288 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 289 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
289 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");
290 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 291 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
291 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 292 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
292 CPAN::Shell->o (conf => q<commit>); 293 CPAN::Shell->o (conf => q<commit>);
293 ' || fatal "error while initialising CPAN" 294 ' || fatal "error while initialising CPAN"
294 295
296 touch "$PERL_PREFIX/staticstamp.install"
297 fi
298
299 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall"; then
295 NOCHECK_INSTALL=+ 300 NOCHECK_INSTALL=+
296 instcpan $STATICPERL_MODULES 301 instcpan $STATICPERL_MODULES
297 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 302 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
298 303
299 postinstall || fatal "postinstall hook failed" 304 postinstall || fatal "postinstall hook failed"
300 305
301 touch "$PREFIX/staticstamp.install" 306 touch "$PERL_PREFIX/staticstamp.postinstall"
307 fi
302} 308}
303 309
304############################################################################# 310#############################################################################
305# install a module from CPAN 311# install a module from CPAN
306 312
311installing modules from CPAN 317installing modules from CPAN
312$@ 318$@
313EOF 319EOF
314 320
315 for mod in "$@"; do 321 for mod in "$@"; do
316 "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 322 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \
317 || fatal "$mod: unable to install from CPAN" 323 || fatal "$mod: unable to install from CPAN"
318 done 324 done
319 rm -rf "$STATICPERL/build" 325 rm -rf "$STATICPERL/build"
320} 326}
321 327
335 echo $mod 341 echo $mod
336 ( 342 (
337 rcd $mod 343 rcd $mod
338 make -f Makefile.aperl map_clean >/dev/null 2>&1 344 make -f Makefile.aperl map_clean >/dev/null 2>&1
339 make distclean >/dev/null 2>&1 345 make distclean >/dev/null 2>&1
340 "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 346 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
341 make || fatal "$mod: error building module" 347 make || fatal "$mod: error building module"
342 "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 348 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module"
343 make distclean >/dev/null 2>&1 349 make distclean >/dev/null 2>&1
344 exit 0 350 exit 0
345 ) || exit $? 351 ) || exit $?
346 done 352 done
347} 353}
348 354
349############################################################################# 355#############################################################################
350# do schmorpy stuff
351
352MODSRCDIR=~/src
353
354instmodsrc() {
355 for mod in "$@"; do
356 instmod_src "$MODSRCDIR/$mod"
357 done
358}
359
360install_schmorp() {
361 install
362
363 instcpan Data::Dump Term::ReadLine::Perl Term::ANSIColor Term::ReadKey
364 instcpan Digest::SHA Digest::MD6 Digest::SHA256 Digest::MD4 Digest::HMAC_MD5 Digest::HMAC_MD6 Digest::FNV
365 #instcpan Net::SSLeay # requires static -ldl
366
367 instmodsrc common-sense Crypt-Twofish2 Array-Heap Convert-Scalar Compress-LZF JSON-XS
368 instmodsrc EV Guard Async-Interrupt IO-AIO
369 instmodsrc AnyEvent AnyEvent-AIO Coro AnyEvent-HTTP
370 instmodsrc Linux-Inotify2 EV-Loop-Async
371
372 instcpan AnyEvent::HTTPD
373}
374
375#############################################################################
376# main 356# main
377 357
378podusage() { 358podusage() {
379 echo 359 echo
380 if [ -e "$PREFIX/bin/perl" ]; then 360 if [ -e "$PERL_PREFIX/bin/perl" ]; then
381 "$PREFIX/bin/perl" -MPod::Usage -e \ 361 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
382 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 362 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
383 2>/dev/null && exit 363 2>/dev/null && exit
384 fi 364 fi
385 # try whatever perl we can find 365 # try whatever perl we can find
386 perl -MPod::Usage -e \ 366 perl -MPod::Usage -e \
395} 375}
396 376
397catmkbundle() { 377catmkbundle() {
398 { 378 {
399 read dummy 379 read dummy
400 echo "#!$PREFIX/bin/perl" 380 echo "#!$PERL_PREFIX/bin/perl"
401 cat 381 cat
402 } <<'MKBUNDLE' 382 } <<'MKBUNDLE'
403#CAT mkbundle 383#CAT mkbundle
404MKBUNDLE 384MKBUNDLE
405} 385}
406 386
407bundle() { 387bundle() {
408 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 388 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
409 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 389 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
410 "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 390 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@"
411} 391}
412 392
413if [ $# -gt 0 ]; then 393if [ $# -gt 0 ]; then
414 while [ $# -gt 0 ]; do 394 while [ $# -gt 0 ]; do
415 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 395 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
416 mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" 396 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
417 397
418 command="${1#--}"; shift 398 command="${1#--}"; shift
419 case "$command" in 399 case "$command" in
420 fetch | configure | build | install | clean | distclean) 400 fetch | configure | build | install | clean | distclean)
421 verblock <<EOF 401 verblock <<EOF
422$command 402$command
423EOF 403EOF
424 "$command" 404 ( "$command" )
425 ;; 405 ;;
426 instsrc ) 406 instsrc )
427 instsrc "$@" 407 ( instsrc "$@" )
428 exit 408 exit
429 ;; 409 ;;
430 instcpan ) 410 instcpan )
431 instcpan "$@" 411 ( instcpan "$@" )
432 exit 412 exit
433 ;; 413 ;;
434 instschmorp )
435 install_schmorp
436 ;;
437 cpan ) 414 cpan )
438 install 415 ( install )
439 "$PREFIX/bin/cpan" "$@" 416 "$PERL_PREFIX/bin/cpan" "$@"
440 exit 417 exit
441 ;; 418 ;;
442 mkbundle ) 419 mkbundle )
443 install 420 ( install )
444 bundle "$@" 421 bundle "$@"
445 exit 422 exit
446 ;; 423 ;;
447 mkperl ) 424 mkperl )
448 install 425 ( install )
449 bundle --perl "$@" 426 bundle --perl "$@"
450 exit 427 exit
451 ;; 428 ;;
452 help ) 429 help )
453 podusage 2 430 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines