summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 2ea7775568cb22069b4d04b027584372abc0ec1a (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
77
78
79
80
81
82
83
84
85
86
87
# Maintainer:
# Contributor: Gustavo Alvarez <sl1pkn07@gmail.com>

_pkgname="skanlite"
pkgname="$_pkgname-git"
pkgver=24.08.0.r6.g43d795f
pkgrel=1
pkgdesc='Image Scanning Application'
url='https://invent.kde.org/graphics/skanlite'
license=('GPL-3.0-only')
arch=('x86_64')

depends=(
  'kio'
  'ksanecore'
  'kxmlgui'
  'libksane'
)
makedepends=(
  'extra-cmake-modules'
  'git'
  'kdoctools'
)

provides+=("$_pkgname")
conflicts+=("$_pkgname")

_pkgsrc="$_pkgname"
source=("$_pkgsrc"::"git+$url.git")
sha256sums=('SKIP')

pkgver() {
  cd "$_pkgsrc"

  local _regex='^\s+<release version="([0-9]+\.[0-9]+(\.[0-9]+)?)"\s.*/>$'
  local _file='src/org.kde.skanlite.appdata.xml'

  local _line=$(
    grep -E "$_regex" "$_file" | head -1
  )
  local _version=$(
    printf '%s\n' "$_line" \
      | sed -E "s@$_regex@\1@"
  )
  local _commit=$(
    git log -G "$_line" -1 --pretty=oneline --no-color -- "$_file" \
      | sed 's@\ .*$@@'
  )
  local _revision=$(
    git rev-list --count --cherry-pick "$_commit"...HEAD
  )
  local _hash=$(
    git rev-parse --short=7 HEAD
  )

  printf '%s.r%s.g%s' \
    "$_version" \
    "$_revision" \
    "$_hash"

  local _ver_maj=$(sed -E 's@^([0-9]+)\.([0-9]+)\.([0-9]+)$@\1@' <<< "$_version")
  local _ver_min=$(sed -E 's@^([0-9]+)\.([0-9]+)\.([0-9]+)$@\2@' <<< "$_version")
  local _ver_pat=$(sed -E 's@^([0-9]+)\.([0-9]+)\.([0-9]+)$@\3@' <<< "$_version")

  sed -E \
    -e 's@^(\s*set\s*\(RELEASE_SERVICE_VERSION_MAJOR) .*$@\1 "'"$_ver_maj"'")@' \
    -e 's@^(\s*set\s*\(RELEASE_SERVICE_VERSION_MINOR) .*$@\1 "'"$_ver_min"'")@' \
    -e 's@^(\s*set\s*\(RELEASE_SERVICE_VERSION_MICRO) .*$@\1 "'"$_ver_pat"'")@' \
    -i CMakeLists.txt
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -DQT_MAJOR_VERSION=6
    -DBUILD_TESTING=OFF
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}