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
Exemple #3
0
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)
Exemple #4
0
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)