[rt] genpatch.py: Add Origin header to all patches
svn path=/dists/trunk/linux/; revision=20312
This commit is contained in:
parent
f0b384b44c
commit
db3f17661b
|
@ -4,8 +4,9 @@ linux (3.10~rc7-1~exp2) UNRELEASED; urgency=low
|
||||||
* debian/patches: Add DEP-3 headers (From, Subject, Forwarded/Origin)
|
* debian/patches: Add DEP-3 headers (From, Subject, Forwarded/Origin)
|
||||||
for most patches
|
for most patches
|
||||||
* aufs: Add DEP-3 headers to generated/copied patches
|
* aufs: Add DEP-3 headers to generated/copied patches
|
||||||
* [rt] Make genpatch.py work with upstream patch series as well as git
|
* [rt] genpatch.py: Work with upstream patch series as well as git
|
||||||
- Fold convert-series into genpatch.py
|
- Fold convert-series into genpatch.py
|
||||||
|
* [rt] genpatch.py: Add Origin header to all patches
|
||||||
|
|
||||||
-- Ben Hutchings <ben@decadent.org.uk> Mon, 01 Jul 2013 00:58:08 +0100
|
-- Ben Hutchings <ben@decadent.org.uk> Mon, 01 Jul 2013 00:58:08 +0100
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import os, os.path, re, shutil, subprocess, sys
|
import errno, os, os.path, re, shutil, subprocess, sys
|
||||||
|
|
||||||
def main(source_dir, version=None):
|
def main(source_dir, version):
|
||||||
patch_dir = 'debian/patches'
|
patch_dir = 'debian/patches'
|
||||||
rt_patch_dir = 'features/all/rt'
|
rt_patch_dir = 'features/all/rt'
|
||||||
series_name = 'series-rt'
|
series_name = 'series-rt'
|
||||||
|
@ -16,14 +16,28 @@ def main(source_dir, version=None):
|
||||||
old_series.add(name)
|
old_series.add(name)
|
||||||
|
|
||||||
with open(os.path.join(patch_dir, series_name), 'w') as series_fh:
|
with open(os.path.join(patch_dir, series_name), 'w') as series_fh:
|
||||||
# Add directory prefix to all filenames
|
# Add directory prefix to all filenames.
|
||||||
def add_patch(name):
|
# Add Origin to all patch headers.
|
||||||
|
def add_patch(name, source_patch, origin):
|
||||||
name = os.path.join(rt_patch_dir, name)
|
name = os.path.join(rt_patch_dir, name)
|
||||||
|
path = os.path.join(patch_dir, name)
|
||||||
|
try:
|
||||||
|
os.unlink(path)
|
||||||
|
except OSError, e:
|
||||||
|
if e.errno != errno.ENOENT:
|
||||||
|
raise
|
||||||
|
with open(path, 'w') as patch:
|
||||||
|
in_header = True
|
||||||
|
for line in source_patch:
|
||||||
|
if in_header and line == '\n':
|
||||||
|
patch.write('Origin: %s\n' % origin)
|
||||||
|
in_header = False
|
||||||
|
patch.write(line)
|
||||||
series_fh.write(name)
|
series_fh.write(name)
|
||||||
series_fh.write('\n')
|
series_fh.write('\n')
|
||||||
new_series.add(name)
|
new_series.add(name)
|
||||||
|
|
||||||
if version:
|
if os.path.isdir(os.path.join(source_dir, '.git')):
|
||||||
# Export rebased branch from stable-rt git as patch series
|
# Export rebased branch from stable-rt git as patch series
|
||||||
up_ver = re.sub(r'-rt\d+$', '', version)
|
up_ver = re.sub(r'-rt\d+$', '', version)
|
||||||
args = ['git', 'format-patch', 'v%s..v%s-rebase' % (up_ver, version)]
|
args = ['git', 'format-patch', 'v%s..v%s-rebase' % (up_ver, version)]
|
||||||
|
@ -35,18 +49,24 @@ def main(source_dir, version=None):
|
||||||
with child.stdout as pipe:
|
with child.stdout as pipe:
|
||||||
for line in pipe:
|
for line in pipe:
|
||||||
name = line.strip('\n')
|
name = line.strip('\n')
|
||||||
add_patch(name)
|
with open(os.path.join(patch_dir, rt_patch_dir, name)) as \
|
||||||
|
source_patch:
|
||||||
|
patch_from = source_patch.readline()
|
||||||
|
match = re.match(r'From ([0-9a-f]{40}) ', patch_from)
|
||||||
|
assert match
|
||||||
|
origin = 'https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=%s' % match.group(1)
|
||||||
|
add_patch(name, source_patch, origin)
|
||||||
else:
|
else:
|
||||||
# Copy patch series
|
# Copy patch series
|
||||||
|
up_ver = re.sub(r'(\d+\.\d+)(?:\.\d+)?-rt\d+$', r'\1', version)
|
||||||
|
origin = 'https://www.kernel.org/pub/linux/kernel/projects/rt/%s/patches-%s.tar.xz' % (up_ver, version)
|
||||||
with open(os.path.join(source_dir, 'series'), 'r') as \
|
with open(os.path.join(source_dir, 'series'), 'r') as \
|
||||||
source_series_fh:
|
source_series_fh:
|
||||||
for line in source_series_fh:
|
for line in source_series_fh:
|
||||||
name = line.strip()
|
name = line.strip()
|
||||||
if name != '' and name[0] != '#':
|
if name != '' and name[0] != '#':
|
||||||
shutil.copyfile(os.path.join(source_dir, name),
|
with open(os.path.join(source_dir, name)) as source_patch:
|
||||||
os.path.join(patch_dir, rt_patch_dir,
|
add_patch(name, source_patch, origin)
|
||||||
name))
|
|
||||||
add_patch(name)
|
|
||||||
else:
|
else:
|
||||||
# Leave comments and empty lines unchanged
|
# Leave comments and empty lines unchanged
|
||||||
series_fh.write(line)
|
series_fh.write(line)
|
||||||
|
@ -61,9 +81,8 @@ def main(source_dir, version=None):
|
||||||
print 'Obsoleted patch', os.path.join(patch_dir, name)
|
print 'Obsoleted patch', os.path.join(patch_dir, name)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) not in [2, 3]:
|
if len(sys.argv) != 3:
|
||||||
print >>sys.stderr, '''\
|
print >>sys.stderr, 'Usage: %s DIR RT-VERSION' % sys.argv[0]
|
||||||
Usage: %s REPO RT-VERSION
|
print >>sys.stderr, 'DIR is either a git repo or quilt directory containing the given RT-VERSION.'
|
||||||
%s QUILT-DIR''' % (sys.argv[0], sys.argv[0])
|
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
main(*sys.argv[1:])
|
main(sys.argv[1], sys.argv[2])
|
||||||
|
|
Loading…
Reference in New Issue