#!/usr/bin/env python
# Manually reject packages for proprosed-updates
-# Copyright (C) 2001, 2002, 2003 James Troup <james@nocrew.org>
-# $Id: lauren,v 1.3 2003-11-20 02:37:25 troup Exp $
+# Copyright (C) 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
+# $Id: lauren,v 1.4 2004-04-01 17:13:11 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
################################################################################
-import os, pg, sys, tempfile;
+import os, pg, sys;
import db_access, katie, logging, utils;
import apt_pkg;
################################################################################
# Globals
-lauren_version = "$Revision: 1.3 $";
+lauren_version = "$Revision: 1.4 $";
Cnf = None;
Options = None;
# If we weren't given a manual rejection message, spawn an editor
# so the user can add one in...
if not reject_message:
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
editor = os.environ.get("EDITOR","vi")
answer = 'E';
while answer == 'E':
# Handles NEW and BYHAND packages
# Copyright (C) 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
-# $Id: lisa,v 1.29 2004-03-11 00:14:32 troup Exp $
+# $Id: lisa,v 1.30 2004-04-01 17:13:11 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
################################################################################
-import copy, errno, os, readline, stat, sys, tempfile;
+import copy, errno, os, readline, stat, sys;
import apt_pkg, apt_inst;
import db_access, fernanda, katie, logging, utils;
# Globals
-lisa_version = "$Revision: 1.29 $";
+lisa_version = "$Revision: 1.30 $";
Cnf = None;
Options = None;
def edit_new (new):
# Write the current data to a temporary file
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
temp_file = utils.open_file(temp_filename, 'w');
print_new (new, 0, temp_file);
temp_file.close();
def edit_note(note):
# Write the current data to a temporary file
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
temp_file = utils.open_file(temp_filename, 'w');
temp_file.write(note);
temp_file.close();
def prod_maintainer ():
# Here we prepare an editor and get them ready to prod...
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
editor = os.environ.get("EDITOR","vi")
answer = 'E';
while answer == 'E':
answer = answer[:1].upper();
os.unlink(temp_filename);
if answer == 'A':
- return 1;
+ return;
elif answer == 'Q':
sys.exit(0);
# Otherwise, do the proding...
Cnf["Dinstall::MyAdminAddress"]);
Subst = Katie.Subst;
-
+
Subst["__FROM_ADDRESS__"] = user_email_address;
Subst["__PROD_MESSAGE__"] = prod_message;
Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"];
#!/usr/bin/env python
# General purpose package removal tool for ftpmaster
-# Copyright (C) 2000, 2001, 2002, 2003 James Troup <james@nocrew.org>
-# $Id: melanie,v 1.39 2003-05-02 13:53:57 troup Exp $
+# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
+# $Id: melanie,v 1.40 2004-04-01 17:13:11 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
################################################################################
-import commands, os, pg, re, sys, tempfile
-import utils, db_access
+import commands, os, pg, re, sys;
+import utils, db_access;
import apt_pkg, apt_inst;
################################################################################
# If we don't have a reason; spawn an editor so the user can add one
# Write the rejection email out as the <foo>.reason file
if not Options["Reason"] and not Options["No-Action"]:
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
editor = os.environ.get("EDITOR","vi")
result = os.system("%s %s" % (editor, temp_filename))
if result != 0:
Subst["__BCC__"] = "Bcc: " + ", ".join(bcc);
else:
Subst["__BCC__"] = "X-Filler: 42";
- Subst["__CC__"] = "X-Katie: melanie $Revision: 1.39 $";
+ Subst["__CC__"] = "X-Katie: melanie $Revision: 1.40 $";
if carbon_copy:
Subst["__CC__"] += "\nCc: " + ", ".join(carbon_copy);
Subst["__SUITE_LIST__"] = suites_list;
#!/usr/bin/env python
# Populate the DB
-# Copyright (C) 2000, 2001, 2002, 2003 James Troup <james@nocrew.org>
-# $Id: neve,v 1.18 2003-02-07 14:53:42 troup Exp $
+# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
+# $Id: neve,v 1.19 2004-04-01 17:13:11 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
###############################################################################
-import commands, os, pg, re, sys, tempfile, time;
+import commands, os, pg, re, sys, time;
import apt_pkg;
import db_access, utils;
###############################################################################
def do_sources(sources, suite, component, server):
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
(result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename));
if (result != 0):
utils.fubar("Gunzip invocation failed!\n%s" % (output), result);
#!/usr/bin/env python
# Various different sanity checks
-# Copyright (C) 2000, 2001, 2002, 2003 James Troup <james@nocrew.org>
-# $Id: tea,v 1.26 2003-10-17 11:20:47 troup Exp $
+# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
+# $Id: tea,v 1.27 2004-04-01 17:13:11 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
################################################################################
-import commands, os, pg, stat, string, sys, tempfile, time;
+import commands, os, pg, stat, string, sys, time;
import db_access, utils;
import apt_pkg, apt_inst;
filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component);
print "Processing %s..." % (filename);
# apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance...
- temp_filename = tempfile.mktemp();
- fd = os.open(temp_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700);
- os.close(fd);
+ temp_filename = utils.temp_filename();
(result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename));
if (result != 0):
sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output));
directory = Sources.Section.Find('Directory');
files = Sources.Section.Find('Files');
for i in files.split('\n'):
- s = i.split();
- (md5, size, name) = s;
+ (md5, size, name) = i.split();
filename = "%s/%s/%s" % (Cnf["Dir::Root"], directory, name);
if not os.path.exists(filename):
if directory.find("potato") == -1:
# q = projectB.query("BEGIN WORK");
for i in q_files:
filename = os.path.normpath(i[0] + i[1]);
- file_id = i[2];
+# file_id = i[2];
if os.access(filename, os.R_OK) == 0:
utils.warn("%s: doesn't exist." % (filename));
else:
# Utility functions
# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
-# $Id: utils.py,v 1.64 2004-03-11 00:20:51 troup Exp $
+# $Id: utils.py,v 1.65 2004-04-01 17:13:10 troup Exp $
################################################################################
################################################################################
+def temp_filename(directory=None, dotprefix=None, perms=0700):
+ """Return a secure and unique filename by pre-creating it.
+If 'directory' is non-null, it will be the directory the file is pre-created in.
+If 'dotprefix' is non-null, the filename will be prefixed with a '.'."""
+
+ if directory:
+ old_tempdir = tempfile.tempdir;
+ tempfile.tempdir = directory;
+
+ filename = tempfile.mktemp();
+
+ if dotprefix:
+ filename = "%s/.%s" % (os.path.dirname(filename), os.path.basename(filename));
+ fd = os.open(filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, perms);
+ os.close(fd);
+
+ if directory:
+ tempfile.tempdir = old_tempdir;
+
+ return filename;
+
+################################################################################
+
apt_pkg.init();
Cnf = apt_pkg.newConfiguration();