Commit 29f35803 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add version check in snf-image-update-helper

parent 9728e789
......@@ -28,6 +28,7 @@ edit = sed \
-e 's|@osdir[@]|$(osdir)|g' \
-e 's|@osname[@]|$(osname)|g' \
-e 's|@defaultdir[@]|$(defaultdir)|g' \
-e 's|@VERSION[@]|$(VERSION)|g' \
-e 's|@VERSION_CHECK[@]|$(VERSION_CHECK)|g' \
-e 's|@HELPER_DIR[@]|$(HELPER_DIR)|g' \
-e 's|@HELPER_URL[@]|$(HELPER_URL)|g' \
......
......@@ -16,6 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
SNF_IMAGE_VERSION="@VERSION@"
AWK="awk"
LOSETUP="losetup"
KPARTX="kpartx"
......
......@@ -215,6 +215,8 @@ fi
mv "$helper_img" "$HELPER_DIR/image"
echo "$SNF_IMAGE_VERSION" > "$HELPER_DIR/version"
echo "Files in \`$HELPER_DIR' were updated successfully" >&2
exit 0
......
......@@ -48,12 +48,14 @@ OPTIONS:
-y Assume Yes to all queries and do not prompt
-f Force the installation even if the snf-image and helper versions don't match
EOF
exit "$rc"
}
while getopts "hu:y" opt; do
while getopts "hu:yf" opt; do
case $opt in
h) usage 0
;;
......@@ -61,6 +63,8 @@ while getopts "hu:y" opt; do
;;
y) NO_PROMPT="yes"
;;
f) FORCE="yes"
;;
?) log_error "User \`-h' for help"; exit 1
;;
esac
......@@ -74,6 +78,7 @@ it under $IMAGE_DIR. The following files will be overwritten if present:
\`$HELPER_DIR/kernel'
\`$HELPER_DIR/image'
\`$HELPER_DIR/packages'
\`$HELPER_DIR/version'
EOF
while [[ 1 ]]; do
......@@ -108,6 +113,22 @@ echo >&2
echo "Extracting helper image under \`$HELPER_DIR':" >&2
tar -xvf "$IMAGE_DIR/$IMAGE"
if [ "x$FORCE" != "xyes" ]; then
echo >&2
echo "Checking helper image version ..." >&2
if [ ! -f "$HELPER_DIR/version" ]; then
log_error "File: \`$HELPER_DIR/version' is missing!"
exit 1
fi
helper_version="$(cat $HELPER_DIR/version)"
if [ "x$SNF_IMAGE_VERSION" != "x$helper_version" ]; then
log_error "snf-image version (=$SNF_IMAGE_VERSION) and " \
"helper image version (=$helper_version) don't match!"
log_error "Use \`-f' to bypass the version check."
exit 1
fi
fi
echo >&2
echo "Helper image was installed successfully!" >&2
exit 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment