OLD | NEW |
| (Empty) |
1 # Copyright 1999-2011 Gentoo Foundation | |
2 # Distributed under the terms of the GNU General Public License v2 | |
3 # $Header: /var/cvsroot/gentoo-x86/sys-apps/portage/portage-2.1.9.45.ebuild,v 1.
1 2011/03/27 23:26:23 zmedico Exp $ | |
4 | |
5 # Require EAPI 2 since we now require at least python-2.6 (for python 3 | |
6 # syntax support) which also requires EAPI 2. | |
7 EAPI=2 | |
8 inherit eutils multilib python | |
9 | |
10 DESCRIPTION="Portage is the package management and distribution system for Gento
o" | |
11 HOMEPAGE="http://www.gentoo.org/proj/en/portage/index.xml" | |
12 LICENSE="GPL-2" | |
13 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~spar
c ~x86 ~sparc-fbsd ~x86-fbsd" | |
14 PROVIDE="virtual/portage" | |
15 SLOT="0" | |
16 IUSE="build doc epydoc +ipc linguas_pl python2 python3 selinux" | |
17 | |
18 python_dep="python3? ( =dev-lang/python-3* ) | |
19 !python2? ( !python3? ( | |
20 build? ( || ( dev-lang/python:2.7 dev-lang/python:2.6 ) ) | |
21 !build? ( || ( dev-lang/python:2.7 dev-lang/python:2.6 >=dev-lan
g/python-3 ) ) | |
22 ) ) | |
23 python2? ( !python3? ( || ( dev-lang/python:2.7 dev-lang/python:2.6 ) )
)" | |
24 | |
25 # The pysqlite blocker is for bug #282760. | |
26 DEPEND="${python_dep} | |
27 !build? ( >=sys-apps/sed-4.0.5 ) | |
28 doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 ) | |
29 epydoc? ( >=dev-python/epydoc-2.0 !<=dev-python/pysqlite-2.4.1 )" | |
30 | |
31 RDEPEND="${python_dep} | |
32 !build? ( >=sys-apps/sed-4.0.5 | |
33 >=app-shells/bash-3.2_p17 | |
34 >=app-admin/eselect-1.2 ) | |
35 elibc_FreeBSD? ( sys-freebsd/freebsd-bin ) | |
36 elibc_glibc? ( >=sys-apps/sandbox-1.6 ) | |
37 elibc_uclibc? ( >=sys-apps/sandbox-1.6 ) | |
38 >=app-misc/pax-utils-0.1.17 | |
39 selinux? ( || ( >=sys-libs/libselinux-2.0.94[python] <sys-libs/libselinu
x-2.0.94 ) ) | |
40 !<app-shells/bash-3.2_p17" | |
41 PDEPEND=" | |
42 !build? ( | |
43 >=net-misc/rsync-2.6.4 | |
44 userland_GNU? ( >=sys-apps/coreutils-6.4 ) | |
45 )" | |
46 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532 | |
47 # rsync-2.6.4 rdep is for the --filter option #167668 | |
48 | |
49 SRC_ARCHIVES="http://dev.gentoo.org/~zmedico/portage/archives" | |
50 | |
51 prefix_src_archives() { | |
52 local x y | |
53 for x in ${@}; do | |
54 for y in ${SRC_ARCHIVES}; do | |
55 echo ${y}/${x} | |
56 done | |
57 done | |
58 } | |
59 | |
60 PV_PL="2.1.2" | |
61 PATCHVER_PL="" | |
62 TARBALL_PV=$PV | |
63 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2 | |
64 $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2) | |
65 linguas_pl? ( mirror://gentoo/${PN}-man-pl-${PV_PL}.tar.bz2 | |
66 $(prefix_src_archives ${PN}-man-pl-${PV_PL}.tar.bz2) )" | |
67 | |
68 PATCHVER= | |
69 [[ $TARBALL_PV = $PV ]] || PATCHVER=$PV | |
70 if [ -n "${PATCHVER}" ]; then | |
71 SRC_URI="${SRC_URI} mirror://gentoo/${PN}-${PATCHVER}.patch.bz2 | |
72 $(prefix_src_archives ${PN}-${PATCHVER}.patch.bz2)" | |
73 fi | |
74 | |
75 S="${WORKDIR}"/${PN}-${TARBALL_PV} | |
76 S_PL="${WORKDIR}"/${PN}-${PV_PL} | |
77 | |
78 compatible_python_is_selected() { | |
79 [[ $(/usr/bin/python -c 'import sys ; sys.stdout.write(sys.hexversion >=
0x2060000 and "good" or "bad")') = good ]] | |
80 } | |
81 | |
82 pkg_setup() { | |
83 # Bug #359731 - Die early if get_libdir fails. | |
84 [[ -z $(get_libdir) ]] && \ | |
85 die "get_libdir returned an empty string" | |
86 | |
87 if use python2 && use python3 ; then | |
88 ewarn "Both python2 and python3 USE flags are enabled, but only
one" | |
89 ewarn "can be in the shebangs. Using python3." | |
90 fi | |
91 if ! use python2 && ! use python3 && ! compatible_python_is_selected ; t
hen | |
92 ewarn "Attempting to select a compatible default python interpre
ter" | |
93 local x success=0 | |
94 for x in /usr/bin/python2.* ; do | |
95 x=${x#/usr/bin/python2.} | |
96 if [[ $x -ge 6 ]] 2>/dev/null ; then | |
97 eselect python set python2.$x | |
98 if compatible_python_is_selected ; then | |
99 elog "Default python interpreter is now
set to python-2.$x" | |
100 success=1 | |
101 break | |
102 fi | |
103 fi | |
104 done | |
105 if [ $success != 1 ] ; then | |
106 eerror "Unable to select a compatible default python int
erpreter!" | |
107 die "This version of portage requires at least python-2.
6 to be selected as the default python interpreter (see \`eselect python --help\
`)." | |
108 fi | |
109 fi | |
110 | |
111 if use python3; then | |
112 python_set_active_version 3 | |
113 elif use python2; then | |
114 python_set_active_version 2 | |
115 fi | |
116 } | |
117 | |
118 src_prepare() { | |
119 if [ -n "${PATCHVER}" ] ; then | |
120 if [[ -L $S/bin/ebuild-helpers/portageq ]] ; then | |
121 rm "$S/bin/ebuild-helpers/portageq" \ | |
122 || die "failed to remove portageq helper symlink
" | |
123 fi | |
124 epatch "${WORKDIR}/${PN}-${PATCHVER}.patch" | |
125 fi | |
126 einfo "Setting portage.VERSION to ${PVR} ..." | |
127 sed -e "s/^VERSION=.*/VERSION=\"${PVR}\"/" -i pym/portage/__init__.py ||
\ | |
128 die "Failed to patch portage.VERSION" | |
129 sed -e "1s/VERSION/${PVR}/" -i doc/fragment/version || \ | |
130 die "Failed to patch VERSION in doc/fragment/version" | |
131 sed -e "1s/VERSION/${PVR}/" -i man/* || \ | |
132 die "Failed to patch VERSION in man page headers" | |
133 | |
134 if ! use ipc ; then | |
135 einfo "Disabling ipc..." | |
136 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:"
\ | |
137 -i pym/_emerge/AbstractEbuildProcess.py || \ | |
138 die "failed to patch AbstractEbuildProcess.py" | |
139 fi | |
140 | |
141 if use python3; then | |
142 einfo "Converting shebangs for python3..." | |
143 python_convert_shebangs -r 3 . | |
144 elif use python2; then | |
145 einfo "Converting shebangs for python2..." | |
146 python_convert_shebangs -r 2 . | |
147 fi | |
148 } | |
149 | |
150 src_compile() { | |
151 if use doc; then | |
152 cd "${S}"/doc | |
153 touch fragment/date | |
154 make xhtml xhtml-nochunks || die "failed to make docs" | |
155 fi | |
156 | |
157 if use epydoc; then | |
158 einfo "Generating api docs" | |
159 mkdir "${WORKDIR}"/api | |
160 local my_modules epydoc_opts="" | |
161 my_modules="$(find "${S}/pym" -name "*.py" \ | |
162 | sed -e 's:/__init__.py$::' -e 's:\.py$::' -e "s:^${S}/
pym/::" \ | |
163 -e 's:/:.:g' | sort)" || die "error listing modules" | |
164 # workaround for bug 282760 | |
165 > "$S/pym/pysqlite2.py" | |
166 PYTHONPATH=${S}/pym:${PYTHONPATH:+:}${PYTHONPATH} \ | |
167 epydoc -o "${WORKDIR}"/api \ | |
168 -qqqqq --no-frames --show-imports $epydoc_opts \ | |
169 --name "${PN}" --url "${HOMEPAGE}" \ | |
170 ${my_modules} || die "epydoc failed" | |
171 rm "$S/pym/pysqlite2.py" | |
172 fi | |
173 } | |
174 | |
175 src_test() { | |
176 # make files executable, in case they were created by patch | |
177 find bin -type f | xargs chmod +x | |
178 PYTHONPATH=${S}/pym:${PYTHONPATH:+:}${PYTHONPATH} \ | |
179 ./pym/portage/tests/runTests || die "test(s) failed" | |
180 } | |
181 | |
182 src_install() { | |
183 local libdir=$(get_libdir) | |
184 local portage_base="/usr/${libdir}/portage" | |
185 local portage_share_config=/usr/share/portage/config | |
186 | |
187 cd "${S}"/cnf | |
188 insinto /etc | |
189 doins etc-update.conf dispatch-conf.conf || die | |
190 | |
191 insinto "$portage_share_config" | |
192 doins "$S/cnf/make.globals" || die | |
193 if [ -f "make.conf.${ARCH}".diff ]; then | |
194 patch make.conf "make.conf.${ARCH}".diff || \ | |
195 die "Failed to patch make.conf.example" | |
196 newins make.conf make.conf.example || die | |
197 else | |
198 eerror "" | |
199 eerror "Portage does not have an arch-specific configuration for
this arch." | |
200 eerror "Please notify the arch maintainer about this issue. Usin
g generic." | |
201 eerror "" | |
202 newins make.conf make.conf.example || die | |
203 fi | |
204 | |
205 dosym ..${portage_share_config}/make.globals /etc/make.globals | |
206 | |
207 insinto /etc/logrotate.d | |
208 doins "${S}"/cnf/logrotate.d/elog-save-summary || die | |
209 | |
210 # BSD and OSX need a sed wrapper so that find/xargs work properly | |
211 if use userland_GNU; then | |
212 rm "${S}"/bin/ebuild-helpers/sed || die "Failed to remove sed wr
apper" | |
213 fi | |
214 | |
215 local x symlinks files | |
216 | |
217 cd "$S" || die "cd failed" | |
218 for x in $(find bin -type d) ; do | |
219 exeinto $portage_base/$x || die "exeinto failed" | |
220 cd "$S"/$x || die "cd failed" | |
221 files=$(find . -mindepth 1 -maxdepth 1 -type f ! -type l) | |
222 if [ -n "$files" ] ; then | |
223 doexe $files || die "doexe failed" | |
224 fi | |
225 symlinks=$(find . -mindepth 1 -maxdepth 1 -type l) | |
226 if [ -n "$symlinks" ] ; then | |
227 cp -P $symlinks "$D$portage_base/$x" || die "cp failed" | |
228 fi | |
229 done | |
230 | |
231 cd "$S" || die "cd failed" | |
232 for x in $(find pym/* -type d) ; do | |
233 insinto $portage_base/$x || die "insinto failed" | |
234 cd "$S"/$x || die "cd failed" | |
235 # __pycache__ directories contain no py files | |
236 [[ "*.py" != $(echo *.py) ]] || continue | |
237 doins *.py || die "doins failed" | |
238 symlinks=$(find . -mindepth 1 -maxdepth 1 -type l) | |
239 if [ -n "$symlinks" ] ; then | |
240 cp -P $symlinks "$D$portage_base/$x" || die "cp failed" | |
241 fi | |
242 done | |
243 | |
244 # Symlinks to directories cause up/downgrade issues and the use of these | |
245 # modules outside of portage is probably negligible. | |
246 for x in "${D}${portage_base}/pym/"{cache,elog_modules} ; do | |
247 [ ! -L "${x}" ] && continue | |
248 die "symlink to directory will cause upgrade/downgrade issues: '
${x}'" | |
249 done | |
250 | |
251 exeinto ${portage_base}/pym/portage/tests | |
252 doexe "${S}"/pym/portage/tests/runTests | |
253 | |
254 doman "${S}"/man/*.[0-9] | |
255 if use linguas_pl; then | |
256 doman -i18n=pl "${S_PL}"/man/pl/*.[0-9] | |
257 doman -i18n=pl_PL.UTF-8 "${S_PL}"/man/pl_PL.UTF-8/*.[0-9] | |
258 fi | |
259 | |
260 dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES} | |
261 use doc && dohtml -r "${S}"/doc/* | |
262 use epydoc && dohtml -r "${WORKDIR}"/api | |
263 | |
264 dodir /usr/bin | |
265 for x in ebuild egencache emerge portageq quickpkg repoman ; do | |
266 dosym ../${libdir}/portage/bin/${x} /usr/bin/${x} | |
267 done | |
268 | |
269 dodir /usr/sbin | |
270 local my_syms="archive-conf | |
271 dispatch-conf | |
272 emaint | |
273 emerge-webrsync | |
274 env-update | |
275 etc-update | |
276 fixpackages | |
277 regenworld" | |
278 local x | |
279 for x in ${my_syms}; do | |
280 dosym ../${libdir}/portage/bin/${x} /usr/sbin/${x} | |
281 done | |
282 dosym env-update /usr/sbin/update-env | |
283 dosym etc-update /usr/sbin/update-etc | |
284 | |
285 dodir /etc/portage | |
286 keepdir /etc/portage | |
287 } | |
288 | |
289 pkg_preinst() { | |
290 if ! use build && ! has_version dev-python/pycrypto && \ | |
291 ! has_version '>=dev-lang/python-2.6[ssl]' ; then | |
292 ewarn "If you are an ebuild developer and you plan to commit ebu
ilds" | |
293 ewarn "with this system then please install dev-python/pycrypto
or" | |
294 ewarn "enable the ssl USE flag for >=dev-lang/python-2.6 in orde
r" | |
295 ewarn "to enable RMD160 hash support." | |
296 ewarn "See bug #198398 for more information." | |
297 fi | |
298 if [ -f "${ROOT}/etc/make.globals" ]; then | |
299 rm "${ROOT}/etc/make.globals" | |
300 fi | |
301 | |
302 [[ -n $PORTDIR_OVERLAY ]] && has_version "<${CATEGORY}/${PN}-2.1.6.12" | |
303 REPO_LAYOUT_CONF_WARN=$? | |
304 } | |
305 | |
306 pkg_postinst() { | |
307 # Compile all source files recursively. Any orphans | |
308 # will be identified and removed in postrm. | |
309 python_mod_optimize /usr/$(get_libdir)/portage/pym | |
310 | |
311 if [ $REPO_LAYOUT_CONF_WARN = 0 ] ; then | |
312 ewarn | |
313 echo "If you want overlay eclasses to override eclasses from" \ | |
314 "other repos then see the portage(5) man page" \ | |
315 "for information about the new layout.conf and repos.con
f" \ | |
316 "configuration files." \ | |
317 | fmt -w 75 | while read -r ; do ewarn "$REPLY" ; done | |
318 ewarn | |
319 fi | |
320 | |
321 einfo | |
322 einfo "For help with using portage please consult the Gentoo Handbook" | |
323 einfo "at http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3" | |
324 einfo | |
325 } | |
326 | |
327 pkg_postrm() { | |
328 python_mod_cleanup /usr/$(get_libdir)/portage/pym | |
329 } | |
OLD | NEW |