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.6 by root, Tue Dec 7 10:40:39 2010 UTC vs.
Revision 1.14 by root, Fri Dec 10 20:29:17 2010 UTC

2 2
3############################################################################# 3#############################################################################
4# configuration to fill in 4# configuration to fill in
5 5
6STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
7CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan # which mirror to use
8EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
9 9
10MKBUNDLE="$STATICPERL/mkbundle"
11 10
12# perl build variables 11# perl build variables
13PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed
14PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 12PERL_VERSION=5.12.2 # 5.8.9 is also a good choice
15PERL_CONFIGURE="" # additional Configure arguments 13PERL_CONFIGURE="" # additional Configure arguments
16PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 14PERL_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" 15PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 16
46 44
47# which extra modules you might want to install 45# which extra modules you might want to install
48EXTRA_MODULES="" 46EXTRA_MODULES=""
49 47
50# overridable functions 48# overridable functions
49preconfigure() { : ; }
51postconfigure() { : ; } 50postconfigure() { : ; }
52postbuild() { : ; } 51postbuild() { : ; }
53postinstall() { : ; } 52postinstall() { : ; }
54 53
55# now source user config, if any 54# now source user config, if any
55if [ "$STATICPERLRC" ]; then
56 . "$STATICPERLRC"
57else
56[ -r /etc/staticperlrc ] && . /etc/staticperlrc 58 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
57[ -r ~/.staticperlrc ] && . ~/.staticperlrc 59 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
58[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 60 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
61fi
59 62
60############################################################################# 63#############################################################################
61# support 64# support
65
66MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}"
67PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
68
69unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
70export LC_ALL=C # just to be on the safe side
62 71
63# set version in a way that Makefile.PL can extract 72# set version in a way that Makefile.PL can extract
64VERSION=VERSION; eval \ 73VERSION=VERSION; eval \
65$VERSION=0.1 74$VERSION=0.9
66 75
67BZ2=bz2 76BZ2=bz2
68BZIP2=bzip2 77BZIP2=bzip2
69 78
70fatal() { 79fatal() {
103############################################################################# 112#############################################################################
104# clean 113# clean
105 114
106distclean() { 115distclean() {
107 verblock <<EOF 116 verblock <<EOF
108deleting everything installed by this script 117 deleting everything installed by this script (rm -rf $STATICPERL)
109EOF 118EOF
110 119
111 rm -rf "$STATICPERL" 120 rm -rf "$STATICPERL"
112} 121}
113 122
114############################################################################# 123#############################################################################
115# download/configure/compile/install perl 124# download/configure/compile/install perl
116 125
117clean() { 126clean() {
118 cd "$STATICPERL/src/perl-$PERL_VERSION" 2>/dev/null || return 127 rm -rf "$STATICPERL/src/perl-$PERL_VERSION"
119
120 rm -f staticstamp.configure
121 make distclean >/dev/null 2>&1
122} 128}
123 129
124fetch() { 130fetch() {
125 rcd "$STATICPERL" 131 rcd "$STATICPERL"
126 132
149 verblock <<EOF 155 verblock <<EOF
150unpacking perl 156unpacking perl
151EOF 157EOF
152 158
153 mkdir -p unpack 159 mkdir -p unpack
154 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xpC unpack \ 160 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \
155 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 161 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking"
162 chmod -R u+w unpack/perl-$PERL_VERSION
156 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 163 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
157 rmdir -p unpack 164 rmdir -p unpack
158 fi 165 fi
159} 166}
160 167
173 180
174 verblock <<EOF 181 verblock <<EOF
175configuring $STATICPERL/src/perl-$PERL_VERSION 182configuring $STATICPERL/src/perl-$PERL_VERSION
176EOF 183EOF
177 184
178 clean
179
180 rm -f "$PERL_PREFIX/staticstamp.install" 185 rm -f "$PERL_PREFIX/staticstamp.install"
186
187 make distclean >/dev/null 2>&1
181 188
182 # I hate them 189 # I hate them
183 grep -q -- -fstack-protector Configure && \ 190 grep -q -- -fstack-protector Configure && \
184 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 191 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
192
193 preconfigure
185 194
186# trace configure \ 195# trace configure \
187 sh Configure -Duselargefiles \ 196 sh Configure -Duselargefiles \
188 -Uuse64bitint \ 197 -Uuse64bitint \
189 -Dusemymalloc=n \ 198 -Dusemymalloc=n \
245 254
246 postbuild || fatal "postbuild hook failed" 255 postbuild || fatal "postbuild hook failed"
247} 256}
248 257
249install() { 258install() {
250 [ -e "$PERL_PREFIX/staticstamp.install" ] && return 259 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
251
252 build 260 build
253 261
254 verblock <<EOF 262 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 263installing $STATICPERL/src/perl-$PERL_VERSION
256to $PERL_PREFIX 264to $PERL_PREFIX
257EOF 265EOF
258 266
259 rm -rf "$PERL_PREFIX" 267 ln -sf "perl/bin/" "$STATICPERL/bin"
260 268 ln -sf "perl/lib/" "$STATICPERL/lib"
269
270 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
271 rm -rf "$PERL_PREFIX" # by this rm -rf
272
261 make install || fatal "make install: error while installing" 273 make install || fatal "make install: error while installing"
262 274
263 rcd "$PERL_PREFIX" 275 rcd "$PERL_PREFIX"
264 276
265 # create a "make install" replacement for CPAN 277 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 278 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
267make install UNINST=1 279make || exit
280
268if find blib/arch/auto -type f | grep -q -v .exists; then 281if find blib/arch/auto -type f | grep -q -v .exists; then
269 echo Probably an XS module, rebuilding perl 282 echo Probably an XS module, rebuilding perl
270 make perl 283 if make perl; then
271 rm -f "$PERL_PREFIX"/bin/perl 284 mv perl "$PERL_PREFIX"/bin/perl
272 make -f Makefile.aperl inst_perl
273 make -f Makefile.aperl map_clean 285 make -f Makefile.aperl map_clean
286 else
287 make -f Makefile.aperl map_clean
288 exit 1
289 fi
274fi 290fi
291
292make install UNINST=1
275EOF 293EOF
276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install 294 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
277 295
278 # trick CPAN into avoiding ~/.cpan completely 296 # trick CPAN into avoiding ~/.cpan completely
279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 297 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
280 298
281 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 299 "$PERL_PREFIX"/bin/perl -MCPAN -e '
282 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 300 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
283 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 301 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
284 CPAN::Shell->o (conf => q<init>); 302 CPAN::Shell->o (conf => q<init>);
285 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 303 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
286 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 304 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
287 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 305 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
288 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 306 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
289 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 307 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
290 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 308 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install");
291 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 309 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
292 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 310 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
293 CPAN::Shell->o (conf => q<commit>); 311 CPAN::Shell->o (conf => q<commit>);
294 ' || fatal "error while initialising CPAN" 312 ' || fatal "error while initialising CPAN"
295 313
314 touch "$PERL_PREFIX/staticstamp.install"
315 fi
316
317 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
296 NOCHECK_INSTALL=+ 318 NOCHECK_INSTALL=+
297 instcpan $STATICPERL_MODULES 319 instcpan $STATICPERL_MODULES
298 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 320 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
299 321
300 postinstall || fatal "postinstall hook failed" 322 postinstall || fatal "postinstall hook failed"
301 323
302 touch "$PERL_PREFIX/staticstamp.install" 324 touch "$PERL_PREFIX/staticstamp.postinstall"
325 fi
303} 326}
304 327
305############################################################################# 328#############################################################################
306# install a module from CPAN 329# install a module from CPAN
307 330
380} 403}
381 404
382bundle() { 405bundle() {
383 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 406 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
384 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 407 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
408 CACHE="$STATICPERL/cache"
409 mkdir -p "$CACHE"
385 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 410 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
386} 411}
387 412
388if [ $# -gt 0 ]; then 413if [ $# -gt 0 ]; then
389 while [ $# -gt 0 ]; do 414 while [ $# -gt 0 ]; do
390 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 415 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
391 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 416 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
392 417
393 command="${1#--}"; shift 418 command="${1#--}"; shift
394 case "$command" in 419 case "$command" in
420 version )
421 echo "staticperl version $VERSION"
422 ;;
395 fetch | configure | build | install | clean | distclean) 423 fetch | configure | build | install | clean | distclean)
396 verblock <<EOF
397$command
398EOF
399 ( "$command" ) 424 ( "$command" )
400 ;; 425 ;;
401 instsrc ) 426 instsrc )
402 ( instsrc "$@" ) 427 ( instsrc "$@" )
403 exit 428 exit
417 exit 442 exit
418 ;; 443 ;;
419 mkperl ) 444 mkperl )
420 ( install ) 445 ( install )
421 bundle --perl "$@" 446 bundle --perl "$@"
447 exit
448 ;;
449 mkapp )
450 ( install )
451 bundle --app "$@"
422 exit 452 exit
423 ;; 453 ;;
424 help ) 454 help )
425 podusage 2 455 podusage 2
426 ;; 456 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines