[rt] Fold convert-series into genpatch.py

In the process, stop stripping localversion.patch from an upstream
patch series, which we already stopped doing when exporting patches
from git.

svn path=/dists/trunk/linux/; revision=20310
This commit is contained in:
Ben Hutchings 2013-07-01 03:29:39 +00:00
parent 655014b03d
commit 326f255d1f
3 changed files with 34 additions and 28 deletions

1
debian/changelog vendored
View File

@ -5,6 +5,7 @@ linux (3.10~rc7-1~exp2) UNRELEASED; urgency=low
for most patches
* aufs: Add DEP-5 headers to generated/copied patches
* [rt] Make genpatch.py work with upstream patch series as well as git
- Fold convert-series into genpatch.py
-- Ben Hutchings <ben@decadent.org.uk> Mon, 01 Jul 2013 00:58:08 +0100

View File

@ -1,5 +0,0 @@
#!/bin/sh
# Add directory prefix to all filenames, but leave comments and
# empty lines unchanged. Also comment out localversion.patch.
sed -r -e 's,^localversion.patch,#&,' -e 's,^[^# \t],features/all/rt/&,' "debian/patches/features/all/rt/series" > debian/patches/series-rt

View File

@ -3,41 +3,53 @@
import os, os.path, re, shutil, subprocess, sys
def main(source_dir, version=None):
patch_dir = 'debian/patches/features/all/rt'
patch_dir = 'debian/patches'
rt_patch_dir = 'features/all/rt'
series_name = 'series-rt'
old_series = set()
new_series = set()
with open(os.path.join(patch_dir, 'series'), 'r') as series_fh:
with open(os.path.join(patch_dir, series_name), 'r') as series_fh:
for line in series_fh:
name = line.strip()
if name != '' and name[0] != '#':
old_series.add(name)
if version:
# Export rebased branch from stable-rt git as patch series
up_ver = re.sub(r'-rt\d+$', '', version)
with open(os.path.join(patch_dir, 'series'), 'w') as series_fh:
with open(os.path.join(patch_dir, series_name), 'w') as series_fh:
# Add directory prefix to all filenames
def add_patch(name):
name = os.path.join(rt_patch_dir, name)
series_fh.write(name)
series_fh.write('\n')
new_series.add(name)
if version:
# Export rebased branch from stable-rt git as patch series
up_ver = re.sub(r'-rt\d+$', '', version)
args = ['git', 'format-patch', 'v%s..v%s-rebase' % (up_ver, version)]
env = os.environ.copy()
env['GIT_DIR'] = os.path.join(source_dir, '.git')
child = subprocess.Popen(args, cwd=patch_dir, env=env,
stdout=subprocess.PIPE)
child = subprocess.Popen(args,
cwd=os.path.join(patch_dir, rt_patch_dir),
env=env, stdout=subprocess.PIPE)
with child.stdout as pipe:
for line in pipe:
series_fh.write(line)
name = line.strip('\n')
new_series.add(name)
else:
# Copy patch series
shutil.copyfile(os.path.join(source_dir, 'series'),
os.path.join(patch_dir, 'series'))
with open(os.path.join(patch_dir, 'series'), 'r') as series_fh:
for line in series_fh:
name = line.strip()
if name != '' and name[0] != '#':
shutil.copyfile(os.path.join(source_dir, name),
os.path.join(patch_dir, name))
new_series.add(name)
add_patch(name)
else:
# Copy patch series
with open(os.path.join(source_dir, 'series'), 'r') as \
source_series_fh:
for line in source_series_fh:
name = line.strip()
if name != '' and name[0] != '#':
shutil.copyfile(os.path.join(source_dir, name),
os.path.join(patch_dir, rt_patch_dir,
name))
add_patch(name)
else:
# Leave comments and empty lines unchanged
series_fh.write(line)
for name in new_series:
if name in old_series:
@ -48,8 +60,6 @@ def main(source_dir, version=None):
for name in old_series:
print 'Obsoleted patch', os.path.join(patch_dir, name)
subprocess.check_call([os.path.join(patch_dir, 'convert-series')])
if __name__ == '__main__':
if len(sys.argv) not in [2, 3]:
print >>sys.stderr, '''\