SHA256
1
0
forked from pool/qemu
qemu/checkbundle.sh
2019-09-18 08:58:50 +00:00

51 lines
1.6 KiB
Bash

#!/bin/bash
#
# This script simply does some basic checks on the bundle tarball
# TODO: report if the required base commit isn't there - they may need to fetch the latest from upstream
set -e
source ./config.sh
rm -rf $GIT_DIR
rm -rf $BUNDLE_DIR
mkdir -p $GIT_DIR
mkdir -p $BUNDLE_DIR
tar xJf bundles.tar.xz -C $BUNDLE_DIR
BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$")
git -C $GIT_DIR init
# !!!! I suspect that given the current format of the bundles dir struct, the 1st isn't used
# I suspect also that we are getting a redundant ./ in the path which isn't helpful
for entry in ${BUNDLE_FILES[@]}; do
if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then
SUBDIR=${BASH_REMATCH[1]}
GITREPO_COMMIT_ISH=${BASH_REMATCH[2]}
else
echo "ERROR! BAD BUNDLE CONTENT!"
exit
fi
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then
PATCH_RANGE_INDEX=$i
break
fi
done
if [ "$(git -C $GIT_DIR bundle verify $BUNDLE_DIR/$entry 2>&1>/dev/null|tail --lines=1)" == "error: $GITREPO_COMMIT_ISH" ]; then
echo "Verified bundle name matches bundle's base commit as expected"
fi
git bundle list-heads $BUNDLE_DIR/$entry
LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
if [ -e $LOCAL_REPO ]; then
echo "Found local repo $LOCAL_REPO corresponding to archived git bundle, verifying base commit is present (ok if no error)..."
git -C $LOCAL_REPO verify-commit $GITREPO_COMMIT_ISH || true
else
echo "No local repo $LOCAL_REPO corresponding to archived git bundle"
fi
done
rm -rf $GIT_DIR
rm -rf $BUNDLE_DIR