2021-10-14 04:11:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-17 04:17:55 +00:00
|
|
|
# Fail on any error.
|
|
|
|
set -e
|
|
|
|
|
2021-10-17 05:37:18 +00:00
|
|
|
version=$1
|
|
|
|
packages=${@:2}
|
2021-10-14 04:11:27 +00:00
|
|
|
|
|
|
|
echo -n "* Validating action arguments... ";
|
2021-10-17 05:37:18 +00:00
|
|
|
|
|
|
|
echo $version | grep -o " " > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "aborted."
|
|
|
|
echo "* Version value '$version' cannot contain spaces." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-10-14 04:11:27 +00:00
|
|
|
if [ "$packages" == "" ]; then
|
|
|
|
echo "aborted."
|
|
|
|
echo "* Packages argument cannot be empty." >&2
|
2021-10-17 05:37:18 +00:00
|
|
|
exit 2
|
2021-10-14 04:11:27 +00:00
|
|
|
fi
|
2021-10-17 05:37:18 +00:00
|
|
|
|
2021-10-14 04:11:27 +00:00
|
|
|
for package in $packages; do
|
|
|
|
apt-cache search ^$package$ | grep $package > /dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "aborted."
|
|
|
|
echo "* Package '$package' not found." >&2
|
2021-10-17 05:37:18 +00:00
|
|
|
exit 3
|
2021-10-14 04:11:27 +00:00
|
|
|
fi
|
|
|
|
done
|
2021-10-17 05:37:18 +00:00
|
|
|
|
2021-10-14 04:11:27 +00:00
|
|
|
echo "done."
|