# Maintainer: Dominique Martinet <dominique.martinet@atmark-techno.com>
pkgname=mkswu
pkgver=7.8
pkgrel=0
_ref="$pkgver"
pkgdesc="Helper scripts for swupdate"
url="https://github.com/atmark-techno/mkswu"
arch="noarch"
license="MIT"
depends="busybox findmnt lsblk"
depends_lang="gettext"
makedepends="gettext"
checkdepends="bash coreutils cpio zstd tar"
source="mkswu-7.8.tar.gz"
subpackages="
	$pkgname-lang
	$pkgname-bash-completion
	$pkgname-doc
	$pkgname-swupdate
	"

build() {
	echo "$pkgver" > .version
}

check() {
	./tests/run.sh
}

package() {
	depends="$depends coreutils cpio zstd tar"
	# pandoc is not available on armv7 so we skip installing html,
	# using individual targets instead.
	DESTDIR="$pkgdir" make install_mkswu install_examples \
		install_locales
	# podman_partial_image is installed in abos-base, remove it here
	rm -f "$pkgdir/usr/bin/podman_partial_image"
}

doc() {
	amove /usr/share/mkswu/examples
	# re-move examples/initial_setup.desc back to main package
	# for mkswu --init
	mkdir -p "$pkgdir/usr/share/mkswu/examples"
	mv "$subpkgdir/usr/share/mkswu/examples/initial_setup.desc" \
		"$pkgdir/usr/share/mkswu/examples/"
}

swupdate() {
	cd "$builddir"
	DESTDIR="$subpkgdir" make install_swupdate
	# add $pkgrel at the end of scripts version so development versions
	# of mkswu (git describe "tag-x-hash") are properly considered
	sed -i -e "s/.*/&-$pkgrel/" "$subpkgdir/usr/libexec/mkswu/version"
}

sha512sums="
7eaf3a533171858cb7de4573493140cd676afee2e5de229b4a95fe34f80db8cefd1478013c551cb260d36941704ca9438e003ca6a76bc4f108f1cef0913d658e  mkswu-7.8.tar.gz
"
