X-Git-Url: https://iankelling.org/git/?p=distro-functions;a=blobdiff_plain;f=src%2Fidentify-distros;fp=src%2Fidentify-distros;h=011ddb5d7f28d6c9d92a1c9d79917d84cb379e83;hp=f75cb0f36b3b936c3a9970a9c36300bf0d48ba43;hb=6314c835343decaa195019ed2d38a1cb0d5f6a69;hpb=29a9cf3a392bc7229a332c136b9ea7d4b70b53f2 diff --git a/src/identify-distros b/src/identify-distros index f75cb0f..011ddb5 100644 --- a/src/identify-distros +++ b/src/identify-distros @@ -14,38 +14,72 @@ # limitations under the License. distro-name() { + local x if [[ -f /etc/fedora-release ]]; then echo fedora elif [[ -e /etc/os-release ]]; then sed -rn 's/^ID=(.*)/\1/p' /etc/os-release + elif type -p lsb_release &>/dev/null; then + # well, this is more standard, but it's 2 ms vs 200 ms + x=$(lsb_release -si); echo ${x,,} else echo "unknown distro" return 1 fi } +distro-name-compat() { + local x=$(distro-name) + case $x in + trisquel) + echo ubuntu + ;; + *) + echo $x + ;; + esac +} + distro-name-ver() { echo `distro-name``debian-archive` } debian-archive() { isdeb || return 0 - local archive + local archive expression pri name highpri shortest local policy="${1:-$(apt-cache policy)}" # a = archive # n = codename # o = origin # c = component (licensing component) # l = label (Debian{,-Security,-Updates}) - { for archive in stable testing unstable; do - # print priority + archive name. priority is in - # the previous line after finding the archive. - read -rd '' expression < ${#name} )); then + shortest=$name + fi + done < <(echo "$policy" | sed -rn "$expression" | sort -rn) + echo "$shortest" + } @@ -63,6 +97,18 @@ debian-codename() { archive=$(debian-archive "$policy") echo "$policy" | sed -rn "s/^.*a=$archive,n=([a-z]+).*/\1/p;T;q" } +debian-codename-compat() { + local n=$(debian-codename) + case $n in + flidas) + echo xenial + ;; + *) + echo $n + ;; + esac +} + isfedora() { [[ $(distro-name) == fedora ]] } @@ -72,8 +118,11 @@ isdebian() { isarch() { [[ $(distro-name) == arch ]] } -# is debian/apt based -isdeb() { command -v apt-get &>/dev/null; } isubuntu() { [[ $(distro-name) == ubuntu ]] } +istrisquel() { + [[ $(distro-name) == trisquel ]] +} +# is debian/apt based +isdeb() { command -v apt-get &>/dev/null; }