10
10
A kind of archive garbage collector, supersede NBS binaries (not build
17
16
from canonical.config import config
18
from canonical.launchpad.scripts import (
19
execute_zcml_for_scripts, logger, logger_options)
17
from lp.services.scripts.base import LaunchpadScript, LaunchpadScriptFailure
20
18
from lp.soyuz.scripts.ftpmaster import (
21
19
ArchiveCruftChecker, ArchiveCruftCheckerError)
22
from canonical.lp import initZopeless
23
from contrib.glock import GlobalLock
27
# Parse command-line arguments
28
parser = optparse.OptionParser()
30
logger_options(parser)
33
"-d", "--distro", dest="distro", help="remove from DISTRO")
35
"-n", "--no-action", dest="action", default=True,
36
action="store_false", help="don't do anything")
38
"-s", "--suite", dest="suite", help="only act on SUITE")
40
(options, args) = parser.parse_args()
42
log = logger(options, "archive-cruft-check")
44
log.debug("Acquiring lock")
45
lock = GlobalLock('/var/lock/launchpad-archive-cruft-check.lock')
46
lock.acquire(blocking=True)
48
log.debug("Initializing connection.")
49
execute_zcml_for_scripts()
50
ztm = initZopeless(dbuser=config.archivepublisher.dbuser)
54
archive_path = args[0]
56
log.error('ARCHIVEPATH is require')
59
checker = ArchiveCruftChecker(
60
log, distribution_name=options.distro, suite=options.suite,
61
archive_path=archive_path)
65
except ArchiveCruftCheckerError, info:
69
# XXX cprov 2007-06-26 bug=121784: Disabling by distro-team request.
70
# if checker.nbs_to_remove and options.action:
71
# checker.doRemovals()
22
class ArchiveCruftCheckerScript(LaunchpadScript):
24
usage = "Usage: archive-cruft-check.py [options] <ARCHIVE_PATH>"
26
def add_my_options(self):
27
self.parser.add_option(
28
"-d", "--distro", dest="distro", help="remove from DISTRO")
29
self.parser.add_option(
30
"-n", "--no-action", dest="action", default=True,
31
action="store_false", help="don't do anything")
32
self.parser.add_option(
33
"-s", "--suite", dest="suite", help="only act on SUITE")
36
if len(self.args) != 1:
37
self.parser.error('ARCHIVEPATH is require')
38
archive_path = self.args[0]
40
checker = ArchiveCruftChecker(
41
self.logger, distribution_name=self.options.distro,
42
suite=self.options.suite, archive_path=archive_path)
46
except ArchiveCruftCheckerError, info:
47
raise LaunchpadScriptFailure(info)
49
# XXX cprov 2007-06-26 bug=121784: Disabling by distro-team request.
50
# if checker.nbs_to_remove and options.action:
51
# checker.doRemovals()
78
54
if __name__ == '__main__':
55
ArchiveCruftCheckerScript(
56
'archive-cruft-check', config.archivepublisher.dbuser).lock_and_run()