Don't leak $TMPDIR outside of pyproject macros

During %install, the BRB scripts might be affected by it

Related: rhbz#1950291
This commit is contained in:
Miro Hrončok 2021-05-27 19:28:01 +00:00
parent 18de094680
commit 1cacdb2b62
3 changed files with 14 additions and 6 deletions

View File

@ -15,17 +15,15 @@
%pyproject_record %{_builddir}/pyproject-record
%pyproject_wheel() %{expand:\\\
export TMPDIR="${PWD}/%{_pyproject_builddir}"
mkdir -p "${TMPDIR}"
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\
mkdir -p "${PWD}/%{_pyproject_builddir}"
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="${PWD}/%{_pyproject_builddir}" \\\
%{__python3} -m pip wheel --wheel-dir %{_pyproject_wheeldir} --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check --no-clean --progress-bar off --verbose .
}
%pyproject_install() %{expand:\\\
specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/')
export TMPDIR="${PWD}/%{_pyproject_builddir}"
%{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier
TMPDIR="${PWD}/%{_pyproject_builddir}" %{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier
if [ -d %{buildroot}%{_bindir} ]; then
%py3_shebang_fix %{buildroot}%{_bindir}/*
rm -rfv %{buildroot}%{_bindir}/__pycache__

View File

@ -12,7 +12,7 @@ License: MIT
# In other cases, such as backports, increment the point
# release.
Version: 0
Release: 39.2%{?dist}
Release: 40%{?dist}
# Macro files
Source001: macros.pyproject
@ -110,6 +110,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%license LICENSE
%changelog
* Thu May 27 2021 Miro Hrončok <mhroncok@redhat.com> - 0-40
- Don't leak $TMPDIR outside of pyproject macros
* Thu Apr 22 2021 Miro Hrončok <mhroncok@redhat.com> - 0-39.2
- Handle tox provision (tox.requires / tox.minversion)
- Generate BuildRequires on extras in lower case

View File

@ -36,8 +36,15 @@ Summary: %{summary}
%install
# Internal check that $TMPDIR is not changed
TPMDIR_original="$TMPDIR"
%pyproject_install
# Internal check that $TMPDIR is not changed
test "$TMPDIR" == "$TPMDIR_original"
%check
# Internal check that the RECORD and REQUESTED files are
# always removed in %%pyproject_wheel