[pbuilder] 01/02: buildpacakge-funcs: add a _find_additional_buildresults() function to do proper match of file names passed through ADDITIONAL_BUILDRESULT

Mattia Rizzolo mattia at debian.org
Thu Nov 10 16:58:17 UTC 2016


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

mattia pushed a commit to branch master
in repository pbuilder.

commit e4fd38618467392014cf9d2c0f86687b88295249
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Thu Nov 10 16:39:13 2016 +0000

    buildpacakge-funcs: add a _find_additional_buildresults() function to do proper match of file names passed through ADDITIONAL_BUILDRESULT
    
    Closes: #837813
---
 pbuilder-buildpackage-funcs        | 27 +++++++++++++++++++++++----
 pbuilderrc.5                       | 10 +++++++++-
 t/test_pbuilder-buildpackage-funcs | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/pbuilder-buildpackage-funcs b/pbuilder-buildpackage-funcs
index 1aecc65..967b737 100644
--- a/pbuilder-buildpackage-funcs
+++ b/pbuilder-buildpackage-funcs
@@ -1,7 +1,7 @@
 #! /bin/bash
 #   pbuilder -- personal Debian package builder
 #   Copyright © 2001-2007 Junichi Uekawa <dancer at debian.org>
-#               2015      Mattia Rizzolo <mattia at debian.org>
+#               2015-2016 Mattia Rizzolo <mattia at debian.org>
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -20,6 +20,8 @@
 
 # functions local to pbuilder-buildpackage
 
+. "${BASH_SOURCE%/*}/pbuilder-modules"
+
 get822files () {
     # get list of files listed in the Files field of a .changes or .dsc (to
     # be specified in the first parameter)
@@ -204,9 +206,26 @@ EOF
     rm "$tmpcl"
 }
 
+function _find_additional_buildresults() {
+    local file f
+    local root="${BUILDPLACE}${BUILDDIR}/*"
+    for file in "${ADDITIONAL_BUILDRESULTS[@]}"; do
+        log.d "checking [$file]..."
+        echo "$root/$file" | perl -ne 'print "$_\n" foreach glob($_)' | \
+        while read f ; do
+            if [ -e "$f" ]; then
+                echo "$f"
+            else
+                log.w "file [$f] not found"
+            fi
+        done
+    done
+}
+
 function export_additional_buildresults() {
-    for FILE in "${ADDITIONAL_BUILDRESULTS[@]}"; do
-        log.i "Trying to save additional result ${FILE}"
-        cp -a "${BUILDPLACE}$BUILDDIR/"*"/${FILE}" "${BUILDRESULT}" || true
+    local file
+    for file in _find_additional_buildresults; do
+        log.i "Trying to save additional result '${FILE}'"
+        cp -a "${file}" "${BUILDRESULT}" || true
     done
 }
diff --git a/pbuilderrc.5 b/pbuilderrc.5
index 22f2087..6bfb27f 100644
--- a/pbuilderrc.5
+++ b/pbuilderrc.5
@@ -472,8 +472,16 @@ software which fail miserably when there is no
 .B /proc
 being mounted.
 .TP
-.BI "ADDITIONAL_BUILDRESULTS=" "(foo bar*)"
+.BI "ADDITIONAL_BUILDRESULTS=" "(foo \(dqbar*\(dq \(dqbaz\(rs biz\(dq)"
 Array of additional files to copy out of the build area.
+.br
+In case a wildcard is needed (e.g.
+.BR *.changes )
+quote it to have the wildcard escaped and not expanded at configuration load time,
+but instead expanded at run time when the additional build artifacts are exported.
+Spaces in file names needs to be escaped by using a \(rs or a wildcard to match
+the space.
+
 .TP
 .BI "CONFDIR=" "/etc/pbuilder/conf_files"
 .B pbuilder
diff --git a/t/test_pbuilder-buildpackage-funcs b/t/test_pbuilder-buildpackage-funcs
index 3053ac1..9e0a50e 100755
--- a/t/test_pbuilder-buildpackage-funcs
+++ b/t/test_pbuilder-buildpackage-funcs
@@ -55,14 +55,46 @@ test_getchangesfilesNormal () {
     get822files changes "$DEBIAN_CONTROL"
 }
 
+setup_extraresults () {
+    mkdir -p "$TEMP_DIR/fake-pkg/debian"
+    touch "$TEMP_DIR/file_with_*_asterisk"
+    touch "$TEMP_DIR/file with spaces.changes"
+    #touch "$TEMP_DIR/file with * asterisk and spaces"
+    touch "$TEMP_DIR/file_with_a_normal_name.changes"
+}
+
+test_extraresults1 () {
+    ADDITIONAL_BUILDRESULTS=('../*.changes')
+    _find_additional_buildresults
+}
+
+test_extraresults2 () {
+    ADDITIONAL_BUILDRESULTS=(
+        "../file*with*spaces*"
+        "../file\ with\ spaces.changes"
+        "../file_with_\*_asterisk"
+    )
+    _find_additional_buildresults
+}
+
+
 trap cleanup sigpipe sighup exit
 
 # FIXME move to build dir also because we have to hardoce $TEMP_DIR/ on the result below
 TEMP_DIR="$(mktemp -d)"
 DEBIAN_CONTROL="$(mktemp -p "$TEMP_DIR")"
+BUILDPLACE="$TEMP_DIR"
+BUILDDIR=''
 
 expect_output "$DEBIAN_CONTROL $TEMP_DIR/haskell-concrete-typerep_0.1.0.2.orig.tar.gz $TEMP_DIR/haskell-concrete-typerep_0.1.0.2-2.debian.tar.gz" test_getdscfilesNormal
 expect_output "$DEBIAN_CONTROL $TEMP_DIR/golang-xmpp-dev_0.0~git20140304.orig.tar.gz $TEMP_DIR/golang-xmpp-dev_0.0~git20140304-1.debian.tar.xz" test_getdscfilesWithoutNL
 expect_output "$DEBIAN_CONTROL $TEMP_DIR/pbuilder_0.225.2~bpo8+1.dsc $TEMP_DIR/pbuilder_0.225.2~bpo8+1.tar.xz $TEMP_DIR/pbuilder_0.225.2~bpo8+1_all.deb" test_getchangesfilesNormal
 
+setup_extraresults
+expect_output "$TEMP_DIR/fake-pkg/../file with spaces.changes
+$TEMP_DIR/fake-pkg/../file_with_a_normal_name.changes" test_extraresults1
+expect_output "$TEMP_DIR/fake-pkg/../file with spaces.changes
+$TEMP_DIR/fake-pkg/../file with spaces.changes
+$TEMP_DIR/fake-pkg/../file_with_*_asterisk" test_extraresults2
+
 testlib_summary

-- 
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