mirror of https://github.com/vitalif/phantomjs
Deploy script improvements.
http://code.google.com/p/phantomjs/issues/detail?id=599 Squashed commit of the following: commit 2cdcf8a47567f3c067958383843cccf858af531c Author: Jon Leighton <j@jonathanleighton.com> Date: Sat Jul 7 19:37:38 2012 +0100 Make lib-bundling/brandelf optional in deploy/package.sh This configuration has had some problems and we don't wish to use it in the official packages. Enable it with --bundle-libs. commit 2a2155a4e1f5873aa8624859cead9d66750747f4 Author: Jon Leighton <j@jonathanleighton.com> Date: Sat Jul 7 19:24:40 2012 +0100 notify user if upx is missing commit 9656a99df0ff101150276dc88e0127f68041f617 Author: Jon Leighton <j@jonathanleighton.com> Date: Sat Jul 7 19:23:36 2012 +0100 stripping symbols after upx probably doesn't work, reorder that commit c5f425dc17069c89e7d2ff274309006c728ffab4 Author: Jon Leighton <j@jonathanleighton.com> Date: Sat Jul 7 19:17:07 2012 +0100 fix logical fail1.7
parent
1bcacde12c
commit
7892ff3b3e
|
@ -18,6 +18,12 @@ if [[ ! -f ../bin/phantomjs ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" = "--bundle-libs" ]]; then
|
||||
bundle_libs=1
|
||||
else
|
||||
bundle_libs=0
|
||||
fi
|
||||
|
||||
version=$(../bin/phantomjs --version | sed 's/ /-/' | sed 's/[()]//g')
|
||||
src=..
|
||||
|
||||
|
@ -26,14 +32,6 @@ echo "packaging phantomjs $version"
|
|||
if [[ $OSTYPE = darwin* ]]; then
|
||||
dest="phantomjs-$version-macosx-static"
|
||||
else
|
||||
if [[ ! -f brandelf ]]; then
|
||||
echo
|
||||
echo "brandelf executable not found in current dir"
|
||||
echo -n "compiling it now..."
|
||||
g++ brandelf.c -o brandelf || exit 1
|
||||
echo "done"
|
||||
fi
|
||||
|
||||
dest="phantomjs-$version-linux-$(uname -m)-dynamic"
|
||||
fi
|
||||
|
||||
|
@ -52,18 +50,30 @@ cp -r $src/{ChangeLog,examples,LICENSE.BSD,README.md} $dest/
|
|||
echo "done"
|
||||
echo
|
||||
|
||||
if [[ $OSTYPE == darwin* ]]; then
|
||||
echo -n "compressing binary..."
|
||||
[ ! -z upx ] && upx -qqq -9 $dest/bin/phantomjs
|
||||
echo "done"
|
||||
echo
|
||||
else
|
||||
phantomjs=$dest/bin/phantomjs
|
||||
|
||||
if [[ $OSTYPE != darwin* ]]; then
|
||||
if [[ "$bundle_libs" = "1" ]]; then
|
||||
if [[ ! -f brandelf ]]; then
|
||||
echo
|
||||
echo "brandelf executable not found in current dir"
|
||||
echo -n "compiling it now..."
|
||||
g++ brandelf.c -o brandelf || exit 1
|
||||
echo "done"
|
||||
fi
|
||||
|
||||
libs=$(ldd $phantomjs | egrep -o "/[^ ]+ ")
|
||||
else
|
||||
libs=$(ldd $phantomjs | egrep "libQt" | egrep -o "/[^ ]+ ")
|
||||
fi
|
||||
|
||||
echo -n "copying shared libs..."
|
||||
libld=
|
||||
for l in $(ldd $dest/bin/phantomjs | egrep -o "/[^ ]+ "); do
|
||||
if [[ "$l" != "" ]]; then
|
||||
ll=$(basename $l)
|
||||
cp $l $dest/lib/$ll
|
||||
for l in $libs; do
|
||||
ll=$(basename $l)
|
||||
cp $l $dest/lib/$ll
|
||||
|
||||
if [[ "$bundle_libs" = "1" ]]; then
|
||||
# ensure OS ABI compatibility
|
||||
./brandelf -t SVR4 $dest/lib/$ll
|
||||
if [[ "$l" == *"ld-linux"* ]]; then
|
||||
|
@ -73,36 +83,44 @@ else
|
|||
done
|
||||
echo "done"
|
||||
echo
|
||||
|
||||
if [[ "$bundle_libs" = "1" ]]; then
|
||||
echo -n "writing run script..."
|
||||
mv $phantomjs $phantomjs.bin
|
||||
phantomjs=$phantomjs.bin
|
||||
run=$dest/bin/phantomjs
|
||||
echo '#!/bin/sh' >> $run
|
||||
echo 'path=$(dirname $(dirname $(readlink -f $0)))' >> $run
|
||||
echo 'export LD_LIBRARY_PATH=$path/lib' >> $run
|
||||
echo 'exec $path/lib/'$libld' $phantomjs $@' >> $run
|
||||
chmod +x $run
|
||||
echo "done"
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
# strip to reduce file size
|
||||
echo -n "stripping binary and libs..."
|
||||
|
||||
if [[ $OSTYPE = darwin* ]]; then
|
||||
strip -x $dest/bin/*
|
||||
strip -x $phantomjs
|
||||
else
|
||||
strip -s $dest/lib/* $dest/bin/*
|
||||
strip -s $dest/lib/* $phantomjs
|
||||
fi
|
||||
|
||||
echo "done"
|
||||
echo
|
||||
|
||||
if [[ $OSTYPE != darwin* ]]; then
|
||||
echo -n "writing run script..."
|
||||
# write run scripts
|
||||
mv $dest/bin/phantomjs $dest/bin/phantomjs.bin
|
||||
run=$dest/bin/phantomjs
|
||||
echo '#!/bin/sh' >> $run
|
||||
echo 'path=$(dirname $(dirname $(readlink -f $0)))' >> $run
|
||||
echo 'export LD_LIBRARY_PATH=$path/lib' >> $run
|
||||
echo 'exec $path/lib/'$libld' $path/bin/phantomjs.bin $@' >> $run
|
||||
chmod +x $run
|
||||
echo "done"
|
||||
if [[ $OSTYPE == darwin* ]]; then
|
||||
echo -n "compressing binary..."
|
||||
if [[ ! -z upx ]]; then
|
||||
upx -qqq -9 $phantomjs
|
||||
echo "done"
|
||||
else
|
||||
echo "upx not found"
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
|
||||
echo -n "creating archive..."
|
||||
if [[ $OSTYPE != darwin* ]]; then
|
||||
if [[ $OSTYPE = darwin* ]]; then
|
||||
zip -r $dest.zip $dest
|
||||
else
|
||||
tar -cjf $dest{.tar.bz2,}
|
||||
|
|
Loading…
Reference in New Issue