def sbuild_package(release, component, control_file, arch): """Attempt to build package using sbuild """ global config, options target_email = control_file['Changed-By'] name_version = "%s_%s" % (control_file['Source'], control_file.version()) dsc_file = "%s.dsc" % name_version dsc_controlfile = DebianControlFile(dsc_file) destination_dir = "%s/%s/%s" % (options.output_dir, release, component) if not os.path.exists(destination_dir): os.makedirs(destination_dir, 0755) print "Building: %s" % dsc_file log_name = "%s_%s_%s.log" % (name_version \ , datetime.datetime.now().strftime("%Y_%m_%d_%M_%S"), arch) start_time = time.time() if arch == "i386": arch_str = "i386 -A" arch_list = ['i386', 'all'] else: arch_str = arch arch_list = ['amd64'] if dsc_controlfile['Architecture'] == 'all': print "Skipping Architecture= 'all' " return 0 rc = os.system('sbuild -d %s -c %s-%s --arch %s %s' % (release, release, arch_str, arch, dsc_file)) log_link = "%s_%s.build" % (name_version, arch) if not os.path.exists(log_link): print "Unable to find build log symbolic link" return -1 try: log_filename = os.readlink(log_link) except OSError: print "Unable to find build log symbolic link" return -1 elapsed_time = ` int(time.time() - start_time) ` (dummy, build_tail) = commands.getstatusoutput('tail -2 ' + log_filename) (dummy, not_installed ) = commands.getstatusoutput('grep "but is not installed to anywhere" ' + log_filename) (dummy, missing_dependecy ) = commands.getstatusoutput('grep "Cannot find package that provides" ' + log_filename) report_msg = "List of files:\n" report_msg += "--------------\n" if rc == 0: status = "SUCCESSFUL" for arch_str in arch_list: # We really need the "./" because we have no base dir arch_changes = "./%s_%s.changes" % (name_version, arch_str) report_title = "Build for %s/%s/%s (%s) %s\n" \ % (release, component, name_version, arch, "FAILED") if os.path.exists(arch_changes): changes_file = DebianControlFile(arch_changes) file_list = changes_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) (dummy, lintian_output) = commands.getstatusoutput( 'lintian -i -I -E --pedantic ./%s' % (file_info.name)) report_msg += "Lintian output:\n%s\n\n" % (unicode( lintian_output, 'utf-8', 'ignore')) try: changes_file.move(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) send_mail(config['sender_email'], target_email, report_title, report_msg) return except DebianControlFile.FileNotFoundError, e: report_msg = "File not found: %s" % (e.filename) Log.print_(report_msg) send_mail(config['sender_email'], target_email, report_title, report_msg) return finally:
def sbuild_package(release, component, control_file, arch): """Attempt to build package using sbuild """ global config, options target_email = control_file['Changed-By'] name_version = "%s_%s" % (control_file['Source'] , control_file.version()) dsc_file = "%s.dsc" % name_version dsc_controlfile = DebianControlFile(dsc_file) destination_dir = "%s/%s/%s" % (options.output_dir, release, component) if not os.path.exists(destination_dir): os.makedirs(destination_dir, 0755) print "Building: %s" % dsc_file log_name = "%s_%s_%s.log" % (name_version \ , datetime.datetime.now().strftime("%Y_%m_%d_%M_%S"), arch) start_time = time.time() if arch == "i386": arch_str = "i386 -A" arch_list = ['i386','all'] else: arch_str = arch arch_list = ['amd64'] if dsc_controlfile['Architecture'] == 'all': print "Skipping Architecture= 'all' " return 0 rc = os.system('sbuild -d %s -c %s-%s --arch %s %s' % (release, release, arch_str, arch, dsc_file)) log_link = "%s_%s.build" % (name_version, arch) if not os.path.exists(log_link): print "Unable to find build log symbolic link" return -1 try: log_filename = os.readlink(log_link) except OSError: print "Unable to find build log symbolic link" return -1 elapsed_time = `int(time.time() - start_time)` (dummy, build_tail) = commands.getstatusoutput('tail -2 ' + log_filename) report_msg = "List of files:\n" report_msg += "--------------\n" if rc == 0: status = "SUCCESSFUL" for arch_str in arch_list: # We really need the "./" because we have no base dir arch_changes = "./%s_%s.changes" % (name_version, arch_str) report_title = "Build for %s/%s/%s (%s) %s\n" \ % (release, component, name_version, arch, "FAILED") if os.path.exists(arch_changes): changes_file = DebianControlFile(arch_changes) file_list = changes_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) (dummy, lintian_output) = commands.getstatusoutput('lintian -i -I -E --pedantic ./%s' % (file_info.name)) report_msg += "Lintian output:\n%s\n\n" % (unicode(lintian_output, 'utf-8')) try: changes_file.move(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) send_mail(config['sender_email'], target_email, report_title, report_msg) return except DebianControlFile.FileNotFoundError, e: report_msg = "File not found: %s" % (e.filename) Log.print_(report_msg) send_mail(config['sender_email'], target_email, report_title, report_msg) return finally:
release = commands.getoutput('lsb_release -cs') run_dir = os.getcwd() if not os.path.isdir('/tmp/build_test'): os.mkdir('/tmp/build_test') os.chdir('/tmp/build_test') dsc_file = os.path.basename(dsc_url) # Get and extract, apply the current release, generate a _source changes run_or_exit('dget -ux '+dsc_url) debian_control = DebianControlFile(dsc_file) upstream_version = debian_control.upstream_version() package_name = debian_control['Source'] os.chdir(join('/tmp/build_test', '%s-%s' % (package_name, upstream_version))) run_or_exit('dch -D %s Testing package' % release) run_or_exit('debuild -S -sa -uc') changes_control = DebianControlFile('/tmp/build_test/%s_%s_source.changes' % (package_name, debian_control.version())) if not os.path.exists('/tmp/build_incoming/'+release+'/apps'): os.makedirs('/tmp/build_incoming/'+release+'/apps') changes_control.move('/tmp/build_incoming/'+release+'/apps', '/tmp/build_test/') os.chdir(run_dir) # Test the process run_or_exit('build/process_incoming.py --skip-gpg-check -i /tmp/build_incoming -o /tmp/pre_build') run_or_exit('build/process_pre_build.py --skip-gpg-check -i /tmp/pre_build -o /tmp/post_build') if not os.environ.get('REPREPRO_BASE_DIR'): print "Skipping reprepro test, REPREPRO_BASE_DIR not defined" else: run_or_exit('build/process_post_build.py -i /tmp/post_build')
def check_source_changes(release, component, filename): """ Check a _source.changes file and proceed as described in the script action flow . """ global options global config Log.print_("Checking %s/%s/%s" % (release, component, filename)) source_dir = "%s/%s/%s" \ % (options.input_dir, release, component) full_pre_build_dir = "%s/%s/%s" \ % (options.output_dir, release, component) changes_file = "%s/%s" % (source_dir, filename) if not os.path.exists(full_pre_build_dir): os.makedirs(full_pre_build_dir, 0755) control_file = DebianControlFile("%s/%s" % (source_dir, filename)) 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 name_version = "%s_%s" % (control_file['Source'] \ , control_file.version()) package_release = control_file['Distribution'] if package_release != release: report_title = "Upload for %s/%s/%s FAILED\n" \ % (release, component, name_version) report_msg = u"The release %s on debian/changelog does noth match"\ " the target %s\n" % (package_release, release) Log.print_(report_msg) Log.print_(report_title) send_mail(config['sender_email'], gpg_sign_author, report_title, report_msg) return report_title = "Upload for %s/%s/%s FAILED\n" \ % (release, component, name_version) report_msg = u"File: %s/%s/%s\n" % (release, component, filename) report_msg += '-----------------\n' report_msg = u"Signed By: %s\n\n" % gpg_sign_author orig_file_extensions = [ "gz", "bz2", "lzma", "xz" ] found_orig_file = False # Check if orig_file is available for orig_file_extension in orig_file_extensions: orig_file = "%s_%s.orig.tar.%s" % (control_file['Source'], \ control_file.upstream_version(), orig_file_extension) if not orig_file: Log.print_("FIXME: This should never happen") # FIXME: This should never happen but we should send a message # anyway return if os.path.exists("%s/%s" % (source_dir, orig_file)): found_orig_file = True else: pre_build_orig = "%s/%s" % (full_pre_build_dir, orig_file) if os.path.exists(pre_build_orig): found_orig_file = True Log.print_('No orig.tar.%s, using %s ' % (orig_file_extension, pre_build_orig)) if not found_orig_file: print "report_msg:\n", report_msg report_msg += u"ERROR: Missing orig.tar.[gz,bz2,lzma,xz] for %s\n" \ % (changes_file) Log.print_(report_msg) send_mail(config['sender_email'], gpg_sign_author, report_title, report_msg) return # Get list of files described on the changes report_msg += u"List of files:\n" report_msg += u"--------------\n" file_list = control_file.files_list() for file_info in file_list: report_msg += u"%s (%s) MD5: %s \n" \ % (file_info.name, file_info.size, file_info.md5sum) try: if not options.check_only: control_file.move(full_pre_build_dir) except DebianControlFile.MD5Error, e: report_msg = u"MD5 mismatch: Expected %s, got %s, file: %s\n" \ % (e.expected_md5, e.found_md5, e.name)
dsc_file = os.path.basename(dsc_url) # Get and extract, apply the current release, generate a _source changes run_or_exit('dget -ux ' + dsc_url) debian_control = DebianControlFile(dsc_file) upstream_version = debian_control.upstream_version() package_name = debian_control['Source'] os.chdir(join('/tmp/build_test', '%s-%s' % (package_name, upstream_version))) run_or_exit('dch -D %s Testing package' % release) run_or_exit('debuild -S -sa -uc') changes_control = DebianControlFile('/tmp/build_test/%s_%s_source.changes' % (package_name, debian_control.version())) if not os.path.exists('/tmp/build_incoming/' + release + '/apps'): os.makedirs('/tmp/build_incoming/' + release + '/apps') changes_control.move('/tmp/build_incoming/' + release + '/apps', '/tmp/build_test/') os.chdir(run_dir) # Test the process run_or_exit( 'build/process_incoming.py --skip-gpg-check -i /tmp/build_incoming -o /tmp/pre_build' ) run_or_exit( 'build/process_pre_build.py --skip-gpg-check -i /tmp/pre_build -o /tmp/post_build' ) if not os.environ.get('REPREPRO_BASE_DIR'): print "Skipping reprepro test, REPREPRO_BASE_DIR not defined" else: run_or_exit('build/process_post_build.py -i /tmp/post_build')
def check_source_changes(release, component, filename): """ Check a _source.changes file and proceed as described in the script action flow . """ global options global config Log.print_("Checking %s/%s/%s" % (release, component, filename)) source_dir = "%s/%s/%s" \ % (options.input_dir, release, component) full_pre_build_dir = "%s/%s/%s" \ % (options.output_dir, release, component) changes_file = "%s/%s" % (source_dir, filename) if not os.path.exists(full_pre_build_dir): os.makedirs(full_pre_build_dir, 0755) control_file = DebianControlFile("%s/%s" % (source_dir, filename)) 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 name_version = "%s_%s" % (control_file['Source'] \ , control_file.version()) package_release = control_file['Distribution'] if package_release != release: report_title = "Upload for %s/%s/%s FAILED\n" \ % (release, component, name_version) report_msg = u"The release %s on debian/changelog does noth match"\ " the target %s\n" % (package_release, release) Log.print_(report_msg) Log.print_(report_title) send_mail(config['sender_email'], gpg_sign_author, report_title, report_msg) return report_title = "Upload for %s/%s/%s FAILED\n" \ % (release, component, name_version) report_msg = u"File: %s/%s/%s\n" % (release, component, filename) report_msg += '-----------------\n' report_msg = u"Signed By: %s\n\n" % gpg_sign_author orig_file_extensions = ["gz", "bz2", "lzma", "xz"] found_orig_file = False # Check if orig_file is available for orig_file_extension in orig_file_extensions: orig_file = "%s_%s.orig.tar.%s" % (control_file['Source'], \ control_file.upstream_version(), orig_file_extension) if not orig_file: Log.print_("FIXME: This should never happen") # FIXME: This should never happen but we should send a message # anyway return if os.path.exists("%s/%s" % (source_dir, orig_file)): found_orig_file = True else: pre_build_orig = "%s/%s" % (full_pre_build_dir, orig_file) if os.path.exists(pre_build_orig): found_orig_file = True Log.print_('No orig.tar.%s, using %s ' % (orig_file_extension, pre_build_orig)) if not found_orig_file: print "report_msg:\n", report_msg report_msg += u"ERROR: Missing orig.tar.[gz,bz2,lzma,xz] for %s\n" \ % (changes_file) Log.print_(report_msg) send_mail(config['sender_email'], gpg_sign_author, report_title, report_msg) return # Get list of files described on the changes report_msg += u"List of files:\n" report_msg += u"--------------\n" file_list = control_file.files_list() for file_info in file_list: report_msg += u"%s (%s) MD5: %s \n" \ % (file_info.name, file_info.size, file_info.md5sum) try: if not options.check_only: control_file.move(full_pre_build_dir) except DebianControlFile.MD5Error, e: report_msg = u"MD5 mismatch: Expected %s, got %s, file: %s\n" \ % (e.expected_md5, e.found_md5, e.name)