diff options
-rwxr-xr-x | .githooks/post-commit | 5 | ||||
-rwxr-xr-x | .githooks/pre-commit | 5 | ||||
-rwxr-xr-x | .githooks/prepare-commit-msg | 2 | ||||
-rw-r--r-- | .travis.yml | 2 | ||||
-rwxr-xr-x | .travis/releaser.sh | 2 | ||||
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | build/build.sh | 5 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | contrib/Makefile.am | 33 | ||||
-rwxr-xr-x | docs/generator/buildyaml.sh | 2 | ||||
-rw-r--r-- | installer/README.md | 2 | ||||
-rw-r--r-- | packaging/README.md | 50 | ||||
-rwxr-xr-x | packaging/check-files | 129 | ||||
-rw-r--r-- | packaging/docker/Dockerfile (renamed from docker/Dockerfile) | 28 | ||||
-rw-r--r-- | packaging/docker/README.md (renamed from docker/README.md) | 0 | ||||
-rwxr-xr-x | packaging/docker/build.sh (renamed from docker/build.sh) | 12 | ||||
-rw-r--r-- | packaging/docker/run.sh (renamed from docker/run.sh) | 0 | ||||
-rwxr-xr-x | packaging/git-build | 54 | ||||
-rwxr-xr-x | packaging/gpg-recv-key | 65 | ||||
-rw-r--r-- | packaging/packaging.functions | 322 | ||||
-rwxr-xr-x | packaging/release-msg | 60 | ||||
-rwxr-xr-x | packaging/tar-compare | 77 | ||||
-rwxr-xr-x | packaging/update-tags | 150 |
24 files changed, 29 insertions, 986 deletions
diff --git a/.githooks/post-commit b/.githooks/post-commit deleted file mode 100755 index a1d41c7127..0000000000 --- a/.githooks/post-commit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -if [ -x ./packaging/update-tags ] -then - exec git diff HEAD^ | ./packaging/update-tags - -fi diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index fb2209f085..0000000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -if [ -x ./packaging/check-files ] -then - exec git diff --cached | ./packaging/check-files - -fi diff --git a/.githooks/prepare-commit-msg b/.githooks/prepare-commit-msg deleted file mode 100755 index 530f9576d5..0000000000 --- a/.githooks/prepare-commit-msg +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -test -x ./packaging/release-msg && exec ./packaging/release-msg "$@" diff --git a/.travis.yml b/.travis.yml index f079b93ae1..930ee94792 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ jobs: file: "netdata*.tar.gz" - name: docker images install: sudo apt update -y && sudo apt install -y --only-upgrade docker-ce && docker info - script: "docker/build.sh" + script: "packaging/docker/build.sh" env: REPOSITORY="netdata/netdata" - name: changelog generation script: ".travis/generate_changelog.sh" diff --git a/.travis/releaser.sh b/.travis/releaser.sh index 0b402c542f..07849e9060 100755 --- a/.travis/releaser.sh +++ b/.travis/releaser.sh @@ -53,7 +53,7 @@ git push "https://${GITHUB_TOKEN}:@$(git config --get remote.origin.url | sed -e echo "---- CREATING TAGGED DOCKER CONTAINERS ----" export REPOSITORY="netdata/netdata" -./docker/build.sh +./packaging/docker/build.sh echo "---- CREATING RELEASE ARTIFACTS -----" ./.travis/create_artifacts.sh diff --git a/Makefile.am b/Makefile.am index 5f67fcab19..efcb3380b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,8 +25,6 @@ EXTRA_DIST = \ .lgtm.yml \ .travis \ .github/CODEOWNERS \ - build/build.sh \ - build/Dockerfile \ build/m4/jemalloc.m4 \ build/m4/ax_c___atomic.m4 \ build/m4/ax_check_enable_debug.m4 \ @@ -51,14 +49,13 @@ SUBDIRS = \ diagrams \ makeself \ system \ - contrib \ tests \ $(NULL) dist_noinst_DATA= \ cppcheck.sh \ configs.signatures \ - docker \ + contrib \ netdata.cppcheck \ netdata.spec \ package.json \ @@ -109,7 +109,7 @@ docker run -d --name=netdata \ netdata/netdata ``` -For more information about running netdata in docker, check the [docker installation page](docker/). +For more information about running netdata in docker, check the [docker installation page](packaging/docker/). ![image](https://user-images.githubusercontent.com/2662304/48304090-fd384080-e51b-11e8-80ae-eecb03118dda.png) @@ -463,7 +463,7 @@ Here is a quick list: Directory|Description :---|:--- [`installer`](installer/)|Instructions to install netdata on your systems. -[`docker`](docker/)|Instructions to install netdata using docker. +[`docker`](packaging/docker/)|Instructions to install netdata using docker. [`daemon`](daemon/)|Information about the netdata daemon and its configuration. [`collectors`](collectors/)|Information about data collection plugins. [`health`](health/)|How netdata's health monitoring works, how to create your own alarms and how to configure alarm notification methods. diff --git a/build/build.sh b/build/build.sh index 8176190f67..892a7da988 100755 --- a/build/build.sh +++ b/build/build.sh @@ -1,7 +1,8 @@ #!/bin/bash -if [ -f build.sh ]; then - cd ../ || exit 1 +if [ ! -f .gitignore ]; then + echo "Run as ./travis/$(basename "$0") from top level directory of git repository" + exit 1 fi if [ "$IS_CONTAINER" != "" ]; then diff --git a/configure.ac b/configure.ac index 7d1784db62..01595e7416 100644 --- a/configure.ac +++ b/configure.ac @@ -566,7 +566,6 @@ AC_CONFIG_FILES([ collectors/python.d.plugin/Makefile collectors/statsd.plugin/Makefile collectors/tc.plugin/Makefile - contrib/Makefile daemon/Makefile database/Makefile diagrams/Makefile diff --git a/contrib/Makefile.am b/contrib/Makefile.am deleted file mode 100644 index 80d80d3718..0000000000 --- a/contrib/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later - -MAINTAINERCLEANFILES = $(srcdir)/Makefile.in - -dist_noinst_DATA = \ - README.md \ - debian/copyright \ - debian/netdata.conf \ - debian/source/format \ - debian/control.wheezy \ - debian/compat \ - debian/netdata.install \ - debian/netdata.lintian-overrides \ - debian/rules \ - debian/netdata.docs \ - debian/netdata.default \ - debian/control \ - debian/netdata.postinst.in \ - debian/netdata.service \ - debian/changelog \ - debian/netdata.postrm \ - rhel/build-netdata-rpm.sh \ - $(NULL) - -dist_noinst_SCRIPTS = \ - debian/netdata.init \ - $(NULL) - -debian/changelog: - echo "netdata ($(PACKAGE_VERSION)) UNRELEASED; urgency=medium" | \ - tr '_' '~' > $@ - echo " * Latest release" >> $@ - echo " -- Netdata Team <> `date -R`" >> $@ diff --git a/docs/generator/buildyaml.sh b/docs/generator/buildyaml.sh index 829f81abf2..6b982d40be 100755 --- a/docs/generator/buildyaml.sh +++ b/docs/generator/buildyaml.sh @@ -112,7 +112,7 @@ echo -ne " - 'docs/Why-Netdata.md' echo -ne "- Installation: - 'installer/README.md' - - 'docker/README.md' + - 'packaging/docker/README.md' - 'installer/UPDATE.md' - 'installer/UNINSTALL.md' " diff --git a/installer/README.md b/installer/README.md index 3658b50d8d..388cdb465d 100644 --- a/installer/README.md +++ b/installer/README.md @@ -134,7 +134,7 @@ Once Netdata is installed, see [Getting Started](../docs/GettingStarted.md). ## Run Netdata in a Docker container -You can [Install Netdata with Docker](../docker/#install-netdata-with-docker). +You can [Install Netdata with Docker](../packaging/docker/#install-netdata-with-docker). --- diff --git a/packaging/README.md b/packaging/README.md deleted file mode 100644 index 31a7499467..0000000000 --- a/packaging/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Packaging Tools - -The programs in folder `packaging` are used when packaging from within git -and are not included in source or binary packages. - -For the most part they are used from the git commit hooks (copy -`../.githooks/*` to `../.git/hooks` to automate checking and the release -process. - -The check-files script pulls in `*.functions` and `*/*.functions` to -do the actual work. - -`packaging.functions` contains generic checks on e.g `ChangeLog` -and `configure.ac` and automates release version, checking, tagging -and post-release update. - -Programs and packages with specific needs should create extra -`whatever.functions` and supporting scripts in a subdirectory. - -Making a release ----------------- -` -Just update ChangeLog and configure.ac to specify a suitable version -suffix: - - empty - final release - pre.# - pre-release candidate - rc.# - pre-release candidate - -If it is a final release and there is a package.spec.in, add a new -entry to the top of the %changelog section and update: - PACKAGE_RPM_RELEASE="1" - -The hooks will take over and if everything is OK will tag the release -(you will be asked to sign the tag) and then update the files ready -for further development. - -The release is not pushed out automatically, so if you want to undo -it, run: - -~~~~ -git reset --hard HEAD^^ -git tag -d vx.y.z -~~~~ - -Otherwise you can just push the results; the script outputs the required -instructions upon success. - -Once pushed the infrastructure will build a set of tar-files on the server. -For information on how to verify, sign and make these available, see [here](https://github.com/firehol/infrastructure#firehol-infrastructure) diff --git a/packaging/check-files b/packaging/check-files deleted file mode 100755 index 4372b2364c..0000000000 --- a/packaging/check-files +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-3.0-or-later - -# -# check-files -# -scriptname=check-files -if ! MYTMP=$(mktemp -d -t $scriptname-XXXXXX) -then - echo >&2 - echo >&2 - echo >&2 "Cannot create temporary directory." - echo >&2 - exit 1 -fi - -cleanup() { - status=$? - rm -rf "${MYTMP}" - exit $status -} - -# clean up if we get stopped by Crtl-C or forced logout or normal exit -trap cleanup INT -trap cleanup HUP -trap cleanup 0 - -set -e -if [ "$1" = "--debug" ] -then - set -x - shift -fi - -if [ $# -lt 1 ] -then - echo "check-files [--debug] -|filenames" - echo "e.g." - echo " git diff | ./packaging/check-files -" - echo "for a complete check (v.s. empty repo):" - echo " git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 | ./packaging/check-files -" - echo "or in .git/hooks/pre-commit:" - echo " exec git diff --cached | ./packaging/check-files -" - exit 1 -fi - -if [ ! -x packaging/check-files ] -then - echo "Must be run from base directory" - exit 1 -fi - -if [ "$1" = "-" ] -then - from_cache=Y - f="" -else - from_cache= - for f in "$@" - do - if [ ! -f "$f" ] - then - echo "$f: no such file" - exit 1 - fi - done - - git status --porcelain "$@" | grep "^?" | cut -c4- > $MYTMP/missing.lst - - while read missing - do - git update-index --add --cacheinfo \ - 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 $missing - done < $MYTMP/missing.lst - - empty_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904 - git diff $empty_tree -- "$@" > $MYTMP/diff.full - f=$MYTMP/diff.full - - while read missing - do - git update-index --force-remove $missing - done < $MYTMP/missing.lst -fi - -> $MYTMP/diff.lst sed -e "/^+++ b/{p;s:^+++ b/::;w $MYTMP/files.lst" -e "d;}" $f - -#cat $MYTMP/diff.lst -#cat $MYTMP/files.lst - -dirname="${0%/*}" -if [ "$dirname" = "$0" ]; then dirname="."; fi - -for i in $dirname/*.functions $dirname/*/*.functions -do - if [ -f "$i" ] - then - source $i - echo $i | sed -e 's:.*/::' -e 's/\.functions$//' -e 's/\./_/g' >> $MYTMP/fns - fi -done - -status=0 -while read fn -do - "${fn}_check_init" $filename || status=1 -done < $MYTMP/fns - -while read filename -do - #echo Checking $filename - while read fn - do - if [ $status -eq 0 ] - then - "${fn}_check_file" $filename || status=1 - fi - done < $MYTMP/fns -done < $MYTMP/files.lst - -if [ $status -eq 0 ] -then - while read fn - do - "${fn}_check_fin" $filename || status=1 - done < $MYTMP/fns -fi - -exit $status diff --git a/docker/Dockerfile b/packaging/docker/Dockerfile index 2bad518ede..3f84d065f0 100644 --- a/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -51,17 +51,13 @@ RUN mkdir -p /app/usr/sbin/ \ mv /var/lib/netdata /app/var/lib/ && \ mv /etc/netdata /app/etc/ && \ mv /usr/sbin/netdata /app/usr/sbin/ && \ - mv docker/run.sh /app/usr/sbin/ && \ + mv packaging/docker/run.sh /app/usr/sbin/ && \ chmod +x /app/usr/sbin/run.sh ##################################################################### ARG ARCH FROM multiarch/alpine:${ARCH} -# Configure system -ARG NETDATA_UID=201 -ARG NETDATA_GID=201 - # Reinstall some prerequisites RUN apk --no-cache add curl \ fping \ @@ -75,20 +71,22 @@ RUN apk --no-cache add curl \ py-yaml \ python -# fping from alpine apk is on a different location. Moving it. -RUN mv /usr/sbin/fping /usr/local/bin/fping && \ - chmod 4755 /usr/local/bin/fping && \ - mkdir -p /var/log/netdata && \ - # Add netdata user - addgroup -g ${NETDATA_GID} -S netdata && \ - adduser -S -H -s /usr/sbin/nologin -u ${NETDATA_GID} -h /etc/netdata -G netdata netdata - # Copy files over COPY --from=builder /app / +# Configure system +ARG NETDATA_UID=201 +ARG NETDATA_GID=201 RUN \ - # Apply permissions as described in - # https://github.com/netdata/netdata/tree/master/docs/netdata-security.md#netdata-directories + # fping from alpine apk is on a different location. Moving it. + mv /usr/sbin/fping /usr/local/bin/fping && \ + chmod 4755 /usr/local/bin/fping && \ + mkdir -p /var/log/netdata && \ + # Add netdata user + addgroup -g ${NETDATA_GID} -S netdata && \ + adduser -S -H -s /usr/sbin/nologin -u ${NETDATA_GID} -h /etc/netdata -G netdata netdata && \ + # Apply the permissions as described in + # https://github.com/netdata/netdata/wiki/netdata-security#netdata-directories chown -R root:netdata /etc/netdata && \ chown -R netdata:netdata /var/cache/netdata /var/lib/netdata /usr/share/netdata && \ chown -R root:netdata /usr/lib/netdata && \ diff --git a/docker/README.md b/packaging/docker/README.md index d624855fb7..d624855fb7 100644 --- a/docker/README.md +++ b/packaging/docker/README.md diff --git a/docker/build.sh b/packaging/docker/build.sh index faaa2db794..949c55e650 100755 --- a/docker/build.sh +++ b/packaging/docker/build.sh @@ -6,6 +6,11 @@ set -e +if [ ! -f .gitignore ]; then + echo "Run as ./packaging/docker/$(basename "$0") from top level directory of git repository" + exit 1 +fi + if [ "$1" == "" ]; then VERSION=$(git tag --points-at) else @@ -24,15 +29,11 @@ ARCH_MAP=( ["i386"]="386" ["amd64"]="amd64" ["armhf"]="arm" ["aarch64"]="arm64") docker run --rm --privileged multiarch/qemu-user-static:register --reset -if [ -f Dockerfile ]; then - cd ../ || exit 1 -fi - # Build images using multi-arch Dockerfile. for ARCH in i386 armhf aarch64 amd64; do docker build --build-arg ARCH="${ARCH}-v3.8" \ --tag "${REPOSITORY}:${VERSION}-${ARCH}" \ - --file docker/Dockerfile ./ & + --file packaging/docker/Dockerfile ./ & done wait @@ -71,4 +72,3 @@ docker --config /tmp/docker manifest push -p "${REPOSITORY}:${VERSION}" # Show current manifest (debugging purpose only) docker --config /tmp/docker manifest inspect "${REPOSITORY}:${VERSION}" - diff --git a/docker/run.sh b/packaging/docker/run.sh index b4cf52c7a0..b4cf52c7a0 100644 --- a/docker/run.sh +++ b/packaging/docker/run.sh diff --git a/packaging/git-build b/packaging/git-build deleted file mode 100755 index 645547b7fd..0000000000 --- a/packaging/git-build +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-3.0-or-later - -# When run from the top-level repository, performs a complete clean -# and maintainer-mode rebuild of the FireHOL package. - -if [ ! -f .gitignore -o ! -f configure.ac ] -then - echo "Run as ./packaging/git-build from an autotools git repository" - exit 1 -fi - -# If we are genuinely in a git repo, try to clean it up, otherwise -# just make the assumption -if [ -d .git ] -then - if [ -n "$TRAVIS_TAG" ] - then - echo "Checking we have a good signature during CI build..." - echo "Checking tag: $TRAVIS_TAG" - git tag -v "$TRAVIS_TAG" 2>&1 | tee /tmp/tagcheck - grep -iq "gpg. good signature" /tmp/tagcheck - status=$? - rm -f /tmp/tagcheck - if [ $status -ne 0 ] - then - exit $status - fi - fi - - clean=$(git status -s | grep "^?") - - if [ "$clean" ] - then - if [ "$1" != "-ok" ] - then - echo "Warning: this script runs: git clean -d -f -x" - echo " ensure all required ?? files are added, then re-run with '-ok'" - git status -s | grep '^?' - exit 1 - fi - fi - - set -e - git clean -d -f -x - set +e -fi - -set -e -autoreconf -ivf -./configure --enable-maintainer-mode -set +e -make dist || exit -./packaging/tar-compare . netdata-*.tar.gz || exit diff --git a/packaging/gpg-recv-key b/packaging/gpg-recv-key deleted file mode 100755 index 77874cda73..0000000000 --- a/packaging/gpg-recv-key +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -if [ ! "$KEYSERVER" ] -then - echo "No KEYSERVER environment set, e.g.:" - echo " export KEYSERVER=hkps://hkps.pool.sks-keyservers.net" - exit 1 -fi - -debug="" -if [ "$debug" ] -then - if [ ! "$GNUPGHOME" ] - then - echo "No GNUPGHOME environment set, e.g.:" - echo " export GNUPGHOME=$HOME/.gnupg" - exit 1 - fi - - if [ ! -d "$GNUPGHOME" ] - then - mkdir -p "$GNUPGHOME" - chmod 700 "$GNUPGHOME" - fi -fi - -keyuid="$1" -fingerprint="$2" - -# Modern GPG can import key by fingerprint but the version available -# within travis currently does not, so we extract the short version and -# check it matches manually -key=`echo $fingerprint | cut -f7-10 -d' ' | tr -d ' '` - -gpg --keyserver "$KEYSERVER" --recv-key "$key" || exit 1 -gpg --fingerprint "$key" > /tmp/keystatus.$$ -status=$? - -cat /tmp/keystatus.$$ -if [ $status -ne 0 ] -then - rm -f /tmp/keystatus.$$ - exit 2 -fi - -if ! grep -q "^uid.*<$keyuid>" /tmp/keystatus.$$ -then - rm -f /tmp/keystatus.$$ - echo "Did not find expected uid $keyuid" - exit 3 -fi - -echo "uid looks good" - -if ! grep -q " $fingerprint$" /tmp/keystatus.$$ -then - rm -f /tmp/keystatus.$$ - echo "Did not find expected fingerprint $fingerprint" - exit 3 -fi - -echo "Fingerprint looks good" - -rm -f /tmp/keystatus.$$ -exit 0 diff --git a/packaging/packaging.functions b/packaging/packaging.functions deleted file mode 100644 index cc7b41dc07..0000000000 --- a/packaging/packaging.functions +++ /dev/null @@ -1,322 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-3.0-or-later - -packaging_check_init() { - version_check= -} - -packaging_check_file() { - local filename="$1" status=0 - - case $filename in - configure.ac) - check_versions || status=1 - version_check=Y - ;; - *.spec.in) - check_versions || status=1 - version_check=Y - ;; - ChangeLog) - check_versions || status=1 - version_check=Y - if [ $status -eq 0 ] - then - check_changelog || status=1 - fi - ;; - *) - #echo "No checks found for $filename" - : - ;; - esac - return $status -} - -packaging_check_fin() { - if [ "$version_check" ] - then - version=`get_configure_ac_version` - case "$(match_version $version)" in - prerelease|candidate|release) - try_build || status=1 - if [ $status -eq 0 ] - then - cp $MYTMP/build/*.tar.* . - echo "Check $(cd $MYTMP/build && ls *.tar.gz) before pushing tags" - fi - ;; - esac - fi -} - -get_staged_file() { - local optional=0 - if [ "$1" = "-o" ] - then - optional=1 - shift - fi - - local dir="${1%/*}" - if [ "$dir" = "$1" ]; then dir="."; fi - mkdir -p $MYTMP/files/$dir - - test -f $MYTMP/files/$1 && return 0 - - if [ "$from_cache" ] - then - if [ $optional -eq 1 ] - then - git show :$1 > $MYTMP/files/$1 2> /dev/null || rm -f $MYTMP/files/$1 - else - git show :$1 > $MYTMP/files/$1 - fi - else - if [ $optional -eq 0 -o -f $1 ] - then - cp $1 $MYTMP/files/$1 - fi - fi -} - -try_build() { - if [ -f $MYTMP/success ]; then return 0; fi - mkdir -p $MYTMP/build - git archive HEAD | tar -xf - -C "$MYTMP/build" - git diff --staged | patch -p1 -d "$MYTMP/build" - (cd $MYTMP/build; ./packaging/git-build || touch $MYTMP/fail) - if [ -f $MYTMP/fail ]; then return 1; fi - touch $MYTMP/success - return 0 -} - -get_changelog_version() { - get_staged_file ChangeLog - local v=`sed -ne '1s/.*(\(.*\)).*/\1/p' $MYTMP/files/ChangeLog` - if [ ! "$v" ]; then v="No version in ChangeLog!"; fi - echo "$v" -} - -get_configure_ac_version() { - get_staged_file configure.ac - local v=`sed -n \ - -e '/define(\[VERSION_MAJOR/s/.*\[\([^[]*\)\].*/\1/p' \ - -e '/define(\[VERSION_MINOR/s/.*\[\([^[]*\)\].*/.\1/p' \ - -e '/define(\[VERSION_FIX/s/.*\[\([^[]*\)\].*/.\1/p' \ - -e '/define(\[VERSION_SUFFIX/s/.*\[\([^[]*\)\].*/\1/p' \ - $MYTMP/files/configure.ac | tr -d '\n'` - if [ ! "$v" ]; then v="No version in configure.ac!"; fi - echo "$v" -} - -get_configure_ac_package() { - get_staged_file configure.ac - local v=`sed -n -e 's/AC_INIT(\[\([^]]*\)\].*/\1/p' configure.ac` - if [ ! "$v" ]; then v="noname"; fi - echo "$v" -} - -get_configure_ac_rpmrel() { - get_staged_file configure.ac - local v=`sed -n -e 's/PACKAGE_RPM_RELEASE="\([^"]*\)".*/\1/p' configure.ac` - if [ ! "$v" ]; then v="norpmrel"; fi - echo "$v" -} - -get_spec_version() { - get_staged_file -o "$1".spec.in - test -f $MYTMP/files/"$1".spec.in || return 0 # Spec file is optional - sed -n -e '1,/^%changelog/d' -e '/^*/{' -e 's/.*- \([0-9].*\)/\1/p' -e q -e '}' "$1".spec.in -} - -splitver() { - local maj min fix sfx IFS=.-_ - - maj=$1 - min=$2 - fix=$3 - sfx=$4 - - set -- $5 - eval $maj=\$1 $min=\$2 $fix=\$3 $sfx=\$4 -} - -match_version() { - case "$1" in - [0-9]*.[0-9]*.[0-9]*_*) - # x.y.z_ZZZZ = development branch (can be before or after pre/rc) - echo "development" - ;; - [0-9]*.[0-9]*.[0-9]-pre[0-9]*) - echo "prerelease" - ;; - [0-9]*.[0-9]*.[0-9]-rc.[0-9]*) - echo "candidate" - ;; - [0-9]*.[0-9]*.[0-9]*) - echo "release" - ;; - *) - # Unknown - : - ;; - esac -} - -check_versions() { - local status=0 exact=0 prerelease=0 - - if [ -f $MYTMP/version-checked ] - then - read status < $MYTMP/version-checked - return $status - fi - - local confver=`get_configure_ac_version` - case "$(match_version $confver)" in - development) - : - ;; - prerelease|candidate|release) - exact=1 - ;; - *) - echo "Unrecognised version in configure.ac ($confver)" - status=1 - ;; - esac - - local clogver=`get_changelog_version` - case "$(match_version $clogver)" in - development) - echo "Do not include development branch version in ChangeLog ($clogver)" - status=1 - ;; - prerelease|candidate) - prerelease=1 - ;; - release) - : - ;; - *) - echo "Unrecognised version format in ChangeLog ($clogver)" - status=1 - ;; - esac - - local package=`get_configure_ac_package` - local specver=`get_spec_version $package` - - local clogmaj clogmin clogfix clogsfx - local confmaj confmin conffix confsfx - local specmaj specmin specfix specsfx - - splitver clogmaj clogmin clogfix clogsfx "$clogver" - splitver confmaj confmin conffix confsfx "$confver" - splitver specmaj specmin specfix specsfx "$specver" - - if [ "$specver" ] - then - if [ $specmaj -ne $clogmaj \ - -o $specmin -ne $clogmin \ - -o $specfix -ne $clogfix ] - then - echo "Main version of $package.spec.in ($specver) differs from ChangeLog ($clogver)" - status=1 - fi - fi - - if [ $status -eq 0 -a $exact -eq 0 ] - then - - if [ $confmaj -gt $clogmaj \ - -o $confmin -gt $clogmin \ - -o $conffix -gt $clogfix ] - then - : - elif [ $confmaj -eq $clogmaj \ - -a $confmin -eq $clogmin \ - -a $conffix -eq $clogfix \ - -a $prerelease -eq 1 ] - then - : - else - echo "Version in configure.ac ($confver) lesser than ChangeLog ($clogver)" - status=1 - fi - fi - - if [ $exact -eq 1 ] - then - echo "Running additional release checks" - - if [ "$confver" != "$clogver" ] - then - echo "Version in configure.ac ($confver) differs from ChangeLog ($clogver)" - status=1 - fi - - if [ "$specver" ] - then - local confrpmrel=`get_configure_ac_rpmrel` - if [ "$specsfx" != "$confrpmrel" ] - then - echo "%changelog suffix in $package.spec.in ($specsfx) differs from configure.ac PACKAGE_RPM_RELEASE ($confrpmrel)" - status=1 - fi - fi - - if [ ! "$TRAVIS_TAG" ] - then - if [ "$(git tag -l v$confver)" ] - then - echo "Tag v$confver already exists" - status=1 - fi - - if [ "$(git config user.signingkey)" = "" ] - then - echo "You need to set up a PGP signing key e.g.:" - echo " gpg --list-keys" - echo "and" - echo " git config user.signingkey SHORTID" - echo "or" - echo " git config --global user.signingkey SHORTID" - status=1 - fi - - git status -s | grep "^?" > $MYTMP/needclean - if [ -s $MYTMP/needclean ] - then - echo "The following files must be dealt with before commit:" - cat $MYTMP/needclean - echo "e.g. add them to .gitignore or remove with 'git clean -fdx'" - status=1 - fi - fi - fi - - echo $status > $MYTMP/version-checked - return $status -} |