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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines