Skip to content

Instantly share code, notes, and snippets.

@mogi
Created April 10, 2018 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mogi/9f97bd46db394ceabd1de1f4baf0d493 to your computer and use it in GitHub Desktop.
Save mogi/9f97bd46db394ceabd1de1f4baf0d493 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This command is make sure current version and target version are equal.
PACKAGE_NAME=$1
PREF_FILE="/etc/apt/preferences.d/${PACKAGE_NAME}.pref"
if [ ! -e "${PREF_FILE}" ]; then
echo "${PACKAGE_NAME}.pref is not found. Before using, please deploy config file of 'apt pinning'."
exit 1
fi
PACKAGE_VERSION=$(grep 'Pin:' "${PREF_FILE}"| sed -e 's/Pin: release v=//')
# check package version
dpkg -s ${PACKAGE_NAME}| grep -q "Version: ${PACKAGE_VERSION}" && exit 0 || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment