From efb4fc2cd3f4466e3266fb992303a6746c2dc4de Mon Sep 17 00:00:00 2001 From: Tomas Krizek Date: Thu, 22 Feb 2018 15:13:39 +0100 Subject: [PATCH] packaging: cleanup scripts --- .gitlab-ci.yml | 5 +++-- scripts/build-in-obs.sh | 17 ++++++++++------- scripts/make-archive.sh | 2 +- scripts/make-distrofiles.sh | 28 +++++++++++++++++----------- scripts/make-srpm.sh | 1 + scripts/show-version.sh | 2 -- 6 files changed, 32 insertions(+), 23 deletions(-) delete mode 100755 scripts/show-version.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16966b3bc..e0f147fc8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -346,15 +346,16 @@ pages: - public # trigger obs build for master branch -obs: +obs:devel: stage: deploy only: - master dependencies: [] script: + - scripts/make-archive.sh - scripts/make-distrofiles.sh - echo -e "[general]\napiurl = https://api.opensuse.org\n\n[https://api.opensuse.org]\nuser = CZ-NIC\npass = $OBS_PASSWORD" > /root/.oscrc - - scripts/build-in-obs.sh knot-devel + - scripts/build-in-obs.sh knot-dns-devel - scripts/build-in-obs.sh knot-resolver-devel #arm_build: diff --git a/scripts/build-in-obs.sh b/scripts/build-in-obs.sh index eec967adf..fea8f1a4e 100755 --- a/scripts/build-in-obs.sh +++ b/scripts/build-in-obs.sh @@ -1,18 +1,21 @@ #!/bin/bash -e # Example usage: -# scripts/make-distrofiles.sh -# scripts/build-in-obs.sh knot-resolver-devel +# 1. place tarball to be released in git root dir +# 2. scripts/make-distrofiles.sh +# 3. scripts/build-in-obs.sh knot-resolver-latest -repo=home:CZ-NIC:$1 +project=home:CZ-NIC:$1 +package=knot-resolver -osc co "$repo" knot-resolver -cd "$repo/knot-resolver" -osc del * +osc co "${project}" "${package}" +pushd "${project}/${package}" +osc del * ||: cp ../../*.tar.xz ./ cp -rL ../../distro/fedora/* ./ cp -rL ../../distro/arch/* ./ cp ../../distro/debian/*.debian.tar.xz ./ -cp ../../distro/debian/knot-resolver.dsc ./ +cp "../../distro/debian/${package}.dsc" ./ osc addremove osc ci -n +popd diff --git a/scripts/make-archive.sh b/scripts/make-archive.sh index 3b9b96503..e3b1a9702 100755 --- a/scripts/make-archive.sh +++ b/scripts/make-archive.sh @@ -1,7 +1,7 @@ #!/bin/sh -e # Create a distribution tarball, like 'make dist' from autotools. cd "$(git rev-parse --show-toplevel)" -ver="$(scripts/show-version.sh)" +ver=$(git describe | sed 's/^v//' | sed 's/-/\./g') test 0 -ne $(git status --porcelain | wc -l) && \ echo "Git working tree is dirty, make it clean first" && \ exit 1 diff --git a/scripts/make-distrofiles.sh b/scripts/make-distrofiles.sh index 8fb5547e5..576b21afe 100755 --- a/scripts/make-distrofiles.sh +++ b/scripts/make-distrofiles.sh @@ -1,24 +1,30 @@ #!/bin/bash -e -scripts/make-archive.sh +package=knot-resolver cd "$(git rev-parse --show-toplevel)" -VERSION=$(scripts/show-version.sh) +version=$(ls ${package}*.tar.xz | sed "s/${package}-\(.*\).tar.xz/\1/") + +# Check version for invalid characters +if [[ $(echo "${version}" | grep '^[[:alnum:].]$') -ne 0 ]]; then + echo "Invalid version number: may contain only alphanumeric characters and dots" + exit 1 +fi # Fill in VERSION field in distribution specific files -files='distro/fedora/knot-resolver.spec distro/arch/PKGBUILD distro/debian/debian/changelog distro/debian/knot-resolver.dsc' -for file in $files; do - sed -i "s/__VERSION__/$VERSION/g" "$file" +files="distro/fedora/${package}.spec distro/debian/debian/changelog distro/debian/${package}.dsc distro/arch/PKGBUILD" +for file in ${files}; do + sed -i "s/__VERSION__/${version}/g" "${file}" done # Rename archive to debian format -mv knot-resolver-$VERSION.tar.xz knot-resolver_$VERSION.orig.tar.xz +mv "${package}-${version}.tar.xz" "${package}_${version}.orig.tar.xz" # Create debian archive and dsc pushd distro/debian -tar -chaf knot-resolver_$VERSION-1.debian.tar.xz debian -archive=knot-resolver_$VERSION-1.debian.tar.xz -echo " $(md5sum $archive | cut -d' ' -f1) $(wc -c $archive)" >> knot-resolver.dsc +tar -chaf "${package}_${version}-1.debian.tar.xz" debian +archive=${package}_${version}-1.debian.tar.xz +echo " $(md5sum ${archive} | cut -d' ' -f1) $(wc -c ${archive})" >> ${package}.dsc popd -archive=knot-resolver_$VERSION.orig.tar.xz -echo " $(md5sum $archive | cut -d' ' -f1) $(wc -c $archive)" >> distro/debian/knot-resolver.dsc +archive=${package}_${version}.orig.tar.xz +echo " $(md5sum ${archive} | cut -d' ' -f1) $(wc -c ${archive})" >> distro/debian/${package}.dsc diff --git a/scripts/make-srpm.sh b/scripts/make-srpm.sh index 5fdaa7686..dbccb3410 100755 --- a/scripts/make-srpm.sh +++ b/scripts/make-srpm.sh @@ -3,6 +3,7 @@ # Create a source rpm for Fedora/EPEL cd "$(git rev-parse --show-toplevel)" +scripts/make-archive.sh scripts/make-distrofiles.sh mv knot-resolver_*.orig.tar.xz distro/fedora/ cd distro/fedora diff --git a/scripts/show-version.sh b/scripts/show-version.sh deleted file mode 100755 index 36eafcd34..000000000 --- a/scripts/show-version.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -e -git describe | sed 's/^v//' | sed 's/-/\./g' -- 2.47.3