Exemple #1
0
def extract_changelog(changes_file, component, pool_dir):
    """ 
    Extract the changelog according to the changes_file
    If handling a _source.changes, extract the real changelog
    If handling binary .changes just creat a link for each of the binaries
    """
    global config, options

    extract_dir = '/tmp/changelog_extract'
    control_file = DebianControlFile(changes_file)
    name = control_file['Source']
    name_version = name + '_' + control_file.version()
    if name.startswith('lib'):
        prefix = name[:4]
    else:
        prefix = name[0]

    pool_dir = join(options.output_dir, 'pool', \
                                 component, prefix, name)
    dirname = os.path.dirname(changes_file)
    if changes_file.endswith('_source.changes'):  # Really extract
        if os.path.isdir(extract_dir):
            shutil.rmtree(extract_dir)
        for file in control_file.files_list():
            if file.name.endswith('.dsc'):
                (rc, output) = commands.getstatusoutput('dpkg-source -x %s %s' % \
                          (join(pool_dir, file.name), extract_dir))
                if rc <> 0 or not os.path.isdir(extract_dir):
                    Log.print_(output)
                    Log.print_(
                        "Unable to extract source to retrieve changelog")
                else:
                    extacted_changelog = os.path.join(extract_dir, 'debian',
                                                      'changelog')
                    if not exists(extacted_changelog):
                        Log.print_("Unable to find changelog on source")
                    if not os.path.exists(pool_dir):
                        os.makedirs(pool_dir, 0755)
                    print pool_dir
                    changelog_fn = join(
                        pool_dir,
                        os.path.basename(changes_file).rsplit('.', 1)[0] +
                        '.changelog')
                    shutil.copy(extacted_changelog, changelog_fn)
        if os.path.isdir(extract_dir):
            shutil.rmtree(extract_dir)
    else:  # binary build .changes, create a link to the corresponding source
        files = control_file.files_list()
        for file in files:
            if file.name.endswith('.deb'):
                try:
                    os.symlink(name_version+"_source.changelog", \
                        join(pool_dir, file.name.rsplit('.', 1)[0]+'.changelog'))
                except OSError:  # Already exists ?
                    pass
def extract_changelog(changes_file, component, pool_dir):
    """ 
    Extract the changelog according to the changes_file
    If handling a _source.changes, extract the real changelog
    If handling binary .changes just creat a link for each of the binaries
    """
    global config, options

    extract_dir = "/tmp/changelog_extract"
    control_file = DebianControlFile(changes_file)
    name = control_file["Source"]
    name_version = name + "_" + control_file.version()
    if name.startswith("lib"):
        prefix = name[:4]
    else:
        prefix = name[0]

    pool_dir = join(options.output_dir, "pool", component, prefix, name)
    dirname = os.path.dirname(changes_file)
    if changes_file.endswith("_source.changes"):  # Really extract
        if os.path.isdir(extract_dir):
            shutil.rmtree(extract_dir)
        for file in control_file.files_list():
            if file.name.endswith(".dsc"):
                (rc, output) = commands.getstatusoutput(
                    "dpkg-source -x %s %s" % (join(pool_dir, file.name), extract_dir)
                )
                if rc <> 0 or not os.path.isdir(extract_dir):
                    Log.print_(output)
                    Log.print_("Unable to extract source to retrieve changelog")
                else:
                    extacted_changelog = os.path.join(extract_dir, "debian", "changelog")
                    if not exists(extacted_changelog):
                        Log.print_("Unable to find changelog on source")
                    if not os.path.exists(pool_dir):
                        os.makedirs(pool_dir, 0755)
                    print pool_dir
                    changelog_fn = join(pool_dir, os.path.basename(changes_file).rsplit(".", 1)[0] + ".changelog")
                    shutil.copy(extacted_changelog, changelog_fn)
        if os.path.isdir(extract_dir):
            shutil.rmtree(extract_dir)
    else:  # binary build .changes, create a link to the corresponding source
        files = control_file.files_list()
        for file in files:
            if file.name.endswith(".deb"):
                try:
                    os.symlink(
                        name_version + "_source.changelog", join(pool_dir, file.name.rsplit(".", 1)[0] + ".changelog")
                    )
                except OSError:  # Already exists ?
                    pass
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 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:
Exemple #7
0
        sys.exit(rc)

if len(sys.argv) > 1:
    dsc_url = sys.argv[1]
    
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'):
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
Exemple #9
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 #10
0

if len(sys.argv) > 1:
    dsc_url = sys.argv[1]

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(
Exemple #11
0
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
Exemple #12
0
	Import a repository into the dabase
	"""
    global check_list
    # Get the base release file to check the list of available
    # architectures and components
    Log.log("Importing repository: %s %s [%s] [%s]" \
     % (archive_url, suite, requested_components or "all" \
      , requested_architectures or "all"))
    release_file = "%s/dists/%s/Release" % (archive_url, suite)
    Log.log("Downloading %s" % release_file)
    try:
        f = urllib2.urlopen(release_file)
    except HTTPError, e:
        print "Error %s : %s" % (e.code, release_file)
        return 1
    Release = DebianControlFile(contents=f.read())
    f.close()
    architectures = Release['Architectures'].split()
    components = Release['Components'].split()
    Log.log("Available architectures: %s" % architectures)
    Log.log("Available components: %s" % components)

    # Check if the requested components are available
    if requested_components:
        for component in requested_components[:]:
            if component not in components:
                Log.print_("Requested unavailable component %s" % component)
                return 2

    # Check if the requested architectures are available
    if requested_architectures:
Exemple #13
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)