summaryrefslogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
authorGeorge Rawlinson2022-11-13 21:06:25 +1300
committerGeorge Rawlinson2022-11-13 21:06:25 +1300
commitddd332e6920faa66166cb0ab0e222481452e01bc (patch)
tree3b0f8a78c5ccd685a02b73f4d91421f84428ba44 /PKGBUILD
parent807d7c80d6c090a588f4506c86a47f7f64ccee3f (diff)
downloadpackages-ddd332e6920faa66166cb0ab0e222481452e01bc.tar.gz
packages-ddd332e6920faa66166cb0ab0e222481452e01bc.tar.bz2
packages-ddd332e6920faa66166cb0ab0e222481452e01bc.zip
addpkg: xq 1.0.0-1
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD101
1 files changed, 84 insertions, 17 deletions
diff --git a/PKGBUILD b/PKGBUILD
index ba0cf85..d7114b4 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,24 +1,91 @@
1# Maintainer: syui <syui@users.noreply.github.com> 1# Maintainer: George Rawlinson <grawlinson@archlinux.org>
2
2pkgname=xq 3pkgname=xq
3pkgver=0.3.4 4pkgver=1.0.0
4pkgrel=1 5pkgrel=1
5pkgdesc="xml to json convert parser" 6pkgdesc='Command-line XML and HTML beautifier and content extractor'
6arch=('x86_64' 'i686') 7arch=('x86_64')
7url="https://github.com/syui/xq" 8url='https://github.com/sibprogrammer/xq'
8makedepends=('go-pie')
9license=('MIT') 9license=('MIT')
10source=("${pkgname}-${pkgver}::${url}/archive/$pkgver.tar.gz") 10depends=('glibc')
11sha256sums=('6dc017cf06a598f8bc781a508ff0e63bbc5d7828026b8e7733dc387aec280ceb') 11makedepends=('git' 'go')
12build(){ 12options=('!lto')
13 cd "${pkgname}-${pkgver}" 13_commit='21fca280a144fbf34ab1a58efa39acb495a46764'
14 go build \ 14source=(
15 "$pkgname::git+$url#commit=$_commit"
16 'manpage-template.patch'
17)
18b2sums=('SKIP'
19 '4673d2c90996be27f5889f97541f1c4bd0c89c48d5b0573846d7e7a791bba3eaa66ca9774a054911d0014ee33e48bb19084fa3340a12756b2369928c4b951eb3')
20
21pkgver() {
22 cd "$pkgname"
23
24 git describe --tags | sed 's/^v//'
25}
26
27prepare() {
28 cd "$pkgname"
29
30 # create directory for build output
31 mkdir build
32
33 # download dependencies
34 go mod download
35
36 # turn man page into a template
37 patch -p1 -i "$srcdir/manpage-template.patch"
38}
39
40build() {
41 cd "$pkgname"
42
43 # set Go flags
44 export CGO_CPPFLAGS="${CPPFLAGS}"
45 export CGO_CFLAGS="${CFLAGS}"
46 export CGO_CXXFLAGS="${CXXFLAGS}"
47
48 # commit date for binary & man page
49 local _commit_date=$(git show --no-patch --format=%cd --date=format:%Y-%m-%d)
50
51 go build -v \
15 -trimpath \ 52 -trimpath \
16 -ldflags "-extldflags ${LDFLAGS}" \ 53 -buildmode=pie \
17 -o $pkgname . 54 -mod=readonly \
55 -modcacherw \
56 -ldflags "-linkmode external -extldflags ${LDFLAGS} \
57 -X main.commit=$_commit \
58 -X main.date=$_commit_date \
59 -X main.version=$pkgver" \
60 -o build \
61 .
62
63 # template-ify man page
64 sed \
65 -e "s/@DATE@/$_commit_date/" \
66 -e "s/@VERSION@/$pkgver/" \
67 -i docs/xq.man
18} 68}
19package() { 69
20 cd "${pkgname}-${pkgver}" 70check() {
21 install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname" 71 cd "$pkgname"
72
73 go test -v ./...
22} 74}
23 75
24# vim:set ts=2 sw=2 et: 76package() {
77 cd "$pkgname"
78
79 # binary
80 install -vDm755 -t "$pkgdir/usr/bin" build/xq
81
82 # documentation
83 install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
84 cp -vr assets "$pkgdir/usr/share/doc/$pkgname"
85
86 # man
87 install -vDm644 docs/xq.man "$pkgdir/usr/share/man/man1/$pkgname.1"
88
89 # license
90 install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
91}