]> git.donarmstrong.com Git - neurodebian.git/commitdiff
Move on to repository config files.
authorMichael Hanke <michael.hanke@gmail.com>
Wed, 29 Apr 2009 18:37:09 +0000 (20:37 +0200)
committerMichael Hanke <michael.hanke@gmail.com>
Wed, 29 Apr 2009 18:37:09 +0000 (20:37 +0200)
Makefile
debneuro.cfg [new file with mode: 0644]
reblender
sphinx/index.rst

index 45071d87ba04c3caa28fe5dc1612f02c1d316e9a..a65b6d16e54c97b9b3553e867036032c8fec3677 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 
 WWW_UPLOAD_URI = elrond:/home/hanke/public_html/archive
-WWW_DIR = build/_build/html
+WWW_DIR = build/html
 
 
 prep:
@@ -8,7 +8,7 @@ prep:
        cp -r sphinx/* build/src
 
 
-html: prep update-db
+html: prep source
        cd build/src && $(MAKE) html BUILDDIR=$(CURDIR)/build
 
 
@@ -16,26 +16,24 @@ clean:
        -rm -rf build
 
 
-update-db:
-#              -r http://apsy.gse.uni-magdeburg.de/debian/dists/lenny/Release \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/squeeze/Release \
-#      rm -f build/db.db
-       ./reblender \
+distclean: clean
+       -rm -rf cache
+
+
+source:
+       ./reblender generate \
+               --cfg debneuro.cfg \
                --db build/db.db \
                --outdir build/src \
-               --pkgaddenum pkgs \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/dapper/Release \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/gutsy/Release \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/hardy/Release \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/intrepid/Release \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/etch/Release \
-               -r http://apsy.gse.uni-magdeburg.de/debian/dists/sid/Release \
-               -t svn://svn.debian.org/blends/projects/med/trunk/debian-med/tasks/imaging \
-               -t svn://svn.debian.org/blends/projects/med/trunk/debian-med/tasks/imaging-dev \
-               -t svn://svn.debian.org/blends/projects/science/trunk/debian-science/tasks/neuroscience-cognitive \
-               -f fsl-doc -f fslview-doc -f fsl-atlases -f fsl-possum-data \
-               -f fsl-first-data -f fsl-feeds \
-               -p svn://svn.debian.org/blends/projects/science/trunk/debian-science/tasks/neuroscience-cognitive
+               --pkgaddenum pkgs
+
+
+refresh-db:
+       mkdir -p build
+#      rm -f build/db.db
+       ./reblender refreshdb \
+               --cfg debneuro.cfg \
+               --db build/db.db
 
 
 upload-website: html
diff --git a/debneuro.cfg b/debneuro.cfg
new file mode 100644 (file)
index 0000000..9392ab7
--- /dev/null
@@ -0,0 +1,44 @@
+[packages]
+# Packages listed in the following taskfiles will be featured on the website
+# _if_ they are also present in the repository
+select taskfiles =
+ svn://svn.debian.org/blends/projects/med/trunk/debian-med/tasks/imaging
+ svn://svn.debian.org/blends/projects/med/trunk/debian-med/tasks/imaging-dev
+ svn://svn.debian.org/blends/projects/science/trunk/debian-science/tasks/neuroscience-cognitive
+
+# Additional selection filter (similar to 'select taskfiles'), only listing
+# package names
+select names = fsl-doc fslview-doc fsl-atlases fsl-possum-data fsl-first-data
+ fsl-feeds libnifti1
+
+# Information about prospective packages to be imported from taskfiles
+prospective =
+ svn://svn.debian.org/blends/projects/science/trunk/debian-science/tasks/neuroscience-cognitive
+
+
+[repositories]
+# Release files of all repositories to be contained in the website
+releases =
+ http://apsy.gse.uni-magdeburg.de/debian/dists/dapper/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/gutsy/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/hardy/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/intrepid/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/jaunty/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/etch/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/lenny/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/squeeze/Release
+ http://apsy.gse.uni-magdeburg.de/debian/dists/sid/Release
+
+
+[release codenames]
+etch = Debian GNU/Linux 4.0 (etch)
+lenny = Debian GNU/Linux 5.0 (lenny)
+squeeze = Debian testing (squeeze)
+sid = Debian unstable (sid)
+dapper = Ubuntu 6.06 LTS "Dapper Drake" (dapper)
+edgy = Ubuntu 6.10 "Edgy Eft" (edgy)
+feisty = Ubuntu 7.04 "Feisty Fawn" (feisty)
+gutsy = Ubuntu 7.10 "Gutsy Gibbon" (gutsy)
+hardy = Ubuntu 8.04 LTS "Hardy Heron" (hardy)
+intrepid = Ubuntu 8.10 "Intrepid Ibex" (intrepid)
+jaunty = Ubuntu 9.04 "Jaunty Jackalope" (jaunty)
index 3afd33a1ed869a7bc6f9c567979f498114b650d7..4e1f35489a6d1341e14708c663832d0ef43d6aa9 100755 (executable)
--- a/reblender
+++ b/reblender
@@ -14,27 +14,18 @@ import shutil
 import pysvn
 from optparse import OptionParser, Option, OptionGroup, OptionConflictError
 
-codename2descr = {
-    'apsy_etch': 'Debian GNU/Linux 4.0 (etch)',
-    'apsy_lenny': 'Debian GNU/Linux 5.0 (lenny)',
-    'apsy_squeeze': 'Debian testing (squeeze)',
-    'apsy_sid': 'Debian unstable (sid)',
-    'apsy_dapper': 'Ubuntu 6.06 LTS "Dapper Drake" (dapper)',
-    'apsy_edgy': 'Ubuntu 6.10 "Edgy Eft" (edgy)',
-    'apsy_feisty': 'Ubuntu 7.04 "Feisty Fawn" (feisty)',
-    'apsy_gutsy': 'Ubuntu 7.10 "Gutsy Gibbon" (gutsy)',
-    'apsy_hardy': 'Ubuntu 8.04 LTS "Hardy Heron" (hardy)',
-    'apsy_intrepid': 'Ubuntu 8.10 "Intrepid Ibex" (intrepid)',
-    'apsy_jaunty': 'Ubuntu 9.04 "Jaunty Jackalope" (jaunty)',
-    }
-
-def transCodename(codename):
+
+def transCodename(codename, cfg):
     """Translate a known codename into a release description.
 
     Unknown codenames will simply be returned as is.
     """
-    if codename in codename2descr.keys():
-        return codename2descr[codename]
+    # strip repository codename
+    codename = codename[codename.find('_') + 1:]
+
+    # if we know something, tell
+    if codename in cfg.options('release codenames'):
+        return cfg.get('release codenames', codename)
     else:
         return codename
 
@@ -62,7 +53,7 @@ class AptListsCache(object):
             self.ro_cachedirs = []
 
         # always use system cache
-        self.ro_cachedirs.append('/var/lib/apt/lists/')
+        #self.ro_cachedirs.append('/var/lib/apt/lists/')
 
         # create cachedir
         createDir(self.cachedir)
@@ -369,12 +360,12 @@ class DebianPkgArchive(SafeConfigParser):
             self.set(pkg, 'debtags', ', '.join(debtags))
 
 
-    def writeSourcesLists(self, outdir):
+    def writeSourcesLists(self, outdir, cfg):
         createDir(outdir)
         createDir(os.path.join(outdir, 'static'))
 
         fl = open(os.path.join(outdir, 'sources_lists'), 'w')
-        for trans, r in sorted([(transCodename(k), k) 
+        for trans, r in sorted([(transCodename(k, cfg), k) 
                 for k in self.releases.keys()]):
             # need to turn 'apsy_lenny' back into 'lenny'
             debneuro_r = r.split('_')[1]
@@ -466,7 +457,7 @@ class DebianPkgArchive(SafeConfigParser):
         self.pkgfilter = pkgs
 
 
-def genPkgPage(db, pkg):
+def genPkgPage(db, pkg, cfg):
     """
     :Parameters:
       db: database
@@ -508,18 +499,21 @@ def genPkgPage(db, pkg):
         s += '\n**Homepage**: %s\n' % db.get(pkg, 'homepage')
 
     s += '\nBinary packages'\
-        '\n===============\n'
+         '\n===============\n'
 
     s += genMaintainerSection(db, pkg)
 
     if db.has_option(pkg, 'wnpp debian'):
-        s += 'A Debian packaging effort has been officially announced. ' \
-             'Please see the corresponding `intent-to-package bug report`_ ' \
-             'for more information about its current status.\n\n' \
-             '.. _intent-to-package bug report: http://bugs.debian.org/%s\n\n' \
-             % db.get(pkg, 'wnpp debian')
+        s += """\
+A Debian packaging effort has been officially announced. Please see the
+corresponding `intent-to-package bug report`_ for more information about
+its current status.
+
+.. _intent-to-package bug report: http://bugs.debian.org/%s
 
-    s += genBinaryPackageSummary(db, pkg, 'DebNeuro repository')
+""" % db.get(pkg, 'wnpp debian')
+
+    s += genBinaryPackageSummary(db, pkg, 'DebNeuro repository', cfg)
 
 #    if db.has_option(pkg, 'external pkg url'):
 #        s += 'Other unofficial ressources\n' \
@@ -533,8 +527,12 @@ def genMaintainerSection(db, pkg):
     s = ''
 
     if not db.has_option(pkg, 'maintainer'):
-        s += '\nCurrently, nobody seems to be responsible for creating or ' \
-             'maintaining Debian packages of this software.\n\n'
+        s += """\
+
+Currently, nobody seems to be responsible for creating or maintaining
+Debian packages of this software.
+
+"""
         return s
 
     # there is someone responsible
@@ -542,40 +540,55 @@ def genMaintainerSection(db, pkg):
 
     # do we have actual packages, or is it just a note
     if not db.has_option(pkg, 'releases'):
-        s += '\nThere are currently no binary packages available. However, ' \
-             'the last known packaging effort was started by %s which ' \
-             'meanwhile might have led to an initial unofficial Debian ' \
-             'packaging.\n\n' % maintainer
+        s += """\
+
+There are currently no binary packages available. However, the last known
+packaging effort was started by %s which meanwhile might have led to an
+initial unofficial Debian packaging.
+
+""" % maintainer
         return s
 
     s += '\n**Maintainer**: %s\n\n' % maintainer
 
     if not maintainer.startswith('Michael Hanke'):
-        s += '\n.. note::\n'
-        s += '  Do not contact the original package maintainer regarding ' \
-             '  bugs in this unofficial binary package. Instead, contact ' \
-             '  the repository maintainer at michael.hanke@gmail.com\ .'
+        s += """\
+
+.. note::
+  Do not contact the original package maintainer regarding
+  bugs in this unofficial binary package. Instead, contact
+  the repository maintainer at michael.hanke@gmail.com\ .
+
+"""
 
     return s
 
 
-def genBinaryPackageSummary(db, pkg, reposname):
+def genBinaryPackageSummary(db, pkg, reposname, cfg):
     # do nothing if the are no packages
     if not db.has_option(pkg, 'releases'):
         return ''
 
     s = '\n%s\n%s\n' % (reposname, '-' * len(reposname))
 
-    s += 'The repository contains binary packages for the following ' \
-         'distribution releases and system architectures. Note, that the ' \
-         'corresponding source packages are of course available too. Please ' \
-         'click on the release name to access them.\n\n'
+    s += """\
+The repository contains binary packages for the following distribution
+releases and system architectures. The corresponding source packages
+are available too. Please click on the release name to access them.
+
+.. note::
+  Do not download this package manually if you plan to use it
+  regularly. Instead configure your package manager to use this
+  repository by following the instructions on the
+  :ref:`front page <repository_howto>`.
+
+"""
 
     # for all releases this package is part of
     for rel in db.get(pkg, 'releases').split(', '):
         # write release description and component
         s += '\n`%s <%s>`_:\n  ' \
-                % (transCodename(rel),
+                % (transCodename(rel, cfg),
                    db.get(pkg, 'poolurl %s' % rel))
 
         s += '[%s] ' % db.get(pkg, 'component ' + rel)
@@ -663,7 +676,7 @@ def writePkgsBy(db, key, value2id, outdir, heading):
     toc.close()
 
 
-def writeRst(db, outdir, addenum_dir=None):
+def writeRst(db, outdir, cfg, addenum_dir=None):
     createDir(outdir)
     createDir(os.path.join(outdir, 'pkgs'))
 
@@ -677,7 +690,7 @@ def writeRst(db, outdir, addenum_dir=None):
     for p in sorted(db.sections()):
         print "Generating page for '%s'" % p
         pf = open(os.path.join(outdir, 'pkgs', '%s.rst' % p), 'w')
-        pf.write(genPkgPage(db, p))
+        pf.write(genPkgPage(db, p, cfg))
 
         # check for doc addons
         if addenum_dir is not None:
@@ -700,6 +713,11 @@ def prepOptParser(op):
                   default=None,
                   help="Database file to read. Default: None")
 
+    op.add_option("--cfg",
+                  action="store", type="string", dest="cfg",
+                  default=None,
+                  help="Repository config file.")
+
     op.add_option("-o", "--outdir",
                   action="store", type="string", dest="outdir",
                   default=None,
@@ -709,49 +727,65 @@ def prepOptParser(op):
                   action="append", dest="release_urls",
                   help="None")
 
-    op.add_option("-t", "--taskfile-url",
-                  action="append", dest="taskfile_urls",
-                  help="None")
-
-    op.add_option("-f", "--featured",
-                  action="append", dest="featured_pkgs",
-                  help="None")
-
-    op.add_option("-p", "--prospective",
-                  action="append", dest="prospective_pkgs",
-                  help="None")
-
     op.add_option("--pkgaddenum", action="store", dest="addenum_dir",
                   type="string", default=None, help="None")
 
 
+
 def main():
     op = OptionParser(version="%prog 0.0.1")
     prepOptParser(op)
 
     (opts, args) = op.parse_args()
 
-    dpa = DebianPkgArchive(init_db=opts.db)
+    if len(args) != 1:
+        print('There needs to be exactly one command')
+        sys.exit(1)
 
-    if not opts.taskfile_urls is None:
-        dpa.setPkgFilterFromTaskFile(opts.taskfile_urls)
+    cmd = args[0]
 
-    if not opts.featured_pkgs is None:
-        dpa.pkgfilter += opts.featured_pkgs
+    if opts.cfg is None:
+        print("'--cfg' option is mandatory.")
+        sys.exit(1)
 
-    if not opts.prospective_pkgs is None:
-        for p in opts.prospective_pkgs:
-            dpa.importProspectivePkgsFromTaskFile(p)
 
-    if not opts.release_urls is None:
-        for rurl in opts.release_urls:
-            dpa.importRelease(rurl, force_update=False)
+    cfg = SafeConfigParser()
+    cfg.read(opts.cfg)
+
+    # load existing db, unless renew is requested
+    if cmd == 'refreshdb':
+        dpa = DebianPkgArchive()
+    else:
+        dpa = DebianPkgArchive(init_db=opts.db)
 
-    if not opts.outdir is None:
-        dpa.writeSourcesLists(opts.outdir)
-        writeRst(dpa, opts.outdir, opts.addenum_dir)
+
+    if cmd == 'generate':
+        if opts.outdir is None:
+            print('Not output directory specified!')
+            sys.exit(1)
+
+        dpa.writeSourcesLists(opts.outdir, cfg)
+        writeRst(dpa, opts.outdir, cfg, opts.addenum_dir)
         writePkgsBy(dpa, 'maintainer', maintainer2email, opts.outdir,
                     'Packages maintained by <ITEM>')
+        # stop here
+        sys.exit(0)
+
+
+    if cfg.has_option('packages', 'select taskfiles'):
+        dpa.setPkgFilterFromTaskFile(cfg.get('packages',
+                                             'select taskfiles').split())
+
+    if cfg.has_option('packages', 'select names'):
+        dpa.pkgfilter += cfg.get('packages', 'select names').split()
+
+    if cfg.has_option('packages', 'prospective'):
+        for p in cfg.get('packages', 'prospective').split():
+            dpa.importProspectivePkgsFromTaskFile(p)
+
+    if cfg.has_option('repositories', 'releases'):
+        for rurl in cfg.get('repositories', 'releases').split():
+            dpa.importRelease(rurl, force_update=False)
 
     if not opts.db is None:
         dpa.save(opts.db)
index 1ad9cebb4e3504b1baeba26d6e252de8d4b26127..99dce9c2c27263f3fb01db218b9c5080744fc378 100644 (file)
@@ -22,6 +22,8 @@ All other packages are available through the search engine or from the
 :ref:`full package list <full_pkg_list>`.
 
 
+.. _repository_howto:
+
 How to use this repository
 ==========================