def hasfiles(to_check, ignore): p = path(to_check) fl = p.files() found = [] for f in fl: if ignore not in f: found.append(f) if found: print sys.argv[0] + ": files exist" for f in found: print f
def main(): parser = argparse.ArgumentParser(description = "Remove a package from the package cache.") parser.add_argument("pkg",\ help="The package to remove", metavar="PKG") options = parser.parse_args() config = file(".cyg-apt").readlines() cache_tag = "cache" cache_tag_size = len(cache_tag) for l in config: k, v = l.split ('=', 2) __main__.__dict__[k] = eval (v) c = path(cache) cache_files = c.files() for f in cache_files: if options.pkg in f: #print f os.system("rm " + f)
def main(): global dists parser = argparse.ArgumentParser(description = " Fixes md5sum in setup-2.ini to match newly built package. It is an error for given files not to exist in the .ini under that package."\ "Example usage: " + sys.argv[0] + " testpkg test-pkg-0.0.1-0-src.tar.bz test-pkg-0.0.1-0.tar.bz" ) parser.add_argument("inifile",\ help="The setup.ini to patch.", metavar="INI") parser.add_argument("package",\ help="The package name to fix the md5sums for.", metavar="PKG") parser.add_argument("files",\ help="The package files to fix.", nargs = "*", metavar="FILES") options = parser.parse_args() target_package = options.package target_files = [] for f in options.files: target_files.append(f) # Yeah I know this looks wrong but that's globals for you get_setup_ini(options.inifile) inifile = options.inifile pkgs = dists["curr"] namekeys = pkgs.keys() if target_package not in namekeys: error(target_package + " is not in " + inifile) return 1 sections = ["install", "source"] for f in target_files: basename = path(f).basename() found_section = 0 for s in sections: if basename in pkgs[target_package][s]: found_section = s break if not found_section: error(basename + " is not in install: or source: of " +\ target_package + "in " + inifile ) return 1 #def gen_diff(diff_filename, packagename, linenum, oldline,\ # filename, basename, section): for f in target_files: basename = path(f).basename() #def find_line(inifile, target_package, section, filename): (linenum, line) = find_line(inifile, target_package,\ found_section, basename) diff_filename = basename + ".diff" diff = gen_diff(diff_filename, target_package, linenum, line,\ f, basename, found_section) df = file(diff_filename, "w") df.writelines(diff) df.close()