如何检查 sources.list.d 中的 repo 是否支持特定的 Ubuntu 版本

如何检查 sources.list.d 中的 repo 是否支持特定的 Ubuntu 版本

Ubuntu 的新版本刚刚发布,在跳上升级潮流之前,你需要检查/etc/apt/sources.list.d你最喜欢的应用程序的 repo 源(在)是否已经添加了对上述 Ubuntu 版本的支持

答案1

这是一个简化任务的简单脚本

#!/bin/bash

# enter the codename of ubuntu dist that you're upgrading/updating to
TARGET_DIST="utopic"


[[ -f /etc/lsb-release ]] && . /etc/lsb-release || exit 1
echo "Checking support of your current 3rd party apt sources for dist: $TARGET_DIST"
for list in /etc/apt/sources.list.d/*.list; do
    # get repo uri and dist
    read -r uri dist <<< $(sed -rn '/^deb/{s/.*((ftp|http)[^ ]+) ([^ ]+).*/\1 \3/p}' $list)

    # in case uri is blank
    [[ -z "$uri" ]] && continue

    # some repo don't use proper target dist names but names like stable/unstable
    # so if $dist doesnt correspond to our current dist codename we assume they support all ubuntu releases
    if [[ "$dist" != "$DISTRIB_CODENAME" ]]; then
        status="assume200"
    else
        # Release files can either be in InRelease or Release (for older apt client)
        # See https://wiki.debian.org/RepositoryFormat#A.22Release.22_files
        status=$(curl -sLI -w "%{http_code}" -o /dev/null "$uri/dists/$TARGET_DIST/Release")
        if [[ "$status" != "200" ]]; then
            status=$(curl -sLI -w "%{http_code}" -o /dev/null "$uri/dists/$TARGET_DIST/InRelease")
        fi
    fi

    if [[ "$status" == "200" ]]; then
        result="OK"
    elif [[ "$status" == "assume200" ]]; then
        result="OK ($dist)"
    else
        result="Nope"
    fi
    # finally display formatted results
    printf "%-50s : %s\n" ${list##*/} "$result"
done

输出:

Checking support of your current 3rd party apt sources for dist: utopic
alexx2000-doublecmd-svn-trusty.list                : Nope
b-eltzner-qpdfview-trusty.list                     : Nope
dropbox.list                                       : Nope
google-chrome.list                                 : OK (stable)
linrunner-tlp-trusty.list                          : Nope
nesthib-weechat-stable-trusty.list                 : Nope
rvm-smplayer-trusty.list                           : Nope
spotify-stable.list                                : OK (stable)
steam.list                                         : OK (precise)
ubuntu-wine-ppa-trusty.list                        : Nope
virtualbox.list                                    : Nope

相关内容