def check_source_changes(release, component, filename): """ Check a _source.changes file and proceed as described in the script action flow . """ global config, options Log.print_("Building %s/%s/%s" % (release, component, filename)) source_dir = "%s/%s/%s" \ % (options.input_dir, release, component) destination_dir = "/tmp/build-%s-%s" % (release, component) changes_file = "%s/%s" % (source_dir, filename) # Remove previous failed status if os.path.exists('%s.failed' % changes_file): os.unlink('%s.failed' % changes_file) if not os.path.exists(destination_dir): os.makedirs(destination_dir, 0755) control_file = DebianControlFile(changes_file) if not options.skip_gpg: gpg_sign_author = control_file.verify_gpg(os.environ['HOME'] \ +'/debfactory/keyrings/uploaders.gpg ', Log.verbose) if not gpg_sign_author: Log.print_("ERROR: Unable to verify GPG key for %s" % changes_file) return else: gpg_sign_author = control_file['Changed-By'] if not gpg_sign_author: Log.print_("ERROR: Changed-By was not found in %s" % changes_file) return report_title = "%s/%s/%s build FAILED\n" \ % (release, component, filename) try: control_file.copy(destination_dir) except DebianControlFile.MD5Error, e: report_msg = "MD5 mismatch: Expected %s, got %s, file: %s\n" \ % (e.expected_md5, e.found_md5, e.name) Log.print_(report_msg) control_file.remove() send_mail(config['sender_email'], gpg_sign_author, report_title, report_msg) return
def check_source_changes(release, component, filename): """ Check a _source.changes file and proceed as described in the script action flow . """ global config, options Log.print_("Building %s/%s/%s" % (release, component, filename)) source_dir = "%s/%s/%s" \ % (options.input_dir, release, component) destination_dir = "/tmp/build-%s-%s" % (release, component) changes_file = "%s/%s" % (source_dir, filename) # Remove previous failed status if os.path.exists('%s.failed' % changes_file): os.unlink('%s.failed' % changes_file) if not os.path.exists(destination_dir): os.makedirs(destination_dir, 0755) control_file = DebianControlFile(changes_file) if not options.skip_gpg: gpg_sign_author = control_file.verify_gpg(os.environ['HOME'] \ +'/debfactory/keyrings/uploaders.gpg ', Log.verbose) if not gpg_sign_author: Log.print_("ERROR: Unable to verify GPG key for %s" % changes_file) return else: gpg_sign_author = control_file['Changed-By'] if not gpg_sign_author: Log.print_("ERROR: Changed-By was not found in %s" % changes_file) return report_title = "%s/%s/%s build FAILED\n" \ % (release, component, filename) try: control_file.copy(destination_dir) except DebianControlFile.MD5Error, e: report_msg = "MD5 mismatch: Expected %s, got %s, file: %s\n" \ % (e.expected_md5, e.found_md5, e.name) Log.print_(report_msg) control_file.remove() send_mail(config['sender_email'], gpg_sign_author, report_title, report_msg) return
def check_changes(release, component, filename): """ Check a _.changes file and include it into the repository """ global config, options source_dir = "%s/%s/%s" % (options.input_dir, release, component) changes_file = "%s/%s" % (source_dir, filename) if not os.path.exists(changes_file): return 1 Log.print_("Including %s/%s/%s" % (release, component, filename)) # Remove previous failed status if exists("%s.failed" % changes_file): os.unlink("%s.failed" % changes_file) control_file = DebianControlFile(changes_file) name = control_file["Source"] version = control_file.version() name_version = "%s_%s" % (control_file["Source"], control_file.version()) report_title = "Include on testing for %s/%s/%s FAILED\n" % (release, component, name_version) report_msg = "File: %s/%s/%s\n" % (release, component, filename) report_msg += "-----------------\n" # target_mails.append(control_file['Changed-By']) report_msg += "Signed By: %s\n\n" % control_file["Changed-By"] # Get list of files described on the changes report_msg += "List of files:\n" report_msg += "--------------\n" file_list = control_file.files_list() for file_info in file_list: report_msg += "%s (%s) MD5: %s \n" % (file_info.name, file_info.size, file_info.md5sum) if name.startswith("lib"): prefix = name[:4] else: prefix = name[0] pool_dir = join(options.output_dir, "pool", component, prefix, name) file_on_dest = "%s/%s" % (pool_dir, filename) # Remove all packages related to source package if filename.endswith("_source.changes"): os.system("reprepro removesrc %s-getdeb-testing %s %s" % (release, name, control_file["Version"])) # Delete orphaned changelogs changelogs = glob.glob("%s/*.changelog" % (pool_dir)) for changelog in changelogs: deb = changelog.rsplit(".", 1)[0] + ".deb" if not os.path.exists(deb): Log.print_("Removing changelog: %s" % (changelog)) os.unlink(changelog) # Include the package (use standard as "normal" does not exist due to Debian policy) # (LP: #735381, #735428) # Now use "optional" as priority because it fits even better to the Debian policy # (LP: #1085565) command = "reprepro -P optional --ignore=wrongdistribution -C %s include %s-getdeb-testing %s" % ( component, release, changes_file, ) (rc, output) = commands.getstatusoutput(command) print output report_msg += output if rc == 0: extract_changelog(changes_file, component, pool_dir) status = "SUCCESSFUL" control_file.remove() else: status = "FAILED" shutil.move(changes_file, "%s.failed" % changes_file) report_title = "Included on testing %s/%s/%s %s\n" % (release, component, name_version, status) Log.print_(report_title) return rc
def check_changes(release, component, filename): """ Check a _.changes file and include it into the repository """ global config, options source_dir = "%s/%s/%s" \ % (options.input_dir, release, component) changes_file = "%s/%s" % (source_dir, filename) if not os.path.exists(changes_file): return 1 Log.print_("Including %s/%s/%s" % (release, component, filename)) # Remove previous failed status if exists('%s.failed' % changes_file): os.unlink('%s.failed' % changes_file) control_file = DebianControlFile(changes_file) name = control_file['Source'] version = control_file.version() name_version = "%s_%s" % (control_file['Source'] \ , control_file.version()) report_title = "Include on testing for %s/%s/%s FAILED\n" \ % (release, component, name_version) report_msg = "File: %s/%s/%s\n" % (release, component, filename) report_msg += '-----------------\n' #target_mails.append(control_file['Changed-By']) report_msg += "Signed By: %s\n\n" % control_file['Changed-By'] # Get list of files described on the changes report_msg += "List of files:\n" report_msg += "--------------\n" file_list = control_file.files_list() for file_info in file_list: report_msg += "%s (%s) MD5: %s \n" \ % (file_info.name, file_info.size, file_info.md5sum) if name.startswith('lib'): prefix = name[:4] else: prefix = name[0] pool_dir = join(options.output_dir, 'pool', \ component, prefix, name) file_on_dest = "%s/%s" % (pool_dir, filename) # Remove all packages related to source package if (filename.endswith("_source.changes")): os.system("reprepro removesrc %s-getdeb-testing %s %s" % (release, name, control_file['Version'])) # Delete orphaned changelogs changelogs = glob.glob("%s/*.changelog" % (pool_dir)) for changelog in changelogs: deb = changelog.rsplit('.', 1)[0] + '.deb' if not os.path.exists(deb): Log.print_("Removing changelog: %s" % (changelog)) os.unlink(changelog) # Include the package (use standard as "normal" does not exist due to Debian policy) # (LP: #735381, #735428) # Now use "optional" as priority because it fits even better to the Debian policy # (LP: #1085565) command = "reprepro -P optional --ignore=wrongdistribution -C %s include %s-getdeb-testing %s" \ % (component, release, changes_file) (rc, output) = commands.getstatusoutput(command) print output report_msg += output if rc == 0: extract_changelog(changes_file, component, pool_dir) status = "SUCCESSFUL" control_file.remove() else: status = "FAILED" shutil.move(changes_file, "%s.failed" % changes_file) report_title = "Included on testing %s/%s/%s %s\n" \ % (release, component, name_version, status) Log.print_(report_title) return rc