| 1 |
# Copyright 1999-2012 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.2.0_alpha126.ebuild,v 1.1 2012/09/12 08:00:36 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=3 |
| 8 |
inherit eutils 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="~amd64-fbsd ~sparc-fbsd ~x86-fbsd" |
| 14 |
SLOT="0" |
| 15 |
IUSE="build doc epydoc +ipc linguas_pl pypy1_9 python2 python3 selinux xattr" |
| 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_ssl="python3? ( =dev-lang/python-3*[ssl] ) |
| 20 |
!pypy1_9? ( !python2? ( !python3? ( |
| 21 |
|| ( >=dev-lang/python-2.7[ssl] dev-lang/python:2.6[threads,ssl] ) |
| 22 |
) ) ) |
| 23 |
pypy1_9? ( !python2? ( !python3? ( dev-python/pypy:1.9[bzip2,ssl] ) ) ) |
| 24 |
python2? ( !python3? ( || ( dev-lang/python:2.7[ssl] dev-lang/python:2.6[ssl,threads] ) ) )" |
| 25 |
python_dep="${python_dep_ssl//\[ssl\]}" |
| 26 |
python_dep="${python_dep//,ssl}" |
| 27 |
python_dep="${python_dep//ssl,}" |
| 28 |
|
| 29 |
# The pysqlite blocker is for bug #282760. |
| 30 |
DEPEND="${python_dep} |
| 31 |
>=sys-apps/sed-4.0.5 sys-devel/patch |
| 32 |
doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 ) |
| 33 |
epydoc? ( >=dev-python/epydoc-2.0 !<=dev-python/pysqlite-2.4.1 )" |
| 34 |
# Require sandbox-2.2 for bug #288863. |
| 35 |
# For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's |
| 36 |
# quite slow, so it's not considered in the dependencies as an alternative to |
| 37 |
# to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so |
| 38 |
# for now, don't pull in xattr deps for other kernels. |
| 39 |
# For whirlpool hash, require python[ssl] or python-mhash (bug #425046). |
| 40 |
RDEPEND="${python_dep} |
| 41 |
!build? ( >=sys-apps/sed-4.0.5 |
| 42 |
>=app-shells/bash-3.2_p17 |
| 43 |
>=app-admin/eselect-1.2 |
| 44 |
|| ( ${python_dep_ssl} dev-python/python-mhash ) |
| 45 |
) |
| 46 |
elibc_FreeBSD? ( sys-freebsd/freebsd-bin ) |
| 47 |
elibc_glibc? ( >=sys-apps/sandbox-2.2 ) |
| 48 |
elibc_uclibc? ( >=sys-apps/sandbox-2.2 ) |
| 49 |
>=app-misc/pax-utils-0.1.17 |
| 50 |
xattr? ( kernel_linux? ( || ( >=dev-lang/python-3.3_pre20110902 dev-python/pyxattr ) ) ) |
| 51 |
selinux? ( || ( >=sys-libs/libselinux-2.0.94[python] <sys-libs/libselinux-2.0.94 ) ) |
| 52 |
!<app-shells/bash-3.2_p17 |
| 53 |
!<app-admin/logrotate-3.8.0" |
| 54 |
PDEPEND=" |
| 55 |
!build? ( |
| 56 |
>=net-misc/rsync-2.6.4 |
| 57 |
userland_GNU? ( >=sys-apps/coreutils-6.4 ) |
| 58 |
)" |
| 59 |
# coreutils-6.4 rdep is for date format in emerge-webrsync #164532 |
| 60 |
# NOTE: FEATURES=install-sources requires debugedit and rsync |
| 61 |
|
| 62 |
SRC_ARCHIVES="http://dev.gentoo.org/~zmedico/portage/archives" |
| 63 |
|
| 64 |
prefix_src_archives() { |
| 65 |
local x y |
| 66 |
for x in ${@}; do |
| 67 |
for y in ${SRC_ARCHIVES}; do |
| 68 |
echo ${y}/${x} |
| 69 |
done |
| 70 |
done |
| 71 |
} |
| 72 |
|
| 73 |
PV_PL="2.1.2" |
| 74 |
PATCHVER_PL="" |
| 75 |
TARBALL_PV=2.2.0_alpha124 |
| 76 |
SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2 |
| 77 |
$(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2) |
| 78 |
linguas_pl? ( mirror://gentoo/${PN}-man-pl-${PV_PL}.tar.bz2 |
| 79 |
$(prefix_src_archives ${PN}-man-pl-${PV_PL}.tar.bz2) )" |
| 80 |
|
| 81 |
PATCHVER= |
| 82 |
[[ $TARBALL_PV = $PV ]] || PATCHVER=$PV |
| 83 |
if [ -n "${PATCHVER}" ]; then |
| 84 |
SRC_URI="${SRC_URI} mirror://gentoo/${PN}-${PATCHVER}.patch.bz2 |
| 85 |
$(prefix_src_archives ${PN}-${PATCHVER}.patch.bz2)" |
| 86 |
fi |
| 87 |
|
| 88 |
S="${WORKDIR}"/${PN}-${TARBALL_PV} |
| 89 |
S_PL="${WORKDIR}"/${PN}-${PV_PL} |
| 90 |
|
| 91 |
compatible_python_is_selected() { |
| 92 |
[[ $("${EPREFIX}/usr/bin/python" -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x2060000 and "good" or "bad")') = good ]] |
| 93 |
} |
| 94 |
|
| 95 |
current_python_has_xattr() { |
| 96 |
[[ $("${EPREFIX}/usr/bin/python" -c 'import sys ; sys.stdout.write(sys.hexversion >= 0x3030000 and "yes" or "no")') = yes ]] || \ |
| 97 |
"${EPREFIX}/usr/bin/python" -c 'import xattr' 2>/dev/null |
| 98 |
} |
| 99 |
|
| 100 |
pkg_setup() { |
| 101 |
if use python2 && use python3 ; then |
| 102 |
ewarn "Both python2 and python3 USE flags are enabled, but only one" |
| 103 |
ewarn "can be in the shebangs. Using python3." |
| 104 |
fi |
| 105 |
if use pypy1_9 && use python3 ; then |
| 106 |
ewarn "Both pypy1_9 and python3 USE flags are enabled, but only one" |
| 107 |
ewarn "can be in the shebangs. Using python3." |
| 108 |
fi |
| 109 |
if use pypy1_9 && use python2 ; then |
| 110 |
ewarn "Both pypy1_9 and python2 USE flags are enabled, but only one" |
| 111 |
ewarn "can be in the shebangs. Using python2" |
| 112 |
fi |
| 113 |
if ! use pypy1_9 && ! use python2 && ! use python3 && \ |
| 114 |
! compatible_python_is_selected ; then |
| 115 |
ewarn "Attempting to select a compatible default python interpreter" |
| 116 |
local x success=0 |
| 117 |
for x in /usr/bin/python2.* ; do |
| 118 |
x=${x#/usr/bin/python2.} |
| 119 |
if [[ $x -ge 6 ]] 2>/dev/null ; then |
| 120 |
eselect python set python2.$x |
| 121 |
if compatible_python_is_selected ; then |
| 122 |
elog "Default python interpreter is now set to python-2.$x" |
| 123 |
success=1 |
| 124 |
break |
| 125 |
fi |
| 126 |
fi |
| 127 |
done |
| 128 |
if [ $success != 1 ] ; then |
| 129 |
eerror "Unable to select a compatible default python interpreter!" |
| 130 |
die "This version of portage requires at least python-2.6 to be selected as the default python interpreter (see \`eselect python --help\`)." |
| 131 |
fi |
| 132 |
fi |
| 133 |
|
| 134 |
if use python3; then |
| 135 |
python_set_active_version 3 |
| 136 |
elif use python2; then |
| 137 |
python_set_active_version 2 |
| 138 |
elif use pypy1_9; then |
| 139 |
python_set_active_version 2.7-pypy-1.9 |
| 140 |
fi |
| 141 |
} |
| 142 |
|
| 143 |
src_prepare() { |
| 144 |
if [ -n "${PATCHVER}" ] ; then |
| 145 |
if [[ -L $S/bin/ebuild-helpers/portageq ]] ; then |
| 146 |
rm "$S/bin/ebuild-helpers/portageq" \ |
| 147 |
|| die "failed to remove portageq helper symlink" |
| 148 |
fi |
| 149 |
epatch "${WORKDIR}/${PN}-${PATCHVER}.patch" |
| 150 |
fi |
| 151 |
einfo "Setting portage.VERSION to ${PVR} ..." |
| 152 |
sed -e "s/^VERSION=.*/VERSION=\"${PVR}\"/" -i pym/portage/__init__.py || \ |
| 153 |
die "Failed to patch portage.VERSION" |
| 154 |
sed -e "1s/VERSION/${PVR}/" -i doc/fragment/version || \ |
| 155 |
die "Failed to patch VERSION in doc/fragment/version" |
| 156 |
sed -e "1s/VERSION/${PVR}/" -i man/* || \ |
| 157 |
die "Failed to patch VERSION in man page headers" |
| 158 |
|
| 159 |
if ! use ipc ; then |
| 160 |
einfo "Disabling ipc..." |
| 161 |
sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \ |
| 162 |
-i pym/_emerge/AbstractEbuildProcess.py || \ |
| 163 |
die "failed to patch AbstractEbuildProcess.py" |
| 164 |
fi |
| 165 |
|
| 166 |
if use xattr && use kernel_linux ; then |
| 167 |
einfo "Adding FEATURES=xattr to make.globals ..." |
| 168 |
echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \ |
| 169 |
|| die "failed to append to make.globals" |
| 170 |
fi |
| 171 |
|
| 172 |
if use python3; then |
| 173 |
einfo "Converting shebangs for python3..." |
| 174 |
python_convert_shebangs -r 3 . |
| 175 |
elif use python2; then |
| 176 |
einfo "Converting shebangs for python2..." |
| 177 |
python_convert_shebangs -r 2 . |
| 178 |
elif use pypy1_9; then |
| 179 |
einfo "Converting shebangs for pypy-c1.9..." |
| 180 |
python_convert_shebangs -r 2.7-pypy-1.9 . |
| 181 |
fi |
| 182 |
|
| 183 |
if [[ -n ${EPREFIX} ]] ; then |
| 184 |
einfo "Setting portage.const.EPREFIX ..." |
| 185 |
sed -e "s|^\(SANDBOX_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/bin/sandbox\"\)|\\1${EPREFIX}\\2|" \ |
| 186 |
-e "s|^\(FAKEROOT_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/bin/fakeroot\"\)|\\1${EPREFIX}\\2|" \ |
| 187 |
-e "s|^\(BASH_BINARY[[:space:]]*=[[:space:]]*\"\)\(/bin/bash\"\)|\\1${EPREFIX}\\2|" \ |
| 188 |
-e "s|^\(MOVE_BINARY[[:space:]]*=[[:space:]]*\"\)\(/bin/mv\"\)|\\1${EPREFIX}\\2|" \ |
| 189 |
-e "s|^\(PRELINK_BINARY[[:space:]]*=[[:space:]]*\"\)\(/usr/sbin/prelink\"\)|\\1${EPREFIX}\\2|" \ |
| 190 |
-e "s|^\(EPREFIX[[:space:]]*=[[:space:]]*\"\).*|\\1${EPREFIX}\"|" \ |
| 191 |
-i pym/portage/const.py || \ |
| 192 |
die "Failed to patch portage.const.EPREFIX" |
| 193 |
|
| 194 |
einfo "Prefixing shebangs ..." |
| 195 |
find . -type f -print0 | \ |
| 196 |
while read -r -d $'\0' ; do |
| 197 |
local shebang=$(head -n1 "$REPLY") |
| 198 |
if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then |
| 199 |
sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \ |
| 200 |
die "sed failed" |
| 201 |
fi |
| 202 |
done |
| 203 |
|
| 204 |
einfo "Adjusting make.globals ..." |
| 205 |
sed -e 's|^SYNC=.*|SYNC="rsync://rsync.prefix.freens.org/gentoo-portage-prefix"|' \ |
| 206 |
-e "s|^\(PORTDIR=\)\(/usr/portage\)|\\1\"${EPREFIX}\\2\"|" \ |
| 207 |
-e "s|^\(PORTAGE_TMPDIR=\)\(/var/tmp\)|\\1\"${EPREFIX}\\2\"|" \ |
| 208 |
-i cnf/make.globals || die "sed failed" |
| 209 |
|
| 210 |
einfo "Adding FEATURES=force-prefix to make.globals ..." |
| 211 |
echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \ |
| 212 |
|| die "failed to append to make.globals" |
| 213 |
fi |
| 214 |
|
| 215 |
cd "${S}/cnf" || die |
| 216 |
if [ -f "make.conf.${ARCH}".diff ]; then |
| 217 |
patch make.conf "make.conf.${ARCH}".diff || \ |
| 218 |
die "Failed to patch make.conf.example" |
| 219 |
else |
| 220 |
eerror "" |
| 221 |
eerror "Portage does not have an arch-specific configuration for this arch." |
| 222 |
eerror "Please notify the arch maintainer about this issue. Using generic." |
| 223 |
eerror "" |
| 224 |
fi |
| 225 |
} |
| 226 |
|
| 227 |
src_compile() { |
| 228 |
if use doc; then |
| 229 |
emake docbook || die |
| 230 |
fi |
| 231 |
|
| 232 |
if use epydoc; then |
| 233 |
einfo "Generating api docs" |
| 234 |
emake epydoc || die |
| 235 |
fi |
| 236 |
} |
| 237 |
|
| 238 |
src_test() { |
| 239 |
# make files executable, in case they were created by patch |
| 240 |
find bin -type f | xargs chmod +x |
| 241 |
emake test || die |
| 242 |
} |
| 243 |
|
| 244 |
src_install() { |
| 245 |
emake DESTDIR="${D}" \ |
| 246 |
sysconfdir="${EPREFIX}/etc" \ |
| 247 |
prefix="${EPREFIX}/usr" \ |
| 248 |
install || die |
| 249 |
|
| 250 |
# Use dodoc for compression, since the Makefile doesn't do that. |
| 251 |
dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES} || die |
| 252 |
|
| 253 |
if use linguas_pl; then |
| 254 |
doman -i18n=pl "${S_PL}"/man/pl/*.[0-9] || die |
| 255 |
doman -i18n=pl_PL.UTF-8 "${S_PL}"/man/pl_PL.UTF-8/*.[0-9] || die |
| 256 |
fi |
| 257 |
|
| 258 |
# Set PYTHONPATH for portage API consumers. This way we don't have |
| 259 |
# to rely on patched python having the correct path, since it has |
| 260 |
# been known to incorrectly add /usr/libx32/portage/pym to sys.path. |
| 261 |
echo "PYTHONPATH=${EPREFIX}/usr/lib/portage/pym" > \ |
| 262 |
"${T}/05portage" || die |
| 263 |
doenvd "${T}/05portage" || die |
| 264 |
} |
| 265 |
|
| 266 |
pkg_preinst() { |
| 267 |
if [[ $ROOT == / ]] ; then |
| 268 |
# Run some minimal tests as a sanity check. |
| 269 |
local test_runner=$(find "$ED" -name runTests) |
| 270 |
if [[ -n $test_runner && -x $test_runner ]] ; then |
| 271 |
einfo "Running preinst sanity tests..." |
| 272 |
"$test_runner" || die "preinst sanity tests failed" |
| 273 |
fi |
| 274 |
fi |
| 275 |
|
| 276 |
if use xattr && ! current_python_has_xattr ; then |
| 277 |
ewarn "For optimal performance in xattr handling, install" |
| 278 |
ewarn "dev-python/pyxattr, or install >=dev-lang/python-3.3 and" |
| 279 |
ewarn "enable USE=python3 for $CATEGORY/$PN." |
| 280 |
fi |
| 281 |
|
| 282 |
if ! use build && ! has_version dev-python/pycrypto && \ |
| 283 |
! has_version '>=dev-lang/python-2.6[ssl]' ; then |
| 284 |
ewarn "If you are an ebuild developer and you plan to commit ebuilds" |
| 285 |
ewarn "with this system then please install dev-python/pycrypto or" |
| 286 |
ewarn "enable the ssl USE flag for >=dev-lang/python-2.6 in order" |
| 287 |
ewarn "to enable RMD160 hash support." |
| 288 |
ewarn "See bug #198398 for more information." |
| 289 |
fi |
| 290 |
|
| 291 |
has_version "<=${CATEGORY}/${PN}-2.2_pre5" \ |
| 292 |
&& WORLD_MIGRATION_UPGRADE=true || WORLD_MIGRATION_UPGRADE=false |
| 293 |
|
| 294 |
# If portage-2.1.6 is installed and the preserved_libs_registry exists, |
| 295 |
# assume that the NEEDED.ELF.2 files have already been generated. |
| 296 |
has_version "<=${CATEGORY}/${PN}-2.2_pre7" && \ |
| 297 |
! ( [ -e "${EROOT}"var/lib/portage/preserved_libs_registry ] && \ |
| 298 |
has_version ">=${CATEGORY}/${PN}-2.1.6_rc" ) \ |
| 299 |
&& NEEDED_REBUILD_UPGRADE=true || NEEDED_REBUILD_UPGRADE=false |
| 300 |
} |
| 301 |
|
| 302 |
pkg_postinst() { |
| 303 |
# Compile all source files recursively. Any orphans |
| 304 |
# will be identified and removed in postrm. |
| 305 |
python_mod_optimize /usr/lib/portage/pym |
| 306 |
|
| 307 |
if $WORLD_MIGRATION_UPGRADE && \ |
| 308 |
grep -q "^@" "${EROOT}/var/lib/portage/world"; then |
| 309 |
einfo "moving set references from the worldfile into world_sets" |
| 310 |
cd "${EROOT}/var/lib/portage/" |
| 311 |
grep "^@" world >> world_sets |
| 312 |
sed -i -e '/^@/d' world |
| 313 |
fi |
| 314 |
|
| 315 |
if $NEEDED_REBUILD_UPGRADE ; then |
| 316 |
einfo "rebuilding NEEDED.ELF.2 files" |
| 317 |
for cpv in "${EROOT}/var/db/pkg"/*/*; do |
| 318 |
if [ -f "${cpv}/NEEDED" ]; then |
| 319 |
rm -f "${cpv}/NEEDED.ELF.2" |
| 320 |
while read line; do |
| 321 |
filename=${line% *} |
| 322 |
needed=${line#* } |
| 323 |
needed=${needed//+/++} |
| 324 |
needed=${needed//#/##} |
| 325 |
needed=${needed//%/%%} |
| 326 |
newline=$(scanelf -BF "%a;%F;%S;%r;${needed}" $filename) |
| 327 |
newline=${newline// - } |
| 328 |
echo "${newline:3}" >> "${cpv}/NEEDED.ELF.2" |
| 329 |
done < "${cpv}/NEEDED" |
| 330 |
fi |
| 331 |
done |
| 332 |
fi |
| 333 |
} |
| 334 |
|
| 335 |
pkg_postrm() { |
| 336 |
python_mod_cleanup /usr/lib/portage/pym |
| 337 |
} |