47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
#!/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
|