[kernel] r5195 - people/waldi/linux-2.6/debian/bin
Bastian Blank
waldi at costa.debian.org
Tue Jan 3 15:14:34 UTC 2006
Author: waldi
Date: Tue Jan 3 15:14:33 2006
New Revision: 5195
Modified:
people/waldi/linux-2.6/debian/bin/apply.py
Log:
debian/bin/apply.py: Implement patch per arch and subarch. It is currently done
by completely deapply the arch specific patches if it needs to change set of
general patches.
Modified: people/waldi/linux-2.6/debian/bin/apply.py
==============================================================================
--- people/waldi/linux-2.6/debian/bin/apply.py (original)
+++ people/waldi/linux-2.6/debian/bin/apply.py Tue Jan 3 15:14:33 2006
@@ -25,7 +25,7 @@
continue
items = line.split(' ')
- operation, patch = items[:2]
+ operation, patch = items
if operation in ('+', '-'):
patchfile = os.path.join(home, patch)
@@ -43,15 +43,6 @@
else:
raise RuntimeError, 'Undefined operation "%s" in series %s' % (operation, name)
- add = {}
- for s in items[2:]:
- s = tuple(s.split('_'))
- if len(s) > 2:
- raise RuntimeError, "parse error"
- if len(s) == 2:
- raise RuntimeError, "Patch per flavour is not supported currently"
- add[s] = True
-
self.append((operation, patch, patchinfo))
def __repr__(self):
@@ -144,7 +135,71 @@
return ret
class series_extra(series):
- pass
+ def __init__(self, name, home, extra, reverse = False):
+ self.extra = extra
+ self.name = name
+ self.reverse = reverse
+
+ filename = os.path.join(home, 'series', name + '-extra')
+ if not os.path.exists(filename):
+ raise RuntimeError, "Can't find series file for %s" % name
+
+ f = file(filename)
+ for line in f.readlines():
+ line = line.strip()
+
+ if len(line) == 0 or line[0] == '#':
+ continue
+
+ items = line.split(' ')
+ operation, patch = items[:2]
+
+ if operation in ('+', '-'):
+ patchfile = os.path.join(home, patch)
+ for suffix, type in (('', 0), ('.bz2', 1), ('.gz', 2)):
+ if os.path.exists(patchfile + suffix):
+ patchinfo = patchfile + suffix, type
+ break
+ else:
+ raise RuntimeError, "Can't find patch %s for series %s" % (patchfile, name)
+ else:
+ raise RuntimeError, 'Undefined operation "%s" in series %s' % (operation, name)
+
+ extra = {}
+ for s in items[2:]:
+ s = tuple(s.split('_'))
+ if len(s) > 2:
+ raise RuntimeError, "parse error"
+ if len(s) == 2:
+ raise RuntimeError, "Patch per flavour is not supported currently"
+ extra[s] = True
+ if not self._check_extra(extra):
+ operation = '.'
+
+ self.append((operation, patch, patchinfo))
+
+ def _check_extra(self, extra):
+ if extra.has_key(tuple(self.extra[:1])):
+ return True
+ if extra.has_key(tuple(self.extra[:2])):
+ return True
+ if extra.has_key(tuple(self.extra[:3])):
+ return True
+ return False
+
+ @staticmethod
+ def read_all(s, home, extra, reverse = False):
+ ret = []
+
+ for name in s:
+ filename = os.path.join(home, 'series', name + '-extra')
+ if not os.path.exists(filename):
+ warn("Can't find series file for %s" % name)
+ else:
+ i = series_extra(name, home, extra, reverse)
+ ret.append(i)
+
+ return ret
class version(object):
__slots__ = "upstream", "revision"
@@ -160,7 +215,7 @@
class version_file(object):
_file = 'version.Debian'
- extra = []
+ extra = ()
in_progress = False
def __init__(self, ver = None, overwrite = False):
@@ -193,7 +248,7 @@
except ValueError:
raise RuntimeError, 'Can\'t read version in %s: "%s"' % (self._file, list[0])
if len(list) == 2:
- self.extra = list[1].split('_')
+ self.extra = tuple(list[1].split('_'))
def _write(self):
file(self._file, 'w').write('%s\n' % self)
@@ -202,8 +257,12 @@
self.in_progress = True
self._write()
- def commit(self):
+ def commit(self, version = None, extra = None):
self.in_progress = False
+ if version is not None:
+ self.version = version
+ if extra is not None:
+ self.extra = extra
self._write()
def main():
@@ -231,6 +290,7 @@
target_extra = []
if options.arch: target_extra.append(options.arch)
if options.subarch: target_extra.append(options.subarch)
+ if options.flavour: target_extra.append(options.flavour)
target_extra = tuple(target_extra)
if current.revision not in revisions:
@@ -245,22 +305,36 @@
current_index = revisions.index(current.revision)
target_index = revisions.index(target.revision)
+ if current_extra:
+ consider = revisions[current_index:0:-1]
+ s = series_extra.read_all(consider, home, current_extra, reverse = True)
+ vfile.begin()
+ for i in s:
+ i.apply()
+ vfile.commit(current, ())
+
if current_index < target_index:
consider = revisions[current_index + 1:target_index + 1]
s = series.read_all(consider, home)
vfile.begin()
for i in s:
i.apply()
- vfile.version = target
- vfile.commit()
+ vfile.commit(target, ())
elif current_index > target_index:
consider = revisions[current_index:target_index:-1]
s = series.read_all(consider, home, reverse = True)
vfile.begin()
for i in s:
i.apply()
- vfile.version = target
- vfile.commit()
+ vfile.commit(target, ())
+
+ if target_extra:
+ consider = revisions[1:target_index + 1]
+ s = series_extra.read_all(consider, home, target_extra)
+ vfile.begin()
+ for i in s:
+ i.apply()
+ vfile.commit(target, target_extra)
def parse_options():
from optparse import OptionParser
@@ -306,9 +380,9 @@
options, args = parser.parse_args()
if options.arch is None and options.subarch is not None:
- warn('You specified a subarch without an arch, this is not really working')
+ raise RuntimeError('You specified a subarch without an arch, this is not really working')
if options.subarch is None and options.flavour is not None:
- warn('You specified a flavour without a subarch, this is not really working')
+ raise RuntimeError('You specified a flavour without a subarch, this is not really working')
return options, args
More information about the Kernel-svn-changes
mailing list