duckstation/scripts/generate-metainfo.sh

37 lines
924 B
Bash
Raw Normal View History

#!/usr/bin/env bash
SCRIPTDIR=$(realpath $(dirname "${BASH_SOURCE[0]}"))
if [[ $# -lt 1 ]]; then
2023-09-30 02:38:21 +00:00
echo "Output directory must be provided as a parameter"
exit 1
fi
2023-09-30 02:38:21 +00:00
APPID="org.duckstation.DuckStation"
OUTDIR=$(realpath "$1")
OUTFILE="${OUTDIR}/${APPID}.metainfo.xml"
2023-09-30 02:38:21 +00:00
pushd "${SCRIPTDIR}" >/dev/null
GIT_DATE=$(git log -1 --pretty=%cd --date=short)
GIT_VERSION=$(git tag --points-at HEAD)
GIT_HASH=$(git rev-parse HEAD)
if [[ "${GIT_VERSION}" == "" ]]; then
2023-10-07 03:15:50 +00:00
GIT_VERSION=$(git describe --dirty | tr -d '\r\n')
if [[ "${GIT_VERSION}" == "" ]]; then
GIT_VERSION=$(git rev-parse HEAD)
fi
fi
2023-09-30 02:38:21 +00:00
popd >/dev/null
echo "GIT_DATE: ${GIT_DATE}"
echo "GIT_VERSION: ${GIT_VERSION}"
echo "GIT_HASH: ${GIT_HASH}"
2023-09-30 02:38:21 +00:00
cp "${SCRIPTDIR}/${APPID}.metainfo.xml.in" "${OUTFILE}"
sed -i -e "s/@GIT_VERSION@/${GIT_VERSION}/" "${OUTFILE}"
sed -i -e "s/@GIT_DATE@/${GIT_DATE}/" "${OUTFILE}"
sed -i -e "s/@GIT_HASH@/${GIT_HASH}/" "${OUTFILE}"