From 523fe5c7bf7c34bba8aa1125076efcd8fcca7063 Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Tue, 6 Jul 2010 00:29:44 +0200 Subject: [PATCH] Add start of a generate_packages_sources command Signed-off-by: Joerg Jaspert --- dak/generate_packages_sources.py | 113 +++++++++++++++++++++++++++++++ daklib/dbconn.py | 3 + 2 files changed, 116 insertions(+) create mode 100755 dak/generate_packages_sources.py diff --git a/dak/generate_packages_sources.py b/dak/generate_packages_sources.py new file mode 100755 index 00000000..d51779f9 --- /dev/null +++ b/dak/generate_packages_sources.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python + +""" Generate Packages/Sources files + +@contact: Debian FTPMaster +@copyright: 2000, 2001, 2002, 2006 James Troup +@copyright: 2009 Mark Hymers +@copyright: 2010 Joerg Jaspert + +""" + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +################################################################################ + +import os +import os.path +import stat +import sys +from datetime import datetime +import apt_pkg + +from daklib import daklog +from daklib.dbconn import * +from daklib.config import Config + +################################################################################ + +Options = None +Logger = None + +################################################################################ + +def usage (exit_code=0): + print """Usage: dak generate-packages-sources [OPTIONS] +Generate the Packages/Sources files + + -s, --suite=SUITE(s) process this suite + Default: All suites not marked 'untouchable' + -f, --force Allow processing of untouchable suites + CAREFUL: Only to be used at point release time! + -h, --help show this help and exit + +SUITE can be a space seperated list, e.g. + --suite=unstable testing + """ + + sys.exit(exit_code) + +################################################################################ + +def main (): + global Options, Logger + + cnf = Config() + + for i in ["Help", "Suite", "Force"]: + if not cnf.has_key("Generate-Packages-Sources::Options::%s" % (i)): + cnf["Generate-Packages-Sources::Options::%s" % (i)] = "" + + Arguments = [('h',"help","Generate-Packages-Sources::Options::Help"), + ('s',"suite","Generate-Packages-Sources::Options::Suite"), + ('f',"force","Generate-Packages-Sources::Options::Force")] + + suite_names = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv) + Options = cnf.SubTree("Generate-Packages-Sources::Options") + + if Options["Help"]: + usage() + +# Logger = daklog.Logger(cnf, 'generate-packages-sources') + + session = DBConn().session() + + if Options["Suite"]: + # Something here + suites = [] + for s in suite_names: + suite = get_suite(s.lower(), session) + if suite: + suites.append(suite) + else: + print "cannot find suite %s" % s +# Logger.log(['cannot find suite %s' % s]) + else: + suites=session.query(Suite).filter(Suite.untouchable == 'false').all() + + for s in suites: + print "Working on: %s" % (s.suite_name) + sys.exit(0) + # For each given suite, look up object and call generate-filelist + for s in suites: + Logger.log(['generating filelist for %s' % (s.suite_name)]) + s.generate_filelist(Logger) + +# Logger.close() + +####################################################################################### + +if __name__ == '__main__': + main() diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 559dbf17..13d324ca 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2487,6 +2487,9 @@ class Suite(object): return "\n".join(ret) + def generate_packages_sources(self, Logger): + """ Generate Packages/Sources files for the given suite" + __all__.append('Suite') @session_wrapper -- 2.39.5