[Blends-commit] [Git][blends-team/blends][experimental] 5 commits: Add UDD query options to blend-gen-control

Ole Streicher gitlab at salsa.debian.org
Thu Mar 29 19:51:31 UTC 2018


Ole Streicher pushed to branch experimental at Debian Blends Team / blends


Commits:
0fb78e41 by Ole Streicher at 2018-03-29T21:33:17+02:00
Add UDD query options to blend-gen-control

- - - - -
24faa7f3 by Ole Streicher at 2018-03-29T21:35:14+02:00
Update changelog for 0.6.103 release

- - - - -
ed526453 by Ole Streicher at 2018-03-29T21:41:18+02:00
Add python3 dep, and use python3 instead of python3-all in build-dep

- - - - -
4879c3f3 by Ole Streicher at 2018-03-29T21:42:10+02:00
Remove trailing whitespaces in d/changelog

- - - - -
3df36e29 by Ole Streicher at 2018-03-29T21:43:50+02:00
Update d/copyright of blends-gen-control (rewritten from scratch)

- - - - -


4 changed files:

- debian/changelog
- debian/control
- debian/copyright
- devtools/blend-gen-control


Changes:

=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
-blends (0.6.103) UNRELEASED; urgency=medium
+blends (0.6.103) experimental; urgency=low
 
+  [ Andreas Tille ]
   * d/control:
      - Build-Depends: dh-python, python3-all
      - blends-dev: Depends: ${python3:Depends}
@@ -7,8 +8,12 @@ blends (0.6.103) UNRELEASED; urgency=medium
   * ignore false lintian warning binary-package-depends-on-toolchain-package
   * cme fix dpkg-control
   * Take over tasks_diff from blends-gsoc to create dependency_data
+  * Use Deb822List to evaluate taskprefix in tasks_diff
+
+  [ Ole Streicher ]
+  * Add UDD query options to blend-gen-control
 
- -- Andreas Tille <tille at debian.org>  Wed, 28 Mar 2018 16:22:10 +0200
+ -- Ole Streicher <olebole at debian.org>  Thu, 29 Mar 2018 21:33:29 +0200
 
 blends (0.6.102) experimental; urgency=low
 
@@ -449,7 +454,7 @@ blends (0.6.3) unstable; urgency=low
 
   * Section for cdd-common misc instead of devel
   * Updated mailing list address of Debian Pure Blends team
-  * devtools/blends-gen-control: 
+  * devtools/blends-gen-control:
      - If a task lists not a single package which is available in
        the target distribution the metapackage will be suppressed
        if option '-S' is set; there is one exception which is needed
@@ -736,7 +741,7 @@ cdd (0.3.10) unstable; urgency=low
   * Otavio Salvador
     - cdd-gen-control:
       o Add -D suport to cdd-gen-control to degrade dependencies to
-        recommends; 
+        recommends;
       o Add support for architecture dependent packages;
       o Add fallback to architecture independent packages so allow
         backward compatibility;


=====================================
debian/control
=====================================
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Build-Depends-Indep: xmlto,
                      dblatex,
                      w3m,
                      dh-python,
-                     python3-all
+                     python3
 Standards-Version: 4.1.3
 Vcs-Browser: https://salsa.debian.org/blends-team/blends
 Vcs-Git: https://salsa.debian.org/blends-team/blends.git
@@ -21,7 +21,7 @@ Package: blends-dev
 Architecture: all
 Depends: debconf,
          make | build-essential,
-         debhelper (>= 9),
+         debhelper (>= 9),python3,
          ${misc:Depends},
          ${python3:Depends}
 Suggests: blends-doc


=====================================
debian/copyright
=====================================
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,12 +1,11 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
 
 Files: *
 Copyright: © 2003-2012 Andreas Tille <tille at debian.org>
 License: GPL-2+
 
 Files: devtools/blend-gen-control
-Copyright: © 2003-2007 Petter Reinholdtsen <pere at debian.org>
-           © 2007-2012 Andreas Tille <tille at debian.org>
+Copyright: © 2018 Ole Streicher <olebole at debian.org>
 License: GPL-2+
 
 Files: share/blends/*


=====================================
devtools/blend-gen-control
=====================================
--- a/devtools/blend-gen-control
+++ b/devtools/blend-gen-control
@@ -100,6 +100,12 @@ class Blend:
         self.update(cache)
         return self
 
+    @property
+    def all(self):
+        '''All Base Dependencies of this task
+        '''
+        return list(itertools.chain(*(t.all for t in self.tasks)))
+
     def fix_dependencies(self):
         '''Fix the dependencies according to available packages
 
@@ -122,8 +128,8 @@ class Blend:
         all_task = Task(
             self, "all",
             '''Description: Default selection of tasks for {task.title}
-This package is part of the {task.title} Pure Blend and installs all
-tasks for a default installation of this blend.'''.format(task=self),
+ This package is part of the {task.title} Pure Blend and installs all
+ tasks for a default installation of this blend.'''.format(task=self),
             base_deps = ['${misc:Depends}'])
         for task in tasks:
             if task.install:
@@ -458,8 +464,9 @@ class Task:
             pkg = cache.get(dep.name)
             if pkg is not None:
                 dep.target_versions += pkg.versions
-            for pkg in cache.get_providing_packages(dep.name):
-                dep.target_versions += pkg.versions
+            if hasattr(cache, 'get_providing_packages'):
+                for pkg in cache.get_providing_packages(dep.name):
+                    dep.target_versions += pkg.versions
 
     def __iadd__(self, cache):
         self.update(cache)
@@ -699,34 +706,91 @@ class Deb822List(list):
             return fd.getvalue()
 
 
-def aptcache(distribution = None):
+def aptcache(release = None, srcdirs = [ '/etc/blends' ]):
     '''Open and update a (temporary) apt cache for the specified distribution.
 
+    :param release: Distribution name
+    :param srcdirs: List of directories to search for ``sources.list.<<release>>``
+
     If the distribution is not given, use the system's cache without update.
     '''
     import tempfile
     import apt
 
-    if distribution is None:
+    if release is None:
         return apt.Cache()
-    d = tempfile.mkdtemp()
-    os.makedirs(os.path.join(d, 'etc', 'apt'))
-    shutil.copytree('/etc/apt/trusted.gpg.d',
-                    os.path.join(d, 'etc', 'apt', 'trusted.gpg.d'))
-    shutil.copy('/etc/blends/sources.list.{}'.format(distribution),
-                    os.path.join(d, 'etc', 'apt', 'sources.list'))
-    c = apt.Cache(rootdir=d, memonly=True)
-    c.update()
-    c.open()
-    shutil.rmtree(d)
-    return c
+    rootdir = tempfile.mkdtemp()
+    try:
+        os.makedirs(os.path.join(rootdir, 'etc', 'apt'))
+        shutil.copytree('/etc/apt/trusted.gpg.d',
+                        os.path.join(rootdir, 'etc', 'apt', 'trusted.gpg.d'))
+        for src_dir in srcdirs:
+            sources_list = os.path.join(src_dir,
+                                        'sources.list.{}'.format(release))
+            if os.path.exists(sources_list):
+                shutil.copy(sources_list,
+                            os.path.join(rootdir, 'etc', 'apt', 'sources.list'))
+                break
+        else:
+            raise OSError("sources.list not found in " + str(srcdirs))
+        cache = apt.Cache(rootdir=rootdir, memonly=True)
+        cache.update()
+        cache.open()
+    finally:
+        shutil.rmtree(rootdir)
+    return cache
+
+
+def uddcache(release, packages, **db_args):
+    '''Create a ``dict`` from UDD that is roughly modelled after ``apt.Cache``.
+
+    The ``dict`` just resolves the version number and archs for the packages.
+    For performance reasons, an initial package list needs to be given.
+
+    :param release: Distribution name
+    :param packages: Initial package list
+    :param db_args: UDD connection parameters
+
+    ``Provided`` dependencies are integrated in the returned ``dict``.
+    '''
+    import collections
+    import psycopg2
+
+    pkgtuple = tuple(set(p.name for p in packages))
+
+    Package = collections.namedtuple('Package',
+                                     ('name', 'versions',))
+    Version = collections.namedtuple('Version',
+                                     ('package', 'architecture', 'version'))
+
+    stmt = '''SELECT packages.package,
+                     packages.provides,
+                     packages.architecture,
+                     packages.version
+              FROM packages, releases
+              WHERE packages.release=releases.release
+                    AND (releases.release=%s  OR releases.role=%s)
+                    AND (packages.package IN %s OR packages.provides in %s);'''
+
+    with psycopg2.connect(**db_args) as conn:
+        cursor = conn.cursor()
+        cursor.execute(stmt, (release, release, pkgtuple, pkgtuple))
+
+        cache = dict()
+        for package, provides, arch, version in cursor:
+            p = cache.setdefault(package, Package(package, []))
+            p.versions.append(Version(p, arch, version))
+            if provides:
+                pp = cache.setdefault(provides, Package(package, []))
+                pp.versions.append(Version(p, arch, version))
+
+        return cache
 
 
 if __name__ == '__main__':
     import sys
     import argparse
 
-    blend_dev_dir = "/usr/share/blends-dev/"
     default_release = "testing"
 
     parser = argparse.ArgumentParser()
@@ -765,10 +829,30 @@ if __name__ == '__main__':
                         action="store_true", default=False,
                         help="modify tasks desc file in case the blend uses udebs")
 
-    parser.add_argument("-U", '--upgrade-tasks', dest="upgrade_tasks",
+    parser.add_argument("-F", '--upgrade-task-format', dest="upgrade_tasks",
                         action="store_true", default=False,
                         help="Upgrade tasks files to the latest format version")
 
+    parser.add_argument("-U", "--udd", dest="udd",
+                        action="store_true", default=False,
+                        help="Query UDD instead of apt")
+
+    parser.add_argument("--udd-host", dest="udd_host",
+                        default="udd-mirror.debian.net",
+                        help="UDD host name (default: udd-mirror.debian.net)")
+
+    parser.add_argument("--udd-user", dest="udd_user",
+                        default="udd-mirror",
+                        help="UDD user (default: udd-mirror)")
+
+    parser.add_argument("--udd-password", dest="udd_password",
+                        default="udd-mirror",
+                        help="UDD password (default: udd-mirror)")
+
+    parser.add_argument("--udd-database", dest="udd_database",
+                        default="udd",
+                        help="UDD database name (default: udd)")
+
     args = parser.parse_args()
 
     if args.release == "current":
@@ -781,7 +865,13 @@ if __name__ == '__main__':
         if not task.is_metapackage:
             blend.tasks.remove(task)
 
-    blend += aptcache(args.release)
+    if args.udd:
+        blend += uddcache(args.release, blend.all, host=args.udd_host,
+                          user=args.udd_user, password=args.udd_password,
+                          database=args.udd_database)
+    else:
+        blend += aptcache(args.release, [ args.dir, '/etc/blends' ])
+
     missing = blend.fix_dependencies()
 
     if args.suppressempty:



View it on GitLab: https://salsa.debian.org/blends-team/blends/compare/dd6e6fe96759d4c5ed2bfec7c6799ffabe27beca...3df36e290636b163cc56e69c5d43e8eb28898460

---
View it on GitLab: https://salsa.debian.org/blends-team/blends/compare/dd6e6fe96759d4c5ed2bfec7c6799ffabe27beca...3df36e290636b163cc56e69c5d43e8eb28898460
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/blends-commit/attachments/20180329/6c6f5f4d/attachment-0001.html>


More information about the Blends-commit mailing list