### this file is sourced not run
# source: step

# Build [1] master commit or [2] official release

repo=jq
pkgname=$repo # for SLACKDESC

# [1] Master commit
# hash=9fa2e51099c55af56e3e541dc4b399f11de74abe # 1.6_2019_02_09
# MD5SUM=acc996f6c1ad72e84f05c300dd0d4b6a       # 1.6_2019_02_09

# hash7=${hash#???????}; hash7=${hash%$hash7}
# PKGVER=1.6_2019.02.09_$hash7
# TARBALL=$repo-$hash.tar.gz
# SRC_URL=https://github.com/jqlang/$repo/archive/$hash.tar.gz

# [2] Official release

PKGVER=1.8.1
TARBALL=$pkgname-$PKGVER.tar.gz
#MD5SUM=3524afabc425c08efca282351594b7fb
#SRC_URL=https://github.com/jqlang/$repo/archive/$TARBALL
MD5SUM=ea4bb241cd9c625b43b0988776db1e03
SRC_URL=https://github.com/jqlang/jq/releases/download/jq-$PKGVER/$TARBALL

# --- common ---

PKGARCH=x86_64
PKGBUILD=1
BUNDLE=

SLACKREQ='liboniguruma'
SLACKSUG=''
SLACKDESC="$pkgname: $pkgname $PKGVER (JSON command-line processor)  
$pkgname:  
$pkgname: jq is a lightweight and flexible command-line JSON processor. jq is like 
$pkgname: sed for JSON data – you can use it to slice and filter and map and 
$pkgname: transform structured data with the same ease that sed, awk, grep and 
$pkgname: friends let you play with text.  
$pkgname: 
$pkgname: License: remix
$pkgname: 
$pkgname: http://stedolan.github.io/jq/
$pkgname: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/${repo:-$pkgname}-* &&
	: patches go here...
}

### default pkg_package
### build
pkg_build() {

<< "EOF" # only for git-based builds
	cd tmp/${repo:-$pkgname}-* &&
	
	# Make executes `git describe`, which expects a git repo. Let's fake it.
	cat > git << EOF &&
#!/bin/sh
case \$* in
	'describe') echo "${PKGVER//_/-}" ;;
	'describe --tags --dirty --match jq-*')
		[ $hash7 ] && echo "$pkgname-${PKGVER%%_*}-1-g$hash7" || echo "${PKGVER}" ;;
	'rev-parse --verify -q jq-1.0') true ;;
	'rev-parse --abbrev-ref HEAD') echo master ;;
	* ) echo >&2 "fake-git can't handle argument(s) \$*"; exit 1 ;;
esac

	chmod +x git &&
	PATH=.:$PATH &&

	autoreconf -fiv &&
EOF

	CONFFLAGS="$CONFFLAGS --with-oniguruma" &&
	pkg_build_autoconf &&
	pkg_build_slackdesc
}

# vim: fdm=marker ft=sh:
