summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 707b28a6c86582745d968f47437568f874d18fbe (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)

_pkgname="transito"
pkgname="${_pkgname}-git"
pkgver=0.10.0.r570.20250628.6aee3c3
pkgrel=1
pkgdesc='A data-provider-agnostic public transportation app that lets you route between locations using openly available public GTFS feeds.'
arch=(
  "aarch64"
  "armv7h"
  "armv8h"
  "loong64"
  "i686"
  "x86_64"
)
url="http://mr.lrdu.org/transito"
_url_gitrepo="https://git.sr.ht/~mil/transito"
license=(
  'GPL-3.0-or-later'  # Main software
)
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  "${_pkgname}-bin"
)
replaces=()
replaces=()
makedepends=(
  "git"
  "go>=1.24.0"
  "sh"

  "libglvnd"
  "libxkbcommon"
  "libxkbcommon-x11"
  "mesa"
  "sqlite3"
  "vulkan-headers"
  "wayland"
)
depends=(
  'glibc'
  'libEGL.so'
  'libwayland-client.so'
  'libwayland-cursor.so'
  'libwayland-egl.so'
  'libx11'
  'libxcb'
  'libxcursor'
  'libxfixes'
  'libxkbcommon.so'
  'libxkbcommon-x11.so'
)
optdepends=()
backup=()
source=(
  "${_pkgname}::git+${_url_gitrepo}"
)
sha256sums=(
  'SKIP'                                                              # Main upstream source.
)
#options+=('!lto' 'debug' '!strip')



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

  export GOPATH="${srcdir}/.go"
  export GOCACHE="${GOPATH}/cache"
  export GOMODCACHE="${GOPATH}/cache-mod"
  export GOTMPDIR="${GOPATH}/tmp"  # This one is actually needed, otherwise build fails with 'go: creating work dir: stat /var/cache/makepkg/build/transito-git/src/.go/tmp: no such file or directory'.
  export GOBIN="${GOPATH}/bin"

  mkdir -p "${GOCACHE}"
  mkdir -p "${GOMODCACHE}"
  mkdir -p "${GOTMPDIR}"
  mkdir -p "${GOBIN}"

  printf '%s\n' " --> Downloading go dependencies ..."
  go mod download -x -modcacherw

  printf '%s\n' " --> Generating git log ..."
  git log . > git.log
}



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

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

  if [ -z "${_ver}" ]; then
   error "Version could not be determined."
   return 1
  else
   printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}



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

  export GOPATH="${srcdir}/.go"
  export GOCACHE="${GOPATH}/cache"
  export GOMODCACHE="${GOPATH}/cache-mod"
  export GOTMPDIR="${GOPATH}/tmp"
  export GOBIN="${GOPATH}/bin"

  local _CFLAGSADDITIONS='-Wno-discarded-qualifiers'
  CFLAGS+=" ${_CFLAGSADDITIONS}"
  CXXFLAGS+=" ${_CFLAGSADDITIONS}"
  export CFLAGS
  export CXXFLAGS

  # Do not use build.sh, since it _maybe_ checks out some release version and not the latest git commit.
  #printf '%s\n' " --> Building application ('build.sh blinux') ..."
  #sh build.sh blinux

  printf '%s\n' " --> Building application ('go build') ..."
  go build -v -trimpath -tags=sqlite_math_functions,desktop,production
}



# # 'check()' disabled since there are no tests (as of 2026-06-07).
# check() {
#   cd "${srcdir}/${_pkgname}"
# 
#   export GOPATH="${srcdir}/.go"
#   export GOCACHE="${GOPATH}/cache"
#   export GOMODCACHE="${GOPATH}/cache-mod"
#   export GOTMPDIR="${GOPATH}/tmp"
#   export GOBIN="${GOPATH}/bin"
# 
#   printf '%s\n' " --> Checking ... (This may take some time without any output, since some compilation goes on.)"
#   go test -v
# }



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

  export GOPATH="${srcdir}/.go"
  export GOCACHE="${GOPATH}/cache"
  export GOMODCACHE="${GOPATH}/cache-mod"
  export GOTMPDIR="${GOPATH}/tmp"
  export GOBIN="${GOPATH}/bin"

  printf '%s\n' " --> patching 'build.sh' to honour '\$pkgdir' ..."
  sed -E -e "s|([[:space:]])(/usr)|\1${pkgdir}\2|g" -i build.sh

  printf '%s\n' " --> Installing main application ..."
  sed -E -e "s|([[:space:]])(/usr)|\1${pkgdir}\2|g" -i build.sh
  sh build.sh install

  printf '%s\n' " --> Installing documentation ..."
  install -Dvm644 -t "${pkgdir}/usr/share/doc/${_pkgname}" git.log README.md
  cp -rv doc "${pkgdir}/usr/share/doc/${_pkgname}"/
  printf '%s\n' " --> Installing license ..."
  install -Dvm644 -t "${pkgdir}/usr/share/licenses/${pkgname}" "LICENSE"
}