summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7814e904cc26f38b89c4234d592a3a741bcbe08f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>

pkgname=jsonoid-discovery
pkgver=0.40.0
pkgrel=1
pkgdesc='Distributed JSON schema discovery'
arch=('any')
url='https://github.com/dataunitylab/jsonoid-discovery'
license=('MIT')
depends=('java-runtime' 'sh')
makedepends=('jdk11-openjdk' 'pandoc' 'sbt')
options=('!debug' '!strip')

source=(
  "${pkgname}-${pkgver}.tar.gz::https://github.com/dataunitylab/jsonoid-discovery/archive/v${pkgver}.tar.gz"
  'jsonoid.sh'
)

sha512sums=('e4c2f49d2bd682bd394e36db33581ca72623de572ec81b6f02c6d6347f7668a3c3e5e9058d152ed8e76f9fa9a3ebece2d417ec2fb674fe8521367f7d0e290363'
            'd496e686783c20addf51206e7c8ce5725fceff2816d8f3d5cf54b8bd322bb01d357e07d4103a4f09be1bd7e1ec77d8d6abf3d74cdfd74fc70d7610541e8e1b63')

prepare() {
  cd "${pkgname}-${pkgver}"

  echo >&2 'Patching version number'
  sed -i \
    -e 's/(\(version\))/("\1" -> "'"v${pkgver}"'")/' \
    -e "s/\\\${version.value}/${pkgver}/" \
    build.sbt
  sed -i \
    -e 's/("\(jsonoid\)-discover")/("\1")/' \
    -e 's/BuildInfo.version/"'"v${pkgver}"'"/' \
    src/main/scala/io/github/dataunitylab/jsonoid/discovery/DiscoverSchema.scala
}

build() {
  cd "${pkgname}-${pkgver}"
  sbt -v --batch --java-home /usr/lib/jvm/java-11-openjdk \
    assembly
  pandoc --standalone --to man jsonoid.1.md -o jsonoid.1
}

check() {
  cd "$(mktemp -d)"
  echo '{}' > test.json
  java -jar \
    "${srcdir}/${pkgname}-${pkgver}/target/scala-"*"/jsonoid-discovery-${pkgver}.jar" \
    test.json > result.json
  if [[ "$(cat result.json)" != *"Generated by JSONoid v${pkgver}"* ]]; then
    echo >&2 'Unexpected output:'
    cat >&2 result.json
    exit 1
  fi
}

package() {
  cd "${pkgname}-${pkgver}"

  echo >&2 'Packaging the JAR'
  install -D -m 644 "target/scala-"*"/jsonoid-discovery-${pkgver}.jar" \
    "${pkgdir}/usr/share/java/${pkgname}/jsonoid-discovery.jar"

  echo >&2 'Packaging the executable'
  install -D -m 755 '../jsonoid.sh' -T "${pkgdir}/usr/bin/jsonoid"

  echo >&2 'Packaging the man page'
  install -D -m 644 -t "${pkgdir}/usr/share/man/man1" 'jsonoid.1'

  echo >&2 'Packaging the documentation'
  install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
    {BOWTIE-README,CHANGELOG,CODE_OF_CONDUCT,CONTRIBUTING,README,SECURITY}.md

  echo >&2 'Packaging the license'
  install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \
    'LICENSE.md'
}