restructure and integrate code
parent
27f3811300
commit
a7e139ffb8
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
deb2gen = dict()
|
||||
gen2deb = dict()
|
||||
with open("./deb2gen_mapping.list") as f:
|
||||
for line in f:
|
||||
d, g = line.strip().split('\t')
|
||||
deb2gen[d] = g
|
||||
gen2deb[g] = d
|
||||
|
||||
with open("./deb_source_pkgs.list") as f:
|
||||
debian_names = [p[4:].strip() for p in f]
|
||||
|
||||
with open("./gen_source_pkgs.list") as f:
|
||||
gentoo_names = [p.strip() for p in f]
|
||||
|
||||
for p in debian_names:
|
||||
# if mapping exists, continue
|
||||
orig = p
|
||||
if deb2gen.get(p):
|
||||
continue
|
||||
# first try exact match
|
||||
matches = [g for g in gentoo_names if p == g.split('/')[-1]]
|
||||
if matches:
|
||||
print "%s\t%s"%(orig, matches[0])
|
||||
continue
|
||||
# then try substring matches
|
||||
# remove '-perl' prefix
|
||||
if p.endswith("-perl"):
|
||||
p = p[:-5]
|
||||
# remove 'python-' suffix
|
||||
if p.startswith("python-"):
|
||||
p = p[7:]
|
||||
# remove 'lib' suffix
|
||||
if p.startswith("lib"):
|
||||
p = p[3:]
|
||||
# remove dashes, dots and numbers from the end of the package name
|
||||
p = p.rstrip(".-1234567890")
|
||||
matches = [g for g in gentoo_names if p in g.split('/')[-1].lower()]
|
||||
if matches:
|
||||
print "%s\t%s"%(orig, str(matches))
|
||||
continue
|
||||
# we give up and print the debian source package name that was not matched
|
||||
print orig
|
File diff suppressed because it is too large
Load Diff
@ -1,96 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
from os import path
|
||||
from subprocess import Popen, PIPE
|
||||
from functools import cmp_to_key
|
||||
from datetime import datetime
|
||||
|
||||
pym_path = path.join(path.dirname(path.realpath(__file__)), "portage", "pym")
|
||||
sys.path.insert(0, pym_path)
|
||||
|
||||
from portage.versions import pkgcmp, pkgsplit
|
||||
from portage.dep import use_reduce, Atom
|
||||
from portage.exception import InvalidAtom
|
||||
|
||||
def format_timedelta(delta):
|
||||
secs = delta.days*60*60*24+delta.seconds
|
||||
hours = secs/3600
|
||||
minutes = (secs%3600)/60
|
||||
return "%02d:%02d"%(hours, minutes)
|
||||
|
||||
def estimate_remaining_time(before, count, i):
|
||||
now = datetime.now()
|
||||
delta = now-before
|
||||
# delta in seconds
|
||||
delta = delta.days*60*60*24+delta.seconds
|
||||
if delta == 0:
|
||||
return "n.a."
|
||||
speed = float(i)/delta
|
||||
remaining = (count - i)/speed
|
||||
remaining_hours = remaining/3600
|
||||
remaining_minutes = (remaining%3600)/60
|
||||
return "%02d:%02d"%(remaining_hours, remaining_minutes)
|
||||
|
||||
portdir = "./portdir"
|
||||
|
||||
pkgnames = list()
|
||||
|
||||
for cat in os.listdir(portdir):
|
||||
catpath = os.path.join(portdir, cat)
|
||||
if not os.path.isdir(catpath):
|
||||
continue
|
||||
for pkg in os.listdir(catpath):
|
||||
pkgpath = os.path.join(catpath, pkg)
|
||||
if not os.path.isdir(pkgpath):
|
||||
continue
|
||||
pkgs = [pkgsplit(ver[:-7]) for ver in os.listdir(pkgpath) if ver.endswith(".ebuild")]
|
||||
if len(pkgs) > 0:
|
||||
# only grab newest package
|
||||
pkg, ver, rev = sorted(pkgs, key=cmp_to_key(pkgcmp), reverse=True)[0]
|
||||
if rev == "r0":
|
||||
pkgname = "%s/%s-%s"%(cat, pkg, ver)
|
||||
else:
|
||||
pkgname = "%s/%s-%s-%s"%(cat, pkg, ver, rev)
|
||||
pkgnames.append(pkgname)
|
||||
sys.stderr.write("\rGenerating list of packages... %d"%len(pkgnames))
|
||||
|
||||
sys.stderr.write("\rGenerating list of packages... Done.\n")
|
||||
|
||||
count = 0
|
||||
|
||||
deplist = open("./out", "wb")
|
||||
|
||||
before = datetime.now()
|
||||
|
||||
for i, pkgname in enumerate(pkgnames):
|
||||
p = Popen(["./portage/bin/portageq", "metadata", "/", "ebuild", pkgname, "DEPEND"], stderr=PIPE, stdout=PIPE, env={"PORTDIR": portdir})
|
||||
r = p.communicate()
|
||||
if p.returncode != 0:
|
||||
sys.stderr.write("cannot parse %s. Output: %s\n"%(pkgname, r[1]))
|
||||
depend = r[0]
|
||||
all_use = use_reduce(depend, matchall=True)
|
||||
no_use = use_reduce(depend, matchnone=True)
|
||||
# cannot use sets because of possible sublists which are not hashable
|
||||
l = []
|
||||
for a in all_use:
|
||||
# FIXME: do not discard disjunctions
|
||||
if a not in no_use and a != "||" and not isinstance(a, list):
|
||||
try:
|
||||
l.append(Atom(a).cp)
|
||||
except InvalidAtom:
|
||||
sys.stderr.write("Invalid Atom for %s: %s\n"%(pkgname, str(a)))
|
||||
except TypeError:
|
||||
sys.stderr.write("TypeError for %s: %s\n"%(pkgname, str(a)))
|
||||
|
||||
if len(l) > 0:
|
||||
deplist.write("%s %s\n"%(pkgname, " ".join(l)))
|
||||
count +=1
|
||||
|
||||
sys.stderr.write("\rFinding reduced dependencies: %d/%d, found %d. Estimated time left: %s h"%(i, len(pkgnames), count, estimate_remaining_time(before, len(pkgnames), i)))
|
||||
sys.stdout.flush()
|
||||
|
||||
sys.stderr.write("\rFinding reduced dependencies: %d/%d, found %d. Estimated time left: %s h\n"%(i, len(pkgnames), count, estimate_remaining_time(before, len(pkgnames), i)))
|
||||
|
||||
sys.stderr.write("Done. Took %s h\n"%format_timedelta(datetime.now()-before))
|
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for f in `find "./portdir/" -mindepth 2 -maxdepth 2 -type d`; do
|
||||
echo ${f#./portdir/}
|
||||
done > gen_source_pkgs.list
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue