Ver código fonte

More work on static build

Jakob Truelsen 16 anos atrás
pai
commit
b6b0a5ef29
4 arquivos alterados com 238 adições e 138 exclusões
  1. 235 136
      scripts/static-build.sh
  2. 1 1
      static_qt_conf_base
  3. 1 1
      static_qt_conf_linux
  4. 1 0
      static_qt_conf_win

+ 235 - 136
scripts/static-build.sh

@@ -38,6 +38,7 @@ else
     UPX=upx-3.03-i386_linux
 fi
 
+
 #Helper functions
 function get() {
 	[ -f $2.download ] || (rm -rf $2; wget $1 -O $2 && touch $2.download)
@@ -46,149 +47,247 @@ function unpack() {
 	[ -f $1.unpack ] || (echo "unpacking $1"; (tar -xf $1 || unzip $1) && touch $1.unpack)
 }
 
-function exportHere() {
-	rm -rf wkhtmltopdf
-	local HERE=${PWD}
-	cd $BASE || exti 1
-	git checkout-index --prefix=${HERE}/wkhtmltopdf/ -a -f || exit 1	
-	cd $HERE
+function usage() {
+	echo "please specify what static binary you want build (linux, win or all)"
+	exit 1
 }
 
-BUILD=$(pwd)/static-build
+BASE=${PWD}
+BUILD=${BASE}/static-build
+
+VERSION=$2
+
+function checkout() {
 #Create static build directory
-mkdir -p $BUILD
+    mkdir -p $BUILD
+
+    cd ${BUILD}
+    #Fetch most recent version of qt
+    echo "Updating qt from remote"
+    if [ ! -d qt ] ; then
+	git clone git://gitorious.org/+wkhtml2pdf/qt/wkhtmltopdf-qt.git qt || (rm -rf qt && exit 1)
+    fi
+    cd qt
+    git checkout staging || exit 1
+    git pull || exit 1
+    cd ..
+    #Fetch and unpack upx
+    get http://upx.sourceforge.net/download/${UPX}.tar.bz2 ${UPX}.tar.bz2 || exit 1
+    unpack ${UPX}.tar.bz2 || exit 1
+}
+
 cat static_qt_conf_base static_qt_conf_win | sed -re 's/#.*//' | sed -re '/^[ \t]*$/d' | sort -u > $BUILD/conf_win
 cat static_qt_conf_base static_qt_conf_linux | sed -re 's/#.*//' | sed -re '/^[ \t]*$/d' | sort -u > $BUILD/conf_linux
 
-BASE=${PWD}
 
-cd ${BUILD}
-#Fetch most recent version of qt
-echo "Updating qt from remote"
-if [ ! -d qt ] ; then
-    git clone git://gitorious.org/+wkhtml2pdf/qt/wkhtmltopdf-qt.git qt || (rm -rf qt && exit 1)
+function setup_build() {
+    echo "Updating QT"
+
+    [ -d qts ] || git clone ${BUILD}/qt qts || (rm -rf qts && exit 1)
+    cd qts
+    git checkout staging || exit 1
+    git pull || exit 1
+    if ! [ -z "$VERSION" ] ; then
+	git checkout wkhtmltopdf-$VERSION || exit 1
+    fi
+    touch conf
+    cat ${BASE}/static_qt_conf_base ${BASE}/static_qt_conf_${1} | sed -re 's/#.*//' | sed -re '/^[ \t]*$/d' | sort -u > conf_new
+  
+    cd ..
+
+    echo "Updating wkhtmltopdf"
+    [ -d wkhtmltopdf ] || git clone ${BASE} wkhtmltopdf || (rm -rf wkhtmltopdf && exit 1)
+    cd wkhtmltopdf
+    git checkout master || exit 1
+    git pull || exit 1
+    if ! [ -z "$VERSION" ] ; then
+	git checkout "$VERSION" || exit 1
+    fi
+    cd ..
+    cat > build.sh <<EOF
+unset LANG
+unset LC_ALL
+unset LANGUAGE
+HERE="\${PWD}"
+mkdir -p qt/lib
+
+cd qts
+for lib in libssl.a libcrypt.a; do
+  rm -rf lib/\${lib} ../qt/lib/\${lib}
+  path=\$(g++ -print-file-name=\${lib})
+  ln -s \$(g++ -print-file-name=\${lib}) lib/  || exit 1
+  ln -s \$(g++ -print-file-name=\${lib}) ../qt/lib/  || exit 1
+done
+
+if ! cmp conf conf_new; then
+   echo "Configuring QT"
+   export OPENSSL_LIBS='-L../qt/lib ../qt/lib/libssl.a ../qt/lib/libcrypt.a -lssl -lcrypto'
+   (yes yes | ./configure \`cat conf_new\` -prefix "\${HERE}/qt" && cp conf_new conf) || exit 1
 fi
-cd qt
-git checkout staging || exit 1
-git pull || exit 1
-cd ..
-
-#Fetch and unpack upx
-get http://upx.sourceforge.net/download/${UPX}.tar.bz2 ${UPX}.tar.bz2 || exit 1
-unpack ${UPX}.tar.bz2 || exit 1
-
-if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]]; then
-	cd ${BUILD}
-	mkdir -p linux
-	cd linux
-	echo "Updating linux qt"
-	[ -d qts ] || git clone ../qt qts || (rm -rf qts && exit 1)
-	cd qts
-	git checkout staging || exit 1
-	git pull || exit 1
-	if ! [ -z "$2" ] ; then
-	    git checkout wkhtmltopdf-$2 || exit 1
-	fi
-
-	touch conf_linux
-	if ! cmp ${BUILD}/conf_linux conf_linux; then
- 	    (yes yes | ./configure `cat ${BUILD}/conf_linux` -prefix "${BUILD}/linux/qt" && cp ${BUILD}/conf_linux conf_linux) || exit 1
-	fi
-
-	if ! make -j3 -q; then
- 	    make -j3 || exit 1
- 	    make install || exit 1
-	fi
-	cd ..
-
-        [ -d wkhtmltopdf ] || git clone ${BASE} wkhtmltopdf || (rm -rf wkhtmltopdf && exit 1)
-	cd wkhtmltopdf
-	git checkout master || exit 1
-	git pull || exit 1
-	if ! [ -z "$2" ] ; then
-	    git checkout $2 || exit 1
-	fi
-	
-	../qt/bin/qmake || exit 1
-	make -j3 || exit 1
-	strip wkhtmltopdf || exit 1
-	rm -rf ${BASE}/wkhtmltopdf
-	${BUILD}/${UPX}/upx --best wkhtmltopdf -o ${BASE}/wkhtmltopdf || exit 1
+    
+if ! make -j3 -q; then
+   echo "Building QT"
+   make -j3 || exit 1
+   make install || exit 1
 fi
-if [[ "$1" == "all" ]] || [[ "$1" == "win" ]]; then 
-	export WINEPREFIX=`pwd`/mingw
-    #Setup configuration for mingw
-	ln -s / "mingw/dosdevices/z:"
-	cat <<EOF > tmp
-REGEDIT4
-
-[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]
-"PATH"="C:\\\\windows;C:\\\\windows\\\\system32;C:\\\\mingw\\\\bin"
-"INCLUDE"="C:\\\\mingw\\\\include;C:\\\\mingw\\\\include\\\\c++\\\\3.4.5"
-"LIB"="C:\\\\mingw\\\\lib"
+cd ../wkhtmltopdf
+
+echo "Building wkhtmltopdfe"
+../qt/bin/qmake || exit 1
+make -j3 || exit 1
+strip wkhtmltopdf || exit 1
 EOF
-	wine regedit tmp || exit 1
-	rm -f tmp
-
-	#Allowing the build to access files in the unix fs, is a bad idee.
-	rm -rf "mingw/dosdevices/z:"
-
-	echo "Building windows vertion of qt"
-	#Install mingw
-	mkdir -p mingw/drive_c/mingw
-	cd mingw/drive_c/mingw
-	for file in ${MINGWFILES}; do
-		get http://${MIRROR}.dl.sourceforge.net/sourceforge/mingw/${file} ${file} || exit 1
-		unpack ${file} || exit 1
-	done
-	get http://downloads.sourceforge.net/gnuwin32/${OPENSSL} ${OPENSSL} || exit 1
-	unpack ${OPENSSL} || exit 1
-
-	#Unpack, configure and build windows qt
-	unset CPLUS_INCLUDE_PATH
-	unset C_INCLUDE_PATH
-	cd ${BUILD}/mingw/drive_c
-
-	[ -d qts ] || git clone ${BUILD}/qt qts || (rm -rf qts && exit 1)
-	cd qts
-	git checkout staging || exit 1
-	git pull || exit 1
-	if ! [ -z "$2" ] ; then
-	    git checkout wkhtmltopdf-$2 || exit 1
-	fi
-	cd ..
-
-	export CPLUS_INCLUDE_PATH=
-	export C_INCLUDE_PATH=C:\qts\include
-
-	mkdir -p qt
-	cp -r qts/mkspecs qt
-	cd qts
-	if ! cmp ${BUILD}/conf_win conf_win; then
-	    QTDIR=. bin/syncqt
-	    (yes | wine configure.exe -I "C:\qts\include" `cat ${BUILD}/conf_win` -prefix "C:\qt"  && cp ${BUILD}/conf_win conf_win) || exit 1
-	fi
-	if ! wine mingw32-make -j3 -q; then
-		wine mingw32-make -j3 || exit 1
-		wine mingw32-make install || exit 1
-	fi
-	cd ..
-
-        [ -d wkhtmltopdf ] || git clone ${BASE} wkhtmltopdf || (rm -rf wkhtmltopdf && exit 1)
-	cd wkhtmltopdf
-	git checkout master || exit 1
-	git pull || exit 1
-	if ! [ -z "$2" ] ; then
-	    git checkout $2 || exit 1
-	fi
-
-	wine ../qt/bin/qmake.exe wkhtmltopdf.pro -o Makefile -spec win32-g++ || exit 1
-	wine mingw32-make -j5 || exit 1
-	wine strip.exe release/wkhtmltopdf.exe || exit 1
-	rm -rf ${BASE}/wkhtmltopdf.exe
-	${BUILD}/${UPX}/upx --best release/wkhtmltopdf.exe -o ${BASE}/wkhtmltopdf.exe || exit 1
-fi
-if [[ "$1" != "all" ]] && [[ "$1" != "linux" ]] && [[ "$1" != "win" ]]; then
-	echo "please specify what static binary you want build (linux, win or all)"
-	exit 1
-fi
+    chmod +x build.sh
+}
+
+function build_linux_actual() {
+    sleep 0
+}
+
+function build_linux_local() {
+    cd ${BUILD}
+    mkdir -p linux-local
+    cd linux-local
+    setup_build linux
+    ./build.sh
+}
+
+function setup_chroot() {
+    if [ ! -f linux-$2/strapped ]; then
+	sudo rm -rf linux-$2
+	(sudo debootstrap --arch=$2 --variant=buildd $1 ./linux-$2 http://ftp.us.debian.org/debian && sudo touch linux-$2/strapped) || exit 1
+    fi
+    if [ ! -d linux-$2/build ]; then
+	sudo mkdir -p linux-$2/build || exit 1
+	sudo chown --reference=. linux-$2/build -Rv || exit 1
+    fi
+    
+    if [ ! -f linux-$2/installed ]; then
+	echo -e "deb http://ftp.debian.org $1 main non-free contrib\ndeb-src http://ftp.debian.org $1 main non-free contrib" | sudo tee linux-$2/etc/apt/sources.list || exit 1
+	sudo chroot linux-$2 apt-get -y update || exit 1
+	sudo chroot linux-$2 apt-get -y build-dep libqt4-core && sudo touch linux-$2/installed || exit 1
+    fi
+    echo "cd /build && ./build.sh" > linux-$2/build/buildw.sh
+    chmod +x linux-$2/build/buildw.sh || exit 1
+}
+
+function build_linux() {
+    cd ${BUILD}
+    setup_chroot etch $1
+    cd linux-$1/build
+    setup_build linux
+    sudo linux32 chroot ${BUILD}/linux-$1/ /build/buildw.sh
+}
+
+# if [[ "$1" == "all" ]] ||; then
+# 	cd ${BUILD}
+# 	mkdir -p linux
+# 	cd linux
+# 	echo "Updating linux qt"
+
+        
+# 	rm -rf ${BASE}/wkhtmltopdf
+# 	${BUILD}/${UPX}/upx --best wkhtmltopdf -o ${BASE}/wkhtmltopdf || exit 1
+# fi
+# if [[ "$1" == "all" ]] || [[ "$1" == "win" ]]; then 
+# 	export WINEPREFIX=`pwd`/mingw
+#     #Setup configuration for mingw
+# 	ln -s / "mingw/dosdevices/z:"
+# 	cat <<EOF > tmp
+# REGEDIT4
+
+# [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]
+# "PATH"="C:\\\\windows;C:\\\\windows\\\\system32;C:\\\\mingw\\\\bin"
+# "INCLUDE"="C:\\\\mingw\\\\include;C:\\\\mingw\\\\include\\\\c++\\\\3.4.5"
+# "LIB"="C:\\\\mingw\\\\lib"
+# EOF
+# 	wine regedit tmp || exit 1
+# 	rm -f tmp
+
+# 	#Allowing the build to access files in the unix fs, is a bad idee.
+# 	rm -rf "mingw/dosdevices/z:"
+
+# 	echo "Building windows vertion of qt"
+# 	#Install mingw
+# 	mkdir -p mingw/drive_c/mingw
+# 	cd mingw/drive_c/mingw
+# 	for file in ${MINGWFILES}; do
+# 		get http://${MIRROR}.dl.sourceforge.net/sourceforge/mingw/${file} ${file} || exit 1
+# 		unpack ${file} || exit 1
+# 	done
+# 	get http://downloads.sourceforge.net/gnuwin32/${OPENSSL} ${OPENSSL} || exit 1
+# 	unpack ${OPENSSL} || exit 1
+
+# 	#Unpack, configure and build windows qt
+# 	unset CPLUS_INCLUDE_PATH
+# 	unset C_INCLUDE_PATH
+# 	cd ${BUILD}/mingw/drive_c
+
+# 	[ -d qts ] || git clone ${BUILD}/qt qts || (rm -rf qts && exit 1)
+# 	cd qts
+# 	git checkout staging || exit 1
+# 	git pull || exit 1
+# 	if ! [ -z "$2" ] ; then
+# 	    git checkout wkhtmltopdf-$2 || exit 1
+# 	fi
+# 	cd ..
+
+# 	export CPLUS_INCLUDE_PATH=
+# 	export C_INCLUDE_PATH=C:\qts\include
+
+# 	mkdir -p qt
+# 	cp -r qts/mkspecs qt
+# 	cd qts
+# 	if ! cmp ${BUILD}/conf_win conf_win; then
+# 	    QTDIR=. bin/syncqt
+# 	    (yes | wine configure.exe -I "C:\qts\include" `cat ${BUILD}/conf_win` -prefix "C:\qt"  && cp ${BUILD}/conf_win conf_win) || exit 1
+# 	fi
+# 	if ! wine mingw32-make -j3 -q; then
+# 		wine mingw32-make -j3 || exit 1
+# 		wine mingw32-make install || exit 1
+# 	fi
+# 	cd ..
+
+#         [ -d wkhtmltopdf ] || git clone ${BASE} wkhtmltopdf || (rm -rf wkhtmltopdf && exit 1)
+# 	cd wkhtmltopdf
+# 	git checkout master || exit 1
+# 	git pull || exit 1
+# 	if ! [ -z "$2" ] ; then
+# 	    git checkout $2 || exit 1
+# 	fi
+
+# 	wine ../qt/bin/qmake.exe wkhtmltopdf.pro -o Makefile -spec win32-g++ || exit 1
+# 	wine mingw32-make -j5 || exit 1
+# 	wine strip.exe release/wkhtmltopdf.exe || exit 1
+# 	rm -rf ${BASE}/wkhtmltopdf.exe
+# 	${BUILD}/${UPX}/upx --best release/wkhtmltopdf.exe -o ${BASE}/wkhtmltopdf.exe || exit 1
+# fi
+
+
+case "$1" in
+'linux-local')
+	build_linux_local
+	checkout
+	;;
+'linux-i386')
+	build_linux i386
+	checkout
+	;;
+'linux-amd64')
+	checkout
+	build_linux amd64
+	;;
+'windows')
+	checkout
+	build_windows
+	;;
+'release')
+	checkout
+	build_linux i386
+	build_linux amd64
+	build_windows
+	;;
+*)
+	usage
+	;;
+esac

+ 1 - 1
static_qt_conf_base

@@ -14,6 +14,7 @@
 # along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
 -release
 -static
+-fast
 -no-exceptions
 -no-accessibility
 -no-stl
@@ -39,7 +40,6 @@
 -qt-libpng
 -qt-libmng
 -qt-libjpeg
--openssl
 -graphicssystem raster
 -opensource
 -nomake tools

+ 1 - 1
static_qt_conf_linux

@@ -36,4 +36,4 @@
 -no-xsync
 -no-javascript-jit
 -no-svg
-
+-openssl-linked

+ 1 - 0
static_qt_conf_win

@@ -19,3 +19,4 @@
 -no-style-motif
 -no-style-cde
 -qt-style-cleanlooks
+-openssl