summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9f94424f993c4e574752155d9e2b3612e644ac1e (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
# Maintainer: dreieck
# Contributor: petRUShka

_pkgname="balongflash"
pkgname="${_pkgname}-git"
pkgver=3.0+290.r112.20211111.bf43faa
pkgrel=5
pkgdesc='Flashing utility for Huawei E3372 and other modems baesd on Balong v7'
arch=('i686' 'x86_64')
url="https://github.com/forth32/${_pkgname}"
license=('GPL3')
depends=('zlib')
makedepends=('git')
optdepends=()
provides=("${_pkgname}=${pkgver}")
conflicts=("${_pkgname}")

source=(
  "${_pkgname}::git+https://github.com/forth32/${_pkgname}.git"
  "helpmessages_english.txt"
)
sha256sums=(
  'SKIP'
  'd24d9ad7a03a7482ca675d624e39d6b5b8f1423f7137708cc9707f734d22971e'
)

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

  _ver="$(grep -E 'Программа для прошивки устройств на Balong-чипсете, V' balong_flash.c | head -n1 | sed -E 's|.*V([^[:space:]]*)\%i.*|\1|' | sed 's|.$||')"
  _buildno="$(<build)"
  _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 "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}+${_buildno}.r${_rev}.${_date}.${_hash}"
  fi
}

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

  _CFLAGSADDITIONS=" -Wno-error=address-of-packed-member"
  CFLAGS+="${_CFLAGSADDITIONS}"
  CXXFLAGS+="${_CFLAGSADDITIONS}"
  export CFLAGS
  export CXXFLAGS

  make
}

package() {
  cd "${srcdir}/${_pkgname}"
  install -D -v -m755 'balong_flash' "${pkgdir}/usr/bin/balong_flash"
  ln -svr "${pkgdir}/usr/bin/balong_flash" "${pkgdir}/usr/bin/balongflash"

  install -D -v -m644 "README.md" "${pkgdir}/usr/share/doc/${_pkgname}/README.md"
  install -D -v -m644 "${srcdir}/helpmessages_english.txt" "${pkgdir}/usr/share/doc/${_pkgname}/helpmessages_english.txt"
}