3 # Installs Debian packages from queue/accepted into the pool
4 # Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup <james@nocrew.org>
5 # $Id: kelly,v 1.17 2005-11-25 06:59:45 ajt Exp $
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ###############################################################################
23 # Cartman: "I'm trying to make the best of a bad situation, I don't
24 # need to hear crap from a bunch of hippy freaks living in
25 # denial. Screw you guys, I'm going home."
27 # Kyle: "But Cartman, we're trying to..."
29 # Cartman: "uhh.. screw you guys... home."
31 ###############################################################################
33 import errno, fcntl, os, sys, time;
35 import db_access, katie, logging, utils;
37 ###############################################################################
40 kelly_version = "$Revision: 1.17 $";
45 Urgency_Logger = None;
60 installing_to_stable = 0;
62 ###############################################################################
64 # FIXME: this should go away to some Debian specific file
65 # FIXME: should die if file already exists
68 "Urgency Logger object"
69 def __init__ (self, Cnf):
70 "Initialize a new Urgency Logger object"
72 self.timestamp = time.strftime("%Y%m%d%H%M%S");
73 # Create the log directory if it doesn't exist
74 self.log_dir = Cnf["Dir::UrgencyLog"];
75 if not os.path.exists(self.log_dir):
76 umask = os.umask(00000);
77 os.makedirs(self.log_dir, 02775);
79 self.log_filename = "%s/.install-urgencies-%s.new" % (self.log_dir, self.timestamp);
80 self.log_file = utils.open_file(self.log_filename, 'w');
83 def log (self, source, version, urgency):
85 self.log_file.write(" ".join([source, version, urgency])+'\n');
86 self.log_file.flush();
90 "Close a Logger object"
91 self.log_file.flush();
92 self.log_file.close();
94 new_filename = "%s/install-urgencies-%s" % (self.log_dir, self.timestamp);
95 utils.move(self.log_filename, new_filename);
97 os.unlink(self.log_filename);
99 ###############################################################################
101 def reject (str, prefix="Rejected: "):
102 global reject_message;
104 reject_message += prefix + str + "\n";
106 # Recheck anything that relies on the database; since that's not
107 # frozen between accept and our run time.
112 for file in files.keys():
113 # The .orig.tar.gz can disappear out from under us is it's a
114 # duplicate of one in the archive.
115 if not files.has_key(file):
117 # Check that the source still exists
118 if files[file]["type"] == "deb":
119 source_version = files[file]["source version"];
120 source_package = files[file]["source package"];
121 if not changes["architecture"].has_key("source") \
122 and not Katie.source_exists(source_package, source_version, changes["distribution"].keys()):
123 reject("no source found for %s %s (%s)." % (source_package, source_version, file));
125 # Version and file overwrite checks
126 if not installing_to_stable:
127 if files[file]["type"] == "deb":
128 reject(Katie.check_binary_against_db(file), "");
129 elif files[file]["type"] == "dsc":
130 reject(Katie.check_source_against_db(file), "");
131 (reject_msg, is_in_incoming) = Katie.check_dsc_against_db(file);
132 reject(reject_msg, "");
134 # propogate in the case it is in the override tables:
135 if changes.has_key("propdistribution"):
136 for suite in changes["propdistribution"].keys():
137 if Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
140 nopropogate[suite] = 1
142 for suite in propogate.keys():
143 if suite in nopropogate:
145 changes["distribution"][suite] = 1
147 for file in files.keys():
148 # Check the package is still in the override tables
149 for suite in changes["distribution"].keys():
150 if not Katie.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
151 reject("%s is NEW for %s." % (file, suite));
153 ###############################################################################
156 global Cnf, Options, Katie, projectB, changes, dsc, dsc_files, files, pkg, Subst;
158 Cnf = utils.get_conf()
160 Arguments = [('a',"automatic","Dinstall::Options::Automatic"),
161 ('h',"help","Dinstall::Options::Help"),
162 ('n',"no-action","Dinstall::Options::No-Action"),
163 ('p',"no-lock", "Dinstall::Options::No-Lock"),
164 ('s',"no-mail", "Dinstall::Options::No-Mail"),
165 ('V',"version","Dinstall::Options::Version")];
167 for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version"]:
168 if not Cnf.has_key("Dinstall::Options::%s" % (i)):
169 Cnf["Dinstall::Options::%s" % (i)] = "";
171 changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
172 Options = Cnf.SubTree("Dinstall::Options")
177 if Options["Version"]:
178 print "kelly %s" % (kelly_version);
181 Katie = katie.Katie(Cnf);
182 projectB = Katie.projectB;
184 changes = Katie.pkg.changes;
186 dsc_files = Katie.pkg.dsc_files;
187 files = Katie.pkg.files;
191 return changes_files;
193 ###############################################################################
195 def usage (exit_code=0):
196 print """Usage: kelly [OPTION]... [CHANGES]...
197 -a, --automatic automatic run
198 -h, --help show this help and exit.
199 -n, --no-action don't do anything
200 -p, --no-lock don't check lockfile !! for cron.daily only !!
201 -s, --no-mail don't send any mail
202 -V, --version display the version number and exit"""
205 ###############################################################################
208 (summary, short_summary) = Katie.build_summaries();
210 (prompt, answer) = ("", "XXX")
211 if Options["No-Action"] or Options["Automatic"]:
214 if reject_message.find("Rejected") != -1:
215 print "REJECT\n" + reject_message,;
216 prompt = "[R]eject, Skip, Quit ?";
217 if Options["Automatic"]:
220 print "INSTALL\n" + reject_message + summary,;
221 prompt = "[I]nstall, Skip, Quit ?";
222 if Options["Automatic"]:
225 while prompt.find(answer) == -1:
226 answer = utils.our_raw_input(prompt);
227 m = katie.re_default_answer.match(prompt);
230 answer = answer[:1].upper();
235 if not installing_to_stable:
238 stable_install(summary, short_summary);
242 ###############################################################################
244 # Our reject is not really a reject, but an unaccept, but since a) the
245 # code for that is non-trivial (reopen bugs, unannounce etc.), b) this
246 # should be exteremly rare, for now we'll go with whining at our admin
250 Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"];
251 Subst["__REJECT_MESSAGE__"] = reject_message;
252 Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"];
253 reject_mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/kelly.unaccept");
255 # Write the rejection email out as the <foo>.reason file
256 reason_filename = os.path.basename(pkg.changes_file[:-8]) + ".reason";
257 reject_filename = Cnf["Dir::Queue::Reject"] + '/' + reason_filename;
258 # If we fail here someone is probably trying to exploit the race
259 # so let's just raise an exception ...
260 if os.path.exists(reject_filename):
261 os.unlink(reject_filename);
262 fd = os.open(reject_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644);
263 os.write(fd, reject_mail_message);
266 utils.send_mail(reject_mail_message);
267 Logger.log(["unaccepted", pkg.changes_file]);
269 ###############################################################################
272 global install_count, install_bytes;
276 Logger.log(["installing changes",pkg.changes_file]);
278 # Begin a transaction; if we bomb out anywhere between here and the COMMIT WORK below, the DB will not be changed.
279 projectB.query("BEGIN WORK");
281 # Add the .dsc file to the DB
282 for file in files.keys():
283 if files[file]["type"] == "dsc":
284 package = dsc["source"]
285 version = dsc["version"] # NB: not files[file]["version"], that has no epoch
286 maintainer = dsc["maintainer"]
287 maintainer = maintainer.replace("'", "\\'")
288 maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
289 fingerprint_id = db_access.get_or_set_fingerprint_id(dsc["fingerprint"]);
290 install_date = time.strftime("%Y-%m-%d");
291 filename = files[file]["pool name"] + file;
292 dsc_component = files[file]["component"];
293 dsc_location_id = files[file]["location id"];
294 if not files[file].has_key("files id") or not files[file]["files id"]:
295 files[file]["files id"] = db_access.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id)
296 projectB.query("INSERT INTO source (source, version, maintainer, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, '%s', %s)"
297 % (package, version, maintainer_id, files[file]["files id"], install_date, fingerprint_id));
299 for suite in changes["distribution"].keys():
300 suite_id = db_access.get_suite_id(suite);
301 projectB.query("INSERT INTO src_associations (suite, source) VALUES (%d, currval('source_id_seq'))" % (suite_id))
303 # Add the source files to the DB (files and dsc_files)
304 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files[file]["files id"]));
305 for dsc_file in dsc_files.keys():
306 filename = files[file]["pool name"] + dsc_file;
307 # If the .orig.tar.gz is already in the pool, it's
308 # files id is stored in dsc_files by check_dsc().
309 files_id = dsc_files[dsc_file].get("files id", None);
311 files_id = db_access.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id);
312 # FIXME: needs to check for -1/-2 and or handle exception
314 files_id = db_access.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id);
315 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files_id));
317 # Add the .deb files to the DB
318 for file in files.keys():
319 if files[file]["type"] == "deb":
320 package = files[file]["package"]
321 version = files[file]["version"]
322 maintainer = files[file]["maintainer"]
323 maintainer = maintainer.replace("'", "\\'")
324 maintainer_id = db_access.get_or_set_maintainer_id(maintainer);
325 fingerprint_id = db_access.get_or_set_fingerprint_id(changes["fingerprint"]);
326 architecture = files[file]["architecture"]
327 architecture_id = db_access.get_architecture_id (architecture);
328 type = files[file]["dbtype"];
329 source = files[file]["source package"]
330 source_version = files[file]["source version"];
331 filename = files[file]["pool name"] + file;
332 if not files[file].has_key("location id") or not files[file]["location id"]:
333 files[file]["location id"] = db_access.get_location_id(Cnf["Dir::Pool"],files[file]["component"],utils.where_am_i());
334 if not files[file].has_key("files id") or not files[file]["files id"]:
335 files[file]["files id"] = db_access.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
336 source_id = db_access.get_source_id (source, source_version);
338 projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d)"
339 % (package, version, maintainer_id, source_id, architecture_id, files[file]["files id"], type, fingerprint_id));
341 projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)"
342 % (package, version, maintainer_id, architecture_id, files[file]["files id"], type, fingerprint_id));
343 for suite in changes["distribution"].keys():
344 suite_id = db_access.get_suite_id(suite);
345 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id));
347 # If the .orig.tar.gz is in a legacy directory we need to poolify
348 # it, so that apt-get source (and anything else that goes by the
349 # "Directory:" field in the Sources.gz file) works.
350 orig_tar_id = Katie.pkg.orig_tar_id;
351 orig_tar_location = Katie.pkg.orig_tar_location;
352 legacy_source_untouchable = Katie.pkg.legacy_source_untouchable;
353 if orig_tar_id and orig_tar_location == "legacy":
354 q = projectB.query("SELECT DISTINCT ON (f.id) l.path, f.filename, f.id as files_id, df.source, df.id as dsc_files_id, f.size, f.md5sum FROM files f, dsc_files df, location l WHERE df.source IN (SELECT source FROM dsc_files WHERE file = %s) AND f.id = df.file AND l.id = f.location AND (l.type = 'legacy' OR l.type = 'legacy-mixed')" % (orig_tar_id));
357 # Is this an old upload superseded by a newer -sa upload? (See check_dsc() for details)
358 if legacy_source_untouchable.has_key(qid["files_id"]):
360 # First move the files to the new location
361 legacy_filename = qid["path"] + qid["filename"];
362 pool_location = utils.poolify (changes["source"], files[file]["component"]);
363 pool_filename = pool_location + os.path.basename(qid["filename"]);
364 destination = Cnf["Dir::Pool"] + pool_location
365 utils.move(legacy_filename, destination);
366 # Then Update the DB's files table
367 q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, dsc_location_id, qid["files_id"]));
369 # If this is a sourceful diff only upload that is moving non-legacy
370 # cross-component we need to copy the .orig.tar.gz into the new
371 # component too for the same reasons as above.
373 if changes["architecture"].has_key("source") and orig_tar_id and \
374 orig_tar_location != "legacy" and orig_tar_location != dsc_location_id:
375 q = projectB.query("SELECT l.path, f.filename, f.size, f.md5sum FROM files f, location l WHERE f.id = %s AND f.location = l.id" % (orig_tar_id));
376 ql = q.getresult()[0];
377 old_filename = ql[0] + ql[1];
380 new_filename = utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename);
381 new_files_id = db_access.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id);
382 if new_files_id == None:
383 utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename);
384 new_files_id = db_access.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id);
385 projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, source_id, orig_tar_id));
387 # Install the files into the pool
388 for file in files.keys():
389 destination = Cnf["Dir::Pool"] + files[file]["pool name"] + file;
390 utils.move(file, destination);
391 Logger.log(["installed", file, files[file]["type"], files[file]["size"], files[file]["architecture"]]);
392 install_bytes += float(files[file]["size"]);
394 # Copy the .changes file across for suite which need it.
397 for suite in changes["distribution"].keys():
398 if Cnf.has_key("Suite::%s::CopyChanges" % (suite)):
399 copy_changes[Cnf["Suite::%s::CopyChanges" % (suite)]] = "";
400 # and the .katie file...
401 if Cnf.has_key("Suite::%s::CopyKatie" % (suite)):
402 copy_katie[Cnf["Suite::%s::CopyKatie" % (suite)]] = "";
403 for dest in copy_changes.keys():
404 utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest);
405 for dest in copy_katie.keys():
406 utils.copy(Katie.pkg.changes_file[:-8]+".katie", dest);
408 projectB.query("COMMIT WORK");
410 # Move the .changes into the 'done' directory
411 utils.move (pkg.changes_file,
412 os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file)));
414 # Remove the .katie file
415 os.unlink(Katie.pkg.changes_file[:-8]+".katie");
417 if changes["architecture"].has_key("source") and Urgency_Logger:
418 Urgency_Logger.log(dsc["source"], dsc["version"], changes["urgency"]);
420 # Undo the work done in katie.py(accept) to help auto-building
422 projectB.query("BEGIN WORK");
423 for suite in changes["distribution"].keys():
424 if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"):
426 now_date = time.strftime("%Y-%m-%d %H:%M");
427 suite_id = db_access.get_suite_id(suite);
428 dest_dir = Cnf["Dir::QueueBuild"];
429 if Cnf.FindB("Dinstall::SecurityQueueBuild"):
430 dest_dir = os.path.join(dest_dir, suite);
431 for file in files.keys():
432 dest = os.path.join(dest_dir, file);
433 # Remove it from the list of packages for later processing by apt-ftparchive
434 projectB.query("UPDATE queue_build SET in_queue = 'f', last_used = '%s' WHERE filename = '%s' AND suite = %s" % (now_date, dest, suite_id));
435 if not Cnf.FindB("Dinstall::SecurityQueueBuild"):
436 # Update the symlink to point to the new location in the pool
437 pool_location = utils.poolify (changes["source"], files[file]["component"]);
438 src = os.path.join(Cnf["Dir::Pool"], pool_location, os.path.basename(file));
439 if os.path.islink(dest):
441 os.symlink(src, dest);
442 # Update last_used on any non-upload .orig.tar.gz symlink
444 # Determine the .orig.tar.gz file name
445 for dsc_file in dsc_files.keys():
446 if dsc_file.endswith(".orig.tar.gz"):
447 orig_tar_gz = os.path.join(dest_dir, dsc_file);
448 # Remove it from the list of packages for later processing by apt-ftparchive
449 projectB.query("UPDATE queue_build SET in_queue = 'f', last_used = '%s' WHERE filename = '%s' AND suite = %s" % (now_date, orig_tar_gz, suite_id));
450 projectB.query("COMMIT WORK");
455 ################################################################################
457 def stable_install (summary, short_summary):
458 global install_count;
460 print "Installing to stable.";
462 # Begin a transaction; if we bomb out anywhere between here and
463 # the COMMIT WORK below, the DB won't be changed.
464 projectB.query("BEGIN WORK");
466 # Add the source to stable (and remove it from proposed-updates)
467 for file in files.keys():
468 if files[file]["type"] == "dsc":
469 package = dsc["source"];
470 version = dsc["version"]; # NB: not files[file]["version"], that has no epoch
471 q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
474 utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version));
475 source_id = ql[0][0];
476 suite_id = db_access.get_suite_id('proposed-updates');
477 projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id));
478 suite_id = db_access.get_suite_id('stable');
479 projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id));
481 # Add the binaries to stable (and remove it/them from proposed-updates)
482 for file in files.keys():
483 if files[file]["type"] == "deb":
484 package = files[file]["package"];
485 version = files[file]["version"];
486 architecture = files[file]["architecture"];
487 q = projectB.query("SELECT b.id FROM binaries b, architecture a WHERE b.package = '%s' AND b.version = '%s' AND (a.arch_string = '%s' OR a.arch_string = 'all') AND b.architecture = a.id" % (package, version, architecture));
490 utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture));
491 binary_id = ql[0][0];
492 suite_id = db_access.get_suite_id('proposed-updates');
493 projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id));
494 suite_id = db_access.get_suite_id('stable');
495 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id));
497 projectB.query("COMMIT WORK");
499 utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/katie/' + os.path.basename(pkg.changes_file));
501 ## Update the Stable ChangeLog file
502 new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog";
503 changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + "ChangeLog";
504 if os.path.exists(new_changelog_filename):
505 os.unlink (new_changelog_filename);
507 new_changelog = utils.open_file(new_changelog_filename, 'w');
508 for file in files.keys():
509 if files[file]["type"] == "deb":
510 new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file));
511 elif utils.re_issource.match(file):
512 new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file));
514 new_changelog.write("%s\n" % (file));
515 chop_changes = katie.re_fdnic.sub("\n", changes["changes"]);
516 new_changelog.write(chop_changes + '\n\n');
517 if os.access(changelog_filename, os.R_OK) != 0:
518 changelog = utils.open_file(changelog_filename);
519 new_changelog.write(changelog.read());
520 new_changelog.close();
521 if os.access(changelog_filename, os.R_OK) != 0:
522 os.unlink(changelog_filename);
523 utils.move(new_changelog_filename, changelog_filename);
527 if not Options["No-Mail"] and changes["architecture"].has_key("source"):
528 Subst["__SUITE__"] = " into stable";
529 Subst["__SUMMARY__"] = summary;
530 mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/kelly.installed");
531 utils.send_mail(mail_message);
532 Katie.announce(short_summary, 1)
534 # Finally remove the .katie file
535 katie_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyKatie"], os.path.basename(Katie.pkg.changes_file[:-8]+".katie"));
536 os.unlink(katie_file);
538 ################################################################################
540 def process_it (changes_file):
541 global reject_message;
545 # Absolutize the filename to avoid the requirement of being in the
546 # same directory as the .changes file.
547 pkg.changes_file = os.path.abspath(changes_file);
549 # And since handling of installs to stable munges with the CWD;
550 # save and restore it.
551 pkg.directory = os.getcwd();
553 if installing_to_stable:
554 old = Katie.pkg.changes_file;
555 Katie.pkg.changes_file = os.path.basename(old);
556 os.chdir(Cnf["Suite::Proposed-Updates::CopyKatie"]);
560 Katie.update_subst();
562 if installing_to_stable:
563 Katie.pkg.changes_file = old;
569 os.chdir(pkg.directory);
571 ###############################################################################
574 global projectB, Logger, Urgency_Logger, installing_to_stable;
576 changes_files = init();
578 # -n/--dry-run invalidates some other options which would involve things happening
579 if Options["No-Action"]:
580 Options["Automatic"] = "";
582 # Check that we aren't going to clash with the daily cron job
584 if not Options["No-Action"] and os.path.exists("%s/Archive_Maintenance_In_Progress" % (Cnf["Dir::Root"])) and not Options["No-Lock"]:
585 utils.fubar("Archive maintenance in progress. Try again later.");
587 # If running from within proposed-updates; assume an install to stable
588 if os.getcwd().find('proposed-updates') != -1:
589 installing_to_stable = 1;
591 # Obtain lock if not in no-action mode and initialize the log
592 if not Options["No-Action"]:
593 lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT);
595 fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB);
597 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
598 utils.fubar("Couldn't obtain lock; assuming another kelly is already running.");
601 Logger = Katie.Logger = logging.Logger(Cnf, "kelly");
602 if not installing_to_stable and Cnf.get("Dir::UrgencyLog"):
603 Urgency_Logger = Urgency_Log(Cnf);
605 # Initialize the substitution template mapping global
606 bcc = "X-Katie: %s" % (kelly_version);
607 if Cnf.has_key("Dinstall::Bcc"):
608 Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]);
610 Subst["__BCC__"] = bcc;
612 # Sort the .changes files so that we process sourceful ones first
613 changes_files.sort(utils.changes_compare);
615 # Process the changes files
616 for changes_file in changes_files:
617 print "\n" + changes_file;
618 process_it (changes_file);
622 if install_count > 1:
624 sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, utils.size_type(int(install_bytes))));
625 Logger.log(["total",install_count,install_bytes]);
627 if not Options["No-Action"]:
630 Urgency_Logger.close();
632 ###############################################################################
634 if __name__ == '__main__':