+ # Undo the work done in katie.py(accept) to help auto-building
+ # from accepted.
+ if Cnf.FindB("Dinstall::SpecialAcceptedAutoBuild") and \
+ changes["distribution"].has_key("unstable"):
+ now_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()));
+ projectB.query("BEGIN WORK");
+ for file in files.keys():
+ dest = os.path.join(Cnf["Dir::AcceptedAutoBuild"], file);
+ # Remove it from the list of packages for later processing by apt-ftparchive
+ projectB.query("UPDATE unstable_accepted SET in_accepted = 'f', last_used = '%s' WHERE filename = '%s'" % (now_date, dest));
+ # Update the symlink to point to the new location in the pool
+ pool_location = utils.poolify (changes["source"], files[file]["component"]);
+ src = os.path.join(Cnf["Dir::Pool"], pool_location, os.path.basename(file));
+ if os.path.islink(dest):
+ os.unlink(dest);
+ os.symlink(src, dest);
+ # Update last_used on any non-upload .orig.tar.gz symlink
+ if orig_tar_id:
+ # Determine the .orig.tar.gz file name
+ for dsc_file in dsc_files.keys():
+ if dsc_file[-12:] == ".orig.tar.gz":
+ orig_tar_gz = os.path.join(Cnf["Dir::AcceptedAutoBuild"], dsc_file);
+ # Remove it from the list of packages for later processing by apt-ftparchive
+ projectB.query("UPDATE unstable_accepted SET in_accepted = 'f', last_used = '%s' WHERE filename = '%s'" % (now_date, orig_tar_gz));
+ projectB.query("COMMIT WORK");
+
+ install_count = install_count + 1;
+
+################################################################################
+
+def stable_install (summary, short_summary):
+ global install_count;
+
+ print "Installing to stable.";
+
+ # Begin a transaction; if we bomb out anywhere between here and the COMMIT WORK below, the DB will not be changed.
+ projectB.query("BEGIN WORK");
+
+ # Add the source to stable (and remove it from proposed-updates)
+ for file in files.keys():
+ if files[file]["type"] == "dsc":
+ package = dsc["source"];
+ version = dsc["version"]; # NB: not files[file]["version"], that has no epoch
+ q = projectB.query("SELECT id FROM source WHERE source = '%s' AND version = '%s'" % (package, version))
+ ql = q.getresult();
+ if not ql:
+ utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s) in source table." % (package, version));
+ source_id = ql[0][0];
+ suite_id = db_access.get_suite_id('proposed-updates');
+ projectB.query("DELETE FROM src_associations WHERE suite = '%s' AND source = '%s'" % (suite_id, source_id));
+ suite_id = db_access.get_suite_id('stable');
+ projectB.query("INSERT INTO src_associations (suite, source) VALUES ('%s', '%s')" % (suite_id, source_id));
+
+ # Add the binaries to stable (and remove it/them from proposed-updates)
+ for file in files.keys():
+ if files[file]["type"] == "deb":
+ package = files[file]["package"];
+ version = files[file]["version"];
+ architecture = files[file]["architecture"];
+ 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));
+ ql = q.getresult();
+ if not ql:
+ utils.fubar("[INTERNAL ERROR] couldn't find '%s' (%s for %s architecture) in binaries table." % (package, version, architecture));
+ binary_id = ql[0][0];
+ suite_id = db_access.get_suite_id('proposed-updates');
+ projectB.query("DELETE FROM bin_associations WHERE suite = '%s' AND bin = '%s'" % (suite_id, binary_id));
+ suite_id = db_access.get_suite_id('stable');
+ projectB.query("INSERT INTO bin_associations (suite, bin) VALUES ('%s', '%s')" % (suite_id, binary_id));
+
+ projectB.query("COMMIT WORK");
+
+ utils.move (pkg.changes_file, Cnf["Dir::Morgue"] + '/katie/' + os.path.basename(pkg.changes_file));
+
+ ## Update the Stable ChangeLog file
+ new_changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + ".ChangeLog";
+ changelog_filename = Cnf["Dir::Root"] + Cnf["Suite::Stable::ChangeLogBase"] + "ChangeLog";
+ if os.path.exists(new_changelog_filename):
+ os.unlink (new_changelog_filename);
+
+ new_changelog = utils.open_file(new_changelog_filename, 'w');
+ for file in files.keys():
+ if files[file]["type"] == "deb":
+ new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file));
+ elif utils.re_issource.match(file) != None:
+ new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file));
+ else:
+ new_changelog.write("%s\n" % (file));
+ chop_changes = katie.re_fdnic.sub("\n", changes["changes"]);
+ new_changelog.write(chop_changes + '\n\n');
+ if os.access(changelog_filename, os.R_OK) != 0:
+ changelog = utils.open_file(changelog_filename);
+ new_changelog.write(changelog.read());
+ new_changelog.close();
+ if os.access(changelog_filename, os.R_OK) != 0:
+ os.unlink(changelog_filename);
+ utils.move(new_changelog_filename, changelog_filename);
+