diff options
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/patch.py | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 6f7f90095c..a5b31b8f8d 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
@@ -98,7 +98,37 @@ class PatchSet(object): | |||
98 | class PatchTree(PatchSet): | 98 | class PatchTree(PatchSet): |
99 | def __init__(self, dir, d): | 99 | def __init__(self, dir, d): |
100 | PatchSet.__init__(self, dir, d) | 100 | PatchSet.__init__(self, dir, d) |
101 | 101 | self.patchdir = os.path.join(self.dir, 'patches') | |
102 | self.seriespath = os.path.join(self.dir, 'patches', 'series') | ||
103 | bb.utils.mkdirhier(self.patchdir) | ||
104 | |||
105 | def _appendPatchFile(self, patch, strippath): | ||
106 | with open(self.seriespath, 'a') as f: | ||
107 | f.write(os.path.basename(patch) + "," + strippath + "\n") | ||
108 | shellcmd = ["cat", patch, ">" , self.patchdir + "/" + os.path.basename(patch)] | ||
109 | runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) | ||
110 | |||
111 | def _removePatch(self, p): | ||
112 | patch = {} | ||
113 | patch['file'] = p.split(",")[0] | ||
114 | patch['strippath'] = p.split(",")[1] | ||
115 | self._applypatch(patch, False, True) | ||
116 | |||
117 | def _removePatchFile(self, all = False): | ||
118 | if not os.path.exists(self.seriespath): | ||
119 | return | ||
120 | patches = open(self.seriespath, 'r+').readlines() | ||
121 | if all: | ||
122 | for p in reversed(patches): | ||
123 | self._removePatch(os.path.join(self.patchdir, p.strip())) | ||
124 | patches = [] | ||
125 | else: | ||
126 | self._removePatch(os.path.join(self.patchdir, patches[-1].strip())) | ||
127 | patches.pop() | ||
128 | with open(self.seriespath, 'w') as f: | ||
129 | for p in patches: | ||
130 | f.write(p) | ||
131 | |||
102 | def Import(self, patch, force = None): | 132 | def Import(self, patch, force = None): |
103 | """""" | 133 | """""" |
104 | PatchSet.Import(self, patch, force) | 134 | PatchSet.Import(self, patch, force) |
@@ -127,6 +157,10 @@ class PatchTree(PatchSet): | |||
127 | 157 | ||
128 | shellcmd.pop(len(shellcmd) - 1) | 158 | shellcmd.pop(len(shellcmd) - 1) |
129 | output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) | 159 | output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) |
160 | |||
161 | if not reverse: | ||
162 | self._appendPatchFile(patch['file'], patch['strippath']) | ||
163 | |||
130 | return output | 164 | return output |
131 | 165 | ||
132 | def Push(self, force = False, all = False, run = True): | 166 | def Push(self, force = False, all = False, run = True): |
@@ -134,30 +168,37 @@ class PatchTree(PatchSet): | |||
134 | bb.note("patches is %s" % self.patches) | 168 | bb.note("patches is %s" % self.patches) |
135 | if all: | 169 | if all: |
136 | for i in self.patches: | 170 | for i in self.patches: |
137 | if self._current is not None: | ||
138 | self._current = self._current + 1 | ||
139 | else: | ||
140 | self._current = 0 | ||
141 | bb.note("applying patch %s" % i) | 171 | bb.note("applying patch %s" % i) |
142 | self._applypatch(i, force) | 172 | self._applypatch(i, force) |
173 | self._current = i | ||
143 | else: | 174 | else: |
144 | if self._current is not None: | 175 | if self._current is not None: |
145 | self._current = self._current + 1 | 176 | next = self._current + 1 |
146 | else: | 177 | else: |
147 | self._current = 0 | 178 | next = 0 |
148 | bb.note("applying patch %s" % self.patches[self._current]) | 179 | |
149 | return self._applypatch(self.patches[self._current], force) | 180 | bb.note("applying patch %s" % self.patches[next]) |
181 | ret = self._applypatch(self.patches[next], force) | ||
150 | 182 | ||
183 | self._current = next | ||
184 | return ret | ||
151 | 185 | ||
152 | def Pop(self, force = None, all = None): | 186 | def Pop(self, force = None, all = None): |
153 | if all: | 187 | if all: |
154 | for i in self.patches: | 188 | self._removePatchFile(True) |
155 | self._applypatch(i, force, True) | 189 | self._current = None |
156 | else: | 190 | else: |
157 | self._applypatch(self.patches[self._current], force, True) | 191 | self._removePatchFile(False) |
192 | |||
193 | if self._current == 0: | ||
194 | self._current = None | ||
195 | |||
196 | if self._current is not None: | ||
197 | self._current = self._current - 1 | ||
158 | 198 | ||
159 | def Clean(self): | 199 | def Clean(self): |
160 | """""" | 200 | """""" |
201 | self.Pop(all=True) | ||
161 | 202 | ||
162 | class GitApplyTree(PatchTree): | 203 | class GitApplyTree(PatchTree): |
163 | def __init__(self, dir, d): | 204 | def __init__(self, dir, d): |