Package: pbuilder
Version: 0.160
Tags: patch

        Hi,

 Please find attached a patch to support pulling build-depends from
 experimental.

 The result is quite similar to what the experimental auto-builders
 claim they do.  However there's a slight difference: while in both
 cases you need to list to list experimental dependencies of your
 experimental build-deps (recursively), with this pbuilder setup you
 also need to give them in the correct order. [1]

 This is isofunctional to what the experimental buildds do, and I don't
 think there's any speed penalty or regression for regular builds.

 One possible improvement -- and this would solve the above difference
 as well as the limitation of the experimental buildds -- would be to
 recover from apt errors, so I might work later on such a support.


 You might want to suggest the following APT preferences for a sid
 pbuilder in the documentation:
    Explanation: experimental, to be selected by pbuilder if necessary
    Package: *
    Pin: release o=Debian, l=Debian, a=experimental
    Pin-Priority: 400

   Bye,

[1] For example, to build gtk2-engines for gtk >= 2.10, one needs to
change libgtk2.0-dev (>= 2.10.1-1) to libgtk2.0-common (>= 2.10.1-1),
libgtk2.0-0 (>= 2.10.1-1), libgtk2.0-dev (>= 2.10.1-1).
  I didn't check whether the experimental buildds are insensible to the
build-deps order in the above case, I hope they are.
-- 
Loïc Minier <[EMAIL PROTECTED]>
diff -urN pbuilder-0.159/debian/changelog pbuilder-0.160/debian/changelog
--- pbuilder-0.159/debian/changelog     2006-09-26 00:49:04.000000000 +0200
+++ pbuilder-0.160/debian/changelog     2006-10-03 15:20:25.000000000 +0200
@@ -1,3 +1,18 @@
+pbuilder (0.160) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Drop an useless awk invocation in pbuilder-satisfydepends.
+  * Add and use new package_versions() and candidate_version() helpers; the
+    former returns all versions of a package available via APT, the later
+    APT's candidate version.
+  * For versionned build-deps, when building the "apt-get install" command,
+    try APT's candidate version or all available versions available from APT
+    in ascending order (the reverse order of apt-cache's output);
+    checkbuilddep_versiondeps() isn't used for this part of the process
+    anymore, but it is still used to honor build-conflicts.
+
+ -- Loic Minier <[EMAIL PROTECTED]>  Tue,  3 Oct 2006 14:32:58 +0200
+
 pbuilder (0.159) unstable; urgency=low
 
   [Junichi Uekawa]
diff -urN pbuilder-0.159/pbuilder-satisfydepends 
pbuilder-0.160/pbuilder-satisfydepends
--- pbuilder-0.159/pbuilder-satisfydepends      2006-05-31 01:45:45.000000000 
+0200
+++ pbuilder-0.160/pbuilder-satisfydepends      2006-10-03 15:19:43.000000000 
+0200
@@ -21,11 +21,21 @@
 
 set -e
 
+function package_versions() {
+       local PACKAGE="$1"
+       ( $CHROOTEXEC /usr/bin/apt-cache show "$PACKAGE" ) | sed -n 
's/^Version: \(.*\)$/\1/p'
+}
+
+function candidate_version() {
+       local PACKAGE="$1"
+       LC_ALL=C $CHROOTEXEC apt-cache policy "$PACKAGE" | sed -n 's/ 
*Candidate: *\(.*\)/\1/p'
+}
+
 function checkbuilddep_versiondeps () {
     local PACKAGE="$1"
     local COMPARESTRING="$2"
     local DEPSVERSION="$3"
-    local PACKAGEVERSIONS=$( ( $CHROOTEXEC /usr/bin/apt-cache show "$PACKAGE" 
) | sed -n  's/^Version: \(.*\)$/\1/p' | xargs)
+    local PACKAGEVERSIONS=$( package_versions "$PACKAGE" | xargs)
     # no versioned provides.
     if [ "${FORCEVERSION}" = "yes" ]; then
        return 0;
@@ -92,6 +102,8 @@
     local INSTALLPKGMULTI
     local CURRENTREALPKGNAME
     local SATISFIED
+    local PACKAGEVERSIONS
+    local CANDIDATE_VERSION
     echo " -> Attempting to parse the build-deps $Id: 
pbuilder-satisfydepends,v 1.28 2006/05/30 23:45:45 dancer Exp $"
     for INSTALLPKGMULTI in $(cat ${DEBIAN_CONTROL} | \
        awk '
@@ -104,7 +116,7 @@
        sed 's/^[^: ]*://' | \
        tr " " "/" | \
        awk 'BEGIN{RS=","} {print}'); do
-      echo " -> Considering $(echo "$INSTALLPKGMULTI" | tr "/" " " | awk 
'{print $0}' )"
+      echo " -> Considering build-dep$(echo "$INSTALLPKGMULTI" | tr "/" " " )"
       SATISFIED="no"
       for INSTALLPKG in $(echo "$INSTALLPKGMULTI" | \
          awk 'BEGIN{RS="|"} {print}'); do
@@ -116,23 +128,40 @@
                continue;
            fi
        fi
+
+       # the default is to try to install without any version constraint
+       CURRENTREALPKGNAME_WITHVERSION="$CURRENTREALPKGNAME"
+
        if echo "$INSTALLPKG" | grep '[(]' > /dev/null; then
-           #echo "Debug: $INSTALLPKG"
-           if ! checkbuilddep_versiondeps ${CURRENTREALPKGNAME} \
-               $(echo "$INSTALLPKG" | tr "/" " " | sed 's/^.*([ 
]*\(<<\|<=\|>=\|=\|<\|>>\|>\)[ ]*\(.*\)).*$/\1/') \
-               $(echo "$INSTALLPKG" | tr "/" " " | sed 's/^.*([ 
]*\(<<\|<=\|>=\|=\|<\|>>\|>\)[ ]*\(.*\)).*$/\2/') ; then
-             echo "   -> Does not satisfy version, not trying"
-             continue;
-           fi
+           # package versions returned by APT, in reversed order
+           PACKAGEVERSIONS="$( package_versions "$CURRENTREALPKGNAME" | tac | 
xargs )"
+           CANDIDATE_VERSION="$( candidate_version "$CURRENTREALPKGNAME" )"
+
+           # try the candidate version, then all available versions (asc)
+           for VERSION in $CANDIDATE_VERSION $PACKAGEVERSIONS; do
+               if [ $VERSION = $CANDIDATE_VERSION ]; then
+                   echo "   -> Looking at APT's $CURRENTREALPKGNAME"
+               else
+                   echo "   -> Looking at APT's $CURRENTREALPKGNAME $VERSION"
+               fi
+               COMPARESTRING=$(echo "$INSTALLPKG" | tr "/" " " | sed 's/^.*([ 
]*\(<<\|<=\|>=\|=\|<\|>>\|>\)[ ]*\(.*\)).*$/\1/')
+               DEPSVERSION="$(echo "$INSTALLPKG" | tr "/" " " | sed 's/^.*([ 
]*\(<<\|<=\|>=\|=\|<\|>>\|>\)[ ]*\(.*\)).*$/\2/')"
+               if dpkg --compare-versions "$VERSION" "$COMPARESTRING" 
"$DEPSVERSION"; then
+                   if [ $VERSION != $CANDIDATE_VERSION ]; then
+                       
CURRENTREALPKGNAME_WITHVERSION="$CURRENTREALPKGNAME_WITHVERSION=$VERSION"
+                   fi
+                   break;
+               fi
+           done
        fi
-       echo "   -> Trying ${CURRENTREALPKGNAME}"
+       echo "   -> Trying ${CURRENTREALPKGNAME_WITHVERSION}"
 
-       if $CHROOTEXEC /usr/bin/apt-get -s install ${INSTALLPKGLIST} 
${CURRENTREALPKGNAME} >& /dev/null; then
+       if $CHROOTEXEC /usr/bin/apt-get -s install ${INSTALLPKGLIST} 
${CURRENTREALPKGNAME_WITHVERSION} >& /dev/null; then
            SATISFIED="yes"
-           INSTALLPKGLIST="${INSTALLPKGLIST} ${CURRENTREALPKGNAME}"
+           INSTALLPKGLIST="${INSTALLPKGLIST} ${CURRENTREALPKGNAME_WITHVERSION}"
        else
-           echo "       -> Cannot install ${CURRENTREALPKGNAME}; apt errors 
follow:"
-           if $CHROOTEXEC /usr/bin/apt-get -s install ${INSTALLPKGLIST} 
"${CURRENTREALPKGNAME}"; then
+           echo "       -> Cannot install ${CURRENTREALPKGNAME_WITHVERSION}; 
apt errors follow:"
+           if $CHROOTEXEC /usr/bin/apt-get -s install ${INSTALLPKGLIST} 
"${CURRENTREALPKGNAME_WITHVERSION}"; then
                :
            fi
            # package could not be found. -- looking for alternative.

Reply via email to