[pbuilder] 02/04: Add new --source-only-changes option

James Clarke jrtc27 at moszumanska.debian.org
Tue Jan 10 17:03:40 UTC 2017


This is an automated email from the git hooks/post-receive script.

jrtc27 pushed a commit to branch wip/source-only-changes
in repository pbuilder.

commit f5414869162183894e4279aa02c43fef947f6d9f
Author: James Clarke <jrtc27 at jrtc27.com>
Date:   Fri Jan 6 16:47:04 2017 +0000

    Add new --source-only-changes option
---
 pbuilder-buildpackage              | 43 +++++++++++++++++++++++++++++++++++---
 pbuilder-buildpackage-funcs        |  3 +++
 pbuilder-checkparams               |  4 ++++
 pbuilderrc                         |  4 ++++
 t/data/dsc4_native                 | 42 +++++++++++++++++++++++++++++++++++++
 t/test_pbuilder-buildpackage-funcs | 10 +++++++++
 6 files changed, 103 insertions(+), 3 deletions(-)

diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage
index 1b60cfb..9dfaf7c 100755
--- a/pbuilder-buildpackage
+++ b/pbuilder-buildpackage
@@ -155,7 +155,18 @@ log.i "Building the package"
 
 executehooks "A"
 
-DPKG_COMMANDLINE="env PATH=\"$PATH\" HOME=\"$BUILD_HOME\" dpkg-buildpackage -us -uc $DEBBUILDOPTS"
+ENV_PREFIX="env PATH=\"$PATH\" HOME=\"$BUILD_HOME\""
+
+SUBDIR_NAME=$(dsc_get_basename "$PACKAGENAME" "no")
+SUBDIR_NAME=${SUBDIR_NAME//_/-}
+
+DPKG_COMMANDLINE="$ENV_PREFIX dpkg-buildpackage -us -uc $DEBBUILDOPTS"
+
+CHANGES_BASENAME=$(dsc_get_basename "$PACKAGENAME" "yes")
+
+if [ "${SOURCE_ONLY_CHANGES}" = "yes" ]; then
+    DPKG_COMMANDLINE="$DPKG_COMMANDLINE && $ENV_PREFIX dpkg-genchanges --build=source > ../${CHANGES_BASENAME}_source.changes"
+fi
 
 # https://launchpad.net/bugs/816556
 unset DISPLAY
@@ -171,7 +182,7 @@ fi
     if [ -n "$TWICE" ]; then
         DPKG_COMMANDLINE="$DPKG_COMMANDLINE && $DPKG_COMMANDLINE"
     fi
-    DPKG_COMMANDLINE="cd ${BUILDDIR}/*/ && $DPKG_COMMANDLINE"
+    DPKG_COMMANDLINE="cd ${BUILDDIR}/$SUBDIR_NAME/ && $DPKG_COMMANDLINE"
     log.i "Running $DPKG_COMMANDLINE"
     echo "$DPKG_COMMANDLINE" | $UNSHARE $CHROOTEXEC env $SUTOUSER
 ) &
@@ -211,16 +222,42 @@ if [ "$USENETWORK" = "no" ]; then
     copy_local_configuration resolv.conf
 fi
 
+CHANGES_ARCHITECTURE=${ARCHITECTURE:-$(dpkg-architecture -qDEB_HOST_ARCH)}
+
+# dpkg pre-1.18.8 generated _$arch.changes even for indep-only builds,
+# so search for both.
+INDEP_CHANGES_FILE="${BUILDPLACE}$BUILDDIR/${CHANGES_BASENAME}_all.changes"
+if [ "${BINARY_ARCH}" = "all" -a -f "${INDEP_CHANGES_FILE}" ]; then
+    ARCH_CHANGES_FILE="$INDEP_CHANGES_FILE"
+else
+    ARCH_CHANGES_FILE="${BUILDPLACE}$BUILDDIR/${CHANGES_BASENAME}_${CHANGES_ARCHITECTURE}.changes"
+
+    if [ ! -f "${ARCH_CHANGES_FILE}" ]; then
+        log.e "Missing changes file: ${ARCH_CHANGES_FILE}"
+        exit 1
+    fi
+fi
+
+SOURCE_CHANGES_FILE="${BUILDPLACE}$BUILDDIR/${CHANGES_BASENAME}_source.changes"
+
+if [ "${SOURCE_ONLY_CHANGES}" = "yes" -a ! -f "${SOURCE_CHANGES_FILE}" ]; then
+    log.e "Missing source-only changes file: ${SOURCE_CHANGES_FILE}"
+    exit 1
+fi
+
 executehooks "B"
 
 if [ -d "${BUILDRESULT}" ]; then
     chown "${BUILDRESULTUID}:${BUILDRESULTGID}" "${BUILDPLACE}$BUILDDIR/"*
     chgrp "${BUILDRESULTGID}" "${BUILDPLACE}$BUILDDIR/"*
-    for FILE in $(get822files "changes" "${BUILDPLACE}$BUILDDIR"/*.changes) ; do
+    for FILE in $(get822files "changes" "$ARCH_CHANGES_FILE") ; do
         if [ -f "${FILE}" ]; then
             cp -p "${FILE}" "${BUILDRESULT}" || true
         fi
     done
+    if [ "${SOURCE_ONLY_CHANGES}" = "yes" ]; then
+        cp -p "${SOURCE_CHANGES_FILE}" "${BUILDRESULT}"
+    fi
     export_additional_buildresults
     executehooks "I"
 else
diff --git a/pbuilder-buildpackage-funcs b/pbuilder-buildpackage-funcs
index 739f02d..a4f1d1d 100644
--- a/pbuilder-buildpackage-funcs
+++ b/pbuilder-buildpackage-funcs
@@ -84,6 +84,9 @@ function dsc_get_basename() {
     esac
 
     local vs
+    if [ "$with_revision" = "yes" -a -z "${revision:-}" ]; then
+        with_revision=no
+    fi
     # Epoch always omitted
     case "$with_revision" in
         yes) vs="${version}-${revision}" ;;
diff --git a/pbuilder-checkparams b/pbuilder-checkparams
index 507d52e..fd4c4a4 100755
--- a/pbuilder-checkparams
+++ b/pbuilder-checkparams
@@ -233,6 +233,10 @@ while [ -n "$1" ]; do
         DEBBUILDOPTS="${DEBBUILDOPTS} -A"
         shift
         ;;
+    --source-only-changes)
+        SOURCE_ONLY_CHANGES="yes"
+        shift;
+        ;;
     --bin-nmu)
         BIN_NMU="yes"
         BINARY_ARCH="binary"
diff --git a/pbuilderrc b/pbuilderrc
index 9302e68..fcf564a 100644
--- a/pbuilderrc
+++ b/pbuilderrc
@@ -64,6 +64,10 @@ PBUILDERROOTCMD="sudo -E"
 # use cowbuilder for pdebuild
 #PDEBUILD_PBUILDER="cowbuilder"
 
+# Whether to generate an additional source-only .changes file as well as the
+# one generated during the build.
+SOURCE_ONLY_CHANGES=no
+
 # additional build results to copy out of the package build area
 #ADDITIONAL_BUILDRESULTS=(xunit.xml .coverage)
 
diff --git a/t/data/dsc4_native b/t/data/dsc4_native
new file mode 100644
index 0000000..8a015e7
--- /dev/null
+++ b/t/data/dsc4_native
@@ -0,0 +1,42 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA512
+
+Format: 3.0 (native)
+Source: cowdancer
+Binary: cowdancer, cowbuilder, qemubuilder
+Architecture: any
+Version: 0.82
+Maintainer: Debian pbuilder maintenance team <pbuilder-maint at lists.alioth.debian.org>
+Uploaders: James Clarke <jrtc27 at jrtc27.com>, Mattia Rizzolo <mattia at debian.org>,
+Standards-Version: 3.9.8
+Vcs-Browser: https://anonscm.debian.org/git/pbuilder/cowdancer.git
+Vcs-Git: https://anonscm.debian.org/git/pbuilder/cowdancer.git
+Build-Depends: cpio, debhelper (>= 10), dh-exec, klibc-utils [linux-any], libklibc-dev [linux-any], libncurses-dev, pbuilder
+Package-List:
+ cowbuilder deb utils optional arch=any
+ cowdancer deb utils optional arch=any
+ qemubuilder deb utils optional arch=linux-any
+Checksums-Sha1:
+ 05438b1752994ac39a62491eb4ca7f10c6d3b13b 69428 cowdancer_0.82.tar.xz
+Checksums-Sha256:
+ 79614c398007b2934217a9547902b01c35d89cbf2639a518b6587d36c8c41cd3 69428 cowdancer_0.82.tar.xz
+Files:
+ efc191462239628c4e942886cd846ec3 69428 cowdancer_0.82.tar.xz
+
+-----BEGIN PGP SIGNATURE-----
+
+iQJGBAEBCgAwFiEEj1g0K+q+HvQ3lVH7sZN3DBhqHH0FAlhEuUwSHGpydGMyN0Bq
+cnRjMjcuY29tAAoJELGTdwwYahx9umsP/RMAJQLJNp+Q4i+CTIwsssIpOF4IuWQ9
+gn0ecHwKoW2etxO+dHGIfMFeWOa5HqazPIjJGLBq5vk0DgMm/XOi4/F4qeP9YDN/
+oTdNW26fKoU6NNSmoSUjXhupsIqsojcvNe17mQnWX9LLkyTvT0WvKp85ybBo2TCH
+VqtYlqV8L2Ozs1P+ZzNeoQPH7yTWx12RnIaOFjacBRLf78z8Jpzm45GA/7eQ/Zzk
+7YqJyr2DySGUBVvcRNijcjanKBLe1wqRcHDmLRaudvXuZGB6kvQ2PnKDt2btR0qw
+GK5PSvaiZVKhovp21+506KGGFx6Q5mfTQ2oFy32nQVuGPPoMcpPYqgJ1hOyfiPkK
+aXhSu4iyEzOcERESdRjt9A/enkRi6c42i776v2ANRW6I2GvB4bu0YMqgnPtoMwLC
+Jt7beTUpBbW4/F1O+VMgFrd0c7gCsH0IHZmpWbmByMUU/tiXUapN6FNHnDqS7OSq
+GXjUtupZvCZKRbTvQg9B4lO4JF8eBkOC5c1ZO5qvpLTtrjUIG7xx5E8gisNpgqkD
+gE1I+ZC1OF7bjgjnUyhHIWJPFTP0ae4yVGktAxH7h6BaUavzVStYjXc/+lXp+L3l
+daQ8UyWSp8nxd2PludeJ4yZcboxbHxuA4US6BpDtXr73ugepS0eWgYX72yHNIb96
+UfFacf2+7jwm
+=Y9MG
+-----END PGP SIGNATURE-----
diff --git a/t/test_pbuilder-buildpackage-funcs b/t/test_pbuilder-buildpackage-funcs
index 0a76ef6..46eaae6 100755
--- a/t/test_pbuilder-buildpackage-funcs
+++ b/t/test_pbuilder-buildpackage-funcs
@@ -70,6 +70,14 @@ test_dsc_get_basename_epoch_without_revision() {
     dsc_get_basename "$TESTDATA_DIR/dsc3_epoch" no
 }
 
+test_dsc_get_basename_native_with_revision() {
+    dsc_get_basename "$TESTDATA_DIR/dsc4_native" yes
+}
+
+test_dsc_get_basename_native_without_revision() {
+    dsc_get_basename "$TESTDATA_DIR/dsc4_native" no
+}
+
 setup_extraresults () {
     mkdir -p "$TEMP_DIR/fake-pkg/debian"
     touch "$TEMP_DIR/file_with_*_asterisk"
@@ -109,6 +117,8 @@ expect_output "haskell-concrete-typerep_0.1.0.2-2" test_dsc_get_basename_normal_
 expect_output "haskell-concrete-typerep_0.1.0.2" test_dsc_get_basename_normal_without_revision
 expect_output "openssh_7.4p1-5" test_dsc_get_basename_epoch_with_revision
 expect_output "openssh_7.4p1" test_dsc_get_basename_epoch_without_revision
+expect_output "cowdancer_0.82" test_dsc_get_basename_native_with_revision
+expect_output "cowdancer_0.82" test_dsc_get_basename_native_without_revision
 
 setup_extraresults
 expect_output "$TEMP_DIR/fake-pkg/../file with spaces.changes

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/pbuilder.git



More information about the Pbuilder-maint mailing list