diff options
author | George Rawlinson | 2022-11-13 21:06:25 +1300 |
---|---|---|
committer | George Rawlinson | 2022-11-13 21:06:25 +1300 |
commit | ddd332e6920faa66166cb0ab0e222481452e01bc (patch) | |
tree | 3b0f8a78c5ccd685a02b73f4d91421f84428ba44 /PKGBUILD | |
parent | 807d7c80d6c090a588f4506c86a47f7f64ccee3f (diff) | |
download | packages-ddd332e6920faa66166cb0ab0e222481452e01bc.tar.gz packages-ddd332e6920faa66166cb0ab0e222481452e01bc.tar.bz2 packages-ddd332e6920faa66166cb0ab0e222481452e01bc.zip |
addpkg: xq 1.0.0-1
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 101 |
1 files changed, 84 insertions, 17 deletions
@@ -1,24 +1,91 @@ | |||
1 | # Maintainer: syui <syui@users.noreply.github.com> | 1 | # Maintainer: George Rawlinson <grawlinson@archlinux.org> |
2 | |||
2 | pkgname=xq | 3 | pkgname=xq |
3 | pkgver=0.3.4 | 4 | pkgver=1.0.0 |
4 | pkgrel=1 | 5 | pkgrel=1 |
5 | pkgdesc="xml to json convert parser" | 6 | pkgdesc='Command-line XML and HTML beautifier and content extractor' |
6 | arch=('x86_64' 'i686') | 7 | arch=('x86_64') |
7 | url="https://github.com/syui/xq" | 8 | url='https://github.com/sibprogrammer/xq' |
8 | makedepends=('go-pie') | ||
9 | license=('MIT') | 9 | license=('MIT') |
10 | source=("${pkgname}-${pkgver}::${url}/archive/$pkgver.tar.gz") | 10 | depends=('glibc') |
11 | sha256sums=('6dc017cf06a598f8bc781a508ff0e63bbc5d7828026b8e7733dc387aec280ceb') | 11 | makedepends=('git' 'go') |
12 | build(){ | 12 | options=('!lto') |
13 | cd "${pkgname}-${pkgver}" | 13 | _commit='21fca280a144fbf34ab1a58efa39acb495a46764' |
14 | go build \ | 14 | source=( |
15 | "$pkgname::git+$url#commit=$_commit" | ||
16 | 'manpage-template.patch' | ||
17 | ) | ||
18 | b2sums=('SKIP' | ||
19 | '4673d2c90996be27f5889f97541f1c4bd0c89c48d5b0573846d7e7a791bba3eaa66ca9774a054911d0014ee33e48bb19084fa3340a12756b2369928c4b951eb3') | ||
20 | |||
21 | pkgver() { | ||
22 | cd "$pkgname" | ||
23 | |||
24 | git describe --tags | sed 's/^v//' | ||
25 | } | ||
26 | |||
27 | prepare() { | ||
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 | |||
40 | build() { | ||
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 | } |
19 | package() { | 69 | |
20 | cd "${pkgname}-${pkgver}" | 70 | check() { |
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: | 76 | package() { |
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 | } | ||