From 3f4b2d2ab9bb179b05f86faf4f7bfbd062e825ca Mon Sep 17 00:00:00 2001 From: none Date: Sat, 4 Nov 2023 17:46:23 +0100 Subject: [PATCH] Add build.sh to adguard-home --- .../adguard-home/adguard-home-9999.ebuild | 4 +- net-misc/adguard-home/files/Makefile | 4 ++ net-misc/adguard-home/files/build.sh | 55 +++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 net-misc/adguard-home/files/Makefile create mode 100644 net-misc/adguard-home/files/build.sh diff --git a/net-misc/adguard-home/adguard-home-9999.ebuild b/net-misc/adguard-home/adguard-home-9999.ebuild index 4cf5f22..79d005c 100644 --- a/net-misc/adguard-home/adguard-home-9999.ebuild +++ b/net-misc/adguard-home/adguard-home-9999.ebuild @@ -28,8 +28,8 @@ src_configure() { } src_compile() { - emake bin/"$PN" - # CHANNEL=development SIGN=0 VERBOSE=1 ARCH=amd64 OS=linux ./scripts/make/build-release.sh + # emake bin/"$PN" + env CHANNEL=edge SIGN=0 VERBOSE=1 ARCH=amd64 OS=linux ${FILESDIR}/build.sh } src_install() { diff --git a/net-misc/adguard-home/files/Makefile b/net-misc/adguard-home/files/Makefile new file mode 100644 index 0000000..51a8ae3 --- /dev/null +++ b/net-misc/adguard-home/files/Makefile @@ -0,0 +1,4 @@ +GO=${GO:-go} + +all: + diff --git a/net-misc/adguard-home/files/build.sh b/net-misc/adguard-home/files/build.sh new file mode 100644 index 0000000..772cd83 --- /dev/null +++ b/net-misc/adguard-home/files/build.sh @@ -0,0 +1,55 @@ +go="${GO:-go}" +readonly go + + +bump_minor='/^v[0-9]+\.[0-9]+\.0$/ { + print($1 "." $2 + 1 ".0"); + + next; +} + +{ + printf("invalid release version: \"%s\"\n", $0); + + exit 1; +}' +readonly bump_minor + + +get_last_minor_zero() { + git tag\ + | grep -e 'v[0-9]\+\.[0-9]\+\.0$'\ + | sort -k 1.2,1nr -k 2,2nr -t '.'\ + | head -n 1 +} + + +last_minor_zero="$( get_last_minor_zero )" +readonly last_minor_zero +num_commits_since_minor="$( git rev-list --count "${last_minor_zero}..HEAD" )" +readonly num_commits_since_minor + +next_minor="$( echo "$last_minor_zero" | awk -F '.' "$bump_minor" )" +readonly next_minor + +version="${next_minor}-a.${num_commits_since_minor}+$( git rev-parse --short HEAD )" + +CGO_ENABLED='1' +GO111MODULE='on' +export CGO_ENABLED +export GO111MODULE + +version_pkg='github.com/AdguardTeam/AdGuardHome/internal/version' +readonly version_pkg + +ldflags="-s -w" +ldflags="${ldflags} -X ${version_pkg}.version=${version}" +ldflags="${ldflags} -X ${version_pkg}.channel=${channel}" + +"$go" build\ + --ldflags "$ldflags"\ + --race=1\ + --trimpath\ + -o=AdGuardHome\ + -v=1\ + -x=1