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/>.
19
# this is only used if no distro_info available
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"},
19
# this is patched over the top of distro_info
20
# to allow newer data here then available in the pkg installed distro_info
34
22
from simplestreams.log import LOG
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),
40
def _get_fulldata(version, full_codename, lts):
41
codename = full_codename.split()[0].lower()
45
'release_title': "%s LTS" % version if lts else version,
46
'release_codename': full_codename,
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
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"
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)
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})
112
__HARDCODED_REL2VER = {}
113
for __t in __RELEASE_DATA:
114
__v = _get_fulldata(*__t)
115
__HARDCODED_REL2VER[__v['codename']] = __v
92
119
import distro_info
93
120
info = get_ubuntu_info()
96
123
if r['codename'] < "hardy":
98
REL2VER[r['codename']] = {x: r[x] for x in ("version", "devname")}
125
REL2VER[r['codename']] = r.copy()
127
for r in __HARDCODED_REL2VER:
129
REL2VER[r] = __HARDCODED_REL2VER[r]
100
131
except ImportError:
101
REL2VER = HARDCODED_REL2VER
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
142
if __name__ == '__main__':
144
print(json.dumps(REL2VER, indent=1))