summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 87c6940dec3ad9f5e820b43337e11437b6f1281a (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
# Maintainer: Lennard Hofmann <lennard dot hofmann at web dot de>
# Contributor: Gunar C. Gessner <gunar@gunar.uk>
_pkgname="difftastic"
pkgname="${_pkgname}-git"
pkgver=0.57.0.r7.f52ca706f
pkgrel=1
pkgdesc="a diff that understands syntax"
arch=("i686" "x86_64")
url="https://github.com/Wilfred/difftastic"
license=('MIT')
groups=()
depends=('glibc' 'gcc-libs' 'shared-mime-info')
makedepends=('git' 'cargo')
optdepends=()
provides=('difft')
conflicts=('difft')
replaces=()
backup=()
options=()
install=
changelog=
source=("${pkgname}::git+https://github.com/Wilfred/${_pkgname}.git"
        remove-makedepends-jq.patch)
noextract=()
md5sums=('SKIP'
         '2f9a02d83bb816de9d261fba8909aaaa')

pkgver() {
  cd "$srcdir/$pkgname"
  local tag=$(git tag --sort=-v:refname | grep '^[0-9]' | head -1)
  local commits_since=$(git rev-list $tag..HEAD --count)
  echo "$tag.r$commits_since.$(git log --pretty=format:'%h' -n 1)"
}

prepare() {
  cd "$pkgname"

  # download dependencies
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"

  # remove makedepends on jq
  patch -p1 -i "$srcdir/remove-makedepends-jq.patch"
}

build() {
  cd "$pkgname"
  export CFLAGS+=" -ffat-lto-objects"

  cargo build --frozen --release --all-features
}

check() {
  cd "$pkgname"

  # Skip tests that expect to detect interactive terminal
  # Run ignored tests that *are* expected to work if MIME database present
  # c.f. https://github.com/Wilfred/difftastic/commit/34f21c6d
  cargo test --frozen --all-features -- \
    --ignored \
    --skip 'options::tests::test_detect_display_width'
}

package() {
  cd "$pkgname"
  install -D -m 755 "target/release/difft" "${pkgdir}/usr/bin/difft"
  install -D -m 644 LICENSE "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"
}