Johannes Kastl
Hi Dan,
On 13.01.23 at 09:19 Dan Čermák wrote:
and this is how it looks after the ln:
[ 11s] lrwxrwxrwx. 1 abuild abuild 16 Jan 13 09:14 pycodestyle -> pycodestyle-3.10 [ 11s] -rwxr-xr-x. 1 abuild abuild 984 Jan 13 09:14 pycodestyle-3.10 [ 11s] -rwxr-xr-x. 1 abuild abuild 983 Jan 13 09:14 pycodestyle-3.8 [ 11s] -rwxr-xr-x. 1 abuild abuild 983 Jan 13 09:14 pycodestyle-3.9
which, is more or less what I'd expect, is it not?
Yes, but only if I call the ln command **inside this folder**.
Nope: --8<---------------cut here---------------start------------->8--- ❯ mkdir -p /tmp/foo && touch /tmp/foo/bar && ln -sf bar /tmp/foo/baz ❯ ll /tmp/foo/ total 0 -rw-r--r--. 1 dan dan 0 Jan 13 10:18 bar lrwxrwxrwx. 1 dan dan 3 Jan 13 10:18 baz -> bar --8<---------------cut here---------------end--------------->8---
But the ln command is called from inside the "/home/abuild/rpmbuild/BUILD/pycodestyle-2.10.0" directory, not from "/home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/". (At least if the pwd I inserted does not lie to me...).
So in my limited understanding the link should not have been created in the .../usr/bin/ folder, but inside "/home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/".
See this output:
[ 9s] + pwd [ 9s] /home/abuild/rpmbuild/BUILD/pycodestyle-2.10.0 [ 9s] + cp /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.8 [ 9s] + sed -ri '1s@#!.*python.*@#!/usr/bin/python3.8@' /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.8 [ 9s] + cp /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.9 [ 9s] + sed -ri '1s@#!.*python.*@#!/usr/bin/python3.9@' /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.9 [ 9s] + cp /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.10 [ 9s] + sed -ri '1s@#!.*python.*@#!/usr/bin/python3.10@' /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.10
This is from the %python_clone
[ 9s] + pwd [ 9s] /home/abuild/rpmbuild/BUILD/pycodestyle-2.10.0 [ 9s] + ls -lh /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.10 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.8 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.9 [ 9s] -rwxr-xr-x 1 abuild abuild 984 Jan 13 08:29 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle [ 9s] -rwxr-xr-x 1 abuild abuild 984 Jan 13 08:29 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.10 [ 9s] -rwxr-xr-x 1 abuild abuild 983 Jan 13 08:29 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.8 [ 9s] -rwxr-xr-x 1 abuild abuild 983 Jan 13 08:29 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle-3.9
This was the output of "ls -lh %{buildroot}%{_bindir}/pycodestyle*"
[ 9s] + pwd [ 9s] /home/abuild/rpmbuild/BUILD/pycodestyle-2.10.0
Working directory before the ln command.
[ 9s] + ln -sf pycodestyle-3.10 /home/abuild/rpmbuild/BUILDROOT/python-pycodestyle-2.10.0-0.x86_64/usr/bin/pycodestyle
Working directory after the ln command, no file in the current directory:
[ 9s] + ls -lh [ 9s] total 216K [ 9s] -rw-r--r-- 1 abuild abuild 27K Nov 23 18:26 CHANGES.txt [ 9s] -rw-r--r-- 1 abuild abuild 3.1K Nov 23 18:26 CONTRIBUTING.rst [ 9s] -rw-r--r-- 1 abuild abuild 1.3K Nov 23 18:26 LICENSE [ 9s] -rw-r--r-- 1 abuild abuild 243 Nov 23 18:26 MANIFEST.in [ 9s] -rw-r--r-- 1 abuild abuild 31K Nov 23 18:27 PKG-INFO [ 9s] -rw-r--r-- 1 abuild abuild 3.4K Nov 23 18:26 README.rst [ 9s] drwxr-xr-x 3 abuild abuild 4.0K Jan 13 08:29 _build.python38 [ 9s] drwxr-xr-x 3 abuild abuild 4.0K Jan 13 08:29 _build.python39 [ 9s] -rw-r--r-- 1 abuild abuild 10 Jan 13 08:29 _current_flavor [ 9s] drwxr-xr-x 3 abuild abuild 4.0K Jan 13 08:29 build [ 9s] -rw-r--r-- 1 abuild abuild 4 Nov 23 18:26 dev-requirements.txt [ 9s] drwxr-xr-x 2 abuild abuild 4.0K Nov 23 18:27 docs [ 9s] drwxr-xr-x 2 abuild abuild 4.0K Jan 13 08:29 pycodestyle.egg-info [ 9s] -rwxr-xr-x 1 abuild abuild 100K Jan 13 08:29 pycodestyle.py [ 9s] -rw-r--r-- 1 abuild abuild 191 Nov 23 18:27 setup.cfg [ 9s] -rw-r--r-- 1 abuild abuild 1.9K Nov 23 18:26 setup.py [ 9s] drwxr-xr-x 2 abuild abuild 4.0K Nov 23 18:27 testsuite [ 9s] + exit 99
I just tested this, apparently ln has hidden superpowers (that I did not find in the man page):
If I call "ln -sf /tmp/something foo", then "foo" gets created in my current directory. If I call "ln -sf foo /tmp/something" from any directory, then "/tmp/something" gets overwritten with a link to "foo" **relative to the /tmp/ directory**
$ ln -sf foo /tmp/something $ cd /tmp/ $ ll something* lrwxrwxrwx 1 xxx users 3 13. Jan 09:36 something -> foo $
So, that part seems solved. I still do not understand the packaging error for /usr/bin/_current_flavor if I create the link manually inside the directory:
%python_clone %{buildroot}%{_bindir}/pycodestyle cd %{buildroot}%{_bindir}/ln -sf pycodestyle-%{python3_bin_suffix} pycodestyle
This is due to the python flavor switching magic which is performed by
writing the current python flavor into the file _current_flavor. The
macros assume that the switching code is never executed inside
%buildroot and so littering pwd with additional files is not an
issue. It becomes one if you cd into %{buildroot} of course.
Cheers,
Dan
--
Dan Čermák