Skip to content

Instantly share code, notes, and snippets.

@lidaobing
Created September 8, 2010 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lidaobing/570049 to your computer and use it in GitHub Desktop.
Save lidaobing/570049 to your computer and use it in GitHub Desktop.
switch-debian-control.py
#!/usr/bin/env python
import logging
import sys
log = logging.getLogger(__name__)
def main():
lines = file('debian/control').readlines()
l1 = None
l2 = None
for idx, x in enumerate(lines):
if x.startswith('Maintainer:'):
l1 = idx
elif x.startswith('XSBC-Original-Maintainer:'):
l2 = idx
if l1 is None:
log.error("can't find maintainer line")
sys.exit(1)
isUbuntu = l2 is not None
if isUbuntu:
maintainer = lines[l2].lstrip('XSBC-Original-Maintainer:').strip()
else:
maintainer = lines[l1].lstrip('Maintainer:').strip()
if isUbuntu:
lines[l1] = 'Maintainer: %s\n' % maintainer
del lines[l2]
else:
lines[l1] = 'Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>\n' \
+ 'XSBC-Original-Maintainer: %s\n' % maintainer
file('debian/control', 'w').writelines(lines)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment