[pbuilder] 01/03: buildpackage-funcs: add a dsc_get_basename() function returning $srcname-$version as tools expects it

Mattia Rizzolo mattia at debian.org
Fri Jan 13 19:04:59 UTC 2017


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

mattia pushed a commit to branch master
in repository pbuilder.

commit ffbe0ee099ae233b771528bdd5720f7d5feabb6f
Author: James Clarke <jrtc27 at jrtc27.com>
Date:   Fri Jan 6 16:15:56 2017 +0000

    buildpackage-funcs: add a dsc_get_basename() function returning $srcname-$version as tools expects it
    
    It will strip off eventual epoch, and can leave the Debian revision or not as asked
    
    Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
 pbuilder-buildpackage-funcs        | 43 ++++++++++++++++++++++++++++++
 t/data/dsc3_epoch                  | 54 ++++++++++++++++++++++++++++++++++++++
 t/data/dsc4_native                 | 42 +++++++++++++++++++++++++++++
 t/test_pbuilder-buildpackage-funcs | 31 ++++++++++++++++++++++
 4 files changed, 170 insertions(+)

diff --git a/pbuilder-buildpackage-funcs b/pbuilder-buildpackage-funcs
index 911f5e3..a4f1d1d 100644
--- a/pbuilder-buildpackage-funcs
+++ b/pbuilder-buildpackage-funcs
@@ -54,6 +54,49 @@ function copydsc () {
     done
 }
 
+function dsc_get_basename() {
+    local dscfile="$1"
+    local with_revision="$2"
+
+    local src=$(get822field "Source" "$dscfile")
+    local source_version=$(get822field "Version" "$dscfile")
+
+    # Parse version string
+    local epoch
+    local version
+    local revision
+    case "$source_version" in
+        *:*)
+            epoch=${source_version%%:*}
+            source_version=${source_version#*:}
+            ;;
+        *)
+            ;;
+    esac
+    case "$source_version" in
+        *-*)
+            version=${source_version%-*}
+            revision=${source_version##*-}
+            ;;
+        *)
+            version=$source_version
+            ;;
+    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}" ;;
+        no)  vs="${version}" ;;
+        *)   log.error "unexpected with_revision: $with_revision" ; exit 1 ;;
+    esac
+
+    echo "${src}_${vs}"
+}
+
 function checkbuilddep () {
     # call satisfydepends
     local BUILDOPT="--binary-all"
diff --git a/t/data/dsc3_epoch b/t/data/dsc3_epoch
new file mode 100644
index 0000000..d1d3af0
--- /dev/null
+++ b/t/data/dsc3_epoch
@@ -0,0 +1,54 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA256
+
+Format: 3.0 (quilt)
+Source: openssh
+Binary: openssh-client, openssh-client-ssh1, openssh-server, openssh-sftp-server, ssh, ssh-krb5, ssh-askpass-gnome, openssh-client-udeb, openssh-server-udeb
+Architecture: any all
+Version: 1:7.4p1-5
+Maintainer: Debian OpenSSH Maintainers <debian-ssh at lists.debian.org>
+Uploaders: Colin Watson <cjwatson at debian.org>, Matthew Vernon <matthew at debian.org>,
+Homepage: http://www.openssh.com/
+Standards-Version: 3.9.8
+Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ssh/openssh.git
+Vcs-Git: https://anonscm.debian.org/git/pkg-ssh/openssh.git
+Testsuite: autopkgtest
+Testsuite-Triggers: devscripts, openssl, putty-tools, python-twisted-conch, sudo
+Build-Depends: autotools-dev, debhelper (>= 9~), dh-autoreconf, dh-exec, dh-systemd (>= 1.4), dpkg-dev (>= 1.16.1~), libaudit-dev [linux-any], libedit-dev, libgtk-3-dev, libkrb5-dev | heimdal-dev, libpam0g-dev | libpam-dev, libselinux1-dev [linux-any], libssl1.0-dev | libssl-dev (<< 1.1.0~), libsystemd-dev [linux-any], libwrap0-dev | libwrap-dev, zlib1g-dev (>= 1:1.2.3)
+Package-List:
+ openssh-client deb net standard arch=any
+ openssh-client-ssh1 deb net extra arch=any
+ openssh-client-udeb udeb debian-installer optional arch=any
+ openssh-server deb net optional arch=any
+ openssh-server-udeb udeb debian-installer optional arch=any
+ openssh-sftp-server deb net optional arch=any
+ ssh deb net extra arch=all
+ ssh-askpass-gnome deb gnome optional arch=any
+ ssh-krb5 deb oldlibs extra arch=all
+Checksums-Sha1:
+ 2330bbf82ed08cf3ac70e0acf00186ef3eeb97e0 1511780 openssh_7.4p1.orig.tar.gz
+ 4b49d5343fbbca3e0268558c7827ac4e8157ff84 157404 openssh_7.4p1-5.debian.tar.xz
+Checksums-Sha256:
+ 1b1fc4a14e2024293181924ed24872e6f2e06293f3e8926a376b8aec481f19d1 1511780 openssh_7.4p1.orig.tar.gz
+ 7cd48ba265be55eac54956ee2cb94c265f1885c74af328e2eadd73ce44357955 157404 openssh_7.4p1-5.debian.tar.xz
+Files:
+ b2db2a83caf66a208bb78d6d287cdaa3 1511780 openssh_7.4p1.orig.tar.gz
+ 6f07a6e5c9db2c8115d81949936cc0df 157404 openssh_7.4p1-5.debian.tar.xz
+
+-----BEGIN PGP SIGNATURE-----
+Comment: Colin Watson <cjwatson at debian.org> -- Debian developer
+
+iQIzBAEBCAAdFiEErApP8SYRtvzPAcEROTWH2X2GUAsFAlhruL8ACgkQOTWH2X2G
+UAs0xg/9H0xati4RXChKEE9BC3EPJayCLFaZ474S6umPGHrs4DpURMVAwIc0HW6l
+jxEq6ulKBv4JdneKYOTJCHzo2HEr0sHSzUm7B+u2j9mvNk4Qv8zZ1cwxkn/CHK6E
+DwgKMNU7WwRsjV08leVKhb6Z7WLAxDJ//1h7QHSGRdmOuqB/nImqdZwDNADfrLBc
+m1JHOgLB1V4SStdP4byBnuszKVF5hOlWTgTEoiylxVIEuGIS+Eb1y/qbs1Aw6Eff
+A6vObfSef5m5Z/8RWwdxpBlKfQe8bbl5eiG3N2moMy4Xc2fAAGhs64QcFWO4HLhL
+iylzLmMa9Pp2mGhc67UsmEc3ZAQ/LPwjoOLMay+UAZ7x98EyCFCKHOHvk3dooawx
+PeUX7qjZGkgw901zM0DZv+a2Ti5AuAg40Kko7v0ZR+/+EC7aT6/TBDBS+6NvN/pk
+rMATZjyQ2Y08zbIAuAFZLwl350jSSixDNiyCEidIj1fc7Q6YPrxHDCHieI7iarA3
+T+n1RbFFkidInQgkZpbuKleD/Le2x8Wvb/1JG9gLzwo+qYJZoYwt1tAvyN6QEEji
+itnNWs0nalW11N9LSKfp/K3W4ojdC8hCeRdiPnF6Cjfewbra7LM1QnDrPXLbb9sF
+n+EDwGESOWc1EHuzrUpAWnGDf9tm3KQYh8WNdWVgZ+YWfoD08zk=
+=cWkx
+-----END PGP SIGNATURE-----
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 1160a10..46eaae6 100755
--- a/t/test_pbuilder-buildpackage-funcs
+++ b/t/test_pbuilder-buildpackage-funcs
@@ -54,6 +54,30 @@ test_getchangesfilesNormal () {
     get822files changes "$DEBIAN_CONTROL"
 }
 
+test_dsc_get_basename_normal_with_revision() {
+    dsc_get_basename "$TESTDATA_DIR/dsc1" yes
+}
+
+test_dsc_get_basename_normal_without_revision() {
+    dsc_get_basename "$TESTDATA_DIR/dsc1" no
+}
+
+test_dsc_get_basename_epoch_with_revision() {
+    dsc_get_basename "$TESTDATA_DIR/dsc3_epoch" yes
+}
+
+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"
@@ -89,6 +113,13 @@ expect_output "$DEBIAN_CONTROL $TEMP_DIR/haskell-concrete-typerep_0.1.0.2.orig.t
 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
 
+expect_output "haskell-concrete-typerep_0.1.0.2-2" test_dsc_get_basename_normal_with_revision
+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
 $TEMP_DIR/fake-pkg/../file_with_a_normal_name.changes" test_extraresults1

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