diff options
Diffstat (limited to 'xq/PKGBUILD')
| -rw-r--r-- | xq/PKGBUILD | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/xq/PKGBUILD b/xq/PKGBUILD new file mode 100644 index 0000000..3d7c110 --- /dev/null +++ b/xq/PKGBUILD | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | # Maintainer: George Rawlinson <grawlinson@archlinux.org> | ||
| 2 | |||
| 3 | pkgname=xq | ||
| 4 | pkgver=1.2.3 | ||
| 5 | pkgrel=1 | ||
| 6 | pkgdesc='Command-line XML and HTML beautifier and content extractor' | ||
| 7 | arch=('x86_64') | ||
| 8 | url='https://github.com/sibprogrammer/xq' | ||
| 9 | license=('MIT') | ||
| 10 | depends=('glibc') | ||
| 11 | makedepends=('git' 'go') | ||
| 12 | conflicts=('yq') | ||
| 13 | options=('!lto') | ||
| 14 | _commit='2842ec90a2d8143dd90211b083ace7325e6a3a8f' | ||
| 15 | source=( | ||
| 16 | "$pkgname::git+$url#commit=$_commit" | ||
| 17 | 'manpage-template.patch' | ||
| 18 | ) | ||
| 19 | b2sums=('SKIP' | ||
| 20 | 'f2448e22798e018d6962016dc800ff96ae9c23b776742348a7036d613efa8c37e5c8c7a539804f2daebc4c152495cc1cbbcb2635fcf223e958596333cab1b843') | ||
| 21 | |||
| 22 | pkgver() { | ||
| 23 | cd "$pkgname" | ||
| 24 | |||
| 25 | git describe --tags | sed 's/^v//' | ||
| 26 | } | ||
| 27 | |||
| 28 | prepare() { | ||
| 29 | cd "$pkgname" | ||
| 30 | |||
| 31 | # create directory for build output | ||
| 32 | mkdir build | ||
| 33 | |||
| 34 | # download dependencies | ||
| 35 | go mod download | ||
| 36 | |||
| 37 | # turn man page into a template | ||
| 38 | patch -p1 -i "$srcdir/manpage-template.patch" | ||
| 39 | } | ||
| 40 | |||
| 41 | build() { | ||
| 42 | cd "$pkgname" | ||
| 43 | |||
| 44 | # set Go flags | ||
| 45 | export CGO_CPPFLAGS="${CPPFLAGS}" | ||
| 46 | export CGO_CFLAGS="${CFLAGS}" | ||
| 47 | export CGO_CXXFLAGS="${CXXFLAGS}" | ||
| 48 | export GOPATH="${srcdir}" | ||
| 49 | |||
| 50 | # commit date for binary & man page | ||
| 51 | local _commit_date=$(git show --no-patch --format=%cd --date=format:%Y-%m-%d) | ||
| 52 | |||
| 53 | go build -v \ | ||
| 54 | -buildmode=pie \ | ||
| 55 | -mod=readonly \ | ||
| 56 | -modcacherw \ | ||
| 57 | -ldflags "-compressdwarf=false \ | ||
| 58 | -linkmode external \ | ||
| 59 | -extldflags ${LDFLAGS} \ | ||
| 60 | -X main.commit=$_commit \ | ||
| 61 | -X main.date=$_commit_date \ | ||
| 62 | -X main.version=$pkgver" \ | ||
| 63 | -o build \ | ||
| 64 | . | ||
| 65 | |||
| 66 | # template-ify man page | ||
| 67 | sed \ | ||
| 68 | -e "s/@DATE@/$_commit_date/" \ | ||
| 69 | -e "s/@VERSION@/$pkgver/" \ | ||
| 70 | -i docs/xq.man | ||
| 71 | } | ||
| 72 | |||
| 73 | check() { | ||
| 74 | cd "$pkgname" | ||
| 75 | |||
| 76 | go test -v ./... | ||
| 77 | } | ||
| 78 | |||
| 79 | package() { | ||
| 80 | cd "$pkgname" | ||
| 81 | |||
| 82 | # binary | ||
| 83 | install -vDm755 -t "$pkgdir/usr/bin" build/xq | ||
| 84 | |||
| 85 | # documentation | ||
| 86 | install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md | ||
| 87 | cp -vr assets "$pkgdir/usr/share/doc/$pkgname" | ||
| 88 | |||
| 89 | # man | ||
| 90 | install -vDm644 docs/xq.man "$pkgdir/usr/share/man/man1/$pkgname.1" | ||
| 91 | |||
| 92 | # license | ||
| 93 | install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE | ||
| 94 | } | ||
