From ddd332e6920faa66166cb0ab0e222481452e01bc Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Sun, 13 Nov 2022 21:06:25 +1300 Subject: addpkg: xq 1.0.0-1 --- .SRCINFO | 21 +++++----- PKGBUILD | 101 ++++++++++++++++++++++++++++++++++++++++--------- manpage-template.patch | 9 +++++ 3 files changed, 104 insertions(+), 27 deletions(-) create mode 100644 manpage-template.patch diff --git a/.SRCINFO b/.SRCINFO index a92e588..d33f894 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,16 +1,17 @@ -# Generated by mksrcinfo v8 -# Thu Mar 5 01:45:39 UTC 2020 pkgbase = xq - pkgdesc = xml to json convert parser - pkgver = 0.3.4 + pkgdesc = Command-line XML and HTML beautifier and content extractor + pkgver = 1.0.0 pkgrel = 1 - url = https://github.com/syui/xq + url = https://github.com/sibprogrammer/xq arch = x86_64 - arch = i686 license = MIT - makedepends = go-pie - source = xq-0.3.4::https://github.com/syui/xq/archive/0.3.4.tar.gz - sha256sums = 6dc017cf06a598f8bc781a508ff0e63bbc5d7828026b8e7733dc387aec280ceb + makedepends = git + makedepends = go + depends = glibc + options = !lto + source = xq::git+https://github.com/sibprogrammer/xq#commit=21fca280a144fbf34ab1a58efa39acb495a46764 + source = manpage-template.patch + b2sums = SKIP + b2sums = 4673d2c90996be27f5889f97541f1c4bd0c89c48d5b0573846d7e7a791bba3eaa66ca9774a054911d0014ee33e48bb19084fa3340a12756b2369928c4b951eb3 pkgname = xq - diff --git a/PKGBUILD b/PKGBUILD index ba0cf85..d7114b4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,24 +1,91 @@ -# Maintainer: syui +# Maintainer: George Rawlinson + pkgname=xq -pkgver=0.3.4 +pkgver=1.0.0 pkgrel=1 -pkgdesc="xml to json convert parser" -arch=('x86_64' 'i686') -url="https://github.com/syui/xq" -makedepends=('go-pie') +pkgdesc='Command-line XML and HTML beautifier and content extractor' +arch=('x86_64') +url='https://github.com/sibprogrammer/xq' license=('MIT') -source=("${pkgname}-${pkgver}::${url}/archive/$pkgver.tar.gz") -sha256sums=('6dc017cf06a598f8bc781a508ff0e63bbc5d7828026b8e7733dc387aec280ceb') -build(){ - cd "${pkgname}-${pkgver}" - go build \ +depends=('glibc') +makedepends=('git' 'go') +options=('!lto') +_commit='21fca280a144fbf34ab1a58efa39acb495a46764' +source=( + "$pkgname::git+$url#commit=$_commit" + 'manpage-template.patch' +) +b2sums=('SKIP' + '4673d2c90996be27f5889f97541f1c4bd0c89c48d5b0573846d7e7a791bba3eaa66ca9774a054911d0014ee33e48bb19084fa3340a12756b2369928c4b951eb3') + +pkgver() { + cd "$pkgname" + + git describe --tags | sed 's/^v//' +} + +prepare() { + cd "$pkgname" + + # create directory for build output + mkdir build + + # download dependencies + go mod download + + # turn man page into a template + patch -p1 -i "$srcdir/manpage-template.patch" +} + +build() { + cd "$pkgname" + + # set Go flags + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + + # commit date for binary & man page + local _commit_date=$(git show --no-patch --format=%cd --date=format:%Y-%m-%d) + + go build -v \ -trimpath \ - -ldflags "-extldflags ${LDFLAGS}" \ - -o $pkgname . + -buildmode=pie \ + -mod=readonly \ + -modcacherw \ + -ldflags "-linkmode external -extldflags ${LDFLAGS} \ + -X main.commit=$_commit \ + -X main.date=$_commit_date \ + -X main.version=$pkgver" \ + -o build \ + . + + # template-ify man page + sed \ + -e "s/@DATE@/$_commit_date/" \ + -e "s/@VERSION@/$pkgver/" \ + -i docs/xq.man } -package() { - cd "${pkgname}-${pkgver}" - install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname" + +check() { + cd "$pkgname" + + go test -v ./... } -# vim:set ts=2 sw=2 et: +package() { + cd "$pkgname" + + # binary + install -vDm755 -t "$pkgdir/usr/bin" build/xq + + # documentation + install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md + cp -vr assets "$pkgdir/usr/share/doc/$pkgname" + + # man + install -vDm644 docs/xq.man "$pkgdir/usr/share/man/man1/$pkgname.1" + + # license + install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE +} diff --git a/manpage-template.patch b/manpage-template.patch new file mode 100644 index 0000000..6dba9af --- /dev/null +++ b/manpage-template.patch @@ -0,0 +1,9 @@ +--- a/docs/xq.man ++++ b/docs/xq.man +@@ -1,5 +1,5 @@ + .\" Manpage for xq utility +-.TH XQ 1 "06 Nov 2022" "0.0.8" "xq man page" ++.TH XQ 1 "@DATE@" "@VERSION@" "xq man page" + .SH NAME + xq - command-line XML and HTML beautifier and content extractor + .SH SYNOPSIS -- cgit v1.2.3-70-g09d2