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
=== modified file 'debian/local/python-mkdebian'
--- debian/local/python-mkdebian 2009-07-20 14:42:28 +0000
+++ debian/local/python-mkdebian 2009-07-21 09:10:54 +0000
@@ -128,53 +128,66 @@
128 print 'Package uses KDE *.ui files, adding python-kde4-dev build dependency'128 print 'Package uses KDE *.ui files, adding python-kde4-dev build dependency'
129 bdeps += ',\n python-kde4-dev'129 bdeps += ',\n python-kde4-dev'
130130
131 # prepare tags
132 control_content = {
133 'Source': egg['Name'],
134 'Build-Depends': '''cdbs (>= 0.4.43),
135 debhelper (>= 6),
136 python,
137 python-central (>= 0.6.11),
138 python-distutils-extra (>= 2.6)%s''' % bdeps,
139 'Maintainer': author,
140 'Package': egg['Name'],
141 'Depends': '''${misc:Depends},
142 ${python:Depends}%s''' % ',\n '.join(['',] + list(deps)),
143 'Description' : egg.get('Summary', '') + '\n '.join(['',] + list(textwrap.wrap(egg.get('Description', ''), 72)))
144 }
145
146
131 if not os.path.exists('debian/control'):147 if not os.path.exists('debian/control'):
132 f = open('debian/control', 'w')148 f = open('debian/control', 'w')
133 f.write('''Source: %(name)s149 f.write('''Source: %(Source)s
134Section: python150Section: python
135Priority: extra151Priority: extra
136Build-Depends: cdbs (>= 0.4.43),152Build-Depends: %(Build-Depends)s
137 debhelper (>= 6),153Maintainer: %(Maintainer)s
138 python,
139 python-central (>= 0.6.11),
140 python-distutils-extra (>= 2.6)%(bdep)s
141Maintainer: %(maint)s
142Standards-Version: 3.8.2154Standards-Version: 3.8.2
143XS-Python-Version: current155XS-Python-Version: current
144156
145Package: %(name)s157Package: %(Package)s
146Architecture: all158Architecture: all
147XB-Python-Version: ${python:Versions}159XB-Python-Version: ${python:Versions}
148Depends: ${misc:Depends},160Depends: ${misc:Depends},
149 ${python:Depends}%(depends)s161 ${python:Depends}%(Depends)s
150Description: %(desc)s162Description: %(Description)s
151 %(longdesc)s163''' % control_content)
152''' % {'name': egg['Name'], 'maint': author,
153 'depends': ',\n '.join(['',] + list(deps)),
154 'desc': egg.get('Summary', ''),
155 'longdesc': '\n '.join(textwrap.wrap(egg.get('Description', ''), 72)),
156 'bdep': bdeps})
157 f.close()164 f.close()
158 else:165 else:
159 # update debian/control166 # update debian/control
160 in_ = open('debian/control')167 in_ = open('debian/control')
161 out = open('debian/control.new', 'w')168 out = open('debian/control.new', 'w')
169 skip_write_until_new_key = False
162 try:170 try:
163 for line in in_:171 for line in in_:
164 if line.startswith('Depends:'):172
165 break173 # toggle the switch to off if we encounter a new key not overwritten
166 out.write(line)174 # don't do it after the for loop otherwise the effect will be drawned
167
168 # skip over original depends, and write our own
169 print >> out, 'Depends: ${misc:Depends},\n ${python:Depends}%s' % \
170 ',\n '.join(['',] + list(deps))
171
172 for line in in_:
173 if not line.startswith(' '):175 if not line.startswith(' '):
176 skip_until_new_key = False
177
178 for controlkey in control_content:
179 if line.startswith(controlkey):
180 # skip old values and write our own
181 out.write('%s: %s\n' % (controlkey, control_content[controlkey]))
182 skip_until_new_key = True
183 break
184
185 # write current line if not in a overwritten section
186 if not skip_until_new_key:
174 out.write(line)187 out.write(line)
175 break188
176 for line in in_:189 out.close()
177 out.write(line)190 in_.close()
178 except:191 except:
179 os.unlink('debian/control.new')192 os.unlink('debian/control.new')
180 raise193 raise

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: