summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_install.subr
blob: 5518e03aa085dd9150677265c8ba7fc4702ed94b (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
#
# set -o errexit -o noglob are assumed.
#

pkg_install() {
	ex_rtl_fileop mkdir "${PKG_PREFIX}";
	find "${PKG_DESTDIR}"				\
		-type d -exec chmod 0755 {} \;;
	find "${PKG_DESTDIR}"				\
		\( -not -perm /0111 \)			\
		-type f -exec chmod 0644 {} \;;
	find "${PKG_DESTDIR}"				\
		-perm /0111 -type f -exec chmod 0755 {} \;;
	tar -C "${PKG_DESTDIR}" -cpf - .		|\
		tar -C "${PKG_PREFIX}" --overwrite -xpf -;
	if [ "${ARG_PACKAGE:-0}" -eq 1 ]; then
		tar -C "${PKG_DESTDIR}" -cpf - .	|\
			gzip -c -9 - > "${PKG_BASE_DIR}/${PKG_NAME}.tgz"
	fi;
	if [ "${ARG_RPM:-0}" -eq 1 ]\
	&& [ -x "$(which rpmbuild 2>/dev/null)" ]; then
		cat > "${PKG_BASE_DIR}/${PKG_NAME}-${PKG_VERSION:-Unknown}.spec" <<EOF
Name:           ${PKG_NAME}
Version:        ${PKG_VERSION:-Unknown}
Release:        1
Summary:        ${PKG_NAME} ${PKG_VERSION:-Unknown}
License:        Unknown
Group:          Applications
Url:            ${PKG_URL:-${PKG_URLS_GIT:-Unknown}}

%description
${PKG_NAME} ${PKG_VERSION:-Unknown}

%prep
%build
%install
rm -rf "\${RPM_BUILD_ROOT}"
mkdir -p "\${RPM_BUILD_ROOT}"
cp -pPr "${PKG_DESTDIR}/." "\${RPM_BUILD_ROOT}"

%post
%postun
%files
/

%changelog

EOF
		rpmbuild -bb --define="_topdir ${PREFIX_RPM}/${PKG_NAME}-${PKG_VERSION:-Unknown}" --nodeps "${PKG_BASE_DIR}/${PKG_NAME}-${PKG_VERSION:-Unknown}.spec";
		find "${PREFIX_RPM}/${PKG_NAME}-${PKG_VERSION:-Unknown}/RPMS" -iname \*.rpm -exec cp -pP {} "${PREFIX_RPM}/" \;;
		ex_rtl_fileop rm "${PREFIX_RPM}/${PKG_NAME}-${PKG_VERSION:-Unknown}";
		ex_rtl_fileop cp "${PKG_BASE_DIR}/${PKG_NAME}-${PKG_VERSION:-Unknown}.spec" "${PREFIX_RPM}/";
	fi;
};

# vim:filetype=sh