| 1 |
#!/bin/bash |
| 2 |
set -euE -o pipefail -o nounset |
| 3 |
|
| 4 |
COMMAND="/usr/sbin/dhcpoptinj --version" |
| 5 |
# Capture the binary version using the --version option: |
| 6 |
VERSION="$($COMMAND | grep -Po 'version\s+\K[^$]+')" |
| 7 |
# Get upstream version from installed package: |
| 8 |
EXPECTED_VERSION="$(dpkg-query --showformat='${source:Upstream-Version}' --show dhcpoptinj)" |
| 9 |
|
| 10 |
# Ensure that the versions match: |
| 11 |
if [[ "$VERSION" != "$EXPECTED_VERSION" ]]; then |
| 12 |
>&2 echo "ERROR: The version \"$VERSION\" output by $COMMAND does not match the expected version \"$EXPECTED_VERSION\"." |
| 13 |
exit 1 |
| 14 |
fi |