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