From: Tomas Krizek Date: Fri, 15 Feb 2019 11:49:57 +0000 (+0100) Subject: meson: scripts/make-archive.sh - generate dev tarball X-Git-Tag: v4.0.0~24^2~112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=041803d4c334321c322de91d3687c2b77fa705d2;p=thirdparty%2Fknot-resolver.git meson: scripts/make-archive.sh - generate dev tarball --- diff --git a/scripts/make-archive.sh b/scripts/make-archive.sh index 6e6ef3ac9..2a81d7466 100755 --- a/scripts/make-archive.sh +++ b/scripts/make-archive.sh @@ -1,44 +1,33 @@ #!/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 . 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"