Remove our private patch system, which is no longer needed

I converted the main patch series to quilt format in 3.2.20-1, but
this patch system was still used by genorig.py.  One useful
feature that was not available elsewhere was using patch + unifdef
to exclude only part of a source file.  However no source files
have needed this since 3.16-rc4 and I don't expect this to ever
be needed again.

The preceding changes moved the file removal/exclusion list into
debian/copyright and the disabling of broken features into the
main patch series, so the private patch system isn't doing
anything.

So we can now remove it completely.
This commit is contained in:
Ben Hutchings 2018-08-10 14:23:14 +01:00
parent e588a3afcd
commit fac6a14424
4 changed files with 2 additions and 190 deletions

11
debian/bin/genorig.py vendored
View File

@ -14,7 +14,6 @@ import time
import warnings
from debian_linux.debian import Changelog, VersionLinux
from debian_linux.patches import PatchSeries
class Main(object):
@ -52,7 +51,7 @@ class Main(object):
if len(self.input_files) > 1:
self.upstream_patch(self.input_files[1])
# debian_patch() will change file mtimes. Capture the
# exclude_files() will change dir mtimes. Capture the
# original release time so we can apply it to the final
# tarball. Note this doesn't work in case we apply an
# upstream patch, as that doesn't carry a release time.
@ -62,7 +61,6 @@ class Main(object):
os.stat(os.path.join(self.dir, self.orig, 'Makefile'))
.st_mtime))
self.debian_patch()
self.exclude_files()
os.umask(old_umask)
self.tar(orig_date)
@ -126,13 +124,6 @@ class Main(object):
if os.spawnv(os.P_WAIT, '/bin/sh', ['sh', '-c', ' '.join(cmdline)]):
raise RuntimeError("Can't patch source")
def debian_patch(self):
name = "orig"
self.log("Patching source with debian patch (series %s)\n" % name)
fp = open("debian/patches/series-" + name)
series = PatchSeries(name, "debian/patches", fp)
series(dir=os.path.join(self.dir, self.orig))
def exclude_files(self):
self.log("Excluding file patterns specified in debian/copyright\n")
with open("debian/copyright") as f:

1
debian/changelog vendored
View File

@ -25,6 +25,7 @@ linux (4.18~rc7-1~exp1) UNRELEASED; urgency=medium
field
* Move file exclusion from d/p/debian/dfsg/files-1 to d/copyright
* Move disabling of broken features from d/p/series-orig to d/p/series
* Remove our private patch system, which is no longer needed
-- Uwe Kleine-König <ukleinek@debian.org> Sat, 21 Jul 2018 16:52:01 +0200

View File

@ -1,180 +0,0 @@
from __future__ import print_function
import glob
import os
import shutil
import subprocess
class Operation(object):
def __init__(self, name, data):
self.name, self.data = name, data
def __call__(self, dir='.', reverse=False):
try:
if not reverse:
self.do(dir)
else:
self.do_reverse(dir)
self._log(True)
except:
self._log(False)
raise
def _log(self, result):
if result:
s = "OK"
else:
s = "FAIL"
print(""" (%s) %-4s %s""" % (self.operation, s, self.name))
def do(self, dir):
raise NotImplementedError
def do_reverse(self, dir):
raise NotImplementedError
class OperationPatch(Operation):
def __init__(self, name, filename, data):
super(OperationPatch, self).__init__(name, data)
self.filename = filename
def _call(self, dir, *extraargs):
with open(self.filename) as f:
subprocess.check_call(
("patch", "-p1", "-f", "-s", "-t", "--no-backup-if-mismatch") + extraargs,
cwd=dir,
stdin=f,
)
def patch_push(self, dir):
self._call(dir, '--fuzz=1')
def patch_pop(self, dir):
self._call(dir, '-R')
class OperationPatchPush(OperationPatch):
operation = '+'
do = OperationPatch.patch_push
do_reverse = OperationPatch.patch_pop
class OperationPatchPop(OperationPatch):
operation = '-'
do = OperationPatch.patch_pop
do_reverse = OperationPatch.patch_push
class SubOperation(Operation):
def _log(self, result):
if result:
s = "OK"
else:
s = "FAIL"
print(""" %-10s %-4s %s""" % ('(%s)' % self.operation, s, self.name))
class SubOperationFilesRemove(SubOperation):
operation = "remove"
def do(self, dir):
name = os.path.join(dir, self.name)
for n in glob.iglob(name):
if os.path.isdir(n):
shutil.rmtree(n)
else:
os.unlink(n)
class SubOperationFilesUnifdef(SubOperation):
operation = "unifdef"
def do(self, dir):
filename = os.path.join(dir, self.name)
ret = subprocess.call(("unifdef", "-o", filename, filename) + tuple(self.data))
if ret == 0:
raise RuntimeError("unifdef of %s removed nothing" % self.name)
elif ret != 1:
raise RuntimeError("unifdef failed")
class OperationFiles(Operation):
operation = 'X'
suboperations = {
'remove': SubOperationFilesRemove,
'rm': SubOperationFilesRemove,
'unifdef': SubOperationFilesUnifdef,
}
def __init__(self, name, filename, data):
super(OperationFiles, self).__init__(name, data)
ops = []
with open(filename) as f:
for line in f:
line = line.strip()
if not line or line[0] == '#':
continue
items = line.split()
operation, filename = items[:2]
data = items[2:]
if operation not in self.suboperations:
raise RuntimeError('Undefined operation "%s" in series %s' % (operation, name))
ops.append(self.suboperations[operation](filename, data))
self.ops = ops
def do(self, dir):
for i in self.ops:
i(dir=dir)
class PatchSeries(list):
operations = {
'+': OperationPatchPush,
'-': OperationPatchPop,
'X': OperationFiles,
}
def __init__(self, name, root, fp):
self.name, self.root = name, root
for line in fp:
line = line.strip()
if not len(line) or line[0] == '#':
continue
items = line.split(' ')
operation, filename = items[:2]
data = items[2:]
if operation in self.operations:
f = os.path.join(self.root, filename)
if os.path.exists(f):
self.append(self.operations[operation](filename, f, data))
else:
raise RuntimeError("Can't find patch %s for series %s" % (filename, self.name))
else:
raise RuntimeError('Undefined operation "%s" in series %s' % (operation, name))
def __call__(self, cond=bool, dir='.', reverse=False):
if not reverse:
l = self
else:
l = self[::-1]
for i in l:
if cond(i):
i(dir=dir, reverse=reverse)
def __repr__(self):
return '<%s object for %s>' % (self.__class__.__name__, self.name)

View File