cockpit: set RPM_BUILD_ROOT w/ installing#2989
Conversation
|
Forgot to mention, thanks @jelly for reporting this problem while adding fedora-36 to the cockpit CI images for subscription-manager [1]! |
martinpitt
left a comment
There was a problem hiding this comment.
This is an absolutely terrible hack and workaround. I asked in pypa/distutils#70 (comment) , but it is still plain wrong to install custom stuff into /usr.
Can't you install this into /usr/local/ (the correct location for non-distribution code) and run tests with that? E.g. cockpit is totally fine with reading packages from /usr/local/share/cockpit/subscription-manager, and it prefers that over an existing /usr/share/cockpit/subscription-manager/.
|
Or rather, as it fails here: explicitly install into /usr/local and adjust the |
|
Or even better, actually call |
|
For the record, I doubt this is due to the recent change in https://github.com/pypa/distutils -- we have carried this patch in distutils in the standard library since Fedora 27. |
If this indeed started to happen in Fedora 36, this is much more likely caused by https://src.fedoraproject.org/rpms/python3.10/pull-request/63 -- that change landed in rawhide 5 months ago and I am quite sad that you have only discovered this now. See also https://discuss.python.org/t/mechanism-for-distributors-to-add-site-install-schemes-to-python-installations/8467/1 and https://bugs.python.org/issue43976 |
The environment is a testing VM, it does not matter that /usr is polluted. Also, it installed on /usr to make sure to properly override the system installation.
We don't regularly test on Dedora rawhide, and AFAIK the cockpit CI doesn't test on it because of "not exactly stable" (AFAICR).
We have already other CI jobs that check that the spec file works and the package build is correct. Personally I'd like to limit the scope of the testing of this as much as possible. @hroncok python3 ./setup.py install --prefix /usr --root /I get the reasons behind not installing to /usr but rather to /usr/local for "system installations". However, if I explicitly want to install in a certain location, including /usr, I'd expect it to be respected and not silently mangled. This breaks the usability of existing scripts (like this) that, for certain reasons, may want to explicitly install to /usr. |
I don't disagree. The culprit is in the fact that |
Well, technically yes, however adding unexpected parts like this is not exactly a fair chance to the build system, IMHO. Reading the bug makes me think that there is no solution for this in sight soon. Would it be OK from your POV if I amend the message of this to reflect the actual case, and keep the workaround? |
I care for the amended message because I think it's not good to reference an unrelated change in pypa/distutils. Thanks for that. Whether or not you keep the workaround, I don't have a preference, as I don't have enough knowledge about your use case. If you think you must install to |
|
@ptoscano : What's wrong with just installing to /usr/local? (not by accident, but deliberately)? |
integration-tests/vm.install
Outdated
| tar xzf ../subscription-manager-build-extra.tar.gz | ||
| python3 ./setup.py build | ||
| python3 ./setup.py install --prefix /usr --root / | ||
| RPM_BUILD_ROOT="" python3 ./setup.py install --prefix /usr --root / |
There was a problem hiding this comment.
As for the workaround itself, I suggest the following:
| RPM_BUILD_ROOT="" python3 ./setup.py install --prefix /usr --root / | |
| # Simulate installation via RPM package by setting $RPM_BUILD_ROOT | |
| # That way, we install to /usr instead of /usr/local, which is needed to ??? | |
| RPM_BUILD_ROOT=/ python3 ./setup.py install |
Note three things:
- the intent of setting
$RPM_BUILD_ROOTis visible - the value of
$RPM_BUILD_ROOTactually make sense (while technically, it doesn't matter) - the
--prefixand--rootarguments are probably useless so I've removed them
There was a problem hiding this comment.
I can make $RPM_BUILD_ROOT more visible and more correct, however --prefix and --root have to stay as they are, as they are needed in older Fedora and RHEL version (the current cockpit testing matrix for main is fedora >= 34 and rhel >= 8.4).
There was a problem hiding this comment.
as they are needed in older Fedora and RHEL version
Are you sure?
There was a problem hiding this comment.
Root always defaults to /. And prefix defaults to /usr when $RPM_BUILD_ROOT is set.
There was a problem hiding this comment.
Could you please a least try this?
| RPM_BUILD_ROOT="" python3 ./setup.py install --prefix /usr --root / | |
| RPM_BUILD_ROOT="/" python3 ./setup.py install |
There was a problem hiding this comment.
Mea culpa. I've just tested this on CentOS Stream 8 and there is indeed a very weird error happening without --root:
running install_data
error: [Errno 2] No such file or directory: 'build/locale'
With --root /, it is gone. The reason appears to be that without --root the build process goes through bdist_egg and the build fails as your custom build class does not support that. It appears the --root option serves as another undocumented workaround here. Oh my.
There was a problem hiding this comment.
So... should we go ahead with the current changes? (note I updated this PR a couple of hours ago)
There was a problem hiding this comment.
I consider my concerns resolved. Note however that IMHO you are piling up workarounds on top of workarounds and actually building the RPM might be safer.
There was a problem hiding this comment.
Well, the bigger workaround here is the sucky buildsystem, so there isn't much "good" doable when the baseline is already poor... :-(
Note that this was added originally with #2091. Personally speaking, I had bad past experiences with locally installed stuff in /usr/local that was supposed to shadow things in /usr but it really didn't, resulting in broken setups. That's why I never use /usr/local myself on my systems. Another point is that sub-man has bits that have to be in certain system locations, e.g. the package manager plugins. Right now (because of the awful build system we have) they are not installed in the testing system during the cockpit testing, and this is a minor issue that so far has not hit us yet. So we really need to keep doing system installations to fully test sub-man. |
Due to a recent change in Fedora 36 [1], the installation prefix is mangled in certain scenarios [2]. Hence, set a $RPM_BUILD_ROOT environment variable when invoking 'setup.py install', so it works again as it used in older versions of Fedora. This script is used only for the cockpit CI testing, so there is no change for usual builds. [1] https://src.fedoraproject.org/rpms/python3.10/pull-request/63 [2] https://bugzilla.redhat.com/show_bug.cgi?id=2026979
eb26c57 to
763e0ca
Compare
martinpitt
left a comment
There was a problem hiding this comment.
Thanks! I still can't say I like it, but at least the situation is properly analyzed now, and it's the best you can do if you don't want to build/install an rpm. As a non-project member I can't formally approve, but I can at least revoke my "suggesting changes".
Thanks @hroncok for your help here!
jirihnidek
left a comment
There was a problem hiding this comment.
Thanks for all your reviews 👍
Due to a recent change in Fedora 36 [1], the installation prefix is
mangled in certain scenarios [2].
Hence, set a
$RPM_BUILD_ROOTenvironment variable when invokingsetup.py install, so it works again as it used in older versions ofFedora. This script is used only for the cockpit CI testing, so there
is no change for usual builds.
[1] https://src.fedoraproject.org/rpms/python3.10/pull-request/63
[2] https://bugzilla.redhat.com/show_bug.cgi?id=2026979