summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7676acb1b8a90c6752636e9eae2688c6a99dbfa7 (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
#!/bin/bash

# Maintainer: dreieck

# For upstream versions, see https://invisible-island.net/archives/add/

_pkgname=tapecalc
pkgname="${_pkgname}"
epoch=0
pkgver=t20240110
_downloadver="${pkgver##t}" # Strip off leading `t` to get version for download URL.
pkgrel=1

pkgdesc="Fixed-point calculator as a fullscreen editor. You may edit at any position in the expression list. Supports basic arithmetic, interest and sales tax computation. Designed for use as a checkbook or expense-account balancing tool. Formerly known as 'add'."
url="http://invisible-island.net/add/add.html"
license=('LicenseRef-OpenSource_with_conditions')

arch=(
  'i686'
  'x86_64'
  'arm'
  'arm64'
)

depends=(
  'glibc'
  'ncurses'
  'libncursesw.so'
)
makedepends=()
optdepends=()
provides=()
replaces=()
conflicts=()

options=('emptydirs' 'strip')

source=(
  # "add-latest.tar.gz::https://invisible-island.net/datafiles/release/add.tar.gz"
  "https://invisible-island.net/archives/add/add-${_downloadver}.tgz"
  "https://invisible-island.net/archives/add/add-${_downloadver}.tgz.asc"
)

validpgpkeys=('19882D92DDA4C400C22C0D56CC2AF4472167BE03')

sha256sums=(
  '038c814e6349f29595357e05e7059f730ba4513138d11f4bcd8f3dcb3a045e8b'
  '68bad3037e903210b54eacd611e044686c3595bfea65af94f64aec48ae725696'
)

# Since the downloaded file extracts to directories having the version in the name, we want to get the latest one, in case we have old source lying around.
_latestdir() {
  # Arguments: $1 (optional): Base directory where to search.
  local _dir
  if [ $# -ge 1 ]; then
    _dir="$1/"
  else
    _dir=''
  fi
  find "${_dir}"add-* -maxdepth 0 -mindepth 0 -type d | sort --version-sort -r | head -n 1
}

prepare() {
  cd "$(_latestdir "${srcdir}")"

  # The make system's renaming does not change the executable name in 'x+', so we do it by hand here:
  msg "Fixing executable name in 'xterm.sh' ..."
  sed -E "s|([[:space:]])add([[:space:]])|\1${_pkgname}\2|" -i "xterm.sh"

  # The way specifiyng a font size is a bit broken. Changing it ...
  msg "Changing the way to specify fontsize in 'xterm.sg' ..."
  sed -E "s|([[:space:]])\-fn[[:space:]]+[0-9]+x[0-9]+([[:space:]])|\1-xrm 'xterm*font:*-fixed-*-*-*-20-*'\2|" -i "xterm.sh"
}

pkgver() {
  # # We can extract the version information from the extracted directory name, which is simpler:
  # echo "t$(basename "$(_latestdir "${srcdir}")" | sed 's|^[^\-]*-||')"

  # Or we can extract it from the makefile.in, which is consistent with what would end up in the executable:
  cd "$(_latestdir "${srcdir}")"
  grep -E '^[[:space:]]*RELEASE[[:space:]]*=.*[0-9]+' makefile.in | cut -d= -f2 | tr -d '[[:space:]]' # | sed -E 's|^t||'
}


build() {
  cd "$(_latestdir "${srcdir}")"
  ./configure \
    --prefix=/usr \
    --bindir=/usr/bin \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --sharedstatedir=/var/lib \
    --includedir=/usr/include \
    --oldincludedir=/usr/include \
    --program-transform-name 's|add|tapecalc|' \
    --with-ncurses \
    --with-ncursesw \
    --without-pdcurses \
    --without-x \
    --without-Xaw3d \
    --without-Xaw3dxft \
    --without-neXtaw \
    --without-XawPlus
  make
}

package() {
  cd "$(_latestdir "${srcdir}")"

  make DESTDIR="${pkgdir}" install
  chmod 644 "${pkgdir}/usr/share"/*.hlp

  for _docfile in CHANGES README; do
    install -v -D -m644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_docfile}"
  done

  install -v -D -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}