summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a04c089a233c39f0e1364a4d072f4107509393a5 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)
# Contributor: Vadim Yanitskiy

_pkgname=libosmocore
_pkgvariant=nosystemd
_pkgvcs=git
pkgbase="${_pkgname}-${_pkgvariant}-${_pkgvcs}"
pkgname=(
  "${pkgbase}"
  "${pkgbase}-doc"
)
pkgver=1.10.0+30.r4921.20241106.51bbb34a1
pkgrel=1
pkgdesc="Osmocom core library (functions relating to mobile communication standards). Compiled without systemd logging dependency."
arch=(
  'i686'
  'x86_64'
)
url="https://osmocom.org/projects/libosmocore/wiki/Libosmocore"
license=('GPL-2.0-or-later')
makedepends=(
  'autoconf'
  'automake'
  'doxygen'  # to build the documentation.
  'gcc'
  'git'
  'libtool'
  'liburing'
  'make'
  'pkg-config'
  'python'
)
source=("${_pkgname}::git+https://gitea.osmocom.org/osmocom/libosmocore.git")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_pkgname}"

  _ver="$(git describe --tags | sed 's|^[vV]||' | sed 's|-g[0-9a-f]*$||' | sed -E 's|-([0-9]*)$|+\1|')"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Could not determine version."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

prepare() {
  cd "${srcdir}/${_pkgname}"

  autoreconf -i

  git log > "${srcdir}/git.log"
}

build() {
  cd "${srcdir}/${_pkgname}"

  ./configure --prefix=/usr \
              --exec-prefix=/usr \
              --bindir=/usr/bin \
              --sbindir=/usr/sbin \
              --datadir=/usr/share \
              --libexecdir=/usr/lib \
              --localstatedir=/var \
              --docdir="/usr/share/doc/${_pkgname}" \
              --libdir=/usr/lib/ \
              --disable-systemd-logging \
              --disable-external-tests
  make
}

# check() {
### NOTE: 2022-10-15: dtx and vty tests fail.
#   cd "${srcdir}/${_pkgname}"
#   make check
# }

_package_main() {
  pkgdesc="${pkgdesc}"
  arch=("${arch[@]}")
  depends=(
    'glibc'
    'gnutls'
    'libmnl'
    'libusb'
    'liburing'
    'lksctp-tools'
    'pcsclite'
    'sh'
    'talloc'
  )
  optdepends=(
    "${_pkgname}-doc=${pkgver}: Documentation for this software."
  )
  provides=(
    "${_pkgname}=${pkgver}"
    "${_pkgname}-${_pkgvariant}=${pkgver}"
    "${_pkgname}-${_pkgvcs}=${pkgver}"
  )
  conflicts=(
    "${_pkgname}"
    "${_pkgname}-${_pkgvariant}"
    "${_pkgname}-${_pkgvcs}"
  )
  replaces=()

  cd "${srcdir}/${_pkgname}"

  make DESTDIR="${pkgdir}" install
  if [ -d "${pkgdir}/usr/share/doc" ]; then
    msg2 "Removing documentation ..."
    rm -R "${pkgdir}/usr/share/doc"
  fi

  msg2 "Installing license ..."
  install -Dvm644 -t "${pkgdir}/usr/share/licenses/${pkgname}"  COPYING
}

_package_docs() {
  pkgdesc="Documentation for ${_pkgname}."
  arch=('any')
  depends=()
  optdepends=(
    "${_pkgname}=${pkgver}: The software this documentation is for."
  )
  provides=(
    "${_pkgname}-doc=${pkgver}"
    "${_pkgname}-doc-${_pkgvcs}=${pkgver}"
  )
  conflicts=(
    "${_pkgname}-doc"
    "${_pkgname}-doc-${_pkgvcs}"
  )
  replaces=()

  cd "${srcdir}/${_pkgname}"

  mkdir -p "${pkgdir}/staging"
  mkdir -p "${pkgdir}/usr/share/doc"
  make DESTDIR="${pkgdir}/staging" install
  msg2 "Moving documentation in place and removing everything else ..."
  mv "${pkgdir}/staging/usr/share/doc"/* "${pkgdir}/usr/share/doc"/
  rm -R "${pkgdir}/staging"

  msg2 "Installing git repository's information files ..."
  install -Dvm644 -t "${pkgdir}/usr/share/doc/libosmocore" "README.md" "TODO-RELEASE" "${srcdir}/git.log"
}

eval "package_${pkgname}() { _package_main \"\$@\"; }"
eval "package_${pkgname}-doc() { _package_docs \"\$@\"; }"