| ... | ... |
@@ -14,14 +14,21 @@ manually updated, which means they may be out of date. |
| 14 | 14 |
## Usage |
| 15 | 15 |
|
| 16 | 16 |
``` |
| 17 |
-distro-url [<distro> [<variant> [<arch> [<codename> [<version> [<mirror>]]]]]] |
|
| 17 |
+distro-url [guess] [<distro> [<variant> [<arch> [<codename> [<version> [<mirror>]]]]]] |
|
| 18 | 18 |
``` |
| 19 | 19 |
|
| 20 |
+- `guess`: Optional verbatim string, switching from the default filter mode |
|
| 21 |
+ to guess mode. Filter mode interprets the rest of the parameters as |
|
| 22 |
+ [glob][]s (defaulting to `*`, matching everything) to filter an internal |
|
| 23 |
+ list of known good parameter combinations. Guess mode interprets the rest |
|
| 24 |
+ of the parameters as fixed strings (defaulting to sensible values for the |
|
| 25 |
+ given `<distro>`) and will do its best to construct a [URL][] out of them. |
|
| 20 | 26 |
- `<distro>`: The [distro][] to print the [URL][] for. |
| 21 | 27 |
- `<variant>`, `<arch>`, `<codename>`, `<version>`: Optional parameters to |
| 22 | 28 |
select a different [image][] than the default. |
| 23 | 29 |
- `<mirror>`: Optional override of the default [mirror][]. |
| 24 | 30 |
|
| 31 |
+[glob]: https://en.wikipedia.org/wiki/Glob_(programming) |
|
| 25 | 32 |
[mirror]: https://en.wikipedia.org/wiki/Mirror_site |
| 26 | 33 |
|
| 27 | 34 |
## Dependencies |
| ... | ... |
@@ -35,15 +42,23 @@ distro-url [<distro> [<variant> [<arch> [<codename> [<version> [<mirror>]]]]]] |
| 35 | 42 |
## Examples |
| 36 | 43 |
|
| 37 | 44 |
```sh |
| 38 |
-$ distro-url debian |
|
| 39 |
-DISTRO VARIANT ARCH CODENAME VERSION URL |
|
| 40 |
-debian gnome amd64 trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0-live/amd64/iso-hybrid/debian-live-13.5.0-amd64-gnome.iso |
|
| 41 |
- |
|
| 42 | 45 |
$ distro-url debian netinst |
| 43 |
-DISTRO VARIANT ARCH CODENAME VERSION URL |
|
| 44 |
-debian netinst amd64 trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/amd64/iso-cd/debian-13.5.0-amd64-netinst.iso |
|
| 45 |
- |
|
| 46 |
-$ distro-url debian inst arm64 unknown 99.0.0 |
|
| 46 |
+DISTRO VARIANT ARCH CODENAME VERSION URL |
|
| 47 |
+debian netinst amd64 trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/amd64/iso-cd/debian-13.5.0-amd64-netinst.iso |
|
| 48 |
+debian netinst arm64 trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/arm64/iso-cd/debian-13.5.0-arm64-netinst.iso |
|
| 49 |
+debian netinst armhf trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/armhf/iso-cd/debian-13.5.0-armhf-netinst.iso |
|
| 50 |
+debian netinst ppc64el trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/ppc64el/iso-cd/debian-13.5.0-ppc64el-netinst.iso |
|
| 51 |
+debian netinst riscv64 trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/riscv64/iso-cd/debian-13.5.0-riscv64-netinst.iso |
|
| 52 |
+debian netinst s390x trixie 13.5.0 https://cdimage.debian.org/debian-cd/13.5.0/s390x/iso-cd/debian-13.5.0-s390x-netinst.iso |
|
| 53 |
+ |
|
| 54 |
+$ distro-url '*' '*raspi*' |
|
| 55 |
+DISTRO VARIANT ARCH CODENAME VERSION URL |
|
| 56 |
+debian raspi arm64 trixie 13.5.0 https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-raspi-arm64-daily.tar.xz |
|
| 57 |
+ubuntu desktop-raspi arm64 resolute 26.04 https://cdimage.ubuntu.com/ubuntu/releases/resolute/release/ubuntu-26.04-preinstalled-desktop-arm64+raspi.img.xz |
|
| 58 |
+ubuntu server-raspi arm64 resolute 26.04 https://cdimage.ubuntu.com/ubuntu/releases/resolute/release/ubuntu-26.04-preinstalled-server-arm64+raspi.img.xz |
|
| 59 |
+edubuntu desktop-raspi arm64 resolute 26.04 https://cdimage.ubuntu.com/edubuntu/releases/resolute/release/edubuntu-26.04-preinstalled-desktop-arm64+raspi.img.xz |
|
| 60 |
+ |
|
| 61 |
+$ distro-url guess debian inst arm64 unknown 99.0.0 |
|
| 47 | 62 |
DISTRO VARIANT ARCH CODENAME VERSION URL |
| 48 | 63 |
debian inst arm64 unknown 99.0.0 https://cdimage.debian.org/debian-cd/99.0.0/arm64/iso-dvd/debian-99.0.0-arm64-DVD-1.iso |
| 49 | 64 |
``` |
| ... | ... |
@@ -1,13 +1,16 @@ |
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
set -euC |
| 3 | 3 |
|
| 4 |
-# usage: distro-url [<distro> [<variant> [<arch> [<codename> [<version> [<mirror>]]]]]] |
|
| 4 |
+# usage: distro-url [guess] [<distro> [<variant> [<arch> [<codename> [<version> [<mirror>]]]]]] |
|
| 5 | 5 |
|
| 6 | 6 |
main() |
| 7 | 7 |
{
|
| 8 |
+ [ "${1:-}" = 'guess' ] && shift && guess='GUESS' || guess=
|
|
| 8 | 9 |
{
|
| 9 | 10 |
echo 'DISTRO' 'VARIANT' 'ARCH' 'CODENAME' 'VERSION' 'URL' |
| 10 |
- guess "$@" |
|
| 11 |
+ [ "$guess" ] \ |
|
| 12 |
+ && guess "$@" \ |
|
| 13 |
+ || filter "$@" |
|
| 11 | 14 |
} \ |
| 12 | 15 |
| {
|
| 13 | 16 |
[ "$(command -v column)" ] \ |
| ... | ... |
@@ -16,6 +19,45 @@ main() |
| 16 | 19 |
} |
| 17 | 20 |
} |
| 18 | 21 |
|
| 22 |
+filter() |
|
| 23 |
+{
|
|
| 24 |
+ distro="${1:-*}"
|
|
| 25 |
+ variant="${2:-*}"
|
|
| 26 |
+ arch="${3:-*}"
|
|
| 27 |
+ codename="${4:-}"
|
|
| 28 |
+ version="${5:-}"
|
|
| 29 |
+ try() |
|
| 30 |
+ {
|
|
| 31 |
+ for d in $1; do case "$d" in $distro) |
|
| 32 |
+ for v in $2; do case "$v" in $variant) |
|
| 33 |
+ for a in $3; do case "$a" in $arch) |
|
| 34 |
+ guess "$d" "$v" "$a" "$codename" "$version" |
|
| 35 |
+ esac; done |
|
| 36 |
+ esac; done |
|
| 37 |
+ esac; done |
|
| 38 |
+ } |
|
| 39 |
+ try 'debian' 'netinst inst ' 'amd64 arm64 armhf ppc64el riscv64 s390x' |
|
| 40 |
+ try 'debian' 'standard gnome kde lxqt xfce cinnamon mate lxde' 'amd64 ' |
|
| 41 |
+ try 'debian' 'raspi ' ' arm64 ' |
|
| 42 |
+ try 'raspios' 'default full lite ' ' arm64 armhf ' |
|
| 43 |
+ try 'ubuntu' 'desktop server ' 'amd64 ' |
|
| 44 |
+ try 'ubuntu' 'desktop-raspi server-raspi ' ' arm64 ' |
|
| 45 |
+ try 'edubuntu' 'desktop ' 'amd64 ' |
|
| 46 |
+ try 'edubuntu' 'desktop-raspi ' ' arm64 ' |
|
| 47 |
+ try 'kubuntu' 'desktop ' 'amd64 ' |
|
| 48 |
+ try 'lubuntu' 'desktop ' 'amd64 ' |
|
| 49 |
+ try 'xubuntu' 'desktop ' 'amd64 ' |
|
| 50 |
+ try 'ubuntucinnamon' 'desktop ' 'amd64 ' |
|
| 51 |
+ try 'ubuntu-mate' 'desktop ' 'amd64 ' |
|
| 52 |
+ try 'ubuntu-budgie' 'desktop ' 'amd64 ' |
|
| 53 |
+ try 'ubuntu-unity' 'desktop ' 'amd64 ' |
|
| 54 |
+ try 'ubuntustudio' 'desktop ' 'amd64 ' |
|
| 55 |
+ try 'ubuntukylin' 'desktop ' 'amd64 ' |
|
| 56 |
+ try 'linuxmint' 'cinnamon mate xfce ' 'amd64 ' |
|
| 57 |
+ try 'opensuse' 'netinst inst ' 'amd64 ' |
|
| 58 |
+ try 'opensuse' 'gnome kde xfce ' 'amd64 ' |
|
| 59 |
+} |
|
| 60 |
+ |
|
| 19 | 61 |
guess() |
| 20 | 62 |
( |
| 21 | 63 |
distro="${1:-}"
|