summaryrefslogtreecommitdiff
blob: 98741e6825379876bff303495c8f029c7db94978 (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Copyright 2004-2010 Sabayon
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

if [ "${PV}" = "9999" ]; then
	EGIT_COMMIT="master"
	EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/anaconda.git"
	MY_ECLASS="git"
fi
inherit flag-o-matic base python libtool autotools eutils ${MY_ECLASS}

AUDIT_VER="1.7.9"
AUDIT_SRC_URI="http://people.redhat.com/sgrubb/audit/audit-${AUDIT_VER}.tar.gz"

SEPOL_VER="2.0"
LSELINUX_VER="2.0.85"
LSELINUX_SRC_URI="http://userspace.selinuxproject.org/releases/current/devel/libselinux-${LSELINUX_VER}.tar.gz"

DESCRIPTION="Gentoo Redhat Anaconda Installer Port"
HOMEPAGE="http://git.overlays.gentoo.org/gitweb/?p=proj/anaconda.git;a=summary"
if [ "${PV}" = "9999" ]; then
	SRC_URI="${AUDIT_SRC_URI} ${LSELINUX_SRC_URI}"
	KEYWORDS=""
else
	SRC_URI="http://distfiles.sabayon.org/${CATEGORY}/${PN}-${PVR}.tar.bz2 ${AUDIT_SRC_URI} ${LSELINUX_SRC_URI}"
	KEYWORDS="~amd64 ~x86"
fi
S="${WORKDIR}"/${PN}-${PVR}
AUDIT_S="${WORKDIR}/audit-${AUDIT_VER}"
LSELINUX_S="${WORKDIR}/libselinux-${LSELINUX_VER}"

LICENSE="GPL-2 public-domain"
SLOT="0"
IUSE="+ipv6 +nfs ldap"

AUDIT_DEPEND="dev-lang/swig"
AUDIT_RDEPEND="ldap? ( net-nds/openldap )"
LSELINUX_DEPEND="=sys-libs/libsepol-${SEPOL_VER}* dev-lang/swig"
LSELINUX_RDEPEND="=sys-libs/libsepol-${SEPOL_VER}*"
LSELINUX_CONFLICT="!sys-libs/libselinux" # due to pythonX.Y/site-packages+/usr/sbin not being handled
COMMON_DEPEND="app-admin/system-config-keyboard
	>=app-arch/libarchive-2.8
	app-cdr/isomd5sum
	dev-libs/newt
	nfs? ( net-fs/nfs-utils )
	sys-fs/lvm2
	=sys-block/open-iscsi-2.0.870.3-r1"
DEPEND="${COMMON_DEPEND} ${AUDIT_DEPEND} ${LSELINUX_DEPEND} sys-apps/sed"
RDEPEND="${COMMON_DEPEND} ${AUDIT_RDEPEND}
	${LSELINUX_RDEPEND} ${LSELINUX_CONFLICT}
	app-misc/anaconda-runtime
	app-misc/anaconda-runtime-gui"

src_unpack() {
	if [ "${PV}" = "9999" ]; then
		git_src_unpack
		base_src_unpack
	else
		base_src_unpack
	fi
}

src_prepare() {

	# Setup CFLAGS, LDFLAGS
	append-cflags "-I${D}/usr/include/anaconda-runtime"
	append-ldflags "-L${D}/usr/$(get_libdir)/anaconda-runtime"

	# Setup anaconda
	cd "${S}"
	./autogen.sh || die "cannot run autogen"

	##
	## Setup libaudit
	##
	cd "${AUDIT_S}"
	# Patch libaudit to fix new glibc incompatibility
	epatch "${FILESDIR}/audit-glibc-fix.patch"
	# Do not build GUI tools
	sed -i \
		-e '/AC_CONFIG_SUBDIRS.*system-config-audit/d' \
		"${AUDIT_S}"/configure.ac || die "cannot sed libaudit configure.ac"
	sed -i \
		-e 's,system-config-audit,,g' \
		-e '/^SUBDIRS/s,\\$,,g' \
		"${AUDIT_S}"/Makefile.am || die "cannot sed libaudit Makefile.am"
	rm -rf "${AUDIT_S}"/system-config-audit

	if ! use ldap; then
		sed -i \
		-e '/^AC_OUTPUT/s,audisp/plugins/zos-remote/Makefile,,g' \
		"${AUDIT_S}"/configure.ac || die "cannot sed libaudit configure.ac (ldap)"
		sed -i \
			-e '/^SUBDIRS/s,zos-remote,,g' \
			"${AUDIT_S}"/audisp/plugins/Makefile.am || die "cannot sed libaudit Makefile.am (ldap)"
	fi
	eautoreconf

	# Patch libselinux to fix new glibc incompatibility
	cd "${LSELINUX_S}"
	epatch "${FILESDIR}/libselinux-glibc-fix.patch"

}

copy_audit_data_over() {
	dodir "/usr/$(get_libdir)/anaconda-runtime"
	cp -Ra "${AUDIT_S}/fakeroot/usr/$(get_libdir)/anaconda-runtime/"* \
		"${D}/usr/$(get_libdir)/anaconda-runtime" || die "cannot cp audit data"
	dodir "/usr/include/anaconda-runtime"
	cp -Ra "${AUDIT_S}/fakeroot/usr/include/anaconda-runtime/"* \
		"${D}/usr/include/anaconda-runtime" || die "cannot cp audit include data"
}

src_configure() {
	# configure audit
	cd "${AUDIT_S}"
	einfo "configuring audit"
	econf --sbindir=/sbin --libdir=/usr/$(get_libdir)/anaconda-runtime \
		--includedir=/usr/include/anaconda-runtime \
		--without-prelude || die

	# compiling audit here, anaconda configure needs libaudit
	einfo "compiling audit"
	cd "${AUDIT_S}" || die "cannot cd into ${AUDIT_S}"
	base_src_compile

	# installing audit
	einfo "installing audit libs into ${AUDIT_S}/fakeroot temporarily"
	cd "${AUDIT_S}" || die "cannot cd into ${AUDIT_S}"
	( rm -rf fakeroot && mkdir fakeroot ) || die "cannot mkdir"
	emake DESTDIR="${AUDIT_S}/fakeroot" install || die "cannot install libaudit"
	copy_audit_data_over # for proper linking

	# configure anaconda
	cd "${S}"
	einfo "configuring anaconda"
	econf \
		$(use_enable ipv6) $(use_enable selinux) \
		$(use_enable nfs) || die "configure failed"
}

src_compile() {

	cd "${S}"
	base_src_compile

	# compiling libselinux
	einfo "compiling libselinux"
	cd "${LSELINUX_S}" || die "cannot cd into ${LSELINUX_S}"
	LD_RUN_PATH="/usr/$(get_libdir)/anaconda-runtime" \
	emake \
		LDFLAGS="-fPIC ${LDFLAGS}" \
		PYLIBVER="python$(python_get_version)" \
		PYTHONLIBDIR="${D}/usr/$(get_libdir)/python$(python_get_version)" \
		SHLIBDIR="${D}/usr/$(get_libdir)/anaconda-runtime" \
		INCLUDEDIR="${D}/usr/include/anaconda-runtime" \
		all || die
	LD_RUN_PATH="/usr/$(get_libdir)/anaconda-runtime" \
	emake \
		LDFLAGS="-fPIC ${LDFLAGS}" \
		PYLIBVER="python$(python_get_version)" \
		PYTHONLIBDIR="${D}/usr/$(get_libdir)/python$(python_get_version)" \
		SHLIBDIR="${D}/usr/$(get_libdir)/anaconda-runtime" \
		INCLUDEDIR="${D}/usr/include/anaconda-runtime" \
		pywrap || die

		# add compatibility aliases to swig wrapper
		cat "${FILESDIR}/compat.py" >> "${LSELINUX_S}/src/selinux.py" || die

}

src_install() {

	# installing libselinux
	cd "${LSELINUX_S}"
	python_need_rebuild
	LD_RUN_PATH="/usr/$(get_libdir)/anaconda-runtime" \
	emake DESTDIR="${D}" \
		PYLIBVER="python$(python_get_version)" \
		PYTHONLIBDIR="${D}/usr/$(get_libdir)/python$(python_get_version)" \
		LIBDIR="${D}/usr/$(get_libdir)/anaconda-runtime" \
		SHLIBDIR="${D}/usr/$(get_libdir)/anaconda-runtime" \
		INCLUDEDIR="${D}/usr/include/anaconda-runtime" \
		install install-pywrap || die

	# fix libselinux.so link
	dosym libselinux.so.1 /usr/$(get_libdir)/anaconda-runtime/libselinux.so
	# LD_RUN_PATH works with ld >=2.20, so /etc/env.d/99anaconda for now
	# will be dropped in future
	echo "LDPATH=\"/usr/$(get_libdir)/anaconda-runtime\"" > 99anaconda
	doenvd 99anaconda

	cd "${S}"
	copy_audit_data_over # ${D} is cleared
	base_src_install

	# install liveinst for user
	dodir /usr/bin
	exeinto /usr/bin
	doexe "${FILESDIR}"/liveinst
	dosym /usr/bin/liveinst /usr/bin/installer

	# drop .la files for God sake
	find "${D}" -name "*.la" | xargs rm

	# Cleanup .pyc .pyo
	find "${D}" -name "*.py[co]" -type f -delete

	dodir /usr/libexec/fcoe
	cp "${S}/fcoe_edd.sh" "${D}/usr/libexec/fcoe/"
}

pkg_postrm() {
	python_mod_cleanup $(python_get_sitedir)/py${PN}
}

pkg_postinst() {
	python_mod_optimize $(python_get_sitedir)/py${PN}
}