#!/bin/zsh
DO=$0
main() {
	args build_dir fstab= arch! release=edge repositories=main \
		alpine_mirror=http://dl-3.alpinelinux.org/alpine

	fresh-build-dir
	rebuild-if-refetch
	eval $(getvars)

	mkdir -p $build_dir/etc/apk || die "failed to set up apk"

	local repo
	for repo in $=repositories; do
		# APKINDEX: $alpine_mirror/$release/$repo/$arch/APKINDEX.tar.gz
		print -rl - $alpine_mirror/$release/$repo \
			>> $build_dir/etc/apk/repositories \
			|| die "failed to set up apk"
	done

	local -a apk_args
	apk_args=(
		--update-cache
		--root $build_dir
		--arch $arch
		--keys-dir /etc/apk/keys/
		--initdb
		add alpine-keys
	)
	apk.static $apk_args || die "alpine init failed"
}
. ./common.zsh
# vim: fileencoding=utf8 ft=zsh noet sw=4 ts=4 sts=4