Add is_fedora and exit_distro_not_supported functions
Between is_fedora, is_ubuntu and is_suse, we can make the code a bit
simpler to read. We also use exit_distro_not_supported to identify
places where we need implementation details for new distros.
As "/sbin/service --skip-redirect" is Fedora-specific, guard this with a
is_fedora test too.
Change-Id: Ic77c0697ed9be0dbb5df8e73da93463e76025f0c
diff --git a/tools/info.sh b/tools/info.sh
index 583a994..f01dbea 100755
--- a/tools/info.sh
+++ b/tools/info.sh
@@ -90,15 +90,19 @@
if is_ubuntu; then
PKG_DIR=$FILES/apts
-else
+elif is_fedora; then
PKG_DIR=$FILES/rpms
+else
+ exit_distro_not_supported "list of packages"
fi
for p in $(get_packages $PKG_DIR); do
if [[ "$os_PACKAGE" = "deb" ]]; then
ver=$(dpkg -s $p 2>/dev/null | grep '^Version: ' | cut -d' ' -f2)
- else
+ elif [[ "$os_PACKAGE" = "rpm" ]]; then
ver=$(rpm -q --queryformat "%{VERSION}-%{RELEASE}\n" $p)
+ else
+ exit_distro_not_supported "finding version of a package"
fi
echo "pkg|${p}|${ver}"
done