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 fingerprint_id = daklib.database.get_or_set_fingerprint_id(dsc["fingerprint"])
285 install_date = time.strftime("%Y-%m-%d")
286 filename = files[file]["pool name"] + file
287 dsc_component = files[file]["component"]
288 dsc_location_id = files[file]["location id"]
289 if not files[file].has_key("files id") or not files[file]["files id"]:
290 files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id)
291 projectB.query("INSERT INTO source (source, version, maintainer, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, '%s', %s)"
292 % (package, version, maintainer_id, files[file]["files id"], install_date, fingerprint_id))
294 for suite in changes["distribution"].keys():
295 suite_id = daklib.database.get_suite_id(suite)
296 projectB.query("INSERT INTO src_associations (suite, source) VALUES (%d, currval('source_id_seq'))" % (suite_id))
298 # Add the source files to the DB (files and dsc_files)
299 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files[file]["files id"]))
300 for dsc_file in dsc_files.keys():
301 filename = files[file]["pool name"] + dsc_file
302 # If the .orig.tar.gz is already in the pool, it's
303 # files id is stored in dsc_files by check_dsc().
304 files_id = dsc_files[dsc_file].get("files id", None)
306 files_id = daklib.database.get_files_id(filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
307 # FIXME: needs to check for -1/-2 and or handle exception
309 files_id = daklib.database.set_files_id (filename, dsc_files[dsc_file]["size"], dsc_files[dsc_file]["md5sum"], dsc_location_id)
310 projectB.query("INSERT INTO dsc_files (source, file) VALUES (currval('source_id_seq'), %d)" % (files_id))
312 # Add the src_uploaders to the DB
313 if dsc.get("dm-upload-allowed", "no") == "yes":
314 uploader_ids = [maintainer_id]
315 if dsc.has_key("uploaders"):
316 for u in dsc["uploaders"].split(","):
317 u = u.replace("'", "\\'")
320 daklib.database.get_or_set_maintainer_id(u))
321 for u in uploader_ids:
322 projectB.query("INSERT INTO src_uploaders (source, maintainer) VALUES (currval('source_id_seq'), %d)" % (u))
325 # Add the .deb files to the DB
326 for file in files.keys():
327 if files[file]["type"] == "deb":
328 package = files[file]["package"]
329 version = files[file]["version"]
330 maintainer = files[file]["maintainer"]
331 maintainer = maintainer.replace("'", "\\'")
332 maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer)
333 fingerprint_id = daklib.database.get_or_set_fingerprint_id(changes["fingerprint"])
334 architecture = files[file]["architecture"]
335 architecture_id = daklib.database.get_architecture_id (architecture)
336 type = files[file]["dbtype"]
337 source = files[file]["source package"]
338 source_version = files[file]["source version"]
339 filename = files[file]["pool name"] + file
340 if not files[file].has_key("location id") or not files[file]["location id"]:
341 files[file]["location id"] = daklib.database.get_location_id(Cnf["Dir::Pool"],files[file]["component"],daklib.utils.where_am_i())
342 if not files[file].has_key("files id") or not files[file]["files id"]:
343 files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], files[file]["location id"])
344 source_id = daklib.database.get_source_id (source, source_version)
346 projectB.query("INSERT INTO binaries (package, version, maintainer, source, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d)"
347 % (package, version, maintainer_id, source_id, architecture_id, files[file]["files id"], type, fingerprint_id))
349 projectB.query("INSERT INTO binaries (package, version, maintainer, architecture, file, type, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)"
350 % (package, version, maintainer_id, architecture_id, files[file]["files id"], type, fingerprint_id))
351 for suite in changes["distribution"].keys():
352 suite_id = daklib.database.get_suite_id(suite)
353 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES (%d, currval('binaries_id_seq'))" % (suite_id))
355 # If the .orig.tar.gz is in a legacy directory we need to poolify
356 # it, so that apt-get source (and anything else that goes by the
357 # "Directory:" field in the Sources.gz file) works.
358 orig_tar_id = Upload.pkg.orig_tar_id
359 orig_tar_location = Upload.pkg.orig_tar_location
360 legacy_source_untouchable = Upload.pkg.legacy_source_untouchable
361 if orig_tar_id and orig_tar_location == "legacy":
362 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))
365 # Is this an old upload superseded by a newer -sa upload? (See check_dsc() for details)
366 if legacy_source_untouchable.has_key(qid["files_id"]):
368 # First move the files to the new location
369 legacy_filename = qid["path"] + qid["filename"]
370 pool_location = daklib.utils.poolify (changes["source"], files[file]["component"])
371 pool_filename = pool_location + os.path.basename(qid["filename"])
372 destination = Cnf["Dir::Pool"] + pool_location
373 daklib.utils.move(legacy_filename, destination)
374 # Then Update the DB's files table
375 q = projectB.query("UPDATE files SET filename = '%s', location = '%s' WHERE id = '%s'" % (pool_filename, dsc_location_id, qid["files_id"]))
377 # If this is a sourceful diff only upload that is moving non-legacy
378 # cross-component we need to copy the .orig.tar.gz into the new
379 # component too for the same reasons as above.
381 if changes["architecture"].has_key("source") and orig_tar_id and \
382 orig_tar_location != "legacy" and orig_tar_location != dsc_location_id:
383 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))
384 ql = q.getresult()[0]
385 old_filename = ql[0] + ql[1]
388 new_filename = daklib.utils.poolify(changes["source"], dsc_component) + os.path.basename(old_filename)
389 new_files_id = daklib.database.get_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
390 if new_files_id == None:
391 daklib.utils.copy(old_filename, Cnf["Dir::Pool"] + new_filename)
392 new_files_id = daklib.database.set_files_id(new_filename, file_size, file_md5sum, dsc_location_id)
393 projectB.query("UPDATE dsc_files SET file = %s WHERE source = %s AND file = %s" % (new_files_id, source_id, orig_tar_id))
395 # Install the files into the pool
396 for file in files.keys():
397 destination = Cnf["Dir::Pool"] + files[file]["pool name"] + file
398 daklib.utils.move(file, destination)
399 Logger.log(["installed", file, files[file]["type"], files[file]["size"], files[file]["architecture"]])
400 install_bytes += float(files[file]["size"])
402 # Copy the .changes file across for suite which need it.
405 for suite in changes["distribution"].keys():
406 if Cnf.has_key("Suite::%s::CopyChanges" % (suite)):
407 copy_changes[Cnf["Suite::%s::CopyChanges" % (suite)]] = ""
408 # and the .dak file...
409 if Cnf.has_key("Suite::%s::CopyDotDak" % (suite)):
410 copy_dot_dak[Cnf["Suite::%s::CopyDotDak" % (suite)]] = ""
411 for dest in copy_changes.keys():
412 daklib.utils.copy(pkg.changes_file, Cnf["Dir::Root"] + dest)
413 for dest in copy_dot_dak.keys():
414 daklib.utils.copy(Upload.pkg.changes_file[:-8]+".dak", dest)
416 projectB.query("COMMIT WORK")
418 # Move the .changes into the 'done' directory
419 daklib.utils.move (pkg.changes_file,
420 os.path.join(Cnf["Dir::Queue::Done"], os.path.basename(pkg.changes_file)))
422 # Remove the .dak file
423 os.unlink(Upload.pkg.changes_file[:-8]+".dak")
425 if changes["architecture"].has_key("source") and Urgency_Logger:
426 Urgency_Logger.log(dsc["source"], dsc["version"], changes["urgency"])
428 # Undo the work done in queue.py(accept) to help auto-building
430 projectB.query("BEGIN WORK")
431 for suite in changes["distribution"].keys():
432 if suite not in Cnf.ValueList("Dinstall::QueueBuildSuites"):
434 now_date = time.strftime("%Y-%m-%d %H:%M")
435 suite_id = daklib.database.get_suite_id(suite)
436 dest_dir = Cnf["Dir::QueueBuild"]
437 if Cnf.FindB("Dinstall::SecurityQueueBuild"):
438 dest_dir = os.path.join(dest_dir, suite)
439 for file in files.keys():
440 dest = os.path.join(dest_dir, file)
441 # Remove it from the list of packages for later processing by apt-ftparchive
442 projectB.query("UPDATE queue_build SET in_queue = 'f', last_used = '%s' WHERE filename = '%s' AND suite = %s" % (now_date, dest, suite_id))
443 if not Cnf.FindB("Dinstall::SecurityQueueBuild"):
444 # Update the symlink to point to the new location in the pool
445 pool_location = daklib.utils.poolify (changes["source"], files[file]["component"])
446 src = os.path.join(Cnf["Dir::Pool"], pool_location, os.path.basename(file))
447 if os.path.islink(dest):
449 os.symlink(src, dest)
450 # Update last_used on any non-upload .orig.tar.gz symlink
452 # Determine the .orig.tar.gz file name
453 for dsc_file in dsc_files.keys():
454 if dsc_file.endswith(".orig.tar.gz"):
455 orig_tar_gz = os.path.join(dest_dir, dsc_file)
456 # Remove it from the list of packages for later processing by apt-ftparchive
457 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))
458 projectB.query("COMMIT WORK")
463 ################################################################################
465 def stable_install (summary, short_summary):
468 print "Installing to stable."
470 # Begin a transaction; if we bomb out anywhere between here and
471 # the COMMIT WORK below, the DB won't be changed.
472 projectB.query("BEGIN WORK")
474 # Add the source to stable (and remove it from proposed-updates)
475 for file in files.keys():
476 if files[file]["type"] == "dsc":
477 package = dsc["source"]
478 version = dsc["version"]; # NB: not files[file]["version"], that has no epoch
479 q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
482 daklib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version))
484 suite_id = daklib.database.get_suite_id('proposed-updates')
485 projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id))
486 suite_id = daklib.database.get_suite_id('stable')
487 projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id))
489 # Add the binaries to stable (and remove it/them from proposed-updates)
490 for file in files.keys():
491 if files[file]["type"] == "deb":
492 package = files[file]["package"]
493 version = files[file]["version"]
494 architecture = files[file]["architecture"]
495 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))
498 daklib.utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture))
501 suite_id = daklib.database.get_suite_id('proposed-updates')
502 projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id))
503 suite_id = daklib.database.get_suite_id('stable')
504 projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id))
506 projectB.query("COMMIT WORK")
508 daklib.utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/process-accepted/' + os.path.basename(pkg.changes_file))
510 ## Update the Stable ChangeLog file
511 new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog"
512 changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + "ChangeLog"
513 if os.path.exists(new_changelog_filename):
514 os.unlink (new_changelog_filename)
516 new_changelog = daklib.utils.open_file(new_changelog_filename, 'w')
517 for file in files.keys():
518 if files[file]["type"] == "deb":
519 new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file))
520 elif daklib.utils.re_issource.match(file):
521 new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file))
523 new_changelog.write("%s\n" % (file))
524 chop_changes = daklib.queue.re_fdnic.sub("\n", changes["changes"])
525 new_changelog.write(chop_changes + '\n\n')
526 if os.access(changelog_filename, os.R_OK) != 0:
527 changelog = daklib.utils.open_file(changelog_filename)
528 new_changelog.write(changelog.read())
529 new_changelog.close()
530 if os.access(changelog_filename, os.R_OK) != 0:
531 os.unlink(changelog_filename)
532 daklib.utils.move(new_changelog_filename, changelog_filename)
536 if not Options["No-Mail"] and changes["architecture"].has_key("source"):
537 Subst["__SUITE__"] = " into stable"
538 Subst["__SUMMARY__"] = summary
539 mail_message = daklib.utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-accepted.install")
540 daklib.utils.send_mail(mail_message)
541 Upload.announce(short_summary, 1)
543 # Finally remove the .dak file
544 dot_dak_file = os.path.join(Cnf["Suite::Proposed-Updates::CopyDotDak"], os.path.basename(Upload.pkg.changes_file[:-8]+".dak"))
545 os.unlink(dot_dak_file)
547 ################################################################################
549 def process_it (changes_file):
550 global reject_message
554 # Absolutize the filename to avoid the requirement of being in the
555 # same directory as the .changes file.
556 pkg.changes_file = os.path.abspath(changes_file)
558 # And since handling of installs to stable munges with the CWD
559 # save and restore it.
560 pkg.directory = os.getcwd()
562 if installing_to_stable:
563 old = Upload.pkg.changes_file
564 Upload.pkg.changes_file = os.path.basename(old)
565 os.chdir(Cnf["Suite::Proposed-Updates::CopyDotDak"])
569 Upload.update_subst()
571 if installing_to_stable:
572 Upload.pkg.changes_file = old
578 os.chdir(pkg.directory)
580 ###############################################################################
583 global projectB, Logger, Urgency_Logger, installing_to_stable
585 changes_files = init()
587 # -n/--dry-run invalidates some other options which would involve things happening
588 if Options["No-Action"]:
589 Options["Automatic"] = ""
591 # Check that we aren't going to clash with the daily cron job
593 if not Options["No-Action"] and os.path.exists("%s/Archive_Maintenance_In_Progress" % (Cnf["Dir::Root"])) and not Options["No-Lock"]:
594 daklib.utils.fubar("Archive maintenance in progress. Try again later.")
596 # If running from within proposed-updates; assume an install to stable
597 if os.getcwd().find('proposed-updates') != -1:
598 installing_to_stable = 1
600 # Obtain lock if not in no-action mode and initialize the log
601 if not Options["No-Action"]:
602 lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT)
604 fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
606 if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
607 daklib.utils.fubar("Couldn't obtain lock; assuming another 'dak process-accepted' is already running.")
610 Logger = Upload.Logger = daklib.logging.Logger(Cnf, "process-accepted")
611 if not installing_to_stable and Cnf.get("Dir::UrgencyLog"):
612 Urgency_Logger = Urgency_Log(Cnf)
614 # Initialize the substitution template mapping global
615 bcc = "X-DAK: dak process-accepted\nX-Katie: $Revision: 1.18 $"
616 if Cnf.has_key("Dinstall::Bcc"):
617 Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"])
619 Subst["__BCC__"] = bcc
621 # Sort the .changes files so that we process sourceful ones first
622 changes_files.sort(daklib.utils.changes_compare)
624 # Process the changes files
625 for changes_file in changes_files:
626 print "\n" + changes_file
627 process_it (changes_file)
631 if install_count > 1:
633 sys.stderr.write("Installed %d package %s, %s.\n" % (install_count, sets, daklib.utils.size_type(int(install_bytes))))
634 Logger.log(["total",install_count,install_bytes])
636 if not Options["No-Action"]:
639 Urgency_Logger.close()
641 ###############################################################################
643 if __name__ == '__main__':