# Checks Debian packages from Incoming
# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: jennifer,v 1.8 2002-02-25 15:38:06 troup Exp $
+# $Id: jennifer,v 1.15 2002-04-22 11:06:57 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
################################################################################
# Globals
-jennifer_version = "$Revision: 1.8 $";
+jennifer_version = "$Revision: 1.15 $";
Cnf = None;
Options = None;
def Dict(**dict): return dict
-def prefix_multi_line_string(str, prefix):
- out = "";
- for line in string.split(str, '\n'):
- line = string.strip(line);
- if line:
- out = out + "%s %s\n" % (prefix, line);
- # Strip trailing new line
- if out:
- out = out[:-1];
- return out;
-
def reject (str, prefix="Rejected: "):
global reject_message;
if str:
if exit_status:
reject("gpgv failed while checking %s." % (filename));
if string.strip(status):
- reject(prefix_multi_line_string(status, " [GPG status-fd output:]"), "");
+ reject(utils.prefix_multi_line_string(status, " [GPG status-fd output:] "), "");
else:
- reject(prefix_multi_line_string(output, " [GPG output:]"), "");
+ reject(utils.prefix_multi_line_string(output, " [GPG output:] "), "");
return None;
# Sanity check the good stuff we expect
files[file]["type"] = "deb";
# Extract package control information
+ deb_file = utils.open_file(file);
try:
- control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file)));
+ control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file));
except:
reject("%s: debExtractControl() raised %s." % (file, sys.exc_type));
+ deb_file.close();
# Can't continue, none of the checks on control would work.
continue;
+ deb_file.close();
# Check for mandatory fields
for field in [ "Package", "Architecture", "Version" ]:
if string.find(files[file]["priority"],'/') != -1:
reject("file '%s' has invalid priority '%s' [contains '/']." % (file, files[file]["priority"]));
- # Check the md5sum & size against existing files (if any)
+ # Determine the location
location = Cnf["Dir::PoolDir"];
- files[file]["location id"] = db_access.get_location_id (location, component, archive);
+ location_id = db_access.get_location_id (location, component, archive);
+ if location_id == -1:
+ reject("[INTERNAL ERROR] couldn't determine location (Component: %s, Archive: %s)" % (component, archive));
+ files[file]["location id"] = location_id;
+ # Check the md5sum & size against existing files (if any)
files[file]["pool name"] = utils.poolify (changes["source"], files[file]["component"]);
files_id = db_access.get_files_id(files[file]["pool name"] + file, files[file]["size"], files[file]["md5sum"], files[file]["location id"]);
if files_id == -1:
if epochless_dsc_version != files[file]["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);
+ if not m:
+ reject("%s mentioned in the Files field of %s not recognised as source." % (f, file));
+ type = m.group(3);
+ if type == "orig.tar.gz" or type == "tar.gz":
+ has_tar = 1;
+ if not has_tar:
+ reject("no .tar.gz or .orig.tar.gz listed in the Files field of %s." % (file));
+
# Ensure source is newer than existing source in target suites
reject(Katie.check_source_against_db(file),"");
else:
if apt_pkg.md5sum(file_handle) != files[file]["md5sum"]:
reject("md5sum check failed for %s." % (file));
+ file_handle.close();
################################################################################
apt_inst.debExtract(deb_file,tar.callback,"control.tar.gz");
deb_file.seek(0);
apt_inst.debExtract(deb_file,tar.callback,"data.tar.gz");
+ deb_file.close();
#
future_files = tar.future_files.keys();
if future_files:
time.ctime(ancient_date)));
except:
reject("%s: timestamp check failed; caught %s" % (filename, sys.exc_type));
- raise;
################################################################################
################################################################################
# the file is still being uploaded.
def upload_too_new():
+ too_new = 0;
+ # Move back to the original directory to get accurate time stamps
+ cwd = os.getcwd();
+ os.chdir(pkg.directory);
file_list = pkg.files.keys();
file_list.extend(pkg.dsc_files.keys());
file_list.append(pkg.changes_file);
for file in file_list:
try:
- last_modified = time.time()-os.path.getmtime(pkg.changes_file);
+ last_modified = time.time()-os.path.getmtime(file);
if last_modified < int(Cnf["Dinstall::SkipTime"]):
- return 1;
+ too_new = 1;
+ break;
except:
pass;
- return 0;
+ os.chdir(cwd);
+ return too_new;
+
+################################################################################
def action ():
# changes["distribution"] may not exist in corner cases
file_keys = files.keys();
- # Move all the files into the accepted directory
+ # Move all the files into the byhand directory
utils.move (pkg.changes_file, Cnf["Dir::QueueByhandDir"]);
for file in file_keys:
- utils.move (file, Cnf["Dir::QueueByhandDir"]);
+ utils.move (file, Cnf["Dir::QueueByhandDir"], perms=0660);
# Check for override disparities
if not Cnf["Dinstall::Options::No-Mail"]:
# Move all the files into the accepted directory
utils.move (pkg.changes_file, Cnf["Dir::QueueNewDir"]);
for file in file_keys:
- utils.move (file, Cnf["Dir::QueueNewDir"]);
+ utils.move (file, Cnf["Dir::QueueNewDir"], perms=0660);
if not Options["No-Mail"]:
print "Sending new ack.";