From: Pieter Lexis Date: Thu, 10 Aug 2017 16:02:03 +0000 (+0200) Subject: Make the buildscripts use tarballs and more consistent X-Git-Tag: dnsdist-1.2.0~26^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5da07f42b146207e095b85e2f7f147de8f3d7fc6;p=pdns Make the buildscripts use tarballs and more consistent --- diff --git a/build-scripts/README.md b/build-scripts/README.md index 2a987d0cd..dec7a4188 100644 --- a/build-scripts/README.md +++ b/build-scripts/README.md @@ -6,13 +6,67 @@ packages. This README will give a small walkthrough of important files. All `build-*` must be run from the root folder of the pdns repository to ensure their correct functionality. +## How do I build a package + +Before a package can be built, the distribution tarball has to exist in the root +directory. For auth: + + * `autoreconf -i` + * `./configure --without-modules --without-dynmodules --disable-depedency-tracking` + * `make dist` + +For the recursor: + + * `cd pdns/recursordist` + * `autoreconf -i` + * `./configure --disable-depedency-tracking` + * `make dist` + * `mv pdns-recursor*.tar.bz2 ../../` + * `cd -` + +And dnsdist: + + * `cd pdns/dnsdistdist` + * `autoreconf -i` + * `./configure --disable-depedency-tracking` + * `make dist` + * `mv dnsdist*.tar.bz2 ../../` + * `cd -` + +Now two environment variables need to be set, `$VERSION` and `$RELEASE`. + +`$VERSION` must be set to the to the version in the tarball to build a package for. +If the version of the package has to be different (e.g. '4.1.0~beta1'), set +`$VERSION` to *that* number and set `$TARBALLVERSION` to the tarball's version. + +`$RELEASE` is the 'release' version number for the package (e.g. '1.pdns' or +'0.beta1'). + +So, to create a package for 0.0.1 for debian version '0.0.1-1pdns0': + + * VERSION=0.0.1 + * RELEASE=1pdns0 + +0.0.1-beta2 for EL7 (0.0.1-0.beta.2.pdns): + + * VERSION=0.0.1 + * TARBALLVERSION=0.0.1-beta2 + * RELEASE=0.beta.2.pdns + +0.0.1-rc1 for debian (0.0.1~rc1-1pdns0): + + * VERSION=0.0.1~rc1 + * TARBALLVERSION=0.0.1-rc1 + * RELEASE=1pdns0 + +And run the proper script: + ## `build-auth-*` These scripts build (based on the suffix) a package of the authoritative -server. Either RPM's (for several different RHEL-based distro's), .deb's -(for Debian Jessie only at the moment) or statically compiled RPM's and deb's. +server. Either RPM's (for several different RHEL-based distro's), .deb's. ## `build-recursor-*` -Based on suffix, hese scripts build a deb/RPM package for the Recursor. There is +Based on suffix, these scripts build a deb/RPM package for the Recursor. There is also a semi-static build script. ## `build-dnsdist-*` diff --git a/build-scripts/build-auth-debian b/build-scripts/build-auth-debian index d455b5965..8f158c762 100755 --- a/build-scripts/build-auth-debian +++ b/build-scripts/build-auth-debian @@ -1,32 +1,21 @@ #!/bin/sh -export DEBFULLNAME="PowerDNS.COM BV AutoBuilder" -export DEBEMAIL="noreply@powerdns.com" - if [ "$0" != "./build-scripts/build-auth-debian" ]; then echo "Please run me from the root checkout dir" exit 1 fi -if [ -z "$VERSION" ]; then - echo 'Please set $VERSION' >&2 - exit 1 -fi +. build-scripts/functions.sh +TARBALLPREFIX=pdns -if [ -z "$RELEASE" ];then - echo 'Please set $RELEASE' >&2 - exit 1 -fi - -DISTDIR=${DISTDIR:=.} +startup set -e set -x -rm -rf $DISTDIR/debian/ -cp -r build-scripts/debian-authoritative $DISTDIR/debian +cp_tarball_to_tmp -cd $DISTDIR +cd ${SRCDIR} cat > debian/changelog << EOF pdns (${VERSION}-${RELEASE}) unstable; urgency=medium @@ -60,3 +49,5 @@ if $(echo $PDNS_VERSION | grep -q -E '^0\.0\.'); then fi DH_OPTIONS=--parallel fakeroot debian/rules binary + +mv_debs_to_pwd diff --git a/build-scripts/build-auth-rpm b/build-scripts/build-auth-rpm index 91ff63c52..9d9be3a2a 100755 --- a/build-scripts/build-auth-rpm +++ b/build-scripts/build-auth-rpm @@ -5,40 +5,22 @@ if [ "$0" != "./build-scripts/build-auth-rpm" ]; then exit 1 fi -if [ -z "$VERSION" ]; then - echo 'Please set $VERSION' >&2 - exit 1 -fi +. build-scripts/functions.sh +TARBALLPREFIX=pdns -if [ -z "$TARBALLVERSION" ]; then - TARBALLVERSION=$VERSION -fi - -if [ -z "$RELEASE" ];then - echo 'Please set $RELEASE' >&2 - exit 1 -fi +startup set -e set -x -# Prepare the build environment -rpmdev-setuptree - -# This is somethat ugly... -if [ -f pdns-${TARBALLVERSION}.tar.bz2 ]; then - mv pdns-${TARBALLVERSION}.tar.bz2 $HOME/rpmbuild/SOURCES -else - echo "pdns-${TARBALLVERSION}.tar.bz2 not found" >&2 - exit 1 -fi +cp_tarball_to_rpm_sources # Some setups need rpmbuild in a 'special' env RPMBUILD_COMMAND='rpmbuild -bb pdns.spec' if [ -r /etc/os-release ]; then OLDVERSION=$VERSION - source /etc/os-release + . /etc/os-release OS="${NAME} ${VERSION}" VERSION=$OLDVERSION fi @@ -48,8 +30,6 @@ if [ -f /etc/redhat-release ]; then fi case "$OS" in -# Fedora\ *\ 21*) -# ;; CentOS\ *\ 6*) RPMBUILD_COMMAND="scl enable devtoolset-3 -- ${RPMBUILD_COMMAND}" cat > $HOME/rpmbuild/SOURCES/pdns.init <&2 - exit 1 -fi +. build-scripts/functions.sh +TARBALLPREFIX=dnsdist -if [ -z "$DISTDIR" ]; then - DISTDIR='pdns/dnsdistdist' -fi - -if [ -z "$RELEASE" ];then - echo 'Please set $RELEASE' >&2 - exit 1 -fi +startup set -e set -x -rm -rf $DISTDIR/debian/ -cp -r build-scripts/debian-dnsdist $DISTDIR/debian +cp_tarball_to_tmp -cd $DISTDIR +cd ${SRCDIR} cat > debian/changelog << EOF dnsdist (${VERSION}-${RELEASE}) unstable; urgency=medium @@ -46,3 +36,5 @@ fi fakeroot debian/rules debian/control fakeroot debian/rules binary + +mv_debs_to_pwd diff --git a/build-scripts/build-dnsdist-rpm b/build-scripts/build-dnsdist-rpm index 550d3526b..afff087da 100755 --- a/build-scripts/build-dnsdist-rpm +++ b/build-scripts/build-dnsdist-rpm @@ -5,34 +5,15 @@ if [ "$0" != "./build-scripts/build-dnsdist-rpm" ]; then exit 1 fi -if [ -z "$VERSION" ]; then - echo 'Please set $VERSION' >&2 - exit 1 -fi +. build-scripts/functions.sh +TARBALLPREFIX=dnsdist -if [ -z "$TARBALLVERSION" ]; then - TARBALLVERSION=${VERSION} -fi - -if [ -z "$RELEASE" ];then - echo 'Please set $RELEASE' >&2 - exit 1 -fi +startup set -e set -x -# Prepare the build environment -rpmdev-setuptree - -# This is somethat ugly... -if [ -f dnsdist-${TARBALLVERSION}.tar.bz2 ]; then - mv dnsdist-${TARBALLVERSION}.tar.bz2 $HOME/rpmbuild/SOURCES -else - echo "dnsdist-${TARBALLVERSION}.tar.bz2 not found" >&2 - exit 1 -fi - +cp_tarball_to_rpm_sources # Some RPM platforms use systemd, others sysv, we default to systemd here INIT_BUILDREQUIRES='BuildRequires: systemd-devel' diff --git a/build-scripts/build-recursor-debian b/build-scripts/build-recursor-debian index 1e61033a5..d9c56f901 100755 --- a/build-scripts/build-recursor-debian +++ b/build-scripts/build-recursor-debian @@ -5,28 +5,17 @@ if [ "$0" != "./build-scripts/build-recursor-debian" ]; then exit 1 fi -if [ -z "$VERSION" ]; then - echo 'Please set $VERSION' >&2 - exit 1 -fi +. build-scripts/functions.sh +TARBALLPREFIX=pdns-recursor -if [ -z "$RELEASE" ];then - echo 'Please set $RELEASE' >&2 - exit 1 -fi - -if [ -z "$DISTDIR" ]; then - echo 'Please set $DISTDIR to the directory where pdns-recursor.tar.gz was unpacked' >&2 - exit 1 -fi +startup set -e set -x -rm -rf $DISTDIR/debian -cp -r build-scripts/debian-recursor $DISTDIR/debian +cp_tarball_to_tmp -cd $DISTDIR +cd ${SRCDIR} cat > debian/changelog << EOF pdns-recursor (${VERSION}-${RELEASE}) unstable; urgency=medium @@ -48,5 +37,6 @@ if [ ${ID} = "ubuntu" -a ${VERSION_ID} = "14.04" ]; then fi fakeroot debian/rules debian/control - fakeroot debian/rules binary + +mv_debs_to_pwd diff --git a/build-scripts/build-recursor-rpm b/build-scripts/build-recursor-rpm index e05f3bd0c..440a7d9e6 100755 --- a/build-scripts/build-recursor-rpm +++ b/build-scripts/build-recursor-rpm @@ -5,33 +5,15 @@ if [ "$0" != "./build-scripts/build-recursor-rpm" ]; then exit 1 fi -if [ -z "$VERSION" ]; then - echo 'Please set $VERSION' >&2 - exit 1 -fi +. build-scripts/functions.sh +TARBALLPREFIX=pdns-recursor -if [ -z "$TARBALLVERSION" ]; then - TARBALLVERSION=${VERSION} -fi - -if [ -z "$RELEASE" ];then - echo 'Please set $RELEASE' >&2 - exit 1 -fi +startup set -e set -x -# Prepare the build environment -rpmdev-setuptree - -# This is somethat ugly... -if [ -f pdns-recursor-${TARBALLVERSION}.tar.bz2 ]; then - mv pdns-recursor-${TARBALLVERSION}.tar.bz2 $HOME/rpmbuild/SOURCES -else - echo "pdns-recursor-${TARBALLVERSION}.tar.bz2 not found" >&2 - exit 1 -fi +cp_tarball_to_rpm_sources # Some setups need rpmbuild in a 'special' env RPMBUILD_COMMAND='rpmbuild -bb pdns-recursor.spec' @@ -59,7 +41,7 @@ if [ -f /etc/redhat-release ]; then # pidfile: /var/run/pdns_recursor.pid # -# source function library +# . function library . /etc/rc.d/init.d/functions RETVAL=0 diff --git a/build-scripts/functions.sh b/build-scripts/functions.sh new file mode 100644 index 000000000..469da98a8 --- /dev/null +++ b/build-scripts/functions.sh @@ -0,0 +1,47 @@ +startup() { + export DEBFULLNAME="PowerDNS.COM BV AutoBuilder" + export DEBEMAIL="noreply@powerdns.com" + + if [ -z "$VERSION" ]; then + echo 'Please set $VERSION' >&2 + exit 1 + fi + + if [ -z "$RELEASE" ];then + echo 'Please set $RELEASE' >&2 + exit 1 + fi + + TARBALLVERSION=${TARBALLVERSION:-$VERSION} + + TARBALLFILE=${TARBALLPREFIX}-${TARBALLVERSION}.tar.bz2 + + if [ ! -f ${TARBALLFILE} ]; then + echo "${TARBALLFILE} not found" >&2 + exit 1 + fi +} + +cp_tarball_to_tmp() { + DIR=$(mktemp -d) + + tar -xf ${TARBALLFILE} -C ${DIR} + + SRCDIR=${DIR}/${TARBALLPREFIX}-${TARBALLVERSION} + if [ "${TARBALLPREFIX}" = "pdns" ]; then + cp -r build-scripts/debian-authoritative ${SRCDIR}/debian + elif [ "${TARBALLPREFIX}" = "pdns-recursor" ]; then + cp -r build-scripts/debian-recursor ${SRCDIR}/debian + else + cp -r build-scripts/debian-${TARBALLPREFIX} ${SRCDIR}/debian + fi +} + +cp_tarball_to_rpm_sources() { + rpmdev-setuptree + cp ${TARBALLFILE} ${HOME}/rpmbuild/SOURCES +} + +mv_debs_to_pwd() { + mv ${DIR}/*.deb . +}