summaryrefslogtreecommitdiffhomepage
path: root/dist/dist_zipdist.dist
blob: 505fcac6a4eb7d3834991c3e5daa4192789f310e (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
#
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de>
# set +o errexit -o noglob -o nounset is assumed.
#

pkg_dist_zipdist_all() {
	local	_pdza_group_name="${1}" _pdza_pkg_name="${2}" _pdza_restart_at="${3}"	\
		_pdza_dist_fname="" _pdza_pkg_name="" _pdza_pkglist_fname="${PREFIX}/pkglist.native";

	if ! rtl_lmatch \$ARG_DIST "zipdist" ","; then
		return 0;
	fi;

	ex_pkg_dispatch_send "msg_pkg" "dist" "dist_zipdist" "${MSG_zipdist_begin}";
	rtl_log_msg "zipdist" "${MSG_zipdist_begin}";

	for _pdza_pkg_name in $(cat "${_pdza_pkglist_fname}"); do
		if [ ! -e "${BUILD_WORKDIR}/${_pdza_pkg_name}-native-${DEFAULT_TARGET}" ]; then
			rtl_log_msg "fatalexit" "${MSG_zipdist_missing_pkg_build_dir}" "${_pdza_pkg_name}";
		fi;
	done;

	_pdza_dist_fname="${DEFAULT_ZIPDIST_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.zip";

	if [ -e "${BUILD_WORKDIR}/zipdist" ]\
	&& ! rtl_fileop rm "${BUILD_WORKDIR}/zipdist"; then
		return 1;
	elif ! rtl_fileop mkdir "${BUILD_WORKDIR}/zipdist"; then
		return 1;
	elif ! "${BUILD_WORKDIR}/mpackage/mpackage.sh"				\
			--defroot="${DEFAULT_ZIPDIST_DEFROOT}"			\
			--flysyms						\
			--minroot="${PREFIX_MINIPIX}"				\
			--objroot="${BUILD_WORKDIR}"				\
			--pkgroot="${BUILD_WORKDIR}/zipdist/pkgroot"		\
			--product=Midipix					\
			--subset="${_pdza_pkglist_fname}"			\
			--symbols						\
			--sysroot="${BUILD_WORKDIR}/zipdist/sysroot"		\
			--target="${DEFAULT_TARGET}"				\
			--tmproot="${BUILD_WORKDIR}/zipdist/tmproot"		\
			--zipfile="${PREFIX}/${_pdza_dist_fname}"; then
		return 1;
	fi;

	ex_pkg_dispatch_send "msg_pkg" "dist" "dist_zipdist" "${MSG_zipdist_finished}";
	rtl_log_msg "zipdist" "${MSG_zipdist_finished}";

	if [ "${DEFAULT_ZIPDIST_SIGN_GPG_KEY:+}" = 1 ]\
	&& command which gpg >/dev/null 2>&1\
	&& gpg --list-keys "${DEFAULT_ZIPDIST_SIGN_GPG_KEY}" >/dev/null 2>&1;
	then
		ex_pkg_dispatch_send "msg_pkg" "dist" "dist_zipdist" "${MSG_zipdist_signing}";
		rtl_log_msg "zipdist" "${MSG_zipdist_signing}";

		if ! gpg --armor --passphrase-file /dev/null		\
			--local-user "${DEFAULT_ZIPDIST_SIGN_GPG_KEY}"	\
			--sign "${PREFIX}/${_pdza_dist_fname}"; then
			return 1;
		fi;

		ex_pkg_dispatch_send "msg_pkg" "dist" "dist_zipdist" "${MSG_zipdist_signed}";
		rtl_log_msg "zipdist" "${MSG_zipdist_signed}";
	fi;

	ex_pkg_dispatch_send "step" "${_pdza_group_name}" "${_pdza_pkg_name}" "finish";
	ex_pkg_state_set "${_pdza_pkg_name}" "finish";

	return 0;
};

# vim:filetype=sh textwidth=0