Skip to content

Commit

Permalink
build: update get-debian-name.py
Browse files Browse the repository at this point in the history
ship with csv files from distro-info-data 0.60ubuntu0.2.
  • Loading branch information
Chilledheart committed Oct 28, 2024
1 parent 64d5ae4 commit fc00255
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 24 deletions.
22 changes: 22 additions & 0 deletions scripts/distro-info/debian.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version,codename,series,created,release,eol,eol-lts,eol-elts
1.1,Buzz,buzz,1993-08-16,1996-06-17,1997-06-05
1.2,Rex,rex,1996-06-17,1996-12-12,1998-06-05
1.3,Bo,bo,1996-12-12,1997-06-05,1999-03-09
2.0,Hamm,hamm,1997-06-05,1998-07-24,2000-03-09
2.1,Slink,slink,1998-07-24,1999-03-09,2000-10-30
2.2,Potato,potato,1999-03-09,2000-08-15,2003-06-30
3.0,Woody,woody,2000-08-15,2002-07-19,2006-06-30
3.1,Sarge,sarge,2002-07-19,2005-06-06,2008-03-31
4.0,Etch,etch,2005-06-06,2007-04-08,2010-02-15
5.0,Lenny,lenny,2007-04-08,2009-02-14,2012-02-06
6.0,Squeeze,squeeze,2009-02-14,2011-02-06,2014-05-31,2016-02-29
7,Wheezy,wheezy,2011-02-06,2013-05-04,2016-04-25,2018-05-31,2020-06-30
8,Jessie,jessie,2013-05-04,2015-04-26,2018-06-17,2020-06-30,2025-06-30
9,Stretch,stretch,2015-04-26,2017-06-17,2020-07-18,2022-06-30,2027-06-30
10,Buster,buster,2017-06-17,2019-07-06,2022-09-10,2024-06-30,2029-06-30
11,Bullseye,bullseye,2019-07-06,2021-08-14,2024-08-14,2026-08-31,2031-06-30
12,Bookworm,bookworm,2021-08-14,2023-06-10,2026-06-10,2028-06-30,2033-06-30
13,Trixie,trixie,2023-06-10
14,Forky,forky,2025-08-01
,Sid,sid,1993-08-16
,Experimental,experimental,1993-08-16
43 changes: 43 additions & 0 deletions scripts/distro-info/ubuntu.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version,codename,series,created,release,eol,eol-server,eol-esm
4.10,Warty Warthog,warty,2004-03-05,2004-10-20,2006-04-30
5.04,Hoary Hedgehog,hoary,2004-10-20,2005-04-08,2006-10-31
5.10,Breezy Badger,breezy,2005-04-08,2005-10-12,2007-04-13
6.06 LTS,Dapper Drake,dapper,2005-10-12,2006-06-01,2009-07-14,2011-06-01
6.10,Edgy Eft,edgy,2006-06-01,2006-10-26,2008-04-25
7.04,Feisty Fawn,feisty,2006-10-26,2007-04-19,2008-10-19
7.10,Gutsy Gibbon,gutsy,2007-04-19,2007-10-18,2009-04-18
8.04 LTS,Hardy Heron,hardy,2007-10-18,2008-04-24,2011-05-12,2013-05-09
8.10,Intrepid Ibex,intrepid,2008-04-24,2008-10-30,2010-04-30
9.04,Jaunty Jackalope,jaunty,2008-10-30,2009-04-23,2010-10-23
9.10,Karmic Koala,karmic,2009-04-23,2009-10-29,2011-04-30
10.04 LTS,Lucid Lynx,lucid,2009-10-29,2010-04-29,2013-05-09,2015-04-30
10.10,Maverick Meerkat,maverick,2010-04-29,2010-10-10,2012-04-10
11.04,Natty Narwhal,natty,2010-10-10,2011-04-28,2012-10-28
11.10,Oneiric Ocelot,oneiric,2011-04-28,2011-10-13,2013-05-09
12.04 LTS,Precise Pangolin,precise,2011-10-13,2012-04-26,2017-04-28,2017-04-28,2019-04-26
12.10,Quantal Quetzal,quantal,2012-04-26,2012-10-18,2014-05-16
13.04,Raring Ringtail,raring,2012-10-18,2013-04-25,2014-01-27
13.10,Saucy Salamander,saucy,2013-04-25,2013-10-17,2014-07-17
14.04 LTS,Trusty Tahr,trusty,2013-10-17,2014-04-17,2019-04-25,2019-04-25,2024-04-25
14.10,Utopic Unicorn,utopic,2014-04-17,2014-10-23,2015-07-23
15.04,Vivid Vervet,vivid,2014-10-23,2015-04-23,2016-02-04
15.10,Wily Werewolf,wily,2015-04-23,2015-10-22,2016-07-28
16.04 LTS,Xenial Xerus,xenial,2015-10-22,2016-04-21,2021-04-30,2021-04-30,2026-04-23
16.10,Yakkety Yak,yakkety,2016-04-21,2016-10-13,2017-07-20
17.04,Zesty Zapus,zesty,2016-10-13,2017-04-13,2018-01-13
17.10,Artful Aardvark,artful,2017-04-13,2017-10-19,2018-07-19
18.04 LTS,Bionic Beaver,bionic,2017-10-19,2018-04-26,2023-05-31,2023-05-31,2028-04-26
18.10,Cosmic Cuttlefish,cosmic,2018-04-26,2018-10-18,2019-07-18
19.04,Disco Dingo,disco,2018-10-18,2019-04-18,2020-01-23
19.10,Eoan Ermine,eoan,2019-04-18,2019-10-17,2020-07-17
20.04 LTS,Focal Fossa,focal,2019-10-17,2020-04-23,2025-05-29,2025-05-29,2030-04-23
20.10,Groovy Gorilla,groovy,2020-04-23,2020-10-22,2021-07-22
21.04,Hirsute Hippo,hirsute,2020-10-22,2021-04-22,2022-01-20
21.10,Impish Indri,impish,2021-04-22,2021-10-14,2022-07-14
22.04 LTS,Jammy Jellyfish,jammy,2021-10-14,2022-04-21,2027-06-01,2027-06-01,2032-04-21
22.10,Kinetic Kudu,kinetic,2022-04-21,2022-10-20,2023-07-20
23.04,Lunar Lobster,lunar,2022-10-20,2023-04-20,2024-01-25
23.10,Mantic Minotaur,mantic,2023-04-20,2023-10-12,2024-07-11
24.04 LTS,Noble Numbat,noble,2023-10-12,2024-04-25,2029-05-31,2029-05-31,2034-04-25
24.10,Oracular Oriole,oracular,2024-04-25,2024-10-10,2025-07-10
25.04,Plucky Puffin,plucky,2024-10-10,2025-04-17,2026-01-15
75 changes: 51 additions & 24 deletions scripts/get-debian-name.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,55 @@
#!/usr/bin/env python3

import os
import subprocess

def check_string_output(command):
return subprocess.check_output(command, stderr=subprocess.STDOUT).decode().strip()

# https://wiki.debian.org/DebianReleases
# https://wiki.ubuntu.com/Releases
codenames = {
"trusty" : "ubuntu-14.04-trusty",
"xenial" : "ubuntu-16.04-xenial",
"bionic" : "ubuntu-18.04-bionic",
"focal" : "ubuntu-20.04-focal",
"impish" : "ubuntu-21.10-impish",
"jammy" : "ubuntu-22.04-jammy",
"lunar" : "ubuntu-23.04-lunar",
"mantic" : "ubuntu-23.10-mantic",
"noble" : "ubuntu-24.04-noble",
"oracular" : "ubuntu-24.10-oracular",
"stretch" : "debian-9-stretch",
"buster" : "debian-10-buster",
"bullseye" : "debian-11-bullseye",
"bookworm" : "debian-12-bookworm",
"trixie" : "debian-13-trixie",
"testing" : "debian-testing",
"sid" : "debian-sid",
}
_codenames_db = {}

def open_ubuntu_csv_file(csvpath):
import csv
with open(csvpath, newline='') as csvfile:
reader = csv.DictReader(csvfile, delimiter=',')
for row in reader:
version = row['version'].replace(' LTS', '')
codename = row['series']
key = codename
value = 'ubuntu-' + version + '-' + codename
_codenames_db[key] = value

def open_debian_csv_file(csvpath):
import csv
with open(csvpath, newline='') as csvfile:
reader = csv.DictReader(csvfile, delimiter=',')
for row in reader:
version = row['version']
codename = row['series']
key = codename
if version:
value = 'debian-' + version + '-' + codename
else:
value = 'debian-' + codename
_codenames_db[key] = value


def init_codenames_from_distro_info_data():
try:
open_ubuntu_csv_file('/usr/share/distro-info/ubuntu.csv')
except IOError:
# shipped by distro-info-data 0.60ubuntu0.2
open_ubuntu_csv_file('./distro-info/ubuntu.csv')
pass
try:
open_debian_csv_file('/usr/share/distro-info/debian.csv')
except IOError:
# shipped by distro-info-data 0.60ubuntu0.2
open_debian_csv_file('./distro-info/debian.csv')
pass

def main():
os.chdir(os.path.dirname(os.path.abspath(__file__)))
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('codename', nargs='?', help='Debian Distribution Name')
Expand All @@ -37,12 +59,17 @@ def main():
if not codename:
codename = check_string_output(['lsb_release', '-sc']).lower()

if codename in codenames:
print(codenames[codename])
init_codenames_from_distro_info_data()

if codename in _codenames_db:
print(_codenames_db[codename])
else:
id = check_string_output(['lsb_release', '-si']).lower()
release = check_string_output(['lsb_release', '-sr'])
print("%s-%s-%s" % (id, release, codename))
if codename != 'n/a':
print("%s-%s-%s" % (id, release, codename))
else:
print("%s-%s" % (id, release))

if __name__ == '__main__':
main()

0 comments on commit fc00255

Please sign in to comment.