#!/bin/bash
# dev/package/load - package configuration file support

set -e

lib_load 'dev/package/git'


######
# Library Configuration

dev_package_load_config_init() {
	lib_setting_vars -ro package_i7 system_i7 site_i7
	package_i7="$package_repodir/package.i7"
	system_i7="$package_repodir/system.i7"
	site_i7="$package_repodir/site.i7"

	lib_setting_vars -ro --null PREFIX
	lib_setting_vars -ro EXEC_PREFIX DATA_PREFIX \
			PKG_NAME PKG VERSION AUTHOR \
			URL SUPPORT_NAME SUPPORT_EMAIL
	lib_setting_arrays -ro APPS CONF LIBS DIST GROUP_ORDER
	lib_setting_assocs -ro GROUP_NAMES

	lib_setting_vars RELEASE_TYPE
	# $RELEASE_BRANCH - Specifies the type of release that should
	# be produced from the current branch.
	lib_setting_vars RELEASE_BRANCH

	lib_setting_vars DOWNLOAD_SCHEME DOWNLOAD_HOST DOWNLOAD_PATH
	lib_setting_vars PUBLISH_SSH_HOST PUBLISH_SSH_PATH

	# site specific settings (in site.i7)
	lib_setting_vars -ro --null SITE_BRANCH SITE_VERSION

	# $package_release_types[] - List of release types
	# Default: release debug
	lib_setting_arrays package_release_types
	package_release_types=( release debug )

	# $package_release_branches[] - List of release branches
	# Default: stable testing unstable devel
	lib_setting_arrays package_release_branches
	package_release_branches=( stable testing unstable devel )

}

dev_package_load_config_files() {
	case "$1" in
	(pkg) echo "$package_i7" "$system_i7" "$site_i7" ;;
	esac
}

dev_package_load_config_check() {
	RELEASE_TYPE=${RELEASE_TYPE:-release}
	package_release_type_required "$RELEASE_TYPE"

	RELEASE_BRANCH=${RELEASE_BRANCH:-devel}
	package_release_branch_required "$RELEASE_BRANCH"

	EXEC_PREFIX=${EXEC_PREFIX:-${PREFIX:-/usr}}
	DATA_PREFIX=${DATA_PREFIX:-${PREFIX:-/var}}
}


######
# Package Release Types

# package_is_release_type() - Checks if the given string ($1) is
# a known release type.
# Returns: Success if it is a release type
package_is_release_type() {
	has_args 1 "$@"
	in_list "$1" "${package_release_types[@]}"
}

# package_release_type_required() - Produces an error if the given
# string ($1) is not a known release type.
package_release_type_required() {
	local type=$1
	package_is_release_type "$type" \
		|| error "'$type' is an unknown release type, use one of:" \
			"\n\t${package_release_types[@]}"
}

# is_package_release() - Checks whether the package settings indicate
# we are bulding for ``release``.
# Returns: Success if settings indicate a release build.
is_package_release() { [ "$RELEASE_TYPE" = release ]; }


######
# Package Release Branches

# package_is_release_branch() - Checks if the given string ($1) is
# a known release branch.
# Returns: Success if it is a release branch
package_is_release_branch() {
	has_args 1 "$@"
	in_list "$1" "${package_release_branches[@]}"
}

# package_release_branch_required() - Produces an error if the given
# string ($1) is not a known release branch.
package_release_branch_required() {
	local branch=$1
	package_is_release_branch "$branch" \
		|| error "'$branch' is an unknown release branch, use one of:" \
			"\n\t${package_release_branches[@]}"
}

View the Developer Guide Index

View the Reference Manual Index


Generated on Sat Jul 8 19:40:17 PDT 2017 by mcsh d14 v0.22.0.