提交 4edf024f 编写于 作者: J James Troup

parse_changes and build_file_list 2nd argument sanity changes

上级 080f3c9b
......@@ -2,7 +2,7 @@
# Script to automate some parts of checking NEW packages
# Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
# $Id: fernanda.py,v 1.2 2002-05-03 16:06:45 troup Exp $
# $Id: fernanda.py,v 1.3 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -128,8 +128,8 @@ def display_changes (changes_filename):
def check_changes (changes_filename):
display_changes(changes_filename);
changes = utils.parse_changes (changes_filename, 0);
files = utils.build_file_list(changes, "");
changes = utils.parse_changes (changes_filename);
files = utils.build_file_list(changes);
for file in files.keys():
if file[-4:] == ".deb" or file[-5:] == ".udeb":
check_deb(file);
......
......@@ -2,7 +2,7 @@
# Remove obsolete .changes files from proposed-updates
# Copyright (C) 2001, 2002 James Troup <james@nocrew.org>
# $Id: halle,v 1.6 2002-05-08 11:13:02 troup Exp $
# $Id: halle,v 1.7 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -49,8 +49,8 @@ Need either changes files or an admin.txt file with a '.joey' suffix."""
def check_changes (filename):
try:
changes = utils.parse_changes(filename, 0)
files = utils.build_file_list(changes, "");
changes = utils.parse_changes(filename);
files = utils.build_file_list(changes);
except:
utils.warn("Couldn't read changes file '%s'." % (filename));
return;
......
......@@ -2,7 +2,7 @@
# Checks Debian packages from Incoming
# Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
# $Id: jennifer,v 1.19 2002-05-14 22:28:01 troup Exp $
# $Id: jennifer,v 1.20 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -43,7 +43,7 @@ re_is_changes = re.compile (r"(.+?)_(.+?)_(.+?)\.changes$");
################################################################################
# Globals
jennifer_version = "$Revision: 1.19 $";
jennifer_version = "$Revision: 1.20 $";
Cnf = None;
Options = None;
......@@ -355,7 +355,7 @@ def check_changes():
# Parse the .changes field into a dictionary
try:
changes.update(utils.parse_changes(filename, 0));
changes.update(utils.parse_changes(filename));
except utils.cant_open_exc:
reject("can't read changes file '%s'." % (filename));
return 0;
......@@ -365,7 +365,7 @@ def check_changes():
# Parse the Files field from the .changes into another dictionary
try:
files.update(utils.build_file_list(changes, ""));
files.update(utils.build_file_list(changes));
except utils.changes_parse_error_exc, line:
reject("error parsing changes file '%s', can't grok: %s." % (filename, line));
except utils.nk_format_exc, format:
......@@ -713,7 +713,7 @@ def check_dsc ():
if files[file]["type"] == "dsc":
# Parse the .dsc file
try:
dsc.update(utils.parse_changes(file, 1));
dsc.update(utils.parse_changes(file, dsc_whitespace_rules=1));
except utils.cant_open_exc:
# if not -n copy_to_holding() will have done this for us...
if Options["No-Action"]:
......@@ -724,7 +724,7 @@ def check_dsc ():
reject("syntax error in .dsc file '%s', line %s." % (file, line));
# Build up the file list of files mentioned by the .dsc
try:
dsc_files.update(utils.build_file_list(dsc, 1));
dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1));
except utils.no_files_exc:
reject("no Files: field in .dsc file.");
continue;
......
......@@ -2,7 +2,7 @@
# Dependency check proposed-updates
# Copyright (C) 2001, 2002 James Troup <james@nocrew.org>
# $Id: jeri,v 1.6 2002-05-14 15:34:02 troup Exp $
# $Id: jeri,v 1.7 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -187,8 +187,8 @@ def pass_fail (filename, result):
def check_changes (filename):
try:
changes = utils.parse_changes(filename, 0)
files = utils.build_file_list(changes, "");
changes = utils.parse_changes(filename);
files = utils.build_file_list(changes);
except:
utils.warn("Error parsing changes file '%s'" % (filename));
return;
......
......@@ -2,7 +2,7 @@
# General purpose package removal tool for ftpmaster
# Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
# $Id: melanie,v 1.25 2002-05-16 18:01:33 rmurray Exp $
# $Id: melanie,v 1.26 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -255,7 +255,7 @@ def main ():
for i in source_packages.keys():
filename = string.join(source_packages[i], '/');
try:
dsc = utils.parse_changes(filename, 0);
dsc = utils.parse_changes(filename);
except utils.cant_open_exc:
utils.warn("couldn't open '%s'." % (filename));
continue;
......@@ -394,7 +394,7 @@ def main ():
Subst["__BCC__"] = "Bcc: " + string.join(bcc, ", ");
else:
Subst["__BCC__"] = "X-Filler: 42";
Subst["__CC__"] = "X-Melanie: $Revision: 1.25 $";
Subst["__CC__"] = "X-Melanie: $Revision: 1.26 $";
if carbon_copy:
Subst["__CC__"] = Subst["__CC__"] + "\nCc: " + string.join(carbon_copy, ", ");
Subst["__SUITE_LIST__"] = suites_list;
......
......@@ -2,7 +2,7 @@
# Clean incoming of old unused files
# Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
# $Id: shania,v 1.14 2002-05-08 11:13:02 troup Exp $
# $Id: shania,v 1.15 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -129,8 +129,8 @@ def flush_orphans ():
# Proces all .changes and .dsc files.
for changes_filename in changes_files:
try:
changes = utils.parse_changes(changes_filename, 0)
files = utils.build_file_list(changes, "");
changes = utils.parse_changes(changes_filename);
files = utils.build_file_list(changes);
except:
utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type));
continue;
......@@ -139,8 +139,8 @@ def flush_orphans ():
for file in files.keys():
if file[-4:] == ".dsc":
try:
dsc = utils.parse_changes(file, 0)
dsc_files = utils.build_file_list(dsc, 1)
dsc = utils.parse_changes(file);
dsc_files = utils.build_file_list(dsc, is_a_dsc=1);
except:
utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type));
continue;
......
# Utility functions
# Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
# $Id: utils.py,v 1.43 2002-05-10 00:24:14 troup Exp $
# $Id: utils.py,v 1.44 2002-05-18 23:54:51 troup Exp $
# 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
......@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import commands, os, pwd, re, socket, shutil, string, sys, tempfile
import os, pwd, re, socket, shutil, string, sys, tempfile
import apt_pkg
re_comments = re.compile(r"\#.*")
......@@ -123,7 +123,7 @@ def extract_component_from_section(section):
# o The data section must end with a blank line and must be followed by
# "-----BEGIN PGP SIGNATURE-----".
def parse_changes(filename, dsc_whitespace_rules):
def parse_changes(filename, dsc_whitespace_rules=0):
changes_in = open_file(filename);
error = "";
changes = {};
......@@ -199,12 +199,12 @@ def parse_changes(filename, dsc_whitespace_rules):
# Dropped support for 1.4 and ``buggy dchanges 3.4'' (?!) compared to di.pl
def build_file_list(changes, dsc):
def build_file_list(changes, is_a_dsc=0):
files = {}
format = changes.get("format", "")
if format != "":
format = float(format)
if dsc == "" and (format < 1.5 or format > 2.0):
if not is_a_dsc and (format < 1.5 or format > 2.0):
raise nk_format_exc, format;
# No really, this has happened. Think 0 length .dsc file.
......@@ -217,7 +217,7 @@ def build_file_list(changes, dsc):
s = string.split(i)
section = priority = "";
try:
if dsc != "":
if is_a_dsc:
(md5, size, name) = s
else:
(md5, size, section, priority, name) = s
......@@ -428,12 +428,12 @@ def cc_fix_changes (changes):
# Sort by source name, source version, 'have source', and then by filename
def changes_compare (a, b):
try:
a_changes = parse_changes(a, 0)
a_changes = parse_changes(a);
except:
return -1;
try:
b_changes = parse_changes(b, 0)
b_changes = parse_changes(b);
except:
return 1;
......@@ -452,11 +452,11 @@ def changes_compare (a, b):
b_version = b_changes.get("version");
q = apt_pkg.VersionCompare(a_version, b_version);
if q:
return q
return q;
# Sort by 'have source'
a_has_source = a_changes["architecture"].get("source")
b_has_source = b_changes["architecture"].get("source")
a_has_source = a_changes["architecture"].get("source");
b_has_source = b_changes["architecture"].get("source");
if a_has_source and not b_has_source:
return -1;
elif b_has_source and not a_has_source:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册