X-Git-Url: https://iankelling.org/git/?p=distro-functions;a=blobdiff_plain;f=src%2Fidentify-distros;h=f75cb0f36b3b936c3a9970a9c36300bf0d48ba43;hp=0d7a8fe1a9a1eff9b93a178efbe4839871c40c41;hb=c242c573b6ebeeacd95734446881be4bad8a0bbd;hpb=b3f12bb11f16b2bdf52e0d85f000e04b59ba9f1f diff --git a/src/identify-distros b/src/identify-distros index 0d7a8fe..f75cb0f 100644 --- a/src/identify-distros +++ b/src/identify-distros @@ -13,26 +13,67 @@ # See the License for the specific language governing permissions and # limitations under the License. -distro_name() { +distro-name() { if [[ -f /etc/fedora-release ]]; then echo fedora + elif [[ -e /etc/os-release ]]; then + sed -rn 's/^ID=(.*)/\1/p' /etc/os-release else - grep "^ID=.*" /etc/os-release | sed 's/^ID=//' + echo "unknown distro" + return 1 fi } + +distro-name-ver() { + echo `distro-name``debian-archive` +} + +debian-archive() { + isdeb || return 0 + local archive + 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 </dev/null; } isubuntu() { - local d=$(distro_name) - [[ $d == ubuntu ]] || return 1 + [[ $(distro-name) == ubuntu ]] }