# Forked from Alpine to add phone adaptivity patches and systemd!
# Co-Maintainer: Pablo Correa Gomez <pabloyoyoista@postmarketos.org>
# Co-Maintainer: Achill Gilgenast <achill@achill.org>
maintainer="Newbyte <newbyte@postmarketos.org>"
pkgname=gnome-shell-mobile
_pkgver=48.0
pkgver=9999$_pkgver
pkgrel=1
pkgdesc="GNOME shell mobile"
url="https://wiki.gnome.org/Projects/GnomeShell"
# armhf: mutter-mobile, gjs
arch="all !armhf"
license="GPL-2.0-or-later"
depends="
	accountsservice
	adwaita-icon-theme
	adwaita-fonts
	desktop-file-utils
	gnome-bluetooth
	gnome-control-center
	gnome-shell-mobile-schemas
	gsettings-desktop-schemas
	gst-plugin-pipewire
	gst-plugins-good
	gstreamer
	ibus
	librsvg
	mutter-mobile
	polkit
	systemd
	tecla
	unzip
	upower
	xorg-server
	"
makedepends="
	asciidoc
	systemd-dev
	evolution-data-server-dev evolution-dev
	gcr4-dev
	gjs-dev>=1.85.90
	gnome-autoar-dev
	gnome-bluetooth-dev
	gnome-control-center-dev
	gnome-desktop-dev>=3.35.91
	gobject-introspection-dev
	gstreamer-dev
	ibus-dev
	libcanberra-dev
	libnma-dev
	libxml2-dev
	libxml2-utils
	meson
	mutter-mobile-dev>=99946.0
	networkmanager-dev
	pipewire-dev
	polkit-dev
	pulseaudio-dev
	py3-docutils
	py3-setuptools
	python3
	sassc
	startup-notification-dev
	tecla-dev
	"
checkdepends="
	xvfb-run
	mesa-dri-gallium
	"
	# gdm is also needed but introduces circular dep
provides="gnome-shell=$pkgver-r$pkgrel"
subpackages="
	$pkgname-dbg
	$pkgname-doc
	$pkgname-lang
	$pkgname-schemas::noarch
	gnome-mobile-extensions-app:extensions_app:noarch
	"
_commit="48.mobile.0"
_gvc_commit="47c47a423ff2f55bb038d92517e4782cf051496a"
source="gnome-shell-mobile-$_commit.tar.gz::https://gitlab.gnome.org/verdre/gnome-shell-mobile/-/archive/$_commit/gnome-shell-mobile-$_commit.tar.gz
	https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/archive/$_gvc_commit/libgnome-volume-control-$_gvc_commit.tar.gz
	gsh.patch
	pcver.patch
	gjs-1.85.90-girepository.patch
	"
builddir="$srcdir/gnome-shell-mobile-$_commit"
options="!check" # Tests have circular dependency 'gnome-shell <-> gdm'
# To make sure pmb_recommends installs the correct one
_pmb_recommends="gnome-mobile-extensions-app"

# secfixes:
#   0:
#     - CVE-2019-3820

prepare() {
	default_prepare
	rm -rf "$builddir/subprojects/gvc"
	mv "$srcdir/libgnome-volume-control-$_gvc_commit" $builddir/subprojects/gvc
}

build() {
	abuild-meson \
		-Dtests=false \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	xvfb-run meson test -v -C output
}

extensions_app() {
	provides="gnome-extensions-app=$pkgver-r$pkgrel"
	pkgdesc="Manage GNOME Shell extensions"
	depends="gnome-shell-mobile libadwaita"
	replaces="gnome-shell-mobile"

	amove usr/bin/gnome-extensions-app
	amove usr/share/applications/org.gnome.Shell.Extensions.desktop
	amove usr/share/gnome-shell/org.gnome.Extensions
	amove usr/share/gnome-shell/org.gnome.Extensions.data.gresource
	amove usr/share/gnome-shell/org.gnome.Extensions.src.gresource
}

schemas() {
	pkgdesc="GNOME Shell gsetting schemas"
	depends=""
	provides="gnome-shell-schemas=$pkgver-r$pkgrel"

	amove usr/share/glib-2.0/schemas
	amove usr/share/gnome-control-center/keybindings
}

lang() {
	default_lang
	provides="gnome-shell-lang=$pkgver-r$pkgrel"
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	# owned by postmarketos-hidden-desktop-entries
	rm $pkgdir/usr/share/applications/org.gnome.Extensions.desktop
}

sha512sums="
01a4beb195f48a7ce00a50453695ccc10c7a00fcda81428bf1bb07aacef70a14ffed8124faa50ac98d601d4d43f291c2cd48835bdb79d5e8e751677d877a6953  gnome-shell-mobile-48.mobile.0.tar.gz
f1575dd86772e4bad9357f0322b2ba396478ec45a691c072c4ff98c299d8814aaaf0386fb90f883b3862f88495a07177453ac0fb163ce2b17eb7bb5e65ca5d6c  libgnome-volume-control-47c47a423ff2f55bb038d92517e4782cf051496a.tar.gz
40cafbd0da2f2a40ff9e9db1026179d52a3b296a81fa43a98e433c0919800f0ec5231fcad32d523b8f01b8f7c0205dce1332e48493b0101ad02dae9469ac3de0  gsh.patch
0503440b547b78859c3bb87a66308899bcf33cc0b543e04e9c865904ff7fb86b10b66594c37a1726828ee1a497b0e034150be8cf1a9fbd06c59809619f6a31c8  pcver.patch
7d1bd0a60ee389c8fbc830ac573235ac1053fe44e8c249d32fb34427d9a1c0129444d781d311a6474d5e0b97897a14a52013a3aec0c85c120b8b525b835378bb  gjs-1.85.90-girepository.patch
"
