# Forked from Alpine to upgrade to current git master, which has
# Ofono compatibility fixes needed for Plasma Mobile

pkgname=eg25-manager
pkgver=0.3.0_git20210522
_commit="73e16f76994b1d3c587796a35766cc668e30c0cd"
pkgrel=0
pkgdesc="Daemon for managing the Quectel EG25 modem"
url="https://gitlab.com/mobian1/devices/eg25-manager"
arch="all !s390x !mips64"  # no modemmanager
license="GPL-3.0-or-later"
makedepends="
	glib-dev
	libgpiod-dev
	libgudev-dev
	libusb-dev
	meson
	modemmanager-dev
	curl-dev
	"
source="
	https://gitlab.com/mobian1/devices/eg25-manager/-/archive/$_commit/eg25-manager-$_commit.tar.gz
	eg25-manager.confd
	eg25-manager.initd
	0001-mm-iface-clean-out-modem_iface-if-mm-disappears.patch
	0002-config-synchronize-with-modem-power.patch
	0003-at-fast-poweroff-is-only-available-in-newer-firmware.patch
	0004-at-g_free-doesn-t-require-NULL-checking.patch
	0005-at-make-next_at_command-send_at_command-process_at_r.patch
	0006-at-log-expected-result-before-setting-it-to-NULL.patch
	0007-at-allow-custom-callbacks-for-AT-command-response-pr.patch
	0008-gnss-add-GNSS-assistance-support.patch
	"
options="!check"  # no tests
subpackages="$pkgname-openrc"
builddir="$srcdir/eg25-manager-$_commit"

build() {
	abuild-meson . output

	# For some reason, the header files don't get generated first by the meson
	# command below.
	for i in gdbo-manager.h gdbo-modem.h; do
		ninja -C output src/libgdbofono/$i
	done

	meson compile ${JOBS:+-j ${JOBS}} -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm755 "$srcdir"/eg25-manager.initd "$pkgdir"/etc/init.d/eg25-manager
	install -Dm644 "$srcdir"/eg25-manager.confd "$pkgdir"/etc/conf.d/eg25-manager
}

sha512sums="
2b0d706c893744529e035e8dc70b381362e39ddd2be705e346f0fd88e4907093e59b30800ad5ecb90638338b25bb51308349fb26de2c786197aeed8c1fa9c68a  eg25-manager-73e16f76994b1d3c587796a35766cc668e30c0cd.tar.gz
55936830afad2968a214fb39cfe1a9db50421dc2ff4f67d04f08f6bd2b094c3ab46799cfc7743bbc5032682d98d1216203adf5264353a05134bea58524ac070b  eg25-manager.confd
0dd866ce18bac37c3832a463205402f5b34a520e1a57cc37658fb37e21a173fbba2cfab223111c68af768be1d3feeb23e41dbaf6d8dc14a2b2c0c088cf3df041  eg25-manager.initd
029dce7e7d6e79faab2a63acde2fe76109e5e269bf38d72617d00ffbb89001f75b604e79290d449db7a6f960f9872eb41c2d0ab4a6d82d7563b66e954cd4ffa8  0001-mm-iface-clean-out-modem_iface-if-mm-disappears.patch
fe6c37c79ea6e89b6bcce78d015a3770347384181595e2c2ff2d42a76baa626cf430125fcefe7679570da268718039f1cce0aef90fe1a5c5ca123425006bbd03  0002-config-synchronize-with-modem-power.patch
ff263d8ce700e910d895496dc5ad0e8e75da17aaac9357b5c3a7632728daab28d2fe4700e2d7c7ba8d45d83742c60dbb581882f95847f0b22cbb09d0ae4c30a6  0003-at-fast-poweroff-is-only-available-in-newer-firmware.patch
2e6e3acde664a77dbcb67ad348e622779be1a50b8ef1b7a175fd6377e0e02511ff120b8c6e9670e914e74d9d176f6194e87bbf7742c60b4cfaf69dd26ed90f49  0004-at-g_free-doesn-t-require-NULL-checking.patch
a59cb10bf14500daaac70a4dd238133a3dfffbb365c871dc039258ee1b3f89a8a7a81f85d5b9ad8a7428b3a927cff282351a8323dfcfb1556333d04bdae14934  0005-at-make-next_at_command-send_at_command-process_at_r.patch
4726f8a8e3cb011d4f4694fc104a289340b8f04a813df9784f823aa773bcfa401fa683de0b8e3837e78b202def3c23a4946dbae31b602659add97a6a585415f2  0006-at-log-expected-result-before-setting-it-to-NULL.patch
cce1e5439783e2a88aeb88bad837d7cf09c18065f6516fb0936cb6fb9cac95034b67c87f8a42545a3e82393f2c07f9694ea668237165ec0ab566fd4159894d54  0007-at-allow-custom-callbacks-for-AT-command-response-pr.patch
7e798b4547493d6b5f7eeb848682d7e0b4d2b0c066696079e99ee777d82c5ffa04d25f15f4ef6f9197cb5187a6c9c286ffcf0cbad87122d1c36e0f67aa0ca651  0008-gnss-add-GNSS-assistance-support.patch
"
