Permalink
Browse files

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.
  • Loading branch information...
1 parent 2a2155a commit 2cdcf8a47567f3c067958383843cccf858af531c @jonleighton jonleighton committed Jul 7, 2012
Showing with 38 additions and 24 deletions.
  1. +38 −24 deploy/package.sh
View
@@ -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
@@ -55,12 +53,27 @@ echo
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
@@ -71,20 +84,21 @@ if [[ $OSTYPE != darwin* ]]; then
echo "done"
echo
- 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
+ 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 $phantomjs

0 comments on commit 2cdcf8a

Please sign in to comment.