#!/usr/bin/env python
-# Various different sanity checks
+""" Various different sanity checks """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
+from daklib.regexes import re_issource
################################################################################
dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
has_tar = 0
for f in dsc_files.keys():
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if not m:
utils.fubar("%s not recognised as source." % (f))
ftype = m.group(3)
#!/usr/bin/env python
-# Cruft checker and hole filler for overrides
+""" Cruft checker and hole filler for overrides """
# Copyright (C) 2000, 2001, 2002, 2004, 2006 James Troup <james@nocrew.org>
# Copyright (C) 2005 Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
#!/usr/bin/env python
-# Dependency check proposed-updates
+""" Dependency check proposed-updates """
# Copyright (C) 2001, 2002, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
+from daklib.regexes import re_no_epoch
################################################################################
unsat = 0
break
# As part of the same .changes?
- epochless_version = utils.re_no_epoch.sub('', version)
+ epochless_version = re_no_epoch.sub('', version)
dep_filename = "%s_%s_%s.deb" % (dep, epochless_version, arch)
if files.has_key(dep_filename):
if Options["debug"]:
#!/usr/bin/env python
-# Remove obsolete .changes files from proposed-updates
+""" Remove obsolete .changes files from proposed-updates """
# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
################################################################################
-import os, pg, re, sys
+import os, pg, sys
import apt_pkg
from daklib import database
from daklib import utils
+from daklib.regexes import re_isdeb, re_isadeb, re_issource, re_no_epoch
################################################################################
Options = None
pu = {}
-re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$")
-
################################################################################
def usage (exit_code=0):
return
num_files = len(files.keys())
for f in files.keys():
- if utils.re_isadeb.match(f):
+ if re_isadeb.match(f):
m = re_isdeb.match(f)
pkg = m.group(1)
version = m.group(2)
if Options["debug"]:
print "BINARY: %s ==> %s_%s_%s" % (f, pkg, version, arch)
else:
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if m:
pkg = m.group(1)
version = m.group(2)
# FIXME
utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], f, filename))
continue
- pu_version = utils.re_no_epoch.sub('', pu[pkg][arch])
+ pu_version = re_no_epoch.sub('', pu[pkg][arch])
if pu_version == version:
if Options["verbose"]:
print "%s: ok" % (f)
#!/usr/bin/env python
-# Clean incoming of old unused files
+""" Clean incoming of old unused files """
# Copyright (C) 2000, 2001, 2002, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Cleans up unassociated binary and source packages
+""" Cleans up unassociated binary and source packages """
# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Check for fixable discrepancies between stable and unstable
+""" Check for fixable discrepancies between stable and unstable """
# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Bulk manipulation of the overrides
+""" Bulk manipulation of the overrides """
# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
from daklib import utils
from daklib import database
from daklib import logging
+from daklib.regexes import re_comments
################################################################################
start_time = time.time()
projectB.query("BEGIN WORK")
for line in file.readlines():
- line = utils.re_comments.sub('', line).strip()
+ line = re_comments.sub('', line).strip()
if line == "":
continue
#!/usr/bin/env python
-# Manipulate suite tags
+""" Manipulate suite tags """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Check for obsolete binary packages
+""" Check for obsolete binary packages """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg
from daklib import database
from daklib import utils
+from daklib.regexes import re_extract_src_version
################################################################################
bin2source[package]["version"] = version
bin2source[package]["source"] = source
if source.find("(") != -1:
- m = utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
version = m.group(2)
if not bin_pkgs.has_key(package):
#!/usr/bin/env python
-# Debian Archive Kit Database Update Script
+""" Database Update Script - Saner DM db schema """
# Copyright (C) 2008 Michael Casadevall <mcasadevall@debian.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
# coding=utf8
-# Debian Archive Kit Database Update Script
+""" Database Update Script - debversion """
# Copyright © 2008 Michael Casadevall <mcasadevall@debian.org>
# Copyright © 2008 Roger Leigh <rleigh@debian.org>
#!/usr/bin/env python
-# Debian Archive Kit Database Update Script
+""" Database Update Script - Remove unused versioncmp """
# Copyright (C) 2008 Michael Casadevall <mcasadevall@debian.org>
# Copyright (C) 2009 Joerg Jaspert <joerg@debian.org>
#!/usr/bin/env python
-# Dump variables from a .dak file to stdout
+""" Dump variables from a .dak file to stdout """
# Copyright (C) 2001, 2002, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Script to automate some parts of checking NEW packages
+""" Script to automate some parts of checking NEW packages """
# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
-
-################################################################################
-
-re_package = re.compile(r"^(.+?)_.*")
-re_doc_directory = re.compile(r".*/doc/([^/]*).*")
-
-re_contrib = re.compile('^contrib/')
-re_nonfree = re.compile('^non\-free/')
-
-re_arch = re.compile("Architecture: .*")
-re_builddep = re.compile("Build-Depends: .*")
-re_builddepind = re.compile("Build-Depends-Indep: .*")
-
-re_localhost = re.compile("localhost\.localdomain")
-re_version = re.compile('^(.*)\((.*)\)')
-
-re_newlinespace = re.compile('\n')
-re_spacestrip = re.compile('(\s)')
+from daklib.regexes import html_escaping, re_html_escaping, re_version, re_spacestrip, \
+ re_contrib, re_nonfree, re_localhost, re_newlinespace, \
+ re_package, re_doc_directory
################################################################################
def escape_if_needed(s):
if use_html:
- return utils.re_html_escaping.sub(lambda x: utils.html_escaping.get(x.group(0)), s)
+ return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s)
else:
return s
#!/usr/bin/env python
-# Check for users with no packages in the archive
+""" Check for users with no packages in the archive """
# Copyright (C) 2003, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
+""" generates partial package updates list"""
+
###########################################################
-# generates partial package updates list
# idea and basic implementation by Anthony, some changes by Andreas
# parts are stolen from 'dak generate-releases'
if not os.path.isdir(outdir):
os.mkdir(outdir)
- cmd = "diff --ed - %s | gzip -c -9 > %s.gz" % (newfile, difffile)
- # Do we need shell=True?
- w = subprocess.Popen(cmd, shell=True, stdin=PIPE).stdin
-
- # I bet subprocess can do that better than this, but lets do little steps
+ w = os.popen("diff --ed - %s | gzip -c -9 > %s.gz" %
+ (newfile, difffile), "w")
pipe_file(oldf, w)
oldf.close()
#!/usr/bin/env python
-# Create all the Release files
+""" Create all the Release files """
# Copyright (C) 2001, 2002, 2006 Anthony Towns <ajt@debian.org>
#!/usr/bin/env python
-# Populate the DB
+""" Populate the DB """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
###############################################################################
-import commands, os, pg, re, sys, time
+import commands, os, pg, sys, time
import apt_pkg
from daklib import database
from daklib import utils
from daklib.dak_exceptions import *
-
-###############################################################################
-
-re_arch_from_filename = re.compile(r"binary-[^/]+")
+from daklib.regexes import re_arch_from_filename, re_taint_free, re_no_epoch, \
+ re_extract_src_version
###############################################################################
###############################################################################
def check_signature (filename):
- if not utils.re_taint_free.match(os.path.basename(filename)):
+ if not re_taint_free.match(os.path.basename(filename)):
reject("!!WARNING!! tainted filename: '%s'." % (filename))
return None
package = Scanner.Section["package"]
version = Scanner.Section["version"]
directory = Scanner.Section["directory"]
- dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)))
+ dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, re_no_epoch.sub('', version)))
# Sometimes the Directory path is a lie; check in the pool
if not os.path.exists(dsc_file):
if directory.split('/')[0] == "dists":
directory = Cnf["Dir::PoolRoot"] + utils.poolify(package, component)
- dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)))
+ dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, re_no_epoch.sub('', version)))
if not os.path.exists(dsc_file):
utils.fubar("%s not found." % (dsc_file))
install_date = time.strftime("%Y-%m-%d", time.localtime(os.path.getmtime(dsc_file)))
directory = poolify (directory, location)
if directory != "" and not directory.endswith("/"):
directory += '/'
- no_epoch_version = utils.re_no_epoch.sub('', version)
+ no_epoch_version = re_no_epoch.sub('', version)
# Add all files referenced by the .dsc to the files table
ids = []
for line in Scanner.Section["files"].split('\n'):
source = Scanner.Section["source"]
source_version = ""
if source.find("(") != -1:
- m = utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
source_version = m.group(2)
if not source_version:
#!/usr/bin/env python
-# Imports a keyring into the database
+""" Imports a keyring into the database """
# Copyright (C) 2007 Anthony Towns <aj@erisian.com.au>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Sync fingerprint and uid tables with a debian.org LDAP DB
+""" Sync fingerprint and uid tables with a debian.org LDAP DB """
# Copyright (C) 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg
from daklib import database
from daklib import utils
+from daklib.regexes import re_gpg_fingerprint, re_debian_address
################################################################################
Cnf = None
projectB = None
-re_gpg_fingerprint = re.compile(r"^\s+Key fingerprint = (.*)$", re.MULTILINE)
-re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE)
-
################################################################################
def usage(exit_code=0):
#!/usr/bin/env python
-# Sync PostgreSQL users with system users
+""" Sync PostgreSQL users with system users """
# Copyright (C) 2001, 2002, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Display information about package(s) (suite, version, etc.)
+""" Display information about package(s) (suite, version, etc.) """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Generate Maintainers file used by e.g. the Debian Bug Tracking System
+""" Generate Maintainers file used by e.g. the Debian Bug Tracking System """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg
from daklib import database
from daklib import utils
+from daklib.regexes import re_comments
################################################################################
for filename in extra_files:
extrafile = utils.open_file(filename)
for line in extrafile.readlines():
- line = utils.re_comments.sub('', line).strip()
+ line = re_comments.sub('', line).strip()
if line == "":
continue
split = line.split()
#!/usr/bin/env python
-# Output override files for apt-ftparchive and indices/
+""" Output override files for apt-ftparchive and indices/ """
# Copyright (C) 2000, 2001, 2002, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Generate file lists used by apt-ftparchive to generate Packages and Sources files
+""" Generate file lists used by apt-ftparchive to generate Packages and Sources files """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
if not packages.has_key(delete_unique_id):
continue
delete_version = version[0]
- delete_id = packages[delete_unique_id]["id"]
+ delete_id = packages[delete_unique_id]["sourceid"]
delete_arch = packages[delete_unique_id]["arch"]
if not Cnf.Find("Suite::%s::Untouchable" % (suite)) or Options["Force"]:
if Options["No-Delete"]:
suite = packages[unique_id]["suite"]
component = packages[unique_id]["component"]
arch = packages[unique_id]["arch"]
- packagetype = packages[unique_id]["type"]
+ packagetype = packages[unique_id]["filetype"]
d.setdefault(suite, {})
d[suite].setdefault(component, {})
d[suite][component].setdefault(arch, {})
#!/usr/bin/env python
-# Wrapper for Debian Security team
+""" Wrapper for Debian Security team """
# Copyright (C) 2006 Anthony Towns <ajt@debian.org>
# This program is free software; you can redistribute it and/or modify
################################################################################
+import apt_pkg, os, sys, pwd, time, commands
+
from daklib import queue
from daklib import logging
from daklib import utils
from daklib import database
-import apt_pkg, os, sys, pwd, time, re, commands
-
-re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$")
+from daklib.regexes import re_taint_free
Cnf = None
Options = None
#!/usr/bin/env python
-# Microscopic modification and query tool for overrides in projectb
+""" Microscopic modification and query tool for overrides in projectb """
# Copyright (C) 2004, 2006 Daniel Silverstone <dsilvers@digital-scurf.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Poolify (move packages from "legacy" type locations to pool locations)
+""" Poolify (move packages from "legacy" type locations to pool locations) """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_pkg, apt_inst
import daklib.database
import daklib.utils
+from daklib.regexes import re_isadeb, re_extract_src_version, re_no_epoch, re_issource
################################################################################
Cnf = None
projectB = None
-re_isadeb = re.compile (r"(.+?)_(.+?)(_(.+))?\.u?deb$")
-
################################################################################
def usage (exit_code=0):
package = control.Find("Package", "")
source = control.Find("Source", package)
if source.find("(") != -1:
- m = daklib.utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
# If it's a binary, we need to also rename the file to include the architecture
version = control.Find("Version", "")
architecture = control.Find("Architecture", "")
if package == "" or version == "" or architecture == "":
daklib.utils.fubar("%s: couldn't determine required information to rename .deb file." % (legacy_filename))
- version = daklib.utils.re_no_epoch.sub('', version)
+ version = re_no_epoch.sub('', version)
destination_filename = "%s_%s_%s.deb" % (package, version, architecture)
else:
- m = daklib.utils.re_issource.match(base_filename)
+ m = re_issource.match(base_filename)
if m:
source = m.group(1)
else:
#!/usr/bin/env python
-# Installs Debian packages from queue/accepted into the pool
+""" Installs Debian packages from queue/accepted into the pool """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
from daklib import queue
from daklib import utils
from daklib.dak_exceptions import *
+from daklib.regexes import re_default_answer, re_issource, re_fdnic
###############################################################################
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
for newfile in files.keys():
if files[newfile]["type"] == "deb":
new_changelog.write("stable/%s/binary-%s/%s\n" % (files[newfile]["component"], files[newfile]["architecture"], newfile))
- elif utils.re_issource.match(newfile):
+ elif re_issource.match(newfile):
new_changelog.write("stable/%s/source/%s\n" % (files[newfile]["component"], newfile))
else:
new_changelog.write("%s\n" % (newfile))
- chop_changes = queue.re_fdnic.sub("\n", changes["changes"])
+ chop_changes = re_fdnic.sub("\n", changes["changes"])
new_changelog.write(chop_changes + '\n\n')
if os.access(changelog_filename, os.R_OK) != 0:
changelog = utils.open_file(changelog_filename)
#!/usr/bin/env python
# vim:set et ts=4 sw=4:
-# Handles NEW and BYHAND packages
+""" Handles NEW and BYHAND packages """
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
from daklib import logging
from daklib import queue
from daklib import utils
+from daklib.regexes import re_no_epoch, re_default_answer, re_isanum
# Globals
Cnf = None
source_package = files[f]["source package"]
if not Upload.pkg.changes["architecture"].has_key("source") \
and not Upload.source_exists(source_package, source_version, Upload.pkg.changes["distribution"].keys()):
- source_epochless_version = utils.re_no_epoch.sub('', source_version)
+ source_epochless_version = re_no_epoch.sub('', source_version)
dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
found = 0
for q in ["Accepted", "Embargoed", "Unembargoed"]:
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
answer = answer[:1].upper()
if answer == "E" or answer == "D":
got_answer = 1
- elif queue.re_isanum.match (answer):
+ elif re_isanum.match (answer):
answer = int(answer)
if (answer < 1) or (answer > index):
print "%s is not a valid index (%s). Please retry." % (answer, index_range(index))
answer = "XXX"
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
answer = "XXX"
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
#!/usr/bin/env python
-# Checks Debian packages from Incoming
+""" Checks Debian packages from Incoming """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
from daklib import queue
from daklib import utils
from daklib.dak_exceptions import *
+from daklib.regexes import re_valid_version, re_valid_pkg_name, re_changelog_versions, \
+ re_strip_revision, re_strip_srcver, re_spacestrip, \
+ re_isanum, re_no_epoch, re_no_revision, re_taint_free, \
+ re_isadeb, re_extract_src_version, re_issource
from types import *
################################################################################
-re_valid_version = re.compile(r"^([0-9]+:)?[0-9A-Za-z\.\-\+:~]+$")
-re_valid_pkg_name = re.compile(r"^[\dA-Za-z][\dA-Za-z\+\-\.]+$")
-re_changelog_versions = re.compile(r"^\w[-+0-9a-z.]+ \([^\(\) \t]+\)")
-re_strip_revision = re.compile(r"-([^-]+)$")
-re_strip_srcver = re.compile(r"\s+\(\S+\)$")
-re_spacestrip = re.compile('(\s)')
################################################################################
# Ensure all the values in Closes: are numbers
if changes.has_key("closes"):
for i in changes["closes"].keys():
- if queue.re_isanum.match (i) == None:
+ if re_isanum.match (i) == None:
reject("%s: `%s' from Closes field isn't a number." % (filename, i))
# chopversion = no epoch; chopversion2 = no epoch and no revision (e.g. for .orig.tar.gz comparison)
- changes["chopversion"] = utils.re_no_epoch.sub('', changes["version"])
- changes["chopversion2"] = utils.re_no_revision.sub('', changes["chopversion"])
+ changes["chopversion"] = re_no_epoch.sub('', changes["version"])
+ changes["chopversion2"] = re_no_revision.sub('', changes["chopversion"])
# Check there isn't already a changes file of the same name in one
# of the queue directories.
if not Cnf.has_key("Dir::Queue::%s" % (d)): continue
if os.path.exists(Cnf["Dir::Queue::%s" % (d) ] + '/' + f):
reject("%s file already exists in the %s directory." % (f, d))
- if not utils.re_taint_free.match(f):
+ if not re_taint_free.match(f):
reject("!!WARNING!! tainted filename: '%s'." % (f))
# Check the file is readable
if os.access(f, os.R_OK) == 0:
files[f]["byhand"] = 1
files[f]["type"] = "byhand"
# Checks for a binary package...
- elif utils.re_isadeb.match(f):
+ elif re_isadeb.match(f):
has_binaries = 1
files[f]["type"] = "deb"
source = files[f]["source"]
source_version = ""
if source.find("(") != -1:
- m = utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
source_version = m.group(2)
if not source_version:
files[f]["source version"] = source_version
# Ensure the filename matches the contents of the .deb
- m = utils.re_isadeb.match(f)
+ m = re_isadeb.match(f)
# package name
file_package = m.group(1)
if files[f]["package"] != file_package:
reject("%s: package part of filename (%s) does not match package name in the %s (%s)." % (f, file_package, files[f]["dbtype"], files[f]["package"]))
- epochless_version = utils.re_no_epoch.sub('', control.Find("Version"))
+ epochless_version = re_no_epoch.sub('', control.Find("Version"))
# version
file_version = m.group(2)
if epochless_version != file_version:
# Check in the SQL database
if not Upload.source_exists(source_package, source_version, changes["distribution"].keys()):
# Check in one of the other directories
- source_epochless_version = utils.re_no_epoch.sub('', source_version)
+ source_epochless_version = re_no_epoch.sub('', source_version)
dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
if os.path.exists(Cnf["Dir::Queue::Byhand"] + '/' + dsc_filename):
files[f]["byhand"] = 1
# Checks for a source package...
else:
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if m:
has_source = 1
files[f]["package"] = m.group(1)
pass
# Ensure the version number in the .dsc matches the version number in the .changes
- epochless_dsc_version = utils.re_no_epoch.sub('', dsc["version"])
+ epochless_dsc_version = re_no_epoch.sub('', dsc["version"])
changes_version = files[dsc_filename]["version"]
if epochless_dsc_version != files[dsc_filename]["version"]:
reject("version ('%s') in .dsc does not match version ('%s') in .changes." % (epochless_dsc_version, changes_version))
# Ensure there is a .tar.gz in the .dsc file
has_tar = 0
for f in dsc_files.keys():
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if not m:
reject("%s: %s in Files field not recognised as source." % (dsc_filename, f))
continue
# Create a symlink mirror of the source files in our temporary directory
for f in files.keys():
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if m:
src = os.path.join(source_dir, f)
# If a file is missing for whatever reason, give up.
return
# Get the upstream version
- upstr_version = utils.re_no_epoch.sub('', dsc["version"])
+ upstr_version = re_no_epoch.sub('', dsc["version"])
if re_strip_revision.search(upstr_version):
upstr_version = re_strip_revision.sub('', upstr_version)
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
#!/usr/bin/env python
-# Produces a report on NEW and BYHAND packages
+""" Produces a report on NEW and BYHAND packages """
# Copyright (C) 2001, 2002, 2003, 2005, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Manually reject packages for proprosed-updates
+""" Manually reject packages for proprosed-updates """
# Copyright (C) 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
from daklib import logging
from daklib import queue
from daklib import utils
+from daklib.regexes import re_default_answer
################################################################################
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
answer = "XXX"
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
#!/usr/bin/env python
-# General purpose package removal tool for ftpmaster
+""" General purpose package removal tool for ftpmaster """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
from daklib import database
from daklib import utils
from daklib.dak_exceptions import *
-
-################################################################################
-
-re_strip_source_version = re.compile (r'\s+.*$')
-re_build_dep_arch = re.compile(r"\[[^]]+\]")
+from daklib.regexes import re_strip_source_version, re_build_dep_arch
################################################################################
#!/usr/bin/env python
-# based on queue-report
+""" Overview of the DEFERRED queue, based on queue-report """
# Copyright (C) 2001, 2002, 2003, 2005, 2006 James Troup <james@nocrew.org>
# Copyright (C) 2008 Thomas Viehmann <tv@beamnet.de>
from daklib import database
from daklib import queue
from daklib import utils
+from daklib.regexes import re_html_escaping, html_escaping
################################################################################
### work around bug #487902 in debian-python 0.1.10
row_number = 1
-html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'}
-re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
def html_escape(s):
return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s)
#!/usr/bin/env python
-# Output html for packages in NEW
+""" Output html for packages in NEW """
# Copyright (C) 2007 Joerg Jaspert <joerg@debian.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
+""" Split queue/done into date based subdirectories """
# Copyright (C) 2004, 2005, 2006 James Troup <james@nocrew.org>
+# Copyright (C) 2008 Joerg Jaspert <joerg@debian.org>
# 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
#!/usr/bin/env python
-# Various statistical pr0nography fun and games
+""" Various statistical pr0nography fun and games """
# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Display, edit and check the release manager's transition file.
+""" Display, edit and check the release manager's transition file. """
# Copyright (C) 2008 Joerg Jaspert <joerg@debian.org>
# This program is free software; you can redistribute it and/or modify
################################################################################
-import os, pg, sys, time, errno, fcntl, tempfile, pwd, re
+import os, pg, sys, time, errno, fcntl, tempfile, pwd
import apt_pkg
from daklib import database
from daklib import utils
from daklib.dak_exceptions import TransitionsError
+from daklib.regexes import re_broken_package
import yaml
# Globals
Options = None
projectB = None
-re_broken_package = re.compile(r"[a-zA-Z]\w+\s+\-.*")
-
################################################################################
#####################################
#!/usr/bin/env python
-# Debian Archive Kit Database Update Script
+""" Database Update Main Script """
# Copyright (C) 2008 Michael Casadevall <mcasadevall@debian.org>
# This program is free software; you can redistribute it and/or modify
################################################################################
def update_db_to_zero(self):
- # This function will attempt to update a pre-zero database schema to zero
+ """ This function will attempt to update a pre-zero database schema to zero """
# First, do the sure thing, and create the configuration table
try:
-# Exception classes used in dak
+#!/usr/bin/env python
+
+""" Exception classes used in dak """
# Copyright (C) 2008 Mark Hymers <mhy@debian.org>
#!/usr/bin/env python
-# DB access fucntions
+""" DB access fucntions """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
-# Utility functions for extensions
+""" Utility functions for extensions """
# Copyright (C) 2008 Anthony Towns <ajt@dbeian.org>
################################################################################
#!/usr/bin/env python
-# Logging functions
+""" Logging functions """
# Copyright (C) 2001, 2002, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
#!/usr/bin/env python
# vim:set et sw=4:
-# Queue utility functions for dak
+""" Queue utility functions for dak """
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
# This program is free software; you can redistribute it and/or modify
import apt_inst, apt_pkg
import utils, database
from dak_exceptions import *
+from regexes import re_default_answer, re_fdnic, re_bin_only_nmu
from types import *
###############################################################################
-re_isanum = re.compile (r"^\d+$")
-re_default_answer = re.compile(r"\[(.*)\]")
-re_fdnic = re.compile(r"\n\n")
-re_bin_only_nmu = re.compile(r"\+b\d+$")
-
-################################################################################
-
# Determine what parts in a .changes are NEW
def determine_new(changes, files, projectB, warn=1):
--- /dev/null
+#!/usr/bin/env python
+# vim:set et sw=4:
+
+"""Central repository of regexes for dak"""
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
+# Copyright (C) 2009 Mark Hymers <mhy@debian.org>
+
+# 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 re
+
+re_isanum = re.compile (r"^\d+$")
+re_default_answer = re.compile(r"\[(.*)\]")
+re_fdnic = re.compile(r"\n\n")
+re_bin_only_nmu = re.compile(r"\+b\d+$")
+
+re_comments = re.compile(r"\#.*")
+re_no_epoch = re.compile(r"^\d+\:")
+re_no_revision = re.compile(r"-[^-]+$")
+re_arch_from_filename = re.compile(r"/binary-[^/]+/")
+re_extract_src_version = re.compile (r"(\S+)\s*\((.*)\)")
+re_isadeb = re.compile (r"(.+?)_(.+?)_(.+)\.u?deb$")
+
+re_issource = re.compile (r"(.+)_(.+?)\.(orig\.tar\.gz|diff\.gz|tar\.gz|dsc)$")
+
+re_single_line_field = re.compile(r"^(\S*)\s*:\s*(.*)")
+re_multi_line_field = re.compile(r"^\s(.*)")
+re_taint_free = re.compile(r"^[-+~/\.\w]+$")
+
+re_parse_maintainer = re.compile(r"^\s*(\S.*\S)\s*\<([^\>]+)\>")
+re_gpg_uid = re.compile('^uid.*<([^>]*)>')
+
+re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
+re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$")
+
+re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
+
+html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'}
+re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
+
+# From clean_proposed_updates.py
+re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$")
+
+# From examine_package.py
+re_package = re.compile(r"^(.+?)_.*")
+re_doc_directory = re.compile(r".*/doc/([^/]*).*")
+
+re_contrib = re.compile('^contrib/')
+re_nonfree = re.compile('^non\-free/')
+
+re_localhost = re.compile("localhost\.localdomain")
+re_version = re.compile('^(.*)\((.*)\)')
+
+re_newlinespace = re.compile('\n')
+re_spacestrip = re.compile('(\s)')
+
+# From import_archive.py
+re_arch_from_filename = re.compile(r"binary-[^/]+")
+
+# From import_ldap_fingerprints.py
+re_gpg_fingerprint = re.compile(r"^\s+Key fingerprint = (.*)$", re.MULTILINE)
+re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE)
+
+# From new_security_install.py
+re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$")
+
+# From process_unchecked.py
+re_valid_version = re.compile(r"^([0-9]+:)?[0-9A-Za-z\.\-\+:~]+$")
+re_valid_pkg_name = re.compile(r"^[\dA-Za-z][\dA-Za-z\+\-\.]+$")
+re_changelog_versions = re.compile(r"^\w[-+0-9a-z.]+ \([^\(\) \t]+\)")
+re_strip_revision = re.compile(r"-([^-]+)$")
+re_strip_srcver = re.compile(r"\s+\(\S+\)$")
+re_spacestrip = re.compile('(\s)')
+
+# From dak/rm.py
+re_strip_source_version = re.compile (r'\s+.*$')
+re_build_dep_arch = re.compile(r"\[[^]]+\]")
+
+# From dak/transitions.py
+re_broken_package = re.compile(r"[a-zA-Z]\w+\s+\-.*")
#!/usr/bin/env python
# vim:set et ts=4 sw=4:
-# Utility functions
+""" Utility functions """
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
################################################################################
import database
import time
from dak_exceptions import *
+from regexes import re_html_escaping, html_escaping, re_single_line_field, \
+ re_multi_line_field, re_srchasver, re_verwithext, \
+ re_parse_maintainer, re_taint_free, re_gpg_uid
################################################################################
-re_comments = re.compile(r"\#.*")
-re_no_epoch = re.compile(r"^\d+\:")
-re_no_revision = re.compile(r"-[^-]+$")
-re_arch_from_filename = re.compile(r"/binary-[^/]+/")
-re_extract_src_version = re.compile (r"(\S+)\s*\((.*)\)")
-re_isadeb = re.compile (r"(.+?)_(.+?)_(.+)\.u?deb$")
-re_issource = re.compile (r"(.+)_(.+?)\.(orig\.tar\.gz|diff\.gz|tar\.gz|dsc)$")
-
-re_single_line_field = re.compile(r"^(\S*)\s*:\s*(.*)")
-re_multi_line_field = re.compile(r"^\s(.*)")
-re_taint_free = re.compile(r"^[-+~/\.\w]+$")
-
-re_parse_maintainer = re.compile(r"^\s*(\S.*\S)\s*\<([^\>]+)\>")
-re_gpg_uid = re.compile('^uid.*<([^>]*)>')
-
-re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
-re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$")
-
-re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
-
-html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'}
-re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
-
default_config = "/etc/dak/dak.conf"
default_apt_config = "/etc/dak/apt.conf"