~ubuntu-branches/ubuntu/wily/simplestreams/wily-proposed

« back to all changes in this revision

Viewing changes to tools/ubuntu_versions.py

  • Committer: Package Import Robot
  • Author(s): Scott Moser
  • Date: 2015-09-24 21:53:46 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20150924215346-ijw9jcrq49fchix8
Tags: 0.1.0~bzr400-0ubuntu1
* New upstream snapshot.
  - sstream-mirror, sstream-query, sstream-sync: add --no-verify
    flag (LP: #1249018)
  - pep8/flake8 cleanups
  - several closing of filehandle fixes (LP: #1461181)
  - GlanceMirror fix stack trace if no matching entries (LP: #1353724)
  - tools: upstream development tools fixes (not shipped in ubuntu)
  - GlanceMirror: change known Ubuntu arches into appropriate glance
    arch values (LP: #1483159)
  - Ensure all users of 'sync' get checksumming of content by default.
    insert_item now provides a content source that does checksumming
    during reads and raises exception on error (LP: #1487004)
* debian/README.source: add file, doc how to take upstream snapshot
* debian/rules: export SS_REQUIRE_DISTRO_INFO so that test
  runs without a dependency on distro-info

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#   You should have received a copy of the GNU Affero General Public License
17
17
#   along with Simplestreams.  If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
 
# this is only used if no distro_info available
20
 
HARDCODED_REL2VER = {
21
 
    "hardy": {'version': "8.04", 'devname': "Hardy Heron"},
22
 
    "lucid": {'version': "10.04", 'devname': "Lucid Lynx"},
23
 
    "oneiric": {'version': "11.10", 'devname': "Oneiric Ocelot"},
24
 
    "precise": {'version': "12.04", 'devname': "Precise Pangolin"},
25
 
    "quantal": {'version': "12.10", 'devname': "Quantal Quetzal"},
26
 
    "raring": {'version': "13.04", 'devname': "Raring Ringtail"},
27
 
    "saucy": {'version': "13.10", 'devname': "Saucy Salamander"},
28
 
    "trusty": {'version': "14.04", 'devname': "Trusty Tahr"},
29
 
    "utopic": {'version': "14.10", 'devname': "Utopic Unicorn"},
30
 
    "vivid": {'version': "15.04", 'devname': "Vivid Vervet"},
31
 
    "vivid": {'version': "15.10", 'devname': "Wily Werewolf"},
32
 
}
 
19
# this is patched over the top of distro_info
 
20
# to allow newer data here then available in the pkg installed distro_info
33
21
 
34
22
from simplestreams.log import LOG
35
23
 
 
24
__RELEASE_DATA = (
 
25
    # version, full codename, lts
 
26
    ("8.04", "Hardy Heron", True),
 
27
    ("10.04", "Lucid Lynx", True),
 
28
    ("11.10", "Oneiric Ocelot", False),
 
29
    ("12.04", "Precise Pangolin", True),
 
30
    ("12.10", "Quantal Quetzal", False),
 
31
    ("13.04", "Raring Ringtail", False),
 
32
    ("13.10", "Saucy Salamander", False),
 
33
    ("14.04", "Trusty Tahr", True),
 
34
    ("14.10", "Utopic Unicorn", False),
 
35
    ("15.04", "Vivid Vervet", False),
 
36
    ("15.10", "Wily Werewolf", False),
 
37
)
 
38
 
 
39
 
 
40
def _get_fulldata(version, full_codename, lts):
 
41
    codename = full_codename.split()[0].lower()
 
42
    return {
 
43
        'codename': codename,
 
44
        'lts': lts,
 
45
        'release_title': "%s LTS" % version if lts else version,
 
46
        'release_codename': full_codename,
 
47
        'version': version,
 
48
    }
 
49
 
36
50
 
37
51
def get_ubuntu_info(date=None):
38
52
    # this returns a sorted list of dicts
40
54
    # Notably absent is any date information (release or eol)
41
55
    # its harder than you'd like to get at data via the distro_info library
42
56
    #
43
 
    # The resultant dicts looks like this:
44
 
    # {'codename': 'saucy', 'devel': True,
45
 
    #  'full_codename': 'Saucy Salamander',
46
 
    #  'fullname': 'Ubuntu 13.10 "Saucy Salamander"',
47
 
    #  'lts': False, 'supported': True, 'version': '13.10'}
 
57
    # The resultant dicts have the following fields:
 
58
    #  codename: single word codename of ubuntu release ('saucy' or 'trusty')
 
59
    #  devel: boolean, is this the current development release
 
60
    #  lts: boolean, is this release an LTS
 
61
    #  supported: boolean: is this release currently supported
 
62
    #  release_codename: the full code name ('Saucy Salamander', 'Trusty Tahr')
 
63
    #  version: the numeric portion only ('13.10', '14.04')
 
64
    #  release_title: numeric portion + " LTS" if this is an lts
 
65
    #                 '13.10', '14.04 LTS"
48
66
 
49
67
    udi = distro_info.UbuntuDistroInfo()
50
68
    # 'all' is a attribute, not a function. so we can't ask for it formated.
78
96
                 " Using stable release as devel.", e)
79
97
        devel = udi.stable(date=date)
80
98
    ret = []
 
99
 
81
100
    for i, codename in enumerate(codenames):
 
101
        title = "%s LTS" % versions[i] if lts[i] else versions[i]
82
102
        ret.append({'lts': lts[i], 'version': versions[i],
83
103
                    'supported': codename in supported,
84
 
                    'fullname': fullnames[i], 'codename': codename,
85
 
                    'devname': full_codenames[i],
86
 
                    'devel': bool(codename == devel)})
 
104
                    'codename': codename,
 
105
                    'release_codename': full_codenames[i],
 
106
                    'devel': bool(codename == devel),
 
107
                    'release_title': title})
87
108
 
88
109
    return ret
89
110
 
90
111
 
 
112
__HARDCODED_REL2VER = {}
 
113
for __t in __RELEASE_DATA:
 
114
    __v = _get_fulldata(*__t)
 
115
    __HARDCODED_REL2VER[__v['codename']] = __v
 
116
 
 
117
 
91
118
try:
92
119
    import distro_info
93
120
    info = get_ubuntu_info()
95
122
    for r in info:
96
123
        if r['codename'] < "hardy":
97
124
            continue
98
 
        REL2VER[r['codename']] = {x: r[x] for x in ("version", "devname")}
 
125
        REL2VER[r['codename']] = r.copy()
 
126
 
 
127
    for r in __HARDCODED_REL2VER:
 
128
        if r not in REL2VER:
 
129
            REL2VER[r] = __HARDCODED_REL2VER[r]
99
130
 
100
131
except ImportError:
101
 
    REL2VER = HARDCODED_REL2VER
 
132
    import os
 
133
    import sys
 
134
    if os.environ.get("SS_REQUIRE_DISTRO_INFO", "1") not in ("0"):
 
135
        pkg = "python3-distro-info"
 
136
        if sys.version_info.major == 2:
 
137
            pkg = "python-distro-info"
 
138
        raise ValueError("Please install package %s "
 
139
                         "or set SS_REQUIRE_DISTRO_INFO=0" % pkg)
 
140
    REL2VER = __HARDCODED_REL2VER
 
141
 
 
142
if __name__ == '__main__':
 
143
    import json
 
144
    print(json.dumps(REL2VER, indent=1))