1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
#!/usr/bin/env ruby
require 'optionparser'
class DistroMap
attr_reader :entries
def initialize(map = nil)
@entries = map || self.class.builtin_map
end
# Returns the map for our distros.
#
# The key in each case is a string containing a lowercase OS name, a slash,
# and a version number. The value is a map containing the following fields:
#
# name:: a human-readable name for this distro.
# component:: a component suitable for a packagecloud.io URL.
# image:: a Docker image name from build_dockers without any extension.
# equivalent:: packagecloud.io components for which we can upload the same
# package.
# package_type:: the extension for the package format on this OS.
# package_tag:: the trailing component after the version number on this OS.
def self.builtin_map
{
# RHEL EOL https://access.redhat.com/support/policy/updates/errata
# Fedora EOL https://docs.fedoraproject.org/en-US/releases/
# SLES EOL https://www.suse.com/lifecycle/
# opensuse https://en.opensuse.org/Lifetime
# or https://en.wikipedia.org/wiki/OpenSUSE_version_history
"centos/7" => {
name: "RPM RHEL 7/CentOS 7",
component: "el/7",
image: "centos_7",
package_type: "rpm",
package_tag: "-1.el7",
equivalent: [
"el/7", # EOL June 2024
"sles/12.5", # EOL October 2024
],
},
"centos/8" => {
name: "RPM RHEL 8/Rocky Linux 8",
component: "el/8",
image: "centos_8",
package_type: "rpm",
package_tag: "-1.el8",
equivalent: [
"el/8", # EOL May 2029
"opensuse/15.5", # EOL December 2024
"sles/15.5", # EOL December 2024
],
},
"rocky/9" => {
name: "RPM RHEL 9/Rocky Linux 9",
component: "el/9",
image: "rocky_9",
package_type: "rpm",
package_tag: "-1.el9",
equivalent: [
"el/9", # EOL May 2032
"fedora/39", # EOL November 2024
"fedora/40", # EOL May 2025
"fedora/41", # EOL November 2025
"opensuse/15.6", # EOL December 2025
"sles/15.6", # Current
],
},
# Debian EOL https://wiki.debian.org/LTS/
# Ubuntu EOL https://wiki.ubuntu.com/Releases
# Mint EOL https://linuxmint.com/download_all.php
"debian/10" => {
name: "Debian 10",
component: "debian/buster",
image: "debian_10",
package_type: "deb",
package_tag: "",
equivalent: [
"debian/buster", # EOL June 2024
"linuxmint/ulyana", # EOL April 2025
"linuxmint/ulyssa", # EOL April 2025
"linuxmint/uma", # EOL April 2025
"linuxmint/una", # EOL April 2025
"ubuntu/focal", # EOL April 2025
],
},
"debian/11" => {
name: "Debian 11",
component: "debian/bullseye",
image: "debian_11",
package_type: "deb",
package_tag: "",
equivalent: [
"debian/bullseye", # EOL August 2026
"linuxmint/vanessa", # EOL April 2027
"linuxmint/vera", # EOL April 2027
"linuxmint/victoria", # EOL April 2027
"linuxmint/virginia", # EOL April 2027
"ubuntu/jammy", # EOL April 2027
],
},
"debian/12" => {
name: "Debian 12",
component: "debian/bookworm",
image: "debian_12",
package_type: "deb",
package_tag: "",
equivalent: [
"debian/bookworm", # EOL June 2028
"debian/trixie", # Current testing (Debian 13)
"linuxmint/wilma", # EOL April 2029
"ubuntu/noble", # EOL June 2029
"ubuntu/oracular", # EOL July 2025
]
},
}
end
def distro_name_map
entries.map { |k, v| [k, v[:equivalent]] }.to_h
end
def image_names
entries.values.map { |v| v[:image] }.to_a
end
end
class DistroMapProgram
def initialize(stdout, stderr, dmap = nil)
@dmap = DistroMap.new(dmap)
@stdout = stdout
@stderr = stderr
end
def image_names
@stdout.puts @dmap.image_names.join(" ")
end
def distro_markdown
arch = {
"rpm" => ".x86_64",
"deb" => "_amd64",
}
separator = {
"rpm" => "-",
"deb" => "_",
}
result = @dmap.entries.map do |_k, v|
type = v[:package_type]
"[#{v[:name]}](https://packagecloud.io/github/git-lfs/packages/#{v[:component]}/git-lfs#{separator[type]}VERSION#{v[:package_tag]}#{arch[type]}.#{type}/download)\n"
end.join
@stdout.puts result
end
def run(args)
options = {}
OptionParser.new do |parser|
parser.on("--image-names", "Print the names of all images") do
options[:mode] = :image_names
end
parser.on("--distro-markdown", "Print links to packages for all distros") do
options[:mode] = :distro_markdown
end
end.parse!(args)
case options[:mode]
when nil
@stderr.puts "A mode option is required"
2
when :image_names
image_names
0
when :distro_markdown
distro_markdown
0
end
end
end
if $PROGRAM_NAME == __FILE__
exit DistroMapProgram.new($stdout, $stderr).run(ARGV)
end
|