Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 135 lines (114 sloc) 3.582 kb
32afada @danielrobbins cleaning up old and duplicate gecko-mediaplayer
danielrobbins authored
1 #!/usr/bin/python2
2
3 import os,sys
4 import commands
5
6 debug = False
7
8 def runShell(string):
9 if debug:
10 print string
11 else:
12 print "running: %s" % string
13 out = commands.getstatusoutput(string)
14 if out[0] != 0:
15 print "Error executing '%s'" % string
16 print
17 print "output:"
18 print out[1]
19 sys.exit(1)
20
21 class MergeStep(object):
22 pass
23
24 class ApplyPatchSeries(MergeStep):
25 def __init__(self,path):
26 self.path = path
27
28 def run(self,tree):
29 a = open(os.path.join(self.path,"series"),"r")
30 for line in a:
31 if line[0:1] == "#":
32 continue
33 runShell( "( cd %s; git apply %s/%s )" % ( tree.root, self.path, line[:-1] ))
34
35 class SyncDir(MergeStep):
36 def __init__(self,srcroot,srcdir=None,destdir=None):
37 self.srcroot = srcroot
38 self.srcdir = srcdir
39 self.destdir = destdir
40
41 def run(self,tree):
42 if self.srcdir:
43 src = os.path.join(self.srcroot,self.srcdir)+"/"
44 else:
45 src = os.path.normpath(self.srcroot)+"/"
46 if self.destdir:
47 dest = os.path.join(tree.root,self.destdir)+"/"
48 else:
49 if self.srcdir:
50 dest = os.path.join(tree.root,self.srcdir)+"/"
51 else:
52 dest = os.path.normpath(tree.root)+"/"
53 cmd = "rsync -a --exclude /.git %s %s" % ( src, dest )
54 runShell(cmd)
55
56 class UnifiedTree(object):
57 def __init__(self,root,steps):
58 self.root = root
59 self.steps = steps
60
61 def run(self):
62 for step in self.steps:
63 step.run(self)
64
65 class InsertEbuilds(MergeStep):
66
67 def __init__(self,root,replace=False,categories=None):
68 self.root = root
69 self.replace = replace
70 self.categories = categories
71
72 def run(self,tree):
73
74 # Figure out what categories to process:
75 catpath = os.path.join(self.root,"profiles/categories")
76
77 if self.categories != None:
78 # categories specified in __init__:
79 a = self.categories
80 elif os.path.exists(catpath):
81 # categories defined in profile:
82 a = []
83 f = open(os.path.join(self.root,"profiles/categories"),"r")
84 for cat in f.readlines():
85 a.append(cat.strip())
86 f.close()
87 else:
88 # no categories specified to __init__, and no profiles/categories file, so auto-detect categories:
89 a = []
90 cats = os.listdir(self.root)
91 for cat in cats:
92 # All categories have a "-" in them and are directories:
93 if os.path.isdir(os.path.join(self.root,cat)) and cat.find("-") != -1:
94 a.append(cat)
95
96 # Our main loop:
97 print "# Merging in ebuilds from %s" % self.root
98 for cat in a:
99 catdir = os.path.join(self.root,cat)
100 if not os.path.isdir(catdir):
101 # not a valid category in source overlay, so skip it
102 continue
aa661ca @danielrobbins new merge python code - not yet working, but good framework
danielrobbins authored
103 runShell("install -d %s" % catdir)
32afada @danielrobbins cleaning up old and duplicate gecko-mediaplayer
danielrobbins authored
104 for pkg in os.listdir(catdir):
105 pkgdir = os.path.join(catdir, pkg)
106 if not os.path.isdir(pkgdir):
107 # not a valid package dir in source overlay, so skip it
108 continue
109 tpkgdir = os.path.join(tree.root,cat)
110 tpkgdir = os.path.join(tpkgdir,pkg)
111 copy = False
112 if self.replace:
113 runShell("rm -rf %s; cp -a %s %s" % (tpkgdir, pkgdir, tpkgdir ))
114 else:
115 runShell("[ ! -e %s ] && cp -a %s %s || echo \"# skipping %s/%s\"" % (tpkgdir, pkgdir, tpkgdir, cat, pkg ))
116
117 steps = [
118 SyncDir("/var/git/portage-gentoo"),
119 ApplyPatchSeries("/root/git/funtoo-overlay/funtoo/patches"),
120 SyncDir("/root/git/funtoo-overlay","funtoo/profiles","profiles"),
121 SyncDir("/root/git/funtoo-overlay","licenses"),
122 SyncDir("/root/git/funtoo-overlay","eclass"),
123 InsertEbuilds("/root/git/funtoo-overlay",replace=True),
124 InsertEbuilds("/root/git/tarsius-overlay",replace=False)
125 ]
126
127
128 """
129 ProfileFix(),
130 InsertEbuilds("/root/git/tarsius-portage",replace=["sys-apps/foo"])
131 """
132
133 a = UnifiedTree("/var/git/portage-test",steps)
134 a.run()
Something went wrong with that request. Please try again.