「dpkg --compare-versions...」に対応するRPMとは何ですか?

「dpkg --compare-versions...」に対応するRPMとは何ですか?

Debian は、次のコマンドを使用して Debian 互換バージョンを比較する方法を提供しますdpkg

dpkg --compare-versions <version> <operator> <version>

たとえば、特定のバージョンが1.0より前であるかどうかを知りたい場合は、次のものを使用できます。

# gather VERSION from somewhere...
VERSION=0.9

if dpkg --compare-versions "${VERSION}" lt 1.0
then
    echo "unacceptable version as per policy"
    exit 1
fi

RPMベース(RedHat / Fedora)システムでは、そのコマンドは何ですか?

ベストアンサー1

存在する速度> = 4.16.0:

$ rpm --eval "%{lua:print(rpm.vercmp('1.2-1', '2.0-1'))}"
-1

rpm >= 4.7.0 部品のみ比較、不完全なEpoch:Version-Release文字列)

OpenSUSEの場合は、以下もありますzypper vcmp

$ zypper vcmp 0.9.5+git20190908+3abfab2-150300.7.5.1 0.9.5~git20210406.e554475-150400.3.5.1
0.9.5+git20190908+3abfab2-150300.7.5.1 is newer than 0.9.5~git20210406.e554475-150400.3.5.1

おすすめ記事