~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/buildd/debian/upgrade-config

  • Committer: mbp at canonical
  • Date: 2011-11-20 23:37:23 UTC
  • mto: This revision was merged to the branch mainline in revision 14344.
  • Revision ID: mbp@canonical.com-20111120233723-370p96db2crru5tm
Delete canonical.buildd again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
#
3
 
# Copyright 2009, 2010 Canonical Ltd.  This software is licensed under the
4
 
# GNU Affero General Public License version 3 (see the file LICENSE).
5
 
 
6
 
"""Upgrade a launchpad-buildd configuration file."""
7
 
 
8
 
import sys
9
 
import os
10
 
import subprocess
11
 
 
12
 
(old_version, conf_file) = sys.argv[1:]
13
 
 
14
 
def upgrade_to_12():
15
 
    print "Upgrading %s to version 12" % conf_file
16
 
    subprocess.call(["mv", conf_file, conf_file+"-prev12~"])
17
 
    in_file = open(conf_file+"-prev12~", "r")
18
 
    out_file = open(conf_file, "w")
19
 
    for line in in_file:
20
 
        if line.startswith("[debianmanager]"):
21
 
            line += "ogrepath = /usr/share/launchpad-buildd/slavebin/apply-ogre-model\n"
22
 
        if line.startswith("sbuildargs"):
23
 
            line = line.replace("-A", "")
24
 
        out_file.write(line)
25
 
    in_file.close()
26
 
    out_file.close()
27
 
 
28
 
def upgrade_to_34():
29
 
    print "Upgrading %s to version 34" % conf_file
30
 
    subprocess.call(["mv", conf_file, conf_file+"-prev34~"])
31
 
    in_file = open(conf_file+"-prev34~", "r")
32
 
    out_file = open(conf_file, "w")
33
 
    for line in in_file:
34
 
        if line.startswith("[debianmanager]"):
35
 
            line += "sourcespath = /usr/share/launchpad-buildd/slavebin/override-sources-list\n"
36
 
        out_file.write(line)
37
 
    in_file.close()
38
 
    out_file.close()
39
 
 
40
 
def upgrade_to_39():
41
 
    print "Upgrading %s to version 39" % conf_file
42
 
    subprocess.call(["mv", conf_file, conf_file+"-prev39~"])
43
 
    in_file = open(conf_file+"-prev39~", "r")
44
 
    out_file = open(conf_file, "w")
45
 
    for line in in_file:
46
 
        if line.startswith("sbuildargs"):
47
 
            line = line.replace("-dautobuild ","")
48
 
        if line.startswith("[slave]"):
49
 
            line += "ntphost = ntp.buildd\n"
50
 
        out_file.write(line)
51
 
    in_file.close()
52
 
    out_file.close()
53
 
 
54
 
def upgrade_to_57():
55
 
    print "Upgrading %s to version 57" % conf_file
56
 
    subprocess.call(["mv", conf_file, conf_file+"-prev57~"])
57
 
    in_file = open(conf_file+"-prev57~", "r")
58
 
    out_file = open(conf_file, "w")
59
 
    # We want to move all the sbuild lines to a new
60
 
    # 'binarypackagemanager' section at the end.
61
 
    binarypackage_lines = []
62
 
    for line in in_file:
63
 
        if line.startswith("sbuild"):
64
 
            binarypackage_lines.append(line)
65
 
        else:
66
 
            out_file.write(line)
67
 
    out_file.write('[binarypackagemanager]\n')
68
 
    for line in binarypackage_lines:
69
 
        out_file.write(line)
70
 
    in_file.close()
71
 
    out_file.close()
72
 
 
73
 
def upgrade_to_58():
74
 
    print "Upgrading %s to version 58" % conf_file
75
 
    subprocess.call(["mv", conf_file, conf_file+"-prev58~"])
76
 
    in_file = open(conf_file+"-prev58~", "r")
77
 
    out_file = open(conf_file, "w")
78
 
    out_file.write(in_file.read())
79
 
    out_file.write(
80
 
        '\n[sourcepackagerecipemanager]\n'
81
 
        'buildrecipepath = /usr/share/launchpad-buildd'
82
 
        '/slavebin/buildrecipe\n')
83
 
 
84
 
def upgrade_to_59():
85
 
    print "Upgrading %s to version 59" % conf_file
86
 
    subprocess.call(["mv", conf_file, conf_file+"-prev59~"])
87
 
    in_file = open(conf_file+"-prev59~", "r")
88
 
    out_file = open(conf_file, "w")
89
 
    out_file.write(in_file.read())
90
 
    out_file.write(
91
 
        '\n[translationtemplatesmanager]\n'
92
 
        'generatepath = /usr/share/launchpad-buildd/slavebin/generate-translation-templates\n'
93
 
        'resultarchive = translation-templates.tar.gz\n')
94
 
 
95
 
def upgrade_to_63():
96
 
    print "Upgrading %s to version 63" % conf_file
97
 
    subprocess.call(["mv", conf_file, conf_file+"-prev63~"])
98
 
    in_file = open(conf_file+"-prev63~", "r")
99
 
    out_file = open(conf_file, "w")
100
 
    for line in in_file:
101
 
        if not line.startswith('ogrepath'):
102
 
            out_file.write(line)
103
 
 
104
 
 
105
 
if __name__ == "__main__":
106
 
    if old_version.find("~") > 0:
107
 
        old_version = old_version[:old_version.find("~")]
108
 
    if int(old_version) < 12:
109
 
        upgrade_to_12()
110
 
    if int(old_version) < 34:
111
 
        upgrade_to_34()
112
 
    if int(old_version) < 39:
113
 
        upgrade_to_39()
114
 
    if int(old_version) < 57:
115
 
        upgrade_to_57()
116
 
    if int(old_version) < 58:
117
 
        upgrade_to_58()
118
 
    if int(old_version) < 59:
119
 
        upgrade_to_59()
120
 
    if int(old_version) < 63:
121
 
        upgrade_to_63()
122