Make git-archive-recursive always generate VERSION file

This commit is contained in:
Emil Lundberg 2017-12-18 14:58:48 +01:00
parent ff213a7ca2
commit b7c9320ac0
No known key found for this signature in database
GPG Key ID: 5B9688125FF0B636

View File

@ -1,15 +1,10 @@
#!/bin/bash
# Similar to git-archive(1), but recurses into currently checked out submodules.
#
# Usage: git-archive-recursive [ARCHIVE_NAME]
#
# If ARCHIVE_NAME is not given, it defaults to
# "$(basename $(pwd))-$(git rev-parse --short HEAD).tar.gz".
#
# NOTE: Submodules' state is not checked. You should ensure that all submodules
# are checked out to the commits specified in .gitmodules .
PROJECT_NAME="$(basename $(pwd))"
PROJECT_NAME="yubioath-desktop"
TMP_DIR=$(mktemp -d "git-archive-recursive-${PROJECT_NAME}-XXXXXX")
SUBMODULES_DIR="${TMP_DIR}/submodules/"
OUTPUT_DIR="${TMP_DIR}/dist"
@ -28,15 +23,21 @@ die() {
trap die ERR
version=$(python3 compute-version.py "${PROJECT_NAME}"-)
commit=$(git rev-parse --short HEAD)
archive_name="archive-${commit}.tar.gz"
output_archive_base_name="${1:-${PROJECT_NAME}-${commit}}"
output_archive_base_name="${1:-${PROJECT_NAME}}"
output_archive_dir="${OUTPUT_DIR}/${output_archive_base_name}"
output_archive_name="${output_archive_base_name}.tar.gz"
output_archive_name="${output_archive_base_name}-${version}.tar.gz"
mkdir -p "${SUBMODULES_DIR}"
mkdir -p "${output_archive_dir}"
python3 compute-version.py "${PROJECT_NAME}"- > "${output_archive_dir}/${VERSION_FILE}"
echo "Embedded ${VERSION_FILE} file:"
cat "${output_archive_dir}/${VERSION_FILE}"
echo
# Create sources archive for root repo
git archive "$commit" > "${TMP_DIR}/${archive_name}"
# Unpack sources into output directory
@ -64,10 +65,6 @@ for submodule_line in $(git submodule status --recursive); do
fi
done
if [[ -f "${VERSION_FILE}" ]]; then
cp "${VERSION_FILE}" "${output_archive_dir}"
fi
# Bundle all sources together
tar cf "${output_archive_name}" -C "${OUTPUT_DIR}" .