From 8cc4b5cf501b55e4abe98b882f70784da17911d0 Mon Sep 17 00:00:00 2001 From: James Troup Date: Thu, 30 Nov 2000 04:19:30 +0000 Subject: [PATCH] overwriting existing files is no good, mmkay? fix chmod 664 on directories. --- THANKS | 2 +- TODO | 3 +-- init_pool.sql | 2 +- katie | 13 +++++++++++-- utils.py | 6 +++++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/THANKS b/THANKS index d8292fbc..b190663b 100644 --- a/THANKS +++ b/THANKS @@ -6,7 +6,7 @@ Antti-Juhani Kaijanaho Brendan O'Dea Chris Leishman Drake Diedrich -Guy Maor Jason Gunthorpe Michael Beattie Robert Bihlmeyer diff --git a/TODO b/TODO index f5b7e87f..7cf94090 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,13 @@ Show Stopper ------------ - o finish new cron.daily file + o finish new cron.daily file for auric o finish rhona o Testing... lots of it. o jenna needs to munge files in stable - o need to handle (i.e. not crash, but reject) -sa builds. Non-Show Stopper ---------------- diff --git a/init_pool.sql b/init_pool.sql index e7bfb87d..8da4a79f 100644 --- a/init_pool.sql +++ b/init_pool.sql @@ -74,7 +74,7 @@ CREATE TABLE binaries ( file INT4 UNIQUE NOT NULL, -- REFERENCES files, type TEXT NOT NULL, -- joeyh@ doesn't want .udebs and .debs with the same name, which is why the unique () doesn't mention type - unique (package, version, source, architecture) + unique (package, version, architecture) ); CREATE TABLE suite ( diff --git a/katie b/katie index 7ed5dc00..574fe1f3 100755 --- a/katie +++ b/katie @@ -2,7 +2,7 @@ # Installs Debian packaes # Copyright (C) 2000 James Troup -# $Id: katie,v 1.4 2000-11-27 03:15:26 troup Exp $ +# $Id: katie,v 1.5 2000-11-30 04:19:30 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 @@ -375,6 +375,11 @@ def check_files(): else: reject_message = reject_message + "Rejected" reject_message = reject_message + ": %s Old version `%s' >= new version `%s'.\n" % (file, oldfile["version"], files[file]["version"]) + # Check for existing copies of the file + q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND a.arch_string = '%s' AND a.id = b.architecture" % (files[file]["package"], files[file]["version"], files[file]["architecture"])) + if q.getresult() != []: + reject_message = reject_message + "Rejected: can not overwrite existing copy of '%s' already in the archive.\n" % (file) + # Find any old .dsc files elif files[file]["type"] == "dsc": q = projectB.query("SELECT s.id, s.version, f.filename, l.path, c.name FROM source s, src_associations sa, suite su, location l, component c, files f WHERE s.source = '%s' AND su.suite_name = '%s' AND sa.source = s.id AND sa.suite = su.id AND f.location = l.id AND l.component = c.id AND f.id = s.file" @@ -438,6 +443,10 @@ def check_dsc (): if files.has_key(dsc_file): actual_md5 = files[dsc_file]["md5sum"] found = "%s in incoming" % (dsc_file) + # Check the file does not already exist in the archive + q = projectB.query("SELECT f.id FROM files f, location l WHERE f.filename ~ '/%s' AND l.id = f.location" % (dsc_file)); + if q.getresult() != []: + reject_message = reject_message + "Rejected: can not overwrite existing copy of '%s' already in the archive.\n" % (dsc_file) elif dsc_file[-12:] == ".orig.tar.gz": # Check in Incoming # See comment above process_it() for explanation... @@ -469,7 +478,7 @@ def check_dsc (): continue; if actual_md5 != dsc_files[dsc_file]["md5sum"]: reject_message = reject_message + "Rejected: md5sum for %s doesn't match %s.\n" % (found, file) - + if string.find(reject_message, "Rejected:") != -1: return 0 else: diff --git a/utils.py b/utils.py index 40e36cd9..ef86b5ad 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000 James Troup -# $Id: utils.py,v 1.4 2000-11-27 03:15:26 troup Exp $ +# $Id: utils.py,v 1.5 2000-11-30 04:19:30 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 @@ -206,6 +206,8 @@ def move (src, dest): os.umask(umask); #print "Moving %s to %s..." % (src, dest); shutil.copy2(src, dest); + if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]): + dest = dest + '/' + os.path.basename(src); os.chmod(dest, 0664); os.unlink(src); @@ -220,6 +222,8 @@ def copy (src, dest): os.umask(umask); #print "Copying %s to %s..." % (src, dest); shutil.copy2(src, dest); + if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]): + dest = dest + '/' + os.path.basename(src); os.chmod(dest, 0664); ###################################################################################### -- 2.39.5