summaryrefslogtreecommitdiff
path: root/mk/bulk/post-build-conf
blob: cee23300de5c4159a4fa2c4cc55a746ddda0324f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# $NetBSD: post-build-conf,v 1.9 2005/12/03 01:00:37 rillig Exp $
#

# This file is included after the build.conf file by the "build" and
# "pre-build" scripts. It provides functions for printing, checking and
# exporting the configuration variables.

# Note: All functions whose names start with "pbc_" are considered private
# to this file. The "pbc" prefix is an abbreviation for "post-build-conf".

# usage: pbc_showvar varname
pbc_showvar() {
	eval "pbc_isset=\${$1+set}"
	case $pbc_isset in
	"set")	eval "fnv_val=\${$1-}"
		printf "   %-25s = %s\\n" "$1" "${fnv_val}"
		;;
	*)	printf "   %-25s (undefined)\\n" "$1"
		;;
	esac
}

# usage: pbc_section title varname...
pbc_section() {
	printf "%s\\n" "$1"
	shift
	for pbc_var in "$@"; do
		pbc_showvar "${pbc_var}"
	done
	printf "\\n"
}

# usage: show_config_vars
show_config_vars() {
	pbc_section "System information" \
		osrev arch BULK_BUILD_CONF USR_PKGSRC MAKECONF
	pbc_section "Getting distfiles" \
		PRUNEDISTFILES ftp_proxy http_proxy
	pbc_section "Building the packages" \
		PKGLIST NICE_LEVEL
	pbc_section "Generating the report" \
		ADMIN ADMINSIG FTPHOST FTP
	pbc_section "Uploading binary packages" \
		UPDATE_VULNERABILITY_LIST PRUNEPACKAGES MKSUMS SIGN_AS \
		RSYNC_DST RSYNC_OPTS
}

# usage: export_config_vars
export_config_vars() {
	export osrev arch BULK_BUILD_CONF USR_PKGSRC
	export PRUNEDISTFILES ftp_proxy http_proxy
	export PKGLIST NICE_LEVEL ADMIN ADMINSIG
	export UPDATE_VULNERABILITY_LIST PRUNEPACKAGES MKSUMS SIGN_AS
	export RSYNC_DST RSYNC_OPTS FTPHOST FTP
	case ${MAKECONF+set} in
	"set")	export MAKECONF;;
	esac
}

# usage: pbc_die error-message
pbc_die() {
	exec 1>&2
	printf "error: %s\\n" "$@"
	printf "       Please check your bulk build configuration file:\\n"
	case ${BULK_BUILD_CONF+set} in
	"set")	printf "       %s\\n" "${BULK_BUILD_CONF}"
	esac
	exit 1
}

# usage: pbc_checkyesno varname
pbc_checkyesno() {
	eval "pbc_val=\${$1-}"
	case $pbc_val in
	[Yy][Ee][Ss]|[Nn][Oo]) ;;
	*)	pbc_die "$1 must be set to one of YES, yes, NO, no.";;
	esac
}

# usage: pbc_checkexistingfile varname
pbc_checkexistingfile() {
	eval "pbc_val=\${$1-}"

	case $pbc_val in
	/*)	;;
	*)	pbc_die "$1 must be an absolute pathname.";;
	esac

	test -f "${pbc_val}" \
	|| pbc_die "$1 must be the name of an existing file."
}

# usage: pbc_checkexistingdir varname
pbc_checkexistingdir() {
	eval "pbc_val=\${$1-}"

	case $pbc_val in
	/*)	;;
	*)	pbc_die "$1 must be an absolute pathname.";;
	esac

	test -d "${pbc_val}" \
	|| pbc_die "$1 must be the name of an existing directory."
}

# usage: pbc_checknonempty varname
pbc_checknonempty() {
	eval "pbc_isset=\${$1+set}"
	eval "pbc_val=\${$1-}"

	case $pbc_isset in
	"set")	case $pbc_val in
		"")	pbc_die "$1 must be non-empty.";;
		esac;;
	*)	pbc_die "$1 must be defined and non-empty.";;
	esac
}

# usage: pbc_checkdefined varname
pbc_checkdefined() {
	eval "pbc_val=\${$1+set}"

	case $pbc_val in
	"set")	;;
	*)	pbc_die "$1 must be defined.";;
	esac
}

# usage: check_config_vars
check_config_vars() {
	# section "System information"
	pbc_checknonempty osrev
	pbc_checknonempty arch
	pbc_checkexistingfile BULK_BUILD_CONF
	pbc_checkexistingdir USR_PKGSRC
	case ${MAKECONF+set} in
	"set")	pbc_checkexistingfile MAKECONF;;
	esac

	# LEGACY: remove after 2006Q1
	case ${CVS_USER-""}${CVS_FLAGS+set} in
	?*)	pbc_die "CVS_USER and CVS_FLAGS must not be set." \
			"See http://mail-index.netbsd.org/pkgsrc-bulk/2005/11/20/0013.html" \
			"and http://mail-index.netbsd.org/pkgsrc-bulk/2005/11/24/0003.html";;
	esac

	# section "Getting distfiles"
	case ${PRUNEDISTFILES+set} in
	"set")	pbc_checkyesno PRUNEDISTFILES
	esac
	# no checks for ftp_proxy
	# no checks for http_proxy

	# section "Building the packages"
	# no checks for PKGLIST
	# no checks for NICE_LEVEL

	# section "Generating the report"
	# no checks for ADMIN
	# no checks for ADMINSIG
	# no checks for FTPHOST
	# no checks for FTP

	# section "Uploading binary packages"
	pbc_checkyesno UPDATE_VULNERABILITY_LIST
	case ${PRUNEPACKAGES+set} in
	"set")	pbc_checkyesno PRUNEPACKAGES
	esac
	pbc_checkyesno MKSUMS
	# no checks for SIGN_AS
	# no checks for RSYNC_DST
	# no checks for RSYNC_OPTS
}