From 08c876b42b9fd6ab60e5274e78dddff9d75de88a Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sun, 11 Feb 2024 18:29:19 +0000 Subject: [PATCH] pkgbuild: pkgver=1.16.4 pkgrel=1 (genesis) This repo was forked from the upstream Archlinux consul package at commit 4b59c61ed1036182df6fff4621d897312c8c1a6b. This was then modified to download from the open-consul source, and slight improvements made to GOFLAGS + tidied up makedepends. References: https://gitlab.archlinux.org/archlinux/packaging/packages/consul References: https://gitlab.archlinux.org/archlinux/packaging/packages/consul/-/tree/4b59c61ed1036182df6fff4621d897312c8c1a6b --- .SRCINFO | 25 ++++++ .gitignore | 89 ++++++++++++++++++++++ PKGBUILD | 82 ++++++++++++++++++++ consul-ldflags.patch | 31 ++++++++ consul.default | 1 + consul.install | 9 +++ consul.service | 16 ++++ consul.sysusers | 1 + example.json | 7 ++ fix-build-version-info.patch | 75 ++++++++++++++++++ fix-test.patch | 11 +++ unparallelize-or-disable-flaky-tests.patch | 54 +++++++++++++ 12 files changed, 401 insertions(+) create mode 100644 .SRCINFO create mode 100644 .gitignore create mode 100644 PKGBUILD create mode 100644 consul-ldflags.patch create mode 100644 consul.default create mode 100644 consul.install create mode 100644 consul.service create mode 100644 consul.sysusers create mode 100644 example.json create mode 100644 fix-build-version-info.patch create mode 100644 fix-test.patch create mode 100644 unparallelize-or-disable-flaky-tests.patch diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 0000000..2d3c480 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,25 @@ +pkgbase = open-consul + pkgdesc = A tool for service discovery, monitoring and configuration. + pkgver = 1.16.4 + pkgrel = 1 + url = https://developer.hashicorp.com/consul/docs/v1.16.x + install = consul.install + arch = x86_64 + license = MPL2 + makedepends = go + depends = glibc + provides = consul + conflicts = consul + backup = etc/default/consul + source = open-consul-1.16.4.tar.gz::https://git.st8l.com/luxolus/open-consul/archive/25957a17b5eddd1b95ebda13f8a667ec3c02b4c6.tar.gz + source = consul.service + source = consul.default + source = consul.sysusers + source = example.json + sha512sums = SKIP + sha512sums = c70b9d1556f6c7ecb2e915ab685f289cef0e31198bd2e50c74a0483bbfb387beec67334f539a90adbf68b61b07946e98b300ab8a8e26e53b35f4ab4894adeb04 + sha512sums = ec5a800529a297c709fa383c094ecf106351cf0f8ac7b613b972d415d77fe001088902d7ab805e63e78a8e6360323fec1b795db5a4446df1e21b9b4ed31e7079 + sha512sums = ef872aedb2bc022a29292b7972a792b22e684c1ccb904a2b2cfec6d8966c28fb19be1452ce060821c419f1b646b236ba2e783175595e4bb6926d164c27a15c87 + sha512sums = c4292b8f56ee955ed7385a49843fd90d6434029891b3e1e724cb2fc841514c06e2554a26d3937c114371b18c2168c4e64319eb2cbd726ee8b35870df19089348 + +pkgname = open-consul diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39940da --- /dev/null +++ b/.gitignore @@ -0,0 +1,89 @@ +# Created by https://www.toptal.com/developers/gitignore/api/archlinuxpackages,linux,macos,vim +# Edit at https://www.toptal.com/developers/gitignore?templates=archlinuxpackages,linux,macos,vim + +### ArchLinuxPackages ### +*.tar +*.tar.* +*.jar +*.exe +*.msi +*.zip +*.tgz +*.log +*.log.* +*.sig + +pkg/ +src/ + +/open-consul* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# End of https://www.toptal.com/developers/gitignore/api/archlinuxpackages,linux,macos,vim diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..bdbf928 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,82 @@ +# Maintainer: Paul Stemmet +# Contributor: Thore Bödecker +# Contributor: Felix Yan +# Contributor: Justin Kromlinger + +pkgname=open-consul +_commit=25957a17b5eddd1b95ebda13f8a667ec3c02b4c6 +pkgver=1.16.4 +pkgrel=1 +pkgdesc="A tool for service discovery, monitoring and configuration." +provides=('consul') +conflicts=('consul') +arch=('x86_64') +url="https://developer.hashicorp.com/consul/docs/v1.16.x" +license=('MPL2') +depends=('glibc') +makedepends=('go') +source=("${pkgname}-${pkgver}.tar.gz::https://git.st8l.com/luxolus/${pkgname}/archive/${_commit}.tar.gz" + 'consul.service' + 'consul.default' + 'consul.sysusers' + 'example.json') +install=consul.install +backup=('etc/default/consul') +sha512sums=('SKIP' + 'c70b9d1556f6c7ecb2e915ab685f289cef0e31198bd2e50c74a0483bbfb387beec67334f539a90adbf68b61b07946e98b300ab8a8e26e53b35f4ab4894adeb04' + 'ec5a800529a297c709fa383c094ecf106351cf0f8ac7b613b972d415d77fe001088902d7ab805e63e78a8e6360323fec1b795db5a4446df1e21b9b4ed31e7079' + 'ef872aedb2bc022a29292b7972a792b22e684c1ccb904a2b2cfec6d8966c28fb19be1452ce060821c419f1b646b236ba2e783175595e4bb6926d164c27a15c87' + 'c4292b8f56ee955ed7385a49843fd90d6434029891b3e1e724cb2fc841514c06e2554a26d3937c114371b18c2168c4e64319eb2cbd726ee8b35870df19089348') + +export CGO_LDFLAGS="${LDFLAGS}" +export CGO_CFLAGS="${CFLAGS}" +export CGO_CPPFLAGS="${CPPFLAGS}" +export CGO_CXXFLAGS="${CXXFLAGS}" + +export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" + +export XC_OSARCH='linux/amd64' + +prepare() { + cd "${srcdir}/${pkgname}" + + mkdir -p build + + local filename + for filename in "${source[@]}"; do + if [[ "$filename" =~ \.patch$ ]]; then + patch -p1 -N -l -i "$srcdir/${filename##*/}" + fi + done + + go mod download +} + +build() { + cd "${srcdir}/${pkgname}" + + go build -o build ./... +} + +check() { + cd "${srcdir}/${pkgname}" + + # assert version number from commit hash matches pkgver metadata + ./build/consul --version | head -1 | grep -qF -- "v${pkgver}" +} + +package() { + cd "${srcdir}/${pkgname}" + + install -D -d -m750 -o 208 -g 208 "${pkgdir}/var/lib/consul" + install -D -d -m750 -o 0 -g 208 "${pkgdir}/etc/consul.d" + + install -D -m644 "${srcdir}/consul.default" "${pkgdir}/etc/default/consul" + install -D -m644 -o 0 -g 0 "${srcdir}/example.json" "${pkgdir}/usr/share/doc/consul/config.example.json" + install -Dm755 "build/consul" "${pkgdir}/usr/bin/consul" + + install -Dm644 "${srcdir}/consul.service" "${pkgdir}/usr/lib/systemd/system/consul.service" + install -Dm644 "${srcdir}/consul.sysusers" "${pkgdir}/usr/lib/sysusers.d/consul.conf" +} + +# vim:set ts=2 sw=2 et: diff --git a/consul-ldflags.patch b/consul-ldflags.patch new file mode 100644 index 0000000..b97e622 --- /dev/null +++ b/consul-ldflags.patch @@ -0,0 +1,31 @@ +diff -upr b/build-support/functions/20-build.sh c/build-support/functions/20-build.sh +--- b/build-support/functions/20-build.sh 2020-03-04 10:15:04.066148196 +0100 ++++ c/build-support/functions/20-build.sh 2020-03-04 10:13:54.354670580 +0100 +@@ -458,7 +458,7 @@ function build_consul_local { + if [ $os == "windows" ];then + binname="consul.exe" + fi +- debug_run env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go install -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}" && cp "${MAIN_GOPATH}/bin/${GOBIN_EXTRA}${binname}" "${outdir}/${binname}" ++ debug_run env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go install -ldflags "-linkmode external -extldflags ${EXTLDFLAGS} -s -w ${GOLDFLAGS}" -tags "${GOTAGS}" && cp "${MAIN_GOPATH}/bin/${GOBIN_EXTRA}${binname}" "${outdir}/${binname}" + if test $? -ne 0 + then + err "ERROR: Failed to build Consul for ${osarch}" +diff -upr b/GNUmakefile c/GNUmakefile +--- b/GNUmakefile 2020-03-04 10:14:46.245770467 +0100 ++++ c/GNUmakefile 2020-03-04 10:15:32.286746368 +0100 +@@ -17,6 +17,7 @@ MAIN_GOPATH=$(shell go env GOPATH | cut + + ASSETFS_PATH?=agent/bindata_assetfs.go + GOLDFLAGS= ++EXTLDFLAGS := ${LDFLAGS} + + PROTOFILES?=$(shell find . -name '*.proto' | grep -v 'vendor/') + PROTOGOFILES=$(PROTOFILES:.proto=.pb.go) +@@ -120,6 +121,7 @@ export GIT_DIRTY + export GIT_DESCRIBE + export GOTAGS + export GOLDFLAGS ++export EXTLDFLAGS + + # Allow skipping docker build during integration tests in CI since we already + # have a built binary diff --git a/consul.default b/consul.default new file mode 100644 index 0000000..4274b41 --- /dev/null +++ b/consul.default @@ -0,0 +1 @@ +CONSUL_FLAGS="" diff --git a/consul.install b/consul.install new file mode 100644 index 0000000..149ee47 --- /dev/null +++ b/consul.install @@ -0,0 +1,9 @@ +post_upgrade() { + # improved permissions since 0.9.3-1 + if [ "$(vercmp "$2" "0.9.3")" -lt 0 ]; then + chown 0:208 /etc/consul.d + chmod 0750 /etc/consul.d + echo -en "----\nThe directory permissions for /etc/consul.d/ have been fixed.\n----\n" + fi + true +} diff --git a/consul.service b/consul.service new file mode 100644 index 0000000..f6a2b40 --- /dev/null +++ b/consul.service @@ -0,0 +1,16 @@ +[Unit] +Description=Consul Agent +Requires=network-online.target +After=network-online.target + +[Service] +User=consul +Group=consul +EnvironmentFile=-/etc/default/consul +Restart=on-failure +ExecStart=/usr/bin/consul agent $CONSUL_FLAGS -config-dir=/etc/consul.d +ExecReload=/usr/bin/kill -HUP $MAINPID +KillSignal=SIGINT + +[Install] +WantedBy=multi-user.target diff --git a/consul.sysusers b/consul.sysusers new file mode 100644 index 0000000..d285042 --- /dev/null +++ b/consul.sysusers @@ -0,0 +1 @@ +u consul 208 - /var/lib/consul diff --git a/example.json b/example.json new file mode 100644 index 0000000..6d2f2b1 --- /dev/null +++ b/example.json @@ -0,0 +1,7 @@ +{ + "data_dir": "/var/lib/consul", + "disable_update_check": true, + "log_level": "INFO", + "node_name": "example.localdomain", + "server": true +} diff --git a/fix-build-version-info.patch b/fix-build-version-info.patch new file mode 100644 index 0000000..efbf258 --- /dev/null +++ b/fix-build-version-info.patch @@ -0,0 +1,75 @@ +--- a/version/version.go 2018-06-26 09:57:33.703932696 +0200 ++++ b/version/version.go 2018-06-26 09:59:05.986536238 +0200 +@@ -1,7 +1,6 @@ + package version + + import ( +- "fmt" + "strings" + ) + +@@ -27,24 +26,6 @@ var ( + // for displaying to humans. + func GetHumanVersion() string { + version := Version +- if GitDescribe != "" { +- version = GitDescribe +- } +- +- release := VersionPrerelease +- if GitDescribe == "" && release == "" { +- release = "dev" +- } +- +- if release != "" { +- if !strings.HasSuffix(version, "-"+release) { +- // if we tagged a prerelease version then the release is in the version already +- version += fmt.Sprintf("-%s", release) +- } +- if GitCommit != "" { +- version += fmt.Sprintf(" (%s)", GitCommit) +- } +- } + + // Strip off any single quotes added by the git information. + return strings.Replace(version, "'", "", -1) +--- a/GNUmakefile 2020-02-20 16:40:00.000000000 +0100 ++++ b/GNUmakefile 2020-03-04 09:48:52.279500949 +0100 +@@ -16,13 +16,7 @@ GOPATH=$(shell go env GOPATH) + MAIN_GOPATH=$(shell go env GOPATH | cut -d: -f1) + + ASSETFS_PATH?=agent/bindata_assetfs.go +-# Get the git commit +-GIT_COMMIT?=$(shell git rev-parse --short HEAD) +-GIT_COMMIT_YEAR?=$(shell git show -s --format=%cd --date=format:%Y HEAD) +-GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true) +-GIT_DESCRIBE?=$(shell git describe --tags --always --match "v*") +-GIT_IMPORT=github.com/hashicorp/consul/version +-GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE) ++GOLDFLAGS= + + PROTOFILES?=$(shell find . -name '*.proto' | grep -v 'vendor/') + PROTOGOFILES=$(PROTOFILES:.proto=.pb.go) +@@ -348,16 +342,6 @@ tools: + fi + cd .gotools && go get -v $(GOTOOLS) + +-version: +- @echo -n "Version: " +- @$(SHELL) $(CURDIR)/build-support/scripts/version.sh +- @echo -n "Version + release: " +- @$(SHELL) $(CURDIR)/build-support/scripts/version.sh -r +- @echo -n "Version + git: " +- @$(SHELL) $(CURDIR)/build-support/scripts/version.sh -g +- @echo -n "Version + release + git: " +- @$(SHELL) $(CURDIR)/build-support/scripts/version.sh -r -g +- + + docker-images: go-build-image ui-build-image + +@@ -409,4 +393,4 @@ proto: $(PROTOGOFILES) $(PROTOGOBINFILES + + .PHONY: all ci bin dev dist cov test test-ci test-internal cover format vet ui static-assets tools + .PHONY: docker-images go-build-image ui-build-image static-assets-docker consul-docker ui-docker +-.PHONY: version proto proto-rebuild proto-delete test-envoy-integ ++.PHONY: proto proto-rebuild proto-delete test-envoy-integ diff --git a/fix-test.patch b/fix-test.patch new file mode 100644 index 0000000..0522fc7 --- /dev/null +++ b/fix-test.patch @@ -0,0 +1,11 @@ +--- a/GNUmakefile 2020-02-20 16:40:00.000000000 +0100 ++++ b/GNUmakefile 2020-03-04 09:51:30.786193388 +0100 +@@ -212,7 +212,7 @@ cov: other-consul dev-build + rm -f coverage.{sdk,api}.part + go tool cover -html=coverage.out + +-test: other-consul dev-build vet test-internal ++test: other-consul dev-build test-internal + + go-mod-tidy: + @echo "--> Running go mod tidy" diff --git a/unparallelize-or-disable-flaky-tests.patch b/unparallelize-or-disable-flaky-tests.patch new file mode 100644 index 0000000..d0259e4 --- /dev/null +++ b/unparallelize-or-disable-flaky-tests.patch @@ -0,0 +1,54 @@ +diff -upr a/agent/cache/cache_test.go b/agent/cache/cache_test.go +--- a/agent/cache/cache_test.go 2018-11-14 23:37:47.000000000 +0100 ++++ b/agent/cache/cache_test.go 2019-01-08 15:23:12.540631267 +0100 +@@ -213,7 +213,6 @@ func TestCacheGet_blockingInitSameKey(t + // Test that Get with different cache keys both block on initial value + // but that the fetches were both properly called. + func TestCacheGet_blockingInitDiffKeys(t *testing.T) { +- t.Parallel() + + require := require.New(t) + +@@ -299,7 +298,6 @@ func TestCacheGet_blockingIndex(t *testi + // Test a get with an index set will timeout if the fetch doesn't return + // anything. + func TestCacheGet_blockingIndexTimeout(t *testing.T) { +- t.Parallel() + + typ := TestType(t) + defer typ.AssertExpectations(t) +@@ -438,7 +436,6 @@ func TestCacheGet_emptyFetchResult(t *te + // Test that a type registered with a periodic refresh will perform + // that refresh after the timer is up. + func TestCacheGet_periodicRefresh(t *testing.T) { +- t.Parallel() + + typ := TestType(t) + defer typ.AssertExpectations(t) +@@ -525,7 +522,6 @@ func TestCacheGet_periodicRefreshMultipl + + // Test that a refresh performs a backoff. + func TestCacheGet_periodicRefreshErrorBackoff(t *testing.T) { +- t.Parallel() + + typ := TestType(t) + defer typ.AssertExpectations(t) +@@ -566,7 +562,6 @@ func TestCacheGet_periodicRefreshErrorBa + + // Test that a badly behaved RPC that returns 0 index will perform a backoff. + func TestCacheGet_periodicRefreshBadRPCZeroIndexErrorBackoff(t *testing.T) { +- t.Parallel() + + typ := TestType(t) + defer typ.AssertExpectations(t) +diff -upr a/agent/cache-types/connect_ca_leaf_test.go b/agent/cache-types/connect_ca_leaf_test.go +--- a/agent/cache-types/connect_ca_leaf_test.go 2018-11-14 23:37:47.000000000 +0100 ++++ b/agent/cache-types/connect_ca_leaf_test.go 2019-01-08 15:23:55.670339830 +0100 +@@ -870,7 +870,6 @@ func TestConnectCALeaf_changingRoots(t * + // Test that after an initial signing, an expiringLeaf will trigger a + // blocking query to resign. + func TestConnectCALeaf_expiringLeaf(t *testing.T) { +- t.Parallel() + + require := require.New(t) + rpc := TestRPC(t)