Created
September 8, 2010 12:25
-
-
Save lidaobing/570049 to your computer and use it in GitHub Desktop.
switch-debian-control.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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