1 #!/usr/bin/env python 2 3 """ 4 Make a repository/archive source configuration file. 5 6 Copyright (C) 2010, 2013 Paul Boddie <paul@boddie.org.uk> 7 8 This program is free software; you can redistribute it and/or modify it under 9 the terms of the GNU General Public License as published by the Free Software 10 Foundation; either version 3 of the License, or (at your option) any later 11 version. 12 13 This program is distributed in the hope that it will be useful, but WITHOUT 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 details. 17 18 You should have received a copy of the GNU General Public License along with 19 this program. If not, see <http://www.gnu.org/licenses/>. 20 """ 21 22 templates = { 23 24 "Debian" : """ 25 deb http://ftp.%(country)s.debian.org/debian %(codename)s main 26 deb-src http://ftp.%(country)s.debian.org/debian %(codename)s main 27 28 deb http://security.debian.org/ %(codename)s/updates main 29 deb-src http://security.debian.org/ %(codename)s/updates main 30 """, 31 32 "Ubuntu" : """ 33 deb http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s main universe 34 deb-src http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s main universe 35 36 deb http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-security main universe 37 deb-src http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-security main universe 38 39 deb http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-updates main universe 40 deb-src http://%(country)s.archive.ubuntu.com/ubuntu/ %(codename)s-updates main universe 41 """ 42 43 } 44 45 if __name__ == "__main__": 46 import os, sys 47 48 if len(sys.argv) < 2: 49 print "Need a filename for the generated file." 50 sys.exit(1) 51 52 elif len(sys.argv) < 3: 53 print "Need a country to generate source lists." 54 sys.exit(1) 55 56 filename, country = sys.argv[1:3] 57 distribution = os.environ["USERINSTALL_ID"] 58 codename = os.environ["USERINSTALL_CODENAME"] 59 60 try: 61 template = templates[distribution] 62 except KeyError: 63 print "Distribution %s not supported." % distribution 64 sys.exit(1) 65 66 f = open(filename, "w") 67 try: 68 f.write(template % {"codename" : codename, "country" : country}) 69 finally: 70 f.close() 71 72 # vim: tabstop=4 expandtab shiftwidth=4