예제 #1
0
def process(rpm_to_dir, rpm_from_dir, mirror, dontcopy, verbose, recurse,
            progress):

    if verbose: print ">process(..)"

    error_log = []

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    rpm_from_files = grab_rpm_files(rpm_from_dir, recurse)
    rpm_to_files = grab_rpm_files(rpm_to_dir, recurse)
    rpmdiff_inst = rpmdiff_lib.rpmdiff(verbose, progress, pb)

    rpm_from_dict = rpmdiff_inst.generate_rpm_dict(rpm_from_files)
    rpm_to_dict = rpmdiff_inst.generate_rpm_dict(rpm_to_files)

    i = 0.0
    for rpm in rpm_from_dict.keys():
        i = i + 1.0
        if progress:
            percentage = i / len(rpm_from_dict.keys())
            pb.progress(percentage)

        # check if the update exists
        if not rpm_to_dict.has_key(rpm):
            # First, attempt to grab from mirror
            cmd = ("wget -nd -P \"%s\" \"%s/%s-*.rpm\"") % (rpm_to_dir, mirror,
                                                            rpm)
            if verbose: print ">> " + cmd
            output = commands.getoutput(cmd)
            if (not len(list_files(rpm_to_dir, ("%s-*.rpm" % rpm), False))):
                if not dontcopy:
                    # Okay, download didn't work, let's just copy the file over and log it
                    cmd = ("cp %s %s/.") % (rpm_from_dict[rpm]['filename'],
                                            rpm_to_dir)
                    if verbose:
                        print ">> File could not download, default to copy original"
                    output = commands.getoutput(cmd)
                else:
                    if verbose: print ">> File could not download"
                error_log.append(
                    "Problem with %s for %s arch. Could not find in mirror." %
                    (rpm, arch))

    if len(error_log):
        print >> sys.stderr, "ERRORS\n"
        i = 0
        for line in error_log:
            i += 1
            print "[%d] %s" % (i, line)
예제 #2
0
def process(rpm_to_dir, rpm_from_dir, mirror, dontcopy, verbose, recurse, progress):

    if verbose: print ">process(..)"

    error_log = []

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    rpm_from_files = grab_rpm_files(rpm_from_dir, recurse)
    rpm_to_files = grab_rpm_files(rpm_to_dir, recurse)
    rpmdiff_inst = rpmdiff_lib.rpmdiff(verbose, progress, pb)

    rpm_from_dict = rpmdiff_inst.generate_rpm_dict(rpm_from_files)
    rpm_to_dict = rpmdiff_inst.generate_rpm_dict(rpm_to_files)

    i = 0.0
    for rpm in rpm_from_dict.keys():
        i = i + 1.0
        if progress:
            percentage = i / len(rpm_from_dict.keys())
            pb.progress(percentage)

        # check if the update exists
        if not rpm_to_dict.has_key(rpm):
            # First, attempt to grab from mirror
            cmd = ("wget -nd -P \"%s\" \"%s/%s-*.rpm\"") % (rpm_to_dir, mirror, rpm)
            if verbose: print ">> " + cmd
            output = commands.getoutput(cmd)
            if (not len(list_files(rpm_to_dir, ("%s-*.rpm" % rpm), False))):
                if not dontcopy:
                    # Okay, download didn't work, let's just copy the file over and log it
                    cmd = ("cp %s %s/.") % (rpm_from_dict[rpm]['filename'], rpm_to_dir)
                    if verbose: print">> File could not download, default to copy original"
                    output = commands.getoutput(cmd)
                else:
                    if verbose: print">> File could not download"
                error_log.append("Problem with %s for %s arch. Could not find in mirror." % (rpm, arch))

    if len(error_log):
        print >> sys.stderr, "ERRORS\n"
        i = 0
        for line in error_log:
            i += 1
            print "[%d] %s" % (i, line)
예제 #3
0
def process(rpm_to_dir, rpm_from_dir, mirror, arch, verbose, recurse, progress):

    if verbose: print ">process(..)"

    error_log = []

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    rpm_from_files = grab_rpm_files(rpm_from_dir, recurse)
    rpm_to_files = grab_rpm_files(rpm_to_dir, recurse)
    rpmdiff_inst = rpmdiff_lib.rpmdiff(verbose, progress, pb)

    rpm_from_dict = rpmdiff_inst.generate_rpm_dict(rpm_from_files)
    rpm_to_dict = rpmdiff_inst.generate_rpm_dict(rpm_to_files)

    i = 0.0
    for rpm in rpm_from_dict.keys():
        i = i + 1.0
        if progress:
            percentage = i / len(rpm_from_dict.keys())
            pb.progress(percentage)

        # check if the new arch component exists
        if not rpm_to_dict.has_key(rpm):
            # First, attempt to grab from mirror
            new_arch_file = rpm + "-" + rpm_from_dict[rpm]['version'] + "-" + rpm_from_dict[rpm]['release'] + "." + arch + ".rpm"
            path = rpm_to_dir + "/" + new_arch_file
            full_url = mirror + "/" + new_arch_file
            cmd = ("wget -O \"%s\" %s") % (path, full_url)
            if verbose: print ">> " + cmd
            output = commands.getoutput(cmd)
            if not os.path.exists(path):
                # Okay, download didn't work, let's just copy the file over and log it
                cmd = ("cp %s %s/.") % (rpm_from_dict[rpm]['filename'], rpm_to_dir)
                if verbose: print">> File could not download, default to copy original"
                output = commands.getoutput(cmd)
                error_log.append("Problem with %s for %s arch. Could not find in mirror." % (rpm, arch))

    if len(error_log):
        print >> sys.stderr, "ERRORS\n"
        i = 0
        for line in error_log:
            i += 1
            print "[%d] %s" % (i, line)
예제 #4
0
def run_compare(rpm_from, rpm_to, rpm_from_type, rpm_to_type, recurse,
                progress, verbose, binpkg, srcpkg, show_same):
    """ Run the comparison """

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    rdiff = rpmdiff_lib.rpmdiff(verbose, progress, pb)

    rpm_from_dict = {}
    rpm_to_dict = {}
    if rpm_from_type == 'dir':
        if progress: pb.set("Scanning %s :" % rpm_from)
        rpm_from_files = grab_rpm_files(rpm_from, recurse, binpkg, srcpkg)
        rpm_from_dict = rdiff.generate_rpm_dict(rpm_from_files)
        if progress: pb.set("Progress :")
        if progress: pb.clear()
    else:
        print "Error! No other supported types!"
        sys.exit(2)
    if rpm_to_type == 'dir':
        if progress: pb.set("Scanning %s :" % rpm_to)
        rpm_to_files = grab_rpm_files(rpm_to, recurse, binpkg, srcpkg)
        rpm_to_dict = rdiff.generate_rpm_dict(rpm_to_files)
        if progress: pb.set("Progress :")
        if progress: pb.clear()
    else:
        print "Error! No other supported types!"
        sys.exit(2)

    diff_results = rdiff.diff_rpm_dicts(rpm_from_dict, rpm_to_dict)
    if progress: pb.clear()
    print rdiff.produce_data_file(0, show_same)
예제 #5
0
def run_compare(rpm_from, rpm_to, rpm_from_type, rpm_to_type, recurse, progress, verbose, binpkg, srcpkg, show_same):
    """ Run the comparison """

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    rdiff = rpmdiff_lib.rpmdiff(verbose, progress, pb)

    rpm_from_dict = {}
    rpm_to_dict = {}
    if rpm_from_type == 'dir':
        if progress: pb.set("Scanning %s :" % rpm_from)
        rpm_from_files = grab_rpm_files(rpm_from, recurse, binpkg, srcpkg)
        rpm_from_dict = rdiff.generate_rpm_dict(rpm_from_files)
        if progress: pb.set("Progress :")
        if progress: pb.clear()
    else:
        print "Error! No other supported types!"
        sys.exit(2)
    if rpm_to_type == 'dir':
        if progress: pb.set("Scanning %s :" % rpm_to)
        rpm_to_files = grab_rpm_files(rpm_to, recurse, binpkg, srcpkg)
        rpm_to_dict = rdiff.generate_rpm_dict(rpm_to_files)
        if progress: pb.set("Progress :")
        if progress: pb.clear()
    else:
        print "Error! No other supported types!"
        sys.exit(2)

    diff_results = rdiff.diff_rpm_dicts(rpm_from_dict, rpm_to_dict)
    if progress: pb.clear()
    print rdiff.produce_data_file(0, show_same)
예제 #6
0
def process(directory, option, file_out, use_file_out, xml_file, group, verbose, recurse, progress):
    if verbose: print "Inside process..."

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    tree = ElementTree(file=xml_file)
    elem = tree.getroot()

    if verbose: print "Getting rpm_names"

    rpm_names = get_names_from_dir(directory, recurse, pb, progress)

    if verbose: print "Processing names"

    if option == comps_opt.ERASE:
        """ Handle the ERASE operations """
        for subelem in elem:
            for subsub in subelem:
                p = 0.0
                for subsubsub in subsub:
                    p = p + 1.0
                    if progress:
                        percentage = p / len(subsub)
                        pb.progress(percentage)

                    if subsubsub.tag == 'packagereq' and subsubsub.text in rpm_names:
                        subsub.remove(subsubsub)
                        if verbose: print "Found %s, removing" % subsubsub.text
    elif option == comps_opt.ADD:
        """ Handle the ADD operations """
        text = "<group>\n"
        text += "<id>%s</id>\n" % group
        text += "<name>%s</name>\n" % group
        text += "<packagelist>\n"

        p = 0.0
        for name in rpm_names:
            p = p + 1.0
            if progress:
                percentage = p / len(rpm_names)
                pb.progress(percentage)

            text += "<packagereq type=\"mandatory\">%s</packagereq>\n" % name

        text += "</packagelist>\n"
        text += "</group>\n"
        node = fromstring(text)
        elem.append(node)
    else:
        die("Some unknown error has occured. Neither 'ADD' nor 'ERASE' was specified, somehow")

    if progress: pb.clear()

    if verbose: print "Ending, outputing XML"

    if use_file_out:
        ElementTree(tree).write(file_out)
    else:
        dump(tree)