[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Setting up pbuilder or sbuild like experimental buildds



On Sat, Sep 16, 2006, Junichi Uekawa wrote:
> >  I checked the code of pbuilder-satisfydepends, and I see it tries all
> >  versions of "apt-cache show" output to see whether one of them would be
> >  enough, but I see no place where it would request a particular version.
> Yup, that's not supported in current pbuilder-satisfydepends codebase.
> You're welcome to submit a patch, however.

 I just did, it's in #390888 for people following this discussion via
 debian-devel@; testers welcome!

-- 
Loïc Minier <lool@dooz.org>
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 <lool@dooz.org>  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 to: