# doas - run a command as another user. ScrapLinux ships no sudo.
name=doas
version=6.8.2
release=1
desc="Execute commands as another user (OpenBSD doas)"
url="https://github.com/Duncaen/OpenDoas"
license="ISC"
depend="glibc"
provides="sudo-replacement"
source="opendoas-$version.tar.gz::https://github.com/Duncaen/OpenDoas/archive/refs/tags/v$version.tar.gz"
sha256="SKIP"

build() {
	cd "OpenDoas-$version"
	# No PAM: ScrapLinux authenticates against shadow directly.
	./configure --prefix=/usr --sysconfdir=/etc --without-pam
	make -j"$JOBS"
}

package() {
	cd "OpenDoas-$version"
	make DESTDIR="$pkgdir" install
	# Without the setuid bit doas cannot do its job.
	chmod 4755 "$pkgdir/usr/bin/doas"
	# doas.conf itself is not shipped here: scraplinux-base owns
	# /etc/doas.conf (its copy adds the HOME-preserving setenv rule
	# `doas startx` needs to find the real user's .xinitrc), and a package
	# and its base install both declaring the same file is exactly the
	# file-conflict `scraps` refuses to silently resolve either way.
	rm -f "$pkgdir/etc/doas.conf"
	rmdir "$pkgdir/etc" 2>/dev/null || :
}
