Skip to content

Instantly share code, notes, and snippets.

@aslushnikov
Last active July 3, 2022 18:11
Show Gist options
  • Save aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75 to your computer and use it in GitHub Desktop.
Save aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75 to your computer and use it in GitHub Desktop.
/etc/os-release list for popular distributions

Here is a list of os-release values in all kinds of different distributions.

NAME VERSION ID VERSION_ID PLATFORM_ID VARIANT VARIANT_ID BUILD_ID ID_LIKE PRETTY_NAME HOME_URL SUPPORT_URL BUG_REPORT_URL VERSION_CODENAME UBUNTU_CODENAME PRIVACY_POLICY_URL ANSI_COLOR LOGO CPE_NAME DOCUMENTATION_URL REDHAT_BUGZILLA_PRODUCT REDHAT_BUGZILLA_PRODUCT_VERSION REDHAT_SUPPORT_PRODUCT REDHAT_SUPPORT_PRODUCT_VERSION CENTOS_MANTISBT_PROJECT CENTOS_MANTISBT_PROJECT_VERSION
Ubuntu 14.04 Ubuntu 14.04.6 LTS, Trusty Tahr ubuntu 14.04 debian Ubuntu 14.04.6 LTS http://www.ubuntu.com/ http://help.ubuntu.com/ http://bugs.launchpad.net/ubuntu/
Ubuntu 16.04 Ubuntu 16.04.7 LTS (Xenial Xerus) ubuntu 16.04 debian Ubuntu 16.04.7 LTS http://www.ubuntu.com/ http://help.ubuntu.com/ http://bugs.launchpad.net/ubuntu/ xenial xenial
Ubuntu 18.04 Ubuntu 18.04.6 LTS (Bionic Beaver) ubuntu 18.04 debian Ubuntu 18.04.6 LTS https://www.ubuntu.com/ https://help.ubuntu.com/ https://bugs.launchpad.net/ubuntu/ bionic bionic https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
Ubuntu 20.04 Ubuntu 20.04.3 LTS (Focal Fossa) ubuntu 20.04 debian Ubuntu 20.04.3 LTS https://www.ubuntu.com/ https://help.ubuntu.com/ https://bugs.launchpad.net/ubuntu/ focal focal https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
Ubuntu 22.04 Ubuntu 22.04 (Jammy Jellyfish) ubuntu 22.04 debian Ubuntu Jammy Jellyfish (development branch) https://www.ubuntu.com/ https://help.ubuntu.com/ https://bugs.launchpad.net/ubuntu/ jammy jammy https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
Ubuntu 22.04 Ubuntu 22.04 (Jammy Jellyfish) ubuntu 22.04 debian Ubuntu Jammy Jellyfish (development branch) https://www.ubuntu.com/ https://help.ubuntu.com/ https://bugs.launchpad.net/ubuntu/ jammy jammy https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
Fedora 33 Fedora 33 (Container Image) fedora 33 platform:f33 Container Image container Fedora 33 (Container Image) https://fedoraproject.org/ https://fedoraproject.org/wiki/Communicating_and_getting_help https://bugzilla.redhat.com/ https://fedoraproject.org/wiki/Legal:PrivacyPolicy 0;38;2;60;110;180 fedora-logo-icon cpe:/o:fedoraproject:fedora:33 https://docs.fedoraproject.org/en-US/fedora/f33/system-administrators-guide/ Fedora 33 Fedora 33
Fedora 34 Fedora 34 (Container Image) fedora 34 platform:f34 Container Image container Fedora 34 (Container Image) https://fedoraproject.org/ https://fedoraproject.org/wiki/Communicating_and_getting_help https://bugzilla.redhat.com/ https://fedoraproject.org/wiki/Legal:PrivacyPolicy 0;38;2;60;110;180 fedora-logo-icon cpe:/o:fedoraproject:fedora:34 https://docs.fedoraproject.org/en-US/fedora/f34/system-administrators-guide/ Fedora 34 Fedora 34
Fedora 35 Fedora Linux 35 (Container Image) fedora 35 platform:f35 Container Image container Fedora Linux 35 (Container Image) https://fedoraproject.org/ https://ask.fedoraproject.org/ https://bugzilla.redhat.com/ https://fedoraproject.org/wiki/Legal:PrivacyPolicy 0;38;2;60;110;180 fedora-logo-icon cpe:/o:fedoraproject:fedora:35 https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/ Fedora 35 Fedora 35
Fedora 36 Fedora Linux 36 (Container Image Prerelease) fedora 36 platform:f36 Container Image container Fedora Linux 36 (Container Image Prerelease) https://fedoraproject.org/ https://ask.fedoraproject.org/ https://bugzilla.redhat.com/ https://fedoraproject.org/wiki/Legal:PrivacyPolicy 0;38;2;60;110;180 fedora-logo-icon cpe:/o:fedoraproject:fedora:36 https://docs.fedoraproject.org/en-US/fedora/rawhide/system-administrators-guide/ Fedora rawhide Fedora rawhide
Arch Linux Arch Linux arch rolling Arch Linux https://archlinux.org/ https://bbs.archlinux.org/ https://bugs.archlinux.org/ 38;2;23;147;209 archlinux-logo https://wiki.archlinux.org/
CentOS 7 CentOS Linux 7 (Core) centos 7 rhel fedora CentOS Linux 7 (Core) https://www.centos.org/ https://bugs.centos.org/ 0;31 cpe:/o:centos:centos:7 centos 7 CentOS-7 7
CentOS 8 CentOS Linux 8 centos 8 platform:el8 rhel fedora CentOS Linux 8 https://centos.org/ https://bugs.centos.org/ 0;31 cpe:/o:centos:centos:8 CentOS-8 8
Debian 7 Debian GNU/Linux 7 (wheezy) debian 7 Debian GNU/Linux 7 (wheezy) http://www.debian.org/ http://www.debian.org/support/ http://bugs.debian.org/ 1;31
Debian 8 Debian GNU/Linux 8 (jessie) debian 8 Debian GNU/Linux 8 (jessie) http://www.debian.org/ http://www.debian.org/support https://bugs.debian.org/
Debian 9 Debian GNU/Linux 9 (stretch) debian 9 Debian GNU/Linux 9 (stretch) https://www.debian.org/ https://www.debian.org/support https://bugs.debian.org/ stretch
Debian 10 Debian GNU/Linux 10 (buster) debian 10 Debian GNU/Linux 10 (buster) https://www.debian.org/ https://www.debian.org/support https://bugs.debian.org/ buster
Debian 11 Debian GNU/Linux 11 (bullseye) debian 11 Debian GNU/Linux 11 (bullseye) https://www.debian.org/ https://www.debian.org/support https://bugs.debian.org/ bullseye
OpenSUSE 15 openSUSE Leap 15.3 opensuse-leap 15.3 suse opensuse openSUSE Leap 15.3 https://www.opensuse.org/ https://bugs.opensuse.org 0;32 cpe:/o:opensuse:leap:15.3
OpenSUSE 42 openSUSE Leap 42.3 opensuse 42.3 suse openSUSE Leap 42.3 https://www.opensuse.org/ https://bugs.opensuse.org 0;32 cpe:/o:opensuse:leap:42.3
Linux Mint Linux Mint 18.2 (Sonya) linuxmint 18.2 ubuntu Linux Mint 18.2 http://www.linuxmint.com/ http://forums.linuxmint.com/ http://bugs.launchpad.net/linuxmint/ sonya xenial
Scientific Linux 6
Scientific Linux 7 Scientific Linux 7.9 (Nitrogen) scientific 7.9 rhel centos fedora Scientific Linux 7.9 (Nitrogen) http://www.scientificlinux.org// mailto:scientific-linux-devel@listserv.fnal.gov 0;31 cpe:/o:scientificlinux:scientificlinux:7.9:GA Scientific Linux 7 7.9 Scientific Linux 7.9
const { execSync } = require('child_process');
const SMap = require('./smap');
const repos = [
{ name: 'Ubuntu 14.04', image: 'ubuntu:14.04' },
{ name: 'Ubuntu 16.04', image: 'ubuntu:16.04' },
{ name: 'Ubuntu 18.04', image: 'ubuntu:18.04' },
{ name: 'Ubuntu 20.04', image: 'ubuntu:20.04' },
{ name: 'Ubuntu 22.04', image: 'ubuntu:22.04' },
{ name: 'Ubuntu 22.04', image: 'ubuntu:22.04' },
{ name: 'Fedora 33', image: 'fedora:33' },
{ name: 'Fedora 34', image: 'fedora:34' },
{ name: 'Fedora 35', image: 'fedora:35' },
{ name: 'Fedora 36', image: 'fedora:36' },
{ name: 'Arch Linux', image: 'archlinux' },
{ name: 'CentOS 7', image: 'centos:centos7' },
{ name: 'CentOS 8', image: 'centos:centos8' },
{ name: 'Debian 7', image: 'debian:7' },
{ name: 'Debian 8', image: 'debian:8' },
{ name: 'Debian 9', image: 'debian:9' },
{ name: 'Debian 10', image: 'debian:10' },
{ name: 'Debian 11', image: 'debian:11' },
{ name: 'OpenSUSE 15', image: 'opensuse/leap:15' },
{ name: 'OpenSUSE 42', image: 'opensuse/leap:42' },
{ name: 'Linux Mint', image: 'vcatechnology/linux-mint' },
{ name: 'Scientific Linux 6', image: 'scientificlinux/sl:6' },
{ name: 'Scientific Linux 7', image: 'scientificlinux/sl:7' },
];
const osReleaseEntries = [];
for (const { name, image } of repos) {
console.error('processing ' + image);
try {
const result = execSync(`docker run --rm --platform linux/amd64 -t ${image} cat /etc/os-release`).toString();
osReleaseEntries.push(...result.trim().split('\n').filter(line => line.includes('=')).map(line => {
const [fieldName, fieldValue] = line.trim()
.split('=')
.map(a => a.trim())
.map(a => a.startsWith('"') && a.endsWith('"') ? a.substring(1, a.length - 1) : a);
return {name, image, fieldName, fieldValue};
}));
} catch (e) {
// Looks like there's either no docker image for some reason, or no /etc/os-release
}
}
const smap = new SMap(osReleaseEntries);
const importantFields = ['NAME', 'VERSION', 'ID', 'VERSION_ID', 'PLATFORM_ID', 'VARIANT', 'VARIANT_ID', 'BUILD_ID'];
const otherFields = smap.uniqueValues('fieldName').filter(name => !importantFields.includes(name));
const rowNames = ['', ...repos.map(repo => repo.name)];
const columnNames = ['', ...importantFields, ...otherFields];
renderMarkdownTableWithCallback(
rowNames.length,
columnNames.length,
(row, column) => {
if (row === 0 && column === 0)
return '';
if (row === 0)
return columnNames[column];
if (column === 0)
return rowNames[row];
return smap.get({
name: rowNames[row],
fieldName: columnNames[column]
})?.fieldValue ?? '';
}
);
function renderMarkdownTableWithCallback(rows, columns, callback) {
const mx = [];
for (let row = 0; row < rows; ++row) {
const r = [];
for (let column = 0; column < columns; ++column)
r.push(callback(row, column));
mx.push(r);
}
const [headers, ...rest] = mx;
// Header row
console.log('| ' + headers.join(' | ') + ' |');
// Separator
console.log('| ' + headers.map(_ => '---').join(' | ') + ' |');
// Other rows
for (const v of rest)
console.log('| ' + v.join(' | ') + ' |');
}
class SMap {
constructor(entries = []) {
this._entries = entries;
this._indexes = new Map();
this[Symbol.iterator] = () => this._entries[Symbol.iterator]();
}
map(callback) { return this._entries.map(callback); }
filter(callback) { return this._entries.filter(callback); }
slice(from, to) { return this._entries.slice(from, to); }
get size() { return this._entries.length; }
has(selector) {
const entries = this.getAll(selector);
return entries.length > 0;
}
uniqueValues(key) {
const index = this._ensureIndex([key]);
return [...index._data.keys()];
}
get(selector) {
const entries = this.getAll(selector);
return entries.length ? entries[0] : null;
}
getAll(selector) {
const keys = Object.entries(selector).filter(([key, value]) => value !== undefined).map(([key]) => key);
return this._ensureIndex(keys).getAll(selector);
}
_ensureIndex(keys) {
keys.sort();
const indexId = JSON.stringify(keys);
let index = this._indexes.get(indexId);
if (!index) {
index = new Index(this._entries, keys);
this._indexes.set(indexId, index);
}
return index;
}
}
class Index {
constructor(entries, keys) {
this._keys = keys;//keys.slice();
this._lastKey = this._keys.pop();
this._data = new Map();
for (const entry of entries) {
let data = this._data;
for (const key of this._keys) {
const value = entry[key];
let map = data.get(value);
if (!map) {
map = new Map();
data.set(value, map);
}
data = map;
}
const lastValue = entry[this._lastKey];
let array = data.get(lastValue);
if (!array) {
array = [];
data.set(lastValue, array);
}
array.push(entry);
}
}
getAll(selector) {
let data = this._data;
for (const key of this._keys) {
data = data.get(selector[key]);
if (!data)
return [];
}
return data.get(selector[this._lastKey]) || [];
}
}
module.exports = SMap;
@ptandler
Copy link

ptandler commented Jul 3, 2022

@aslushnikov cool script, thanks for sharing! You could add "elementary/docker" to your list of repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment