games-strategy/freeorion: Drop old
[gentoo.git] / sys-apps / portage / portage-2.3.98-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 DISTUTILS_USE_SETUPTOOLS=no
7 PYTHON_COMPAT=( pypy3 python3_6 python3_7 python3_8 )
8 PYTHON_REQ_USE='bzip2(+),threads(+)'
9
10 inherit distutils-r1 linux-info systemd prefix
11
12 DESCRIPTION="Portage is the package management and distribution system for Gentoo"
13 HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage"
14
15 LICENSE="GPL-2"
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
17 SLOT="0"
18 IUSE="apidoc build doc gentoo-dev +ipc +native-extensions +rsync-verify selinux xattr"
19
20 DEPEND="!build? ( $(python_gen_impl_dep 'ssl(+)') )
21         >=app-arch/tar-1.27
22         dev-lang/python-exec:2
23         >=sys-apps/sed-4.0.5 sys-devel/patch
24         doc? ( app-text/xmlto ~app-text/docbook-xml-dtd-4.4 )
25         apidoc? (
26                 dev-python/sphinx
27                 dev-python/sphinx-epytext
28         )"
29 # Require sandbox-2.2 for bug #288863.
30 # For xattr, we can spawn getfattr and setfattr from sys-apps/attr, but that's
31 # quite slow, so it's not considered in the dependencies as an alternative to
32 # to python-3.3 / pyxattr. Also, xattr support is only tested with Linux, so
33 # for now, don't pull in xattr deps for other kernels.
34 # For whirlpool hash, require python[ssl] (bug #425046).
35 # For compgen, require bash[readline] (bug #445576).
36 # app-portage/gemato goes without PYTHON_USEDEP since we're calling
37 # the executable.
38 RDEPEND="
39         >=app-arch/tar-1.27
40         dev-lang/python-exec:2
41         !build? (
42                 >=sys-apps/sed-4.0.5
43                 app-shells/bash:0[readline]
44                 >=app-admin/eselect-1.2
45                 rsync-verify? (
46                         >=app-portage/gemato-14[${PYTHON_USEDEP}]
47                         >=app-crypt/openpgp-keys-gentoo-release-20180706
48                         >=app-crypt/gnupg-2.2.4-r2[ssl(-)]
49                 )
50         )
51         elibc_FreeBSD? ( sys-freebsd/freebsd-bin )
52         elibc_glibc? ( >=sys-apps/sandbox-2.2 )
53         elibc_musl? ( >=sys-apps/sandbox-2.2 )
54         elibc_uclibc? ( >=sys-apps/sandbox-2.2 )
55         kernel_linux? ( sys-apps/util-linux )
56         >=app-misc/pax-utils-0.1.17
57         selinux? ( >=sys-libs/libselinux-2.0.94[python,${PYTHON_USEDEP}] )
58         xattr? ( kernel_linux? (
59                 >=sys-apps/install-xattr-0.3
60         ) )
61         !<app-admin/logrotate-3.8.0
62         !<app-portage/gentoolkit-0.4.6
63         !<app-portage/repoman-2.3.10"
64 PDEPEND="
65         !build? (
66                 >=net-misc/rsync-2.6.4
67                 userland_GNU? ( >=sys-apps/coreutils-6.4 )
68         )"
69 # coreutils-6.4 rdep is for date format in emerge-webrsync #164532
70 # NOTE: FEATURES=installsources requires debugedit and rsync
71
72 SRC_ARCHIVES="https://dev.gentoo.org/~zmedico/portage/archives"
73
74 prefix_src_archives() {
75         local x y
76         for x in ${@}; do
77                 for y in ${SRC_ARCHIVES}; do
78                         echo ${y}/${x}
79                 done
80         done
81 }
82
83 TARBALL_PV=${PV}
84 SRC_URI="mirror://gentoo/${PN}-${TARBALL_PV}.tar.bz2
85         $(prefix_src_archives ${PN}-${TARBALL_PV}.tar.bz2)"
86
87 pkg_pretend() {
88         local CONFIG_CHECK="~IPC_NS ~PID_NS ~NET_NS"
89
90         check_extra_config
91 }
92
93 python_prepare_all() {
94         distutils-r1_python_prepare_all
95
96         # Apply ad325eb10bc6
97         sed -e '1638s|^\t\t\tself\._schedule()|\t\t\tif self._main_exit is not None and not self._main_exit.done():\n\t\t\t\tself._schedule()|' -i lib/_emerge/Scheduler.py || die
98
99         sed -e "s:^VERSION = \"HEAD\"$:VERSION = \"${PV}\":" -i lib/portage/__init__.py || die
100
101         if use gentoo-dev; then
102                 einfo "Disabling --dynamic-deps by default for gentoo-dev..."
103                 sed -e 's:\("--dynamic-deps", \)\("y"\):\1"n":' \
104                         -i lib/_emerge/create_depgraph_params.py || \
105                         die "failed to patch create_depgraph_params.py"
106
107                 einfo "Enabling additional FEATURES for gentoo-dev..."
108                 echo 'FEATURES="${FEATURES} strict-keepdir"' \
109                         >> cnf/make.globals || die
110         fi
111
112         if use native-extensions; then
113                 printf "[build_ext]\nportage-ext-modules=true\n" >> \
114                         setup.cfg || die
115         fi
116
117         if ! use ipc ; then
118                 einfo "Disabling ipc..."
119                 sed -e "s:_enable_ipc_daemon = True:_enable_ipc_daemon = False:" \
120                         -i lib/_emerge/AbstractEbuildProcess.py || \
121                         die "failed to patch AbstractEbuildProcess.py"
122         fi
123
124         if use xattr && use kernel_linux ; then
125                 einfo "Adding FEATURES=xattr to make.globals ..."
126                 echo -e '\nFEATURES="${FEATURES} xattr"' >> cnf/make.globals \
127                         || die "failed to append to make.globals"
128         fi
129
130         if use build || ! use rsync-verify; then
131                 sed -e '/^sync-rsync-verify-metamanifest/s|yes|no|' \
132                         -e '/^sync-webrsync-verify-signature/s|yes|no|' \
133                         -i cnf/repos.conf || die "sed failed"
134         fi
135
136         if [[ -n ${EPREFIX} ]] ; then
137                 einfo "Setting portage.const.EPREFIX ..."
138                 hprefixify -e "s|^(EPREFIX[[:space:]]*=[[:space:]]*\").*|\1${EPREFIX}\"|" \
139                         -w "/_BINARY/" lib/portage/const.py
140
141                 einfo "Prefixing shebangs ..."
142                 while read -r -d $'\0' ; do
143                         local shebang=$(head -n1 "$REPLY")
144                         if [[ ${shebang} == "#!"* && ! ${shebang} == "#!${EPREFIX}/"* ]] ; then
145                                 sed -i -e "1s:.*:#!${EPREFIX}${shebang:2}:" "$REPLY" || \
146                                         die "sed failed"
147                         fi
148                 done < <(find . -type f ! -name etc-update -print0)
149
150                 einfo "Adjusting make.globals, repos.conf and etc-update ..."
151                 hprefixify cnf/{make.globals,repos.conf} bin/etc-update
152
153                 if use prefix-guest ; then
154                         sed -e "s|^\(main-repo = \).*|\\1gentoo_prefix|" \
155                                 -e "s|^\\[gentoo\\]|[gentoo_prefix]|" \
156                                 -e "s|^\(sync-uri = \).*|\\1rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix|" \
157                                 -i cnf/repos.conf || die "sed failed"
158                 fi
159
160                 einfo "Adding FEATURES=force-prefix to make.globals ..."
161                 echo -e '\nFEATURES="${FEATURES} force-prefix"' >> cnf/make.globals \
162                         || die "failed to append to make.globals"
163         fi
164
165         cd "${S}/cnf" || die
166         if [ -f "make.conf.example.${ARCH}".diff ]; then
167                 patch make.conf.example "make.conf.example.${ARCH}".diff || \
168                         die "Failed to patch make.conf.example"
169         else
170                 eerror ""
171                 eerror "Portage does not have an arch-specific configuration for this arch."
172                 eerror "Please notify the arch maintainer about this issue. Using generic."
173                 eerror ""
174         fi
175 }
176
177 python_compile_all() {
178         local targets=()
179         use doc && targets+=( docbook )
180         use apidoc && targets+=( apidoc )
181
182         if [[ ${targets[@]} ]]; then
183                 esetup.py "${targets[@]}"
184         fi
185 }
186
187 python_test() {
188         esetup.py test
189 }
190
191 python_install() {
192         # Install sbin scripts to bindir for python-exec linking
193         # they will be relocated in pkg_preinst()
194         distutils-r1_python_install \
195                 --system-prefix="${EPREFIX}/usr" \
196                 --bindir="$(python_get_scriptdir)" \
197                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
198                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html" \
199                 --portage-bindir="${EPREFIX}/usr/lib/portage/${EPYTHON}" \
200                 --sbindir="$(python_get_scriptdir)" \
201                 --sysconfdir="${EPREFIX}/etc" \
202                 "${@}"
203 }
204
205 python_install_all() {
206         distutils-r1_python_install_all
207
208         local targets=()
209         use doc && targets+=(
210                 install_docbook
211                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
212         )
213         use apidoc && targets+=(
214                 install_apidoc
215                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
216         )
217
218         # install docs
219         if [[ ${targets[@]} ]]; then
220                 esetup.py "${targets[@]}"
221         fi
222
223         systemd_dotmpfilesd "${FILESDIR}"/portage-ccache.conf
224
225         # Due to distutils/python-exec limitations
226         # these must be installed to /usr/bin.
227         local sbin_relocations='archive-conf dispatch-conf emaint env-update etc-update fixpackages regenworld'
228         einfo "Moving admin scripts to the correct directory"
229         dodir /usr/sbin
230         for target in ${sbin_relocations}; do
231                 einfo "Moving /usr/bin/${target} to /usr/sbin/${target}"
232                 mv "${ED}usr/bin/${target}" "${ED}usr/sbin/${target}" || die "sbin scripts move failed!"
233         done
234 }
235
236 pkg_preinst() {
237         python_setup
238         local sitedir=$(python_get_sitedir)
239         [[ -d ${D%/}${sitedir} ]] || die "${D%/}${sitedir}: No such directory"
240         env -u DISTDIR \
241                 -u PORTAGE_OVERRIDE_EPREFIX \
242                 -u PORTAGE_REPOSITORIES \
243                 -u PORTDIR \
244                 -u PORTDIR_OVERLAY \
245                 PYTHONPATH="${D%/}${sitedir}${PYTHONPATH:+:${PYTHONPATH}}" \
246                 "${PYTHON}" -m portage._compat_upgrade.default_locations || die
247
248         # elog dir must exist to avoid logrotate error for bug #415911.
249         # This code runs in preinst in order to bypass the mapping of
250         # portage:portage to root:root which happens after src_install.
251         keepdir /var/log/portage/elog
252         # This is allowed to fail if the user/group are invalid for prefix users.
253         if chown portage:portage "${ED}"var/log/portage{,/elog} 2>/dev/null ; then
254                 chmod g+s,ug+rwx "${ED}"var/log/portage{,/elog}
255         fi
256
257         if has_version "<${CATEGORY}/${PN}-2.3.77"; then
258                 elog "The emerge --autounmask option is now disabled by default, except for"
259                 elog "portions of behavior which are controlled by the --autounmask-use and"
260                 elog "--autounmask-license options. For backward compatibility, previous"
261                 elog "behavior of --autounmask=y and --autounmask=n is entirely preserved."
262                 elog "Users can get the old behavior simply by adding --autounmask to the"
263                 elog "make.conf EMERGE_DEFAULT_OPTS variable. For the rationale for this"
264                 elog "change, see https://bugs.gentoo.org/658648."
265         fi
266 }