#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

#
#	WARNING  this is the 3rd beta version of 3.2.12 not yet officially released
#	The last stable release is 3.2.11 as provided in the jobcore repository
#	Install this for testing and contributing to the development of eudev
#   	Rebuilt today 3/15/23 due to gobject 1.76.0 upgrade 
#	Now pkgrel=04 becomes jobcore eudev-3.2.12-01
#	while eudev-3.2.11 becomes jobcomm/eudev-stable
#
pkgbase=eudev
pkgname=(eudev libeudev)
pkgver=3.2.12  #-pre3
pkgrel=01  ##  gobject-introspection 1.76.0 
_udev_ver=243
# version can be found at $src/configure.ac UDEV_VERSION
pkgdesc="The userspace dev tools (udev) - ex-gentoo forked edition - PRE-3 2.12 edition"
# This is the old official gentoo fork source location
#url="https://github.com/gentoo/eudev"
#url="https://github.com/eudev-project/eudev/releases/download/v3.2.12-pre3/eudev-3.2.12-pre3.tar.gz
#source=("git+https://anongit.gentoo.org/git/proj/eudev.git"
url="https://github.com/eudev-project/eudev/releases/download"
source=($url/v$pkgver-pre3/$pkgbase-$pkgver-pre3.tar.gz{,.asc}
	initcpio_hooks
	initcpio_install
	udev-hwdb.hook )
groups=('base')
makedepends=( gobject-introspection gperf gtk-doc intltool kmod gawk gcc glib2 libxslt libtool m4 make sed util-linux) #  autoconf automake linux-lts-headers -- used before by Obarun
options=( !staticlibs !libtool)

prepare(){
	cd $pkgbase-$pkgver-pre3

	sed -e 's/GROUP="dialout"/GROUP="uucp"/' \
		-e 's/GROUP="tape"/GROUP="storage"/' \
		-e 's/GROUP="cdrom"/GROUP="optical"/' \
		-i rules/*.rules
}

build() {
	cd $pkgbase-$pkgver-pre3
		./configure \
		--prefix=/usr \
		--with-rootprefix=/usr \
		--sysconfdir=/etc \
		--libdir=/usr/lib \
		--bindir=/usr/bin \
		--sbindir=/usr/bin \
		--enable-introspection \
		--enable-kmod \
		--enable-manpages \
		--enable-split-usr

	if [ -f "Makefile" ];then
		msg2 "Cleaning up..."
		make clean
	fi
	make
}

package_eudev() {
	pkgdesc="The userspace dev tools (udev) - pre-3.2.12 edition"
	backup=(
		'etc/udev/udev.conf'
		'usr/lib/udev/rules.d/80-net-name-slot.rules'
	)
	depends=(libeudev kbd kmod hwdata util-linux)

	optdepends=(
		'upower-pm-utils: pm-utils support'
		'libgudev: GObject bindings for libudev'
	)

	provides=("udev=${_udev_ver}" "eudev")
	conflicts=(eudev-git udev eudev-libgudev)
	replaces=(udev smdev nldev)

	cd $pkgbase-$pkgver-pre3

	make DESTDIR="$pkgdir" install

	rm -rv "$pkgdir"/usr/lib/pkgconfig
	rm -v "$pkgdir"/usr/include/libudev.h
	rm -v "$pkgdir"/usr/lib/libudev*.{so*,a}

	install -Dm644 "$srcdir"/initcpio_hooks "$pkgdir"/usr/lib/initcpio/hooks/udev
	install -Dm644 "$srcdir"/initcpio_install "$pkgdir"/usr/lib/initcpio/install/udev
	install -Dm644 "$srcdir"/udev-hwdb.hook "$pkgdir"/usr/share/libalpm/hooks/udev-hwdb.hook
}

package_libeudev() {
	pkgdesc="eudev client libraries - pre 3.2.12 edition"
	depends=(glib2 glibc)
	conflicts=('libudev.so' 'libeudev-git' 'libudev-zero')
	replaces=('libudev-zero' 'libudev')
	provides=("libudev=${_udev_ver}" 'libudev.so')

	cd $pkgbase-$pkgver-pre3

	make -C src/libudev DESTDIR="$pkgdir" install
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(GPL)

validpgpkeys=('BA60BC20F37E59444D6D25001365720913D2F22D')  # Boian Bonev (GnuPG Release Key) <bbonev@ipacct.com>

sha256sums=(abed466623141a8049b50321bce45eeb2345a080945e0ec516031f268a0d8019  # eudev-3.2.12-pre3.tar.gz
	9147d8d6988013b95d7289cf23ada95eea1ad09f100402aa61019b1208c67c32  # eudev-3.2.12-pre3.tar.gz.asc
	892ce43218e0a458981bbce451252c8987dc398e60b8de288e7542b8f2409c13  # initcpio_hooks
	77dd1fd318b4456409aceb077f060b87944defb07cf39d29ad1968dc6f361875  # initcpio_install
	846e9ddbb95c8394ba7efe75107cc1308426921bc042f5d6b48fa4c2dcbac151) # udev-hwdb.hook

##  79f2e799ae08a87cd04b7c62af34b4b98c4b9b808a031b16897a0799f0dfb112  eudev-3.2.12-01-x86_64.pkg.tar.lz
##  61f85f5a68d96e824a4a98ea22de6546febe2780a553ea44cab8970ceff32246  libeudev-3.2.12-01-x86_64.pkg.tar.lz

