summaryrefslogtreecommitdiffhomepage
path: root/vars/invariants_tarballs.vars
blob: 1b89aeb005d8c1a2593817d48c8834c261c9805e (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
#
# set -o errexit -o noglob are assumed.
#

pkgp_dist_tarball_dist() {
	TARBALL_FNAME="${DEFAULT_TARBALL_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${DEFAULT_TARBALL_SUFFIX}";
	tar -cpf - $(find . -maxdepth 1 -mindepth 1 -type d				\
			-not -path ./minipix						\
			-not -path ./minipix_dist					\
			-not -path ./rpm						\
			-not -path ./tmp | sort)					\
		midipix_shortcut.vbs midipix.sh	README SHA256SUMS			|\
	"${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_FNAME}";
	ex_rtl_log_msg info "Finished building binary distribution tarball.";
	if [ -x "$(which gpg 2>/dev/null)" -a -n "${DEFAULT_TARBALL_SIGN_GPG_KEY}" ] &&	\
				gpg --list-keys "${DEFAULT_TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then
		gpg --armor --passphrase-file /dev/null					\
			--local-user "${DEFAULT_TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_FNAME}";
		ex_rtl_log_msg info "Signed binary distribution tarball.";
	fi;
};

pkgp_dist_tarball_toolchain() {
	TARBALL_CROSS_FNAME="${DEFAULT_TARBALL_CROSS_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${DEFAULT_TARBALL_SUFFIX}";
	tar -cpf - bin include lib lib64 libexec share "${PKG_TARGET}"			|\
	"${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_CROSS_FNAME}";
	ex_rtl_log_msg info "Finished building toolchain tarball.";
	if [ -x "$(which gpg 2>/dev/null)" -a -n "${DEFAULT_TARBALL_SIGN_GPG_KEY}" ] &&		\
				gpg --list-keys "${DEFAULT_TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then
		gpg --armor --passphrase-file /dev/null					\
			--local-user "${DEFAULT_TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_CROSS_FNAME}";
		ex_rtl_log_msg info "Signed toolchain tarball.";
	fi;
};

pkgp_dist_tarball_minipix() {
	TARBALL_MINIPIX_FNAME="${DEFAULT_TARBALL_MINIPIX_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${DEFAULT_TARBALL_SUFFIX}";
	tar -cpf - minipix 								\
		midipix_shortcut.vbs midipix.sh README					|\
	"${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_MINIPIX_FNAME}";
	ex_rtl_log_msg info "Finished building binary Minipix distribution tarball.";
	if [ -x "$(which gpg 2>/dev/null)" -a -n "${DEFAULT_TARBALL_SIGN_GPG_KEY}" ] &&		\
				gpg --list-keys "${DEFAULT_TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then
		gpg --armor --passphrase-file /dev/null					\
			--local-user "${DEFAULT_TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_MINIPIX_FNAME}";
		ex_rtl_log_msg info "Signed binary Minipix distribution tarball.";
	fi;
};

pkgp_dist_tarball_src() {
	local _build_tgt_lc="" _build_tgt_uc="" _find_filters="" _pkg_name_lc="" _pkg_name_uc="";
	TARBALL_SRC_FNAME="${DEFAULT_TARBALL_SRC_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${DEFAULT_TARBALL_SUFFIX}";
	ex_rtl_log_msg info "Building source tarball...";
	for _build_tgt_lc in ${BUILD_TARGETS:-${TARGETS_DEFAULT}}; do
		_build_tgt_uc="$(ex_rtl_toupper "${_build_tgt_lc}")";
		for _pkg_name_lc in $(ex_rtl_get_var_unsafe ${_build_tgt_uc}_PACKAGES); do
			_pkg_name_uc="$(ex_rtl_toupper "${_pkg_name_lc}")";
			if [ "$(ex_rtl_get_var_unsafe ${_pkg_name_uc}_SRC_TARBALL_DISABLE)" = "1" ]; then
				_find_filters="${_find_filters:+${_find_filters} }( -not -name ${_pkg_name}-\*-\* )";
			fi;
		done;
	done;
	tar -C "${BUILD_WORKDIR}" -cpf - $(cd "${BUILD_WORKDIR}" && find	\
		-maxdepth 1 -mindepth 1 -name \*-\*-\*				\
		${_find_filters})						|\
	"${TARBALL_COMPRESS_CMD}" ${TARBALL_COMPRESS_ARGS} -c > "${TARBALL_SRC_FNAME}";
	ex_rtl_log_msg info "Finished building source tarball.";
	if [ -x "$(which gpg 2>/dev/null)" -a -n "${DEFAULT_TARBALL_SIGN_GPG_KEY}" ] &&	\
				gpg --list-keys "${DEFAULT_TARBALL_SIGN_GPG_KEY}" >/dev/null 2>&1; then
		gpg --armor --passphrase-file /dev/null				\
			--local-user "${DEFAULT_TARBALL_SIGN_GPG_KEY}" --sign "${TARBALL_SRC_FNAME}";
		ex_rtl_log_msg info "Signed source tarball.";
	fi;
};

pkg_invariants_tarballs_all() {
	if [ -z "${ARG_TARBALL}" ]; then
		exit 0;
	else
		ex_rtl_log_msg info "Building distribution tarballs...";
	fi;
	case "${DEFAULT_TARBALL_SUFFIX}" in
	bz2)	if [ -n "$(which pbzip2 2>/dev/null)" ]; then
			TARBALL_COMPRESS_CMD="pbzip2";
		else
			TARBALL_COMPRESS_CMD="bzip2";
		fi; ;;
	gz)	if [ -n "$(which pigz 2>/dev/null)" ]; then
			TARBALL_COMPRESS_CMD="pigz";
		else
			TARBALL_COMPRESS_CMD="gzip";
		fi; ;;
	xz)	TARBALL_COMPRESS_CMD="xz";
		TARBALL_COMPRESS_ARGS="-T0"; ;;
	*)	ex_rtl_log_msg failexit "Unknown tarball suffix \`.${DEFAULT_TARBALL_SUFFIX}'.";
	esac;
	ex_rtl_fileop cd "${PREFIX}"; PREFIX_BASENAME="${PREFIX_NATIVE##*/}";
	pkgp_dist_tarball_dist; pkgp_dist_tarball_toolchain; pkgp_dist_tarball_minipix;
	if [ "${BUILD}" = "debug" ]; then
		pkgp_dist_tarball_src;
	fi;
};

# vim:filetype=sh