Package: pbuilder
Version: 0.231
Severity: wishlist
Tags: patch

Hi Jessica and Mattia,

pbuilder build expects the filename of a .dsc file. In some cases
(mostly for qa), the .dsc file comes from the source distribution.
Having to download it beforehand and the copying it into the chroot is a
nuisance at best and a performance penalty at worst. Other build tools
such as sbuild allow an alternative convention where only the name of a
source package with an optional version is passed. The build tool then
automatically downloads the requested package using apt-get source from
the configured repositories. I propose pbuilder to allow doing the same.

You'll find a patch that implements the proposed behaviour. It lacks two
crucial aspects though. For one thing, the new behaviour is entirely
undocumented. For another, it requires that the base.tgz has deb-src
uris in the sources.list, which commonly is not the case. So you may
consider the patch a proof-of-concept.

So what do you think about the requested behaviour change and what do
you think about the proposed implementation?

I have more background on this feature request. I'm working on a machine
api for package build tools, an abstraction layer to provide a common
interface to both sbuild and pbuilder. In that process, I figured that
different use cases prefer different ways of supplying source packages.
The common ones seem to be:
 * A .dsc file on the disk
 * A http uri pointing to a .dsc file together with a checksum
 * A source package name with optional version
Initially, I did not consider the last way, but I noticed that when
dispatching builds across different data centers, it would be good to
not have to copy the .dsc around. A url would depend on the data center
to produce decent performance. However, a user of the api should not
have to care where her build is run. That is why I found this last
way crucial and it is what motivates this feature request.

Helmut
diff --minimal -Nru pbuilder-0.231/debian/changelog 
pbuilder-0.231+nmu1/debian/changelog
--- pbuilder-0.231/debian/changelog     2021-01-18 05:19:00.000000000 +0100
+++ pbuilder-0.231+nmu1/debian/changelog        2021-05-12 13:00:14.000000000 
+0200
@@ -1,3 +1,10 @@
+pbuilder (0.231+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Support building a source package name. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Wed, 12 May 2021 13:00:14 +0200
+
 pbuilder (0.231) unstable; urgency=medium
 
   [ Mattia Rizzolo ]
diff --minimal -Nru pbuilder-0.231/pbuilder-buildpackage 
pbuilder-0.231+nmu1/pbuilder-buildpackage
--- pbuilder-0.231/pbuilder-buildpackage        2020-01-18 16:29:06.000000000 
+0100
+++ pbuilder-0.231+nmu1/pbuilder-buildpackage   2021-05-12 13:00:14.000000000 
+0200
@@ -27,15 +27,20 @@
 . "${BASH_SOURCE%/*}/pbuilder-buildpackage-funcs"
 
 PACKAGENAME="$1"
-if [ ! -f "$PACKAGENAME" ]; then
-    log.e "Source package [$PACKAGENAME] does not exist"
-    exit 1;
+if [ -f "$PACKAGENAME" ]; then
+    if [ "${PACKAGENAME:(-4)}" != ".dsc" ]; then
+        log.e "The given filename does not seems to be the name of a Debian 
source package."
+        log.e "You need to pass a file ending with .dsc (given 
'$PACKAGENAME')."
+        exit 1
+    fi
+else
+    case "$PACKAGENAME" in
+        *[^a-zA-Z0-9_.+~-]*|*_*_*|*[^a-z0-9.+-]*_*|[^a-z]*)
+            log.e "Invalid package specification [$PACKAGENAME]"
+            exit 1
+        ;;
+    esac
 fi;
-if [ "${PACKAGENAME:(-4)}" != ".dsc" ]; then
-    log.e "The given filename does not seems to be the name of a Debian source 
package."
-    log.e "You need to pass a file ending with .dsc (given '$PACKAGENAME')."
-    exit 1
-fi
 shift
 if [ -n "$*" ]; then
     log.w "The following options specified after the .dsc will be ignored: 
[$@]"
@@ -101,7 +106,11 @@
 
 if [ -z "${PBUILDER_BUILD_LOGFILE}" ]; then
     if [ "${PKGNAME_LOGFILE}" = "yes" ]; then
-        PBUILDER_BUILD_LOGFILE="${BUILDRESULT}/$(basename "${PACKAGENAME}" 
.dsc)${PKGNAME_LOGFILE_EXTENSION}"
+        if [ -f "$PACKAGENAME" ]; then
+            PBUILDER_BUILD_LOGFILE="${BUILDRESULT}/$(basename "${PACKAGENAME}" 
.dsc)${PKGNAME_LOGFILE_EXTENSION}"
+        else
+            
PBUILDER_BUILD_LOGFILE="${BUILDRESULT}/${PACKAGENAME}${PKGNAME_LOGFILE_EXTENSION}"
+        fi
         exec > >(tee "${PBUILDER_BUILD_LOGFILE}") 2>&1
         PBUILDER_BUILD_LOGFILE=$(readlink -f "${PBUILDER_BUILD_LOGFILE}")
         log.i "Using pkgname logfile"
@@ -122,7 +131,12 @@
 setup_ccache
 SUTOUSER="$CCACHE_ENV $SUTOUSER"
 log.i "Copying source file"
-copydsc "$PACKAGENAME" "${BUILDPLACE}$BUILDDIR"
+if [ -f "$PACKAGENAME" ]; then
+    copydsc "$PACKAGENAME" "${BUILDPLACE}$BUILDDIR"
+else
+    $CHROOTEXEC env -C "$BUILDDIR" apt-get --only-source --download-only 
source "${PACKAGENAME//_/=}"
+    PACKAGENAME=$(echo "$BUILDPLACE$BUILDDIR/${PACKAGENAME%_*}_"*.dsc)
+fi
 copyinputfile "${BUILDPLACE}$BUILDDIR"
 
 # don't allow empty values of BUILDSUBDIR

Reply via email to