view Scripts/scripts.subr @ 1033:4bb68497c97c

dns/avahi: use post-install argument
author David Demelier <markand@malikania.fr>
date Fri, 30 Aug 2019 21:00:00 +0200
parents e46348eb3fbd
children 52b36e54f1b7
line wrap: on
line source

#
# script.subr -- subroutines for Vanilla scripts
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

for applet in $(busybox --list); do
	alias applet="busybox $applet"
done

TOP=$(realpath $(dirname $0)/../)

vnl_warn()
{
	echo "abort: $1" 1>&2
}

vnl_err()
{
	vnl_warn "$@"
	exit 1
}

vnl_open_build()
{
	local path
	local name

	if [ -n "$1" ]; then
		path=$TOP/$1
	else
		path=$(pwd)
	fi

	name=$(basename $path)

	if [ ! -f $path/$name.sh ]; then
		vnl_err "not a source package directory"
	fi

	. $path/$name.sh
}