3 # Installs Debian packages from queue/accepted into the pool
4 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 James Troup <james@nocrew.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ###############################################################################
22 # Cartman: "I'm trying to make the best of a bad situation, I don't
23 # need to hear crap from a bunch of hippy freaks living in
24 # denial. Screw you guys, I'm going home."
26 # Kyle: "But Cartman, we're trying to..."
28 # Cartman: "uhh.. screw you guys... home."
30 ###############################################################################
32 import errno, fcntl, os, sys, time, re
34 import daklib.database
39 ###############################################################################
59 installing_to_stable = 0
61 ###############################################################################
63 # FIXME: this should go away to some Debian specific file
64 # FIXME: should die if file already exists
67 "Urgency Logger object"
68 def __init__ (self, Cnf):
69 "Initialize a new Urgency Logger object"
71 self.timestamp = time.strftime("%Y%m%d%H%M%S")
72 # Create the log directory if it doesn't exist
73 self.log_dir = Cnf["Dir::UrgencyLog"]
74 if not os.path.exists(self.log_dir):
75 umask = os.umask(00000)
76 os.makedirs(self.log_dir, 02775)
78 self.log_filename = "%s/.install-urgencies-%s.new" % (self.log_dir, self.timestamp)
79 self.log_file = daklib.utils.open_file(self.log_filename, 'w')
82 def log (self, source, version, urgency):
84 self.log_file.write(" ".join([source, version, urgency])+'\n')
89 "Close a Logger object"
93 new_filename = "%s/install-urgencies-%s" % (self.log_dir, self.timestamp)
94 daklib.utils.move(self.log_filename, new_filename)
96 os.unlink(self.log_filename)
98 ###############################################################################
100 def reject (str, prefix="Rejected: "):
101 global reject_message
103 reject_message += prefix + str + "\n"
105 # Recheck anything that relies on the database; since that's not
106 # frozen between accept and our run time.
111 for file in files.keys():
112 # The .orig.tar.gz can disappear out from under us is it's a
113 # duplicate of one in the archive.
114 if not files.has_key(file):
116 # Check that the source still exists
117 if files[file]["type"] == "deb":
118 source_version = files[file]["source version"]
119 source_package = files[file]["source package"]
120 if not changes["architecture"].has_key("source") \
121 and not Upload.source_exists(source_package, source_version, changes["distribution"].keys()):
122 reject("no source found for %s %s (%s)." % (source_package, source_version, file))
124 # Version and file overwrite checks
125 if not installing_to_stable:
126 if files[file]["type"] == "deb":
127 reject(Upload.check_binary_against_db(file), "")
128 elif files[file]["type"] == "dsc":
129 reject(Upload.check_source_against_db(file), "")
130 (reject_msg, is_in_incoming) = Upload.check_dsc_against_db(file)
131 reject(reject_msg, "")
133 # propogate in the case it is in the override tables:
134 if changes.has_key("propdistribution"):
135 for suite in changes["propdistribution"].keys():
136 if Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
139 nopropogate[suite] = 1
141 for suite in propogate.keys():
142 if suite in nopropogate:
144 changes["distribution"][suite] = 1
146 for file in files.keys():
147 # Check the package is still in the override tables
148 for suite in changes["distribution"].keys():
149 if not Upload.in_override_p(files[file]["package"], files[file]["component"], suite, files[file].get("dbtype",""), file):
150 reject("%s is NEW for %s." % (file, suite))
152 ###############################################################################
155 global Cnf, Options, Upload, projectB, changes, dsc, dsc_files, files, pkg, Subst
157 Cnf = daklib.utils.get_conf()
159 Arguments = [('a',"automatic","Dinstall::Options::Automatic"),
160 ('h',"help","Dinstall::Options::Help"),
161 ('n',"no-action","Dinstall::Options::No-Action"),
162 ('p',"no-lock", "Dinstall::Options::No-Lock"),
163 ('s',"no-mail", "Dinstall::Options::No-Mail")]
165 for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version"]:
166 if not Cnf.has_key("Dinstall::Options::%s" % (i)):
167 Cnf["Dinstall::Options::%s" % (i)] = ""
169 changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
170 Options = Cnf.SubTree("Dinstall::Options")
175 Upload = daklib.queue.Upload(Cnf)
176 projectB = Upload.projectB
178 changes = Upload.pkg.changes
180 dsc_files = Upload.pkg.dsc_files
181 files = Upload.pkg.files
187 ###############################################################################
189 def usage (exit_code=0):
190 print """Usage: dak process-accepted [OPTION]... [CHANGES]...
191 -a, --automatic automatic run
192 -h, --help show this help and exit.
193 -n, --no-action don't do anything
194 -p, --no-lock don't check lockfile !! for cron.daily only !!
195 -s, --no-mail don't send any mail
196 -V, --version display the version number and exit"""
199 ###############################################################################
202 (summary, short_summary) = Upload.build_summaries()
204 (prompt, answer) = ("", "XXX")
205 if Options["No-Action"] or Options["Automatic"]:
208 if reject_message.find("Rejected") != -1:
209 print "REJECT\n" + reject_message,
210 prompt = "[R]eject, Skip, Quit ?"
211 if Options["Automatic"]:
214 print "INSTALL to " + ", ".join(changes["distribution"].keys())
215 print reject_message + summary,
216 prompt = "[I]nstall, Skip, Quit ?"
217 if Options["Automatic"]:
220 while prompt.find(answer) == -1:
221 answer = daklib.utils.our_raw_input(prompt)
222 m = daklib.queue.re_default_answer.match(prompt)
225 answer = answer[:1].upper()
230 if not installing_to_stable:
233 stable_install(summary, short_summary)
237 ###############################################################################
239 # Our reject is not really a reject, but an unaccept, but since a) the
240 # code for that is non-trivial (reopen bugs, unannounce etc.), b) this
241 # should be exteremly rare, for now we'll go with whining at our admin
245 Subst["__REJECTOR_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"]
246 Subst["__REJECT_MESSAGE__"] = reject_message
247 Subst["__CC__"] = "Cc: " + Cnf["Dinstall::MyEmailAddress"]
248 reject_mail_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.unaccept")
250 # Write the rejection email out as the <foo>.reason file
251 reason_filename = os.path.basename(pkg.changes_file[:-8]) + ".reason"
252 reject_filename = Cnf["Dir::Queue::Reject"] + '/' + reason_filename
253 # If we fail here someone is probably trying to exploit the race
254 # so let's just raise an exception ...
255 if os.path.exists(reject_filename):
256 os.unlink(reject_filename)
257 fd = os.open(reject_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644)
258 os.write(fd, reject_mail_message)
261 daklib.utils.send_mail(reject_mail_message)
262 Logger.log(["unaccepted", pkg.changes_file])
264 ###############################################################################
267 global install_count, install_bytes
271 Logger.log(["installing changes",pkg.changes_file])
273 # Begin a transaction; if we bomb out anywhere between here and the COMMIT WORK below, the DB will not be changed.
274 projectB.query("BEGIN WORK")
276 # Add the .dsc file to the DB
277 for file in files.keys():
278 if files[file]["type"] == "dsc":
279 package = dsc["source"]
280 version = dsc["version"] # NB: not files[file]["version"], that has no epoch
281 maintainer = dsc["maintainer"]
282 maintainer = maintainer.replace("'", "\\'")
283 maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
284 changedby = changes["changed-by"]
285 changedby = changedby.replace("'", "\\'")
286 changedby_id = daklib.database.get_or_set_maintainer_id(changedby)
287 fingerprint_id = daklib.database.get_or_set_fingerprint_id(dsc["fingerprint"])
288 install_date = time.strftime("%Y-%m-%d")
289 filename = files[file]["pool name"] + file
290 dsc_component = files[file]["component"]
291 dsc_location_id = files[file]["location id"]
292 if not files[file].has_key("files id") or not files[file]["files id"]:
293 files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id)
294 projectB.query("INSERT INTO source (source, version, maintainer, changedby, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %s)"
295 % (package, version, maintainer_id, changedby_id, files[file]["files id"], install_date, fingerprint_id))
297 for suite in changes["distribution"].keys():
298 suite_id = daklib.database.get_suite_id(suite)
299 projectB.query("INSERT INTO src_associations (suite, source) VALUES (%d, currval('source_id_seq'))" % (suite_id))
301 # Add the source files to the DB (files and dsc_files)
302 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files[file]["files id"]))
303 for dsc_file in dsc_files.keys():
304 filename = files[file]["pool name"] + dsc_file
305 # If the .orig.tar.gz is already in the pool, it's
306 # files id is stored in dsc_files by check_dsc().
307 files_id = dsc_files[dsc_file].get("files id", None)
309 files_id = daklib.database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
310 # FIXME: needs to check for -1/-2 and or handle exception
312 files_id = daklib.database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
313 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files_id))
315 # Add the src_uploaders to the DB
316 if dsc.get("dm-upload-allowed", "no") == "yes":
317 uploader_ids = [maintainer_id]
318 if dsc.has_key("uploaders"):
319 for u in dsc["uploaders"].split(","):
320 u = u.replace("'", "\\'")
323 daklib.database.get_or_set_maintainer_id(u))
325 for u in uploader_ids:
326 if added_ids.has_key(u):
327 daklib.utils.warn("Already saw uploader %s for source %s" % (u, package))
330 projectB.query("INSERT INTO src_uploaders (source, maintainer) VALUES (currval('source_id_seq'), %d)" % (u))
333 # Add the .deb files to the DB
334 for file in files.keys():
335 if files[file]["type"] == "deb":
336 package = files[file]["package"]
337 version = files[file]["version"]
338 maintainer = files[file]["maintainer"]
339 maintainer = maintainer.replace("'", "\\'")
340 maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
341 fingerprint_id = daklib.database.get_or_set_fingerprint_id(changes["fingerprint"])
342 architecture = files[file]["architecture"]
343 architecture_id = daklib.database.get_architecture_id (architecture)
344 type = files[file]["dbtype"]
345 source = files[file]["source package"]
346 source_version = files[file]["source version"]
347 filename = files[file]["pool name"] + file
348 if not files[file].has_key("location id") or not files[file]["location id"]:
349 files[file]["location id"] = daklib.database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],daklib.utils.where_am_i())
350 if not files[file].has_key("files id") or not files[file]["files id"]:
351 files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
352 source_id = daklib.database.get_source_id (source, source_version)
354 projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d)"
355 % (package, version, maintainer_id, source_id, architecture_id, files[file]["files id"], type, fingerprint_id))
357 projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)"
358 % (package, version, maintainer_id, architecture_id, files[file]["files id"], type, fingerprint_id))
359 for suite in changes["distribution"].keys():
360 suite_id = daklib.database.get_suite_id(suite)
361 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
363 # If the .orig.tar.gz is in a legacy directory we need to poolify
364 # it, so that apt-get source (and anything else that goes by the
365 # "Directory:" field in the Sources.gz file) works.
366 orig_tar_id = Upload.pkg.orig_tar_id
367 orig_tar_location = Upload.pkg.orig_tar_location
368 legacy_source_untouchable = Upload.pkg.legacy_source_untouchable
369 if orig_tar_id and orig_tar_location == "legacy":
370 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))
373 # Is this an old upload superseded by a newer -sa upload? (See check_dsc() for details)
374 if legacy_source_untouchable.has_key(qid["files_id"]):
376 # First move the files to the new location
377 legacy_filename = qid["path"] + qid["filename"]
378 pool_location = daklib.utils.poolify (changes["source"], files[file]["component"])
379 pool_filename = pool_location + os.path.basename(qid["filename"])
380 destination = Cnf["Dir::Pool"] + pool_location
381 daklib.utils.move(legacy_filename, destination)
382 # Then Update the DB's files table
383 q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, dsc_location_id, qid["files_id"]))
385 # If this is a sourceful diff only upload that is moving non-legacy
386 # cross-component we need to copy the .orig.tar.gz into the new
387 # component too for the same reasons as above.
389 if changes["architecture"].has_key("source") and orig_tar_id and \
390 orig_tar_location != "legacy" and orig_tar_location != dsc_location_id:
391 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))
392 ql = q.getresult()[0]
393 old_filename = ql[0] + ql[1]
396 new_filename = daklib.utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename)
397 new_files_id = daklib.database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
398 if new_files_id == None:
399 daklib.utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename)
400 new_files_id = daklib.database.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
401 projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, source_id, orig_tar_id))
403 # Install the files into the pool
404 for file in files.keys():
405 destination = Cnf["Dir::Pool"] + files[file]["pool name"] + file
406 daklib.utils.move(file, destination)
407 Logger.log(["installed", file, files[file]["type"], files[file]["size"], files[file]["architecture"]])
408 install_bytes += float(files[file]["size"])
410 # Copy the .changes file across for suite which need it.
413 for suite in changes["distribution"].keys():
414 if Cnf.has_key("Suite::%s::CopyChanges" % (suite)):
415 copy_changes[Cnf["Suite::%s::CopyChanges" % (suite)]] = ""
416 # and the .dak file...
417 if Cnf.has_key("Suite::%s::CopyDotDak" % (suite)):
418 copy_dot_dak[Cnf["Suite::%s::CopyDotDak" % (suite)]] = ""
419 for dest in copy_changes.keys():
420 daklib.utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest)
421 for dest in copy_dot_dak.keys():
422 daklib.utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest)
424 projectB.query("COMMIT WORK")
426 # Move the .changes into the 'done' directory
427 daklib.utils.move (pkg.changes_file,
428 os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file)))
430 # Remove the .dak file
431 os.unlink(Upload.pkg.changes_file[:-8]+".dak")
433 if changes["architecture"].has_key("source") and Urgency_Logger:
434 Urgency_Logger.log(dsc["source"], dsc["version"], changes["urgency"])
436 # Undo the work done in queue.py(accept) to help auto-building
438 projectB.query("BEGIN WORK")
439 for suite in changes["distribution"].keys():
440 if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"):
442 now_date = time.strftime("%Y-%m-%d %H:%M")
443 suite_id = daklib.database.get_suite_id(suite)
444 dest_dir = Cnf["Dir::QueueBuild"]
445 if Cnf.FindB("Dinstall::SecurityQueueBuild"):
446 dest_dir = os.path.join(dest_dir, suite)
447 for file in files.keys():
448 dest = os.path.join(dest_dir, file)
449 # Remove it from the list of packages for later processing by apt-ftparchive
450 projectB.query("UPDATE queue_build SET in_queue = 'f', last_used = '%s' WHERE filename = '%s' AND suite = %s" % (now_date, dest, suite_id))
451 if not Cnf.FindB("Dinstall::SecurityQueueBuild"):
452 # Update the symlink to point to the new location in the pool
453 pool_location = daklib.utils.poolify (changes["source"], files[file]["component"])
454 src = os.path.join(Cnf["Dir::Pool"], pool_location, os.path.basename(file))
455 if os.path.islink(dest):
457 os.symlink(src, dest)
458 # Update last_used on any non-upload .orig.tar.gz symlink
460 # Determine the .orig.tar.gz file name
461 for dsc_file in dsc_files.keys():
462 if dsc_file.endswith(".orig.tar.gz"):
463 orig_tar_gz = os.path.join(dest_dir, dsc_file)
464 # Remove it from the list of packages for later processing by apt-ftparchive
465 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))
466 projectB.query("COMMIT WORK")
471 ################################################################################
473 def stable_install (summary, short_summary):
476 print "Installing to stable."
478 # Begin a transaction; if we bomb out anywhere between here and
479 # the COMMIT WORK below, the DB won't be changed.
480 projectB.query("BEGIN WORK")
482 # Add the source to stable (and remove it from proposed-updates)
483 for file in files.keys():
484 if files[file]["type"] == "dsc":
485 package = dsc["source"]
486 version = dsc["version"]; # NB: not files[file]["version"], that has no epoch
487 q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
490 daklib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version))
492 suite_id = daklib.database.get_suite_id('proposed-updates')
493 projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id))
494 suite_id = daklib.database.get_suite_id('stable')
495 projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id))
497 # Add the binaries to stable (and remove it/them from proposed-updates)
498 for file in files.keys():
499 if files[file]["type"] == "deb":
500 package = files[file]["package"]
501 version = files[file]["version"]
502 architecture = files[file]["architecture"]
503 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))
506 daklib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture))
509 suite_id = daklib.database.get_suite_id('proposed-updates')
510 projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id))
511 suite_id = daklib.database.get_suite_id('stable')
512 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id))
514 projectB.query("COMMIT WORK")
516 daklib.utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file))
518 ## Update the Stable ChangeLog file
519 new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog"
520 changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + "ChangeLog"
521 if os.path.exists(new_changelog_filename):
522 os.unlink (new_changelog_filename)
524 new_changelog = daklib.utils.open_file(new_changelog_filename, 'w')
525 for file in files.keys():
526 if files[file]["type"] == "deb":
527 new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file))
528 elif daklib.utils.re_issource.match(file):
529 new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file))
531 new_changelog.write("%s\n" % (file))
532 chop_changes = daklib.queue.re_fdnic.sub("\n", changes["changes"])
533 new_changelog.write(chop_changes + '\n\n')
534 if os.access(changelog_filename, os.R_OK) != 0:
535 changelog = daklib.utils.open_file(changelog_filename)
536 new_changelog.write(changelog.read())
537 new_changelog.close()
538 if os.access(changelog_filename, os.R_OK) != 0:
539 os.unlink(changelog_filename)
540 daklib.utils.move(new_changelog_filename, changelog_filename)
544 if not Options["No-Mail"] and changes["architecture"].has_key("source"):
545 Subst["__SUITE__"] = " into stable"
546 Subst["__SUMMARY__"] = summary
547 mail_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.install")
548 daklib.utils.send_mail(mail_message)
549 Upload.announce(short_summary, 1)
551 # Finally remove the .dak file
552 dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(Upload.pkg.changes_file[:-8]+".dak"))
553 os.unlink(dot_dak_file)
555 ################################################################################
557 def process_it (changes_file):
558 global reject_message
562 # Absolutize the filename to avoid the requirement of being in the
563 # same directory as the .changes file.
564 pkg.changes_file = os.path.abspath(changes_file)
566 # And since handling of installs to stable munges with the CWD
567 # save and restore it.
568 pkg.directory = os.getcwd()
570 if installing_to_stable:
571 old = Upload.pkg.changes_file
572 Upload.pkg.changes_file = os.path.basename(old)
573 os.chdir(Cnf["Suite::Proposed-Updates::CopyDotDak"])
577 Upload.update_subst()
579 if installing_to_stable:
580 Upload.pkg.changes_file = old
586 os.chdir(pkg.directory)
588 ###############################################################################
591 global projectB, Logger, Urgency_Logger, installing_to_stable
593 changes_files = init()
595 # -n/--dry-run invalidates some other options which would involve things happening
596 if Options["No-Action"]:
597 Options["Automatic"] = ""
599 # Check that we aren't going to clash with the daily cron job
601 if not Options["No-Action"] and os.path.exists("%s/Archive_Maintenance_In_Progress" % (Cnf["Dir::Root"])) and not Options["No-Lock"]:
602 daklib.utils.fubar("Archive maintenance in progress. Try again later.")
604 # If running from within proposed-updates; assume an install to stable
605 if os.getcwd().find('proposed-updates') != -1:
606 installing_to_stable = 1
608 # Obtain lock if not in no-action mode and initialize the log
609 if not Options["No-Action"]:
610 lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT)
612 fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
614 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
615 daklib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.")
618 Logger = Upload.Logger = daklib.logging.Logger(Cnf, "process-accepted")
619 if not installing_to_stable and Cnf.get("Dir::UrgencyLog"):
620 Urgency_Logger = Urgency_Log(Cnf)
622 # Initialize the substitution template mapping global
623 bcc = "X-DAK: dak process-accepted\nX-Katie: $Revision: 1.18 $"
624 if Cnf.has_key("Dinstall::Bcc"):
625 Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"])
627 Subst["__BCC__"] = bcc
629 # Sort the .changes files so that we process sourceful ones first
630 changes_files.sort(daklib.utils.changes_compare)
632 # Process the changes files
633 for changes_file in changes_files:
634 print "\n" + changes_file
635 process_it (changes_file)
639 if install_count > 1:
641 sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, daklib.utils.size_type(int(install_bytes))))
642 Logger.log(["total",install_count,install_bytes])
644 if not Options["No-Action"]:
647 Urgency_Logger.close()
649 ###############################################################################
651 if __name__ == '__main__':