new build mode for windows mingw cross compilation

master
Marc Wäckerlin 8 years ago
parent 7c024f07bd
commit 514f71d201
  1. 10
      ChangeLog
  2. 17
      bootstrap.sh
  3. 58
      build-in-docker.sh
  4. 15
      resolve-rpmbuilddeps.sh

@ -1,3 +1,13 @@
2016-12-10 14:53
* [r463] ChangeLog, build-in-docker.sh:
fix build on debian
2016-12-10 13:35
* [r462] mrw-c++.spec.in:
fixed rpm builds
2016-12-09 15:51
* [r461] ChangeLog:

@ -301,11 +301,13 @@ VCS=""
VCSDEPENDS=""
if test -d .svn; then
VCS="svn"
VCSDEPENDS="svn2cl, subversion, subversion-tools,"
VCSDEPENDS_DEB="svn2cl, subversion, subversion-tools,"
VCSDEPENDS_RPM="subversion, subversion-tools,"
echo -e " \e[32msuccess\e[0m detected ${VCS}"
elif test -d .git; then
VCS="git"
VCSDEPENDS="git2cl, git,"
VCSDEPENDS_DEB="git2cl, git,"
VCSDEPENDS_RPM="git,"
echo -e " \e[32msuccess\e[0m detected ${VCS}"
else
echo -e " \e[33mignored\e[0m"
@ -1463,7 +1465,7 @@ if testtag AX_USE_DEBIAN_PACKAGING; then
-- @PACKAGER@ @BUILD_DATE@
EOF
BUILD_DEPENDS="debhelper, fakeroot, ${VCSDEPENDS} pkg-config, automake, libtool, autotools-dev, pandoc, lsb-release, fakeroot, $(if testtag AX_USE_DOXYGEN; then echo -n ", doxygen, graphviz, mscgen, default-jre-headless|default-jre"; fi; if testtag AX_USE_PERLDOC; then echo -n ", libpod-tree-perl"; fi; if testtag AX_USE_CPPUNIT; then echo -n ", libcppunit-dev"; fi; if testtag AX_CXX_QT || testtag AX_CHECK_QT AX_REQUIRE_QT; then echo -n ", qt5-default | libqt4-core | libqtcore4, qt5-qmake | qt4-qmake, qtbase5-dev | libqt4-dev, qtbase5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools"; fi)"
BUILD_DEPENDS="debhelper, fakeroot, ${VCSDEPENDS_DEB} pkg-config, automake, libtool, autotools-dev, pandoc, lsb-release, fakeroot, $(if testtag AX_USE_DOXYGEN; then echo -n ", doxygen, graphviz, mscgen, default-jre-headless|default-jre"; fi; if testtag AX_USE_PERLDOC; then echo -n ", libpod-tree-perl"; fi; if testtag AX_USE_CPPUNIT; then echo -n ", libcppunit-dev"; fi; if testtag AX_CXX_QT || testtag AX_CHECK_QT AX_REQUIRE_QT; then echo -n ", qt5-default | libqt4-core | libqtcore4, qt5-qmake | qt4-qmake, qtbase5-dev | libqt4-dev, qtbase5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools"; fi)"
to debian/control.in <<EOF
Source: @PACKAGE_NAME@
Priority: extra
@ -1534,7 +1536,7 @@ else
fi)
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: gnupg, ${VCSDEPENDS} make, automake, autoconf, rpm-build$(
BuildRequires: gnupg, ${VCSDEPENDS_RPM} make, automake, autoconf, rpm-build$(
if testtag AX_USE_CXX; then
echo -n ", binutils-devel, gcc-c++"
fi
@ -1552,13 +1554,16 @@ BuildRequires: gnupg, ${VCSDEPENDS} make, automake, autoconf, rpm-build$(
$(if testtag AX_USE_DOXYGEN; then echo -n "BuildRequires: graphviz"; fi)
%endif
%if 0%{?fedora} || 0%{?rhel} || 0%{?rhl} || 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} || 0%{?mageia}
BuildRequires: which, rpm-sign, pkgconfig$(
BuildRequires: which, pkgconfig$(
if testtag AX_USE_LIBTOOL; then
echo -n ", cppunit-devel"
fi
)
%if 0%{?rhel} > 6 || 0%{?rhl} > 6 || 0%{?centos} > 6 || 0%{?fedora} || 0%{?mageia}
BuildRequires: rpm-sign
%endif
%if 0%{?mageia}
BuildRequires: lsb-release$(
BuildRequires: gnupg, lsb-release$(
if testtag AX_USE_LIBTOOL; then
echo -n ", libltdl-devel"
fi

@ -15,7 +15,9 @@ dirs=("-v $(pwd):/workdir" "-v ${HOME}/.gnupg:/home/$(id -un)/.gnupg")
packages=()
targets="all check distcheck"
commands=()
arch=$(dpkg --print-architecture)
arch=$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)
host=
flags=()
wait=0
if test -e ./build-in-docker.conf; then
# you can preconfigure the variables in file build-in-docker.conf
@ -30,10 +32,12 @@ while test $# -gt 0; do
echo "OPTIONS:"
echo
echo " -h, --help show this help"
echo " -m, --mode <type> mode: deb, rpm, default: ${mode}"
echo " -m, --mode <type> mode: deb, rpm, win, default: ${mode}"
echo " -i, --image <image> use given docker image instead of ${img}"
echo " -a, --arch <arch> build for given hardware architecture"
echo " -t, --targets targets specify build targets, default: ${targets}"
echo " --host <target-arch> host for cross compiling, e.g. i686-w64-mingw32"
echo " -f, --flag <flag> add flag to ./bootstrap.sh or ./configure"
echo " -r, --repo <url> add given apt repository"
echo " -k, --key <url> add public key from url"
echo " -e, --env <var>=<val> set environment variable in docker"
@ -44,7 +48,9 @@ while test $# -gt 0; do
echo
echo " The option -i must be after -m, because mode sets a new default image"
echo " The option -m must be after -t, because mode may be auto detected from targets"
echo " The option -m must be after -h, because mode may set a host"
echo " If target is either deb or rpm, mode is set to the same value"
echo " If target is win, host is set to i686-w64-mingw32"
echo
echo " The options -r -k -e -d -p -c can be repeated several times."
echo
@ -79,6 +85,7 @@ while test $# -gt 0; do
(rpm|zypper) img="opensuse:latest";;
(yum) img="centos:latest";;
(dnf) img="fedora:latest";;
(win) img="ubuntu:latest"; host="${host:---host=i686-w64-mingw32}";;
(*)
echo "**** ERROR: unknown mode '$1', try --help" 1>&2
exit 1
@ -91,7 +98,7 @@ while test $# -gt 0; do
(-a|--arch) shift;
arch="$1"
;;
(-t|--targets) shift
(-t|--targets) shift;
targets="$1"
if test "$1" = "deb" -o "$1" = "rpm"; then
# set mode to same value
@ -99,6 +106,12 @@ while test $# -gt 0; do
continue
fi
;;
(--host) shift;
host="--host=$1"
;;
(-f|--flag) shift;
flags+=("$1")
;;
(-r|--repo) shift;
repos+=("$1")
;;
@ -186,14 +199,14 @@ function ifthenelse() {
os="${arg%%:::*}"
thenpart="${arg#*:::}"
if test "${thenpart/:::/}" = "${thenpart}"; then
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi'
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi'
else
elsepart="${thenpart##*:::}"
thenpart="${thenpart%:::*}"
if test -n "${thenpart}"; then
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi'
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi'
else
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then true; else '"${cmd//ARG/${elsepart}}"'; fi'
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then true; else '"${cmd//ARG/${elsepart}}"'; fi'
fi
fi
fi
@ -261,17 +274,28 @@ gpgcheck=0
EOF
fi
INSTALL_TOOL=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper install -y) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf install -y) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo yum install -y) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo urpmi --auto))
docker exec ${DOCKER_ID} ${INSTALL_TOOL} rpm-build automake libtool subversion gcc-c++ pkgconfig wget
#i=0
#for repo in "${repos[@]}"; do
# INSTALL_REPO=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper ar) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf config-manager --add-repo) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo wget -O/etc/yum.repos.d/additional$i.repo) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo true))
# ifthenelse "${repo}" "${INSTALL_REPO} ARG"
# ((++i))
#done
docker exec -u $(id -u):$(id -g) ${DOCKER_ID} ./bootstrap.sh -c
TGZFILE=$(grep PACKAGE_STRING= configure | sed "s, ,-,g;s,PACKAGE_STRING=',,g;s,',.tar.gz,g")
touch $TGZFILE
docker exec ${DOCKER_ID} ${INSTALL_TOOL} rpm-build automake libtool subversion gcc-c++ pkgconfig wget /usr/bin/lsb_release
i=0
for key in "${keys[@]}"; do
wget -Orpm-key "$key"
docker exec -i ${DOCKER_ID} rpm --import rpm-key
rm rpm-key
done
for repo in "${repos[@]}"; do
INSTALL_REPO=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper ar) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf config-manager --add-repo) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo wget -O/etc/yum.repos.d/additional$i.repo) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo true))
ifthenelse "${repo}" "${INSTALL_REPO} ARG"
((++i))
done
docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh
;;
(win)
if [[ "${img}" =~ "ubuntu" ]]; then
docker exec ${DOCKER_ID} locale-gen ${LANG}
docker exec ${DOCKER_ID} update-locale LANG=${LANG}
fi
docker exec ${DOCKER_ID} apt-get update ${OPTIONS}
docker exec ${DOCKER_ID} apt-get install -y mingw-w64
docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh
;;
esac
docker exec -u $(id -u):$(id -g) ${DOCKER_ID} ./bootstrap.sh -t "${targets}"
docker exec -u $(id -u):$(id -g) ${DOCKER_ID} ./bootstrap.sh -t "${targets}" ${host} ${flags[@]}

@ -14,6 +14,21 @@ INSTALL_TOOL=${INSTALL_TOOL:-$((test -x /usr/bin/zypper && echo zypper install -
SCHROOTNAME="$1"
PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac)
TRAP_CMD=
if test -e ${PACKAGE_NAME}.spec.in -a ! -e ${PACKAGE_NAME}.spec; then
TRAP_CMD+="rm ${PACKAGE_NAME}.spec;"
trap "${TRAP_CMD}" INT TERM EXIT
sed 's,@RPM_DEPEND_IFEXISTS@,,g' ${PACKAGE_NAME}.spec.in | \
sed 's,@[^@]*@, dummytext,g' > ${PACKAGE_NAME}.spec
fi
TGZFILE=$(sed -n '/^Name: */{s///;h};/^Version: */{s///;H;x;s/\n/-/;s/$/.tar.gz/;p}' ${PACKAGE_NAME}.spec)
if ! test -e $TGZFILE; then
TRAP_CMD+="rm ${TGZFILE};"
trap "${TRAP_CMD}" INT TERM EXIT
touch $TGZFILE
fi
if test -n "${SCHROOTNAME}"; then
FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
if test -n "${FILES}"; then

Loading…
Cancel
Save