Merge lp:~didrocks/python-distutils-extra/update_control_file into lp:python-distutils-extra

Proposed by Didier Roche-Tolomelli
Status: Merged
Merged at revision: not available
Proposed branch: lp:~didrocks/python-distutils-extra/update_control_file
Merge into: lp:python-distutils-extra
Diff against target: None lines
To merge this branch: bzr merge lp:~didrocks/python-distutils-extra/update_control_file
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Didier Roche-Tolomelli (community) Needs Resubmitting
Review via email: mp+9090@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Your new branch changes the entire debian/control. I deliberately didn't do that, since the user might make customizations.

If you really want that, you could just have quickly unlink debian/control before calling python-mkdebian, or add a --force-control switch?

review: Needs Fixing
124. By Didier Roche-Tolomelli

add --force-control as a switch to update only depends or whole control file

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

I don't really agree with the "changing entire debian/control" expression. This code just updates only the autogenerated fields depending on project and setup.py file.
That is to say, if someone bumps the Standards-Version: 3.8.2 or XS-Python-Version:, they remain pristine.
Even if user change the fields order or adds its own fields, their're keep untouched.

That's true that keeping an history can be better for automatic merging, even for automated fields, but I really think that setup.py and debian/control may stay in sync for impacted fields.

Nevertheless, here is a new proposal with --force-control switch.

review: Needs Resubmitting
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks, merged with a few cleanups.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/local/python-mkdebian'
2--- debian/local/python-mkdebian 2009-07-20 14:42:28 +0000
3+++ debian/local/python-mkdebian 2009-07-21 09:10:54 +0000
4@@ -128,53 +128,66 @@
5 print 'Package uses KDE *.ui files, adding python-kde4-dev build dependency'
6 bdeps += ',\n python-kde4-dev'
7
8+ # prepare tags
9+ control_content = {
10+ 'Source': egg['Name'],
11+ 'Build-Depends': '''cdbs (>= 0.4.43),
12+ debhelper (>= 6),
13+ python,
14+ python-central (>= 0.6.11),
15+ python-distutils-extra (>= 2.6)%s''' % bdeps,
16+ 'Maintainer': author,
17+ 'Package': egg['Name'],
18+ 'Depends': '''${misc:Depends},
19+ ${python:Depends}%s''' % ',\n '.join(['',] + list(deps)),
20+ 'Description' : egg.get('Summary', '') + '\n '.join(['',] + list(textwrap.wrap(egg.get('Description', ''), 72)))
21+ }
22+
23+
24 if not os.path.exists('debian/control'):
25 f = open('debian/control', 'w')
26- f.write('''Source: %(name)s
27+ f.write('''Source: %(Source)s
28 Section: python
29 Priority: extra
30-Build-Depends: cdbs (>= 0.4.43),
31- debhelper (>= 6),
32- python,
33- python-central (>= 0.6.11),
34- python-distutils-extra (>= 2.6)%(bdep)s
35-Maintainer: %(maint)s
36+Build-Depends: %(Build-Depends)s
37+Maintainer: %(Maintainer)s
38 Standards-Version: 3.8.2
39 XS-Python-Version: current
40
41-Package: %(name)s
42+Package: %(Package)s
43 Architecture: all
44 XB-Python-Version: ${python:Versions}
45 Depends: ${misc:Depends},
46- ${python:Depends}%(depends)s
47-Description: %(desc)s
48- %(longdesc)s
49-''' % {'name': egg['Name'], 'maint': author,
50- 'depends': ',\n '.join(['',] + list(deps)),
51- 'desc': egg.get('Summary', ''),
52- 'longdesc': '\n '.join(textwrap.wrap(egg.get('Description', ''), 72)),
53- 'bdep': bdeps})
54+ ${python:Depends}%(Depends)s
55+Description: %(Description)s
56+''' % control_content)
57 f.close()
58 else:
59 # update debian/control
60 in_ = open('debian/control')
61 out = open('debian/control.new', 'w')
62+ skip_write_until_new_key = False
63 try:
64 for line in in_:
65- if line.startswith('Depends:'):
66- break
67- out.write(line)
68-
69- # skip over original depends, and write our own
70- print >> out, 'Depends: ${misc:Depends},\n ${python:Depends}%s' % \
71- ',\n '.join(['',] + list(deps))
72-
73- for line in in_:
74+
75+ # toggle the switch to off if we encounter a new key not overwritten
76+ # don't do it after the for loop otherwise the effect will be drawned
77 if not line.startswith(' '):
78+ skip_until_new_key = False
79+
80+ for controlkey in control_content:
81+ if line.startswith(controlkey):
82+ # skip old values and write our own
83+ out.write('%s: %s\n' % (controlkey, control_content[controlkey]))
84+ skip_until_new_key = True
85+ break
86+
87+ # write current line if not in a overwritten section
88+ if not skip_until_new_key:
89 out.write(line)
90- break
91- for line in in_:
92- out.write(line)
93+
94+ out.close()
95+ in_.close()
96 except:
97 os.unlink('debian/control.new')
98 raise

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: