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

pkgp_invariants_tarball_dist() {
	local _tarball_compress_cmd="${1}" _tarball_compress_args="${2}" _tarball_suffix="${3}";
	local _tarball_fname="${DEFAULT_TARBALL_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${_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_invariants_tarball_toolchain() {
	local _tarball_compress_cmd="${1}" _tarball_compress_args="${2}" _tarball_suffix="${3}";
	local _tarball_cross_fname="${DEFAULT_TARBALL_CROSS_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${_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_invariants_tarball_minipix() {
	local _tarball_compress_cmd="${1}" _tarball_compress_args="${2}" _tarball_suffix="${3}";
	local _tarball_minipix_fname="${DEFAULT_TARBALL_MINIPIX_FNAME_PREFIX}${BUILD_USER}@${BUILD_HNAME}-${BUILD_DATE_START}.tar.${_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;
};

pkg_invariants_tarballs_all() {
	local _tarball_compress_args="" _tarball_compress_cmd="" _tarball_suffix="" _tarball_suffixes="" _tarball_type="" _tarball_types="";
	if ex_rtl_lmatch "${ARG_DIST}" , tbz2; then
		_tarball_suffixes="${_tarball_suffixes:+${_tarball_suffixes} }bz2";
	fi;
	if ex_rtl_lmatch "${ARG_DIST}" , tgz; then
		_tarball_suffixes="${_tarball_suffixes:+${_tarball_suffixes} }gz";
	fi;
	if ex_rtl_lmatch "${ARG_DIST}" , txz; then
		_tarball_suffixes="${_tarball_suffixes:+${_tarball_suffixes} }xz";
	fi;
	for _tarball_suffix in ${_tarball_suffixes}; do
		ex_rtl_log_msg info "Building ${_tarball_suffix}-compressed distribution tarballs...";
		case "${_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 \`${_tarball_suffix}'.";
		esac;
		ex_rtl_fileop cd "${PREFIX}"; PREFIX_BASENAME="${PREFIX_NATIVE##*/}";
		_tarball_types="dist toolchain minipix";
		for _tarball_type in ${_tarball_types}; do
			pkgp_invariants_tarball_${_tarball_type} "${_tarball_compress_cmd}" "${_tarball_compress_args}" "${_tarball_suffix}";
		done;
	done;
};

# vim:filetype=sh