Skip to content
Snippets Groups Projects
Verified Commit 041803d4 authored by Tomas Krizek's avatar Tomas Krizek
Browse files

meson: scripts/make-archive.sh - generate dev tarball

parent e03d15ff
Branches
Tags
1 merge request!771meson build system
#!/bin/bash
set -o nounset
# Create a develpoment tarball
set -o errexit -o nounset -o xtrace
# Create a distribution tarball, like 'make dist' from autotools.
cd "${MESON_SOURCE_ROOT}"
cd "$(dirname ${0})/.."
# Check if git is clean
test 0 -ne $(git status --porcelain -uno | wc -l) && \
echo "ERROR: Git working tree is dirty, make it clean first" && \
exit 1
git submodule status --recursive | grep -q '^[^ ]' && \
echo "ERROR: Git submodules are dirty, run: git submodule update --recursive --init" && \
exit 2
# devel version
GIT_HASH=$(git rev-parse --short HEAD )
TIMESTAMP=$(date -u +'%s' 2>/dev/null)
RELEASE_VERSION="${1}" # pass in version from meson.project_version()
VERSION="${RELEASE_VERSION}"
# make sure we don't accidentally add / overwrite forgotten changes in git
(git diff-index --quiet HEAD && git diff-index --cached --quiet HEAD) || \
(echo 'git index has uncommited changes!'; exit 1)
# Check version and use devel version if appicable
export GIT_DIR="${MESON_SOURCE_ROOT}/.git"
GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
HAS_GIT=$?
GIT_TAG=$(git describe --exact-match 2>/dev/null)
HAS_TAG=$?
# modify and commit meson.build
sed -i "s/^\(\s*version\s*:\s*'\)\([^']\+\)\('.*\)/\1\2.$TIMESTAMP.$GIT_HASH\3/" meson.build
git add meson.build
git commit -m 'DROP: devel version archive'
if [[ ${HAS_GIT} -eq 0 ]]; then
if [[ ${HAS_TAG} -eq 0 ]]; then
# git tag must match release version number
if [ "${GIT_TAG}" != "v${RELEASE_VERSION}" ]; then
echo "ERROR: Release version number doesn't match git tag!"
exit 1
fi
else
# devel verion has <TIMESTAMP>.<GIT_HASH> appended to it
# if more than one branch is actively developed, switch to the same
# version model as Knot DNS (X.Y.dev.T.G for master, X.Y.Z.T.G for older)
TIMESTAMP=$(date -u +'%s' 2>/dev/null)
VERSION="${RELEASE_VERSION}.${TIMESTAMP}.${GIT_HASH}"
fi
fi
cleanup() {
# undo commit
git reset --hard HEAD^ >/dev/null
}
trap cleanup EXIT
# 'git ls-files --recurse-submodules' works only if modules are initialized
NAME="knot-resolver-${VERSION}"
tar caf "${NAME}.tar.xz" -h --no-recursion --transform "s|^|${NAME}/|" -- $(git ls-files --recurse-submodules)
echo "$PWD/${NAME}.tar.xz"
# create tarball
rm -rf build_dist ||:
meson build_dist
ninja -C build_dist dist
# print path to generated tarball
set +o xtrace
find "${PWD}/build_dist/meson-dist/" -name "knot-resolver-*.tar.xz"
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