Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mockchain still creates a root-owned resultdir #1490

Closed
praiskup opened this issue Oct 23, 2024 · 1 comment · Fixed by #1513
Closed

mockchain still creates a root-owned resultdir #1490

praiskup opened this issue Oct 23, 2024 · 1 comment · Fixed by #1513

Comments

@praiskup
Copy link
Member

Two subsequent runs of mockchain cause this traceback:

$ mockchain -r epel-10-x86_64 /tmp/python-responses/python-responses-0.18.0-1.el9.src.rpm /tmp/python-freezegun/python-freezegun-1.2.2-9.fc42.src.rpm /tmp/python-humanize/python-humanize-4.9.0-2.fc42.src.rpm /home/praiskup/rh/packages/copr-cli/copr-cli-2.0-1.el10_0.src.rpm

## mockchain is deprecated, use mock --chain instead ##

INFO: mock.py version 5.9 starting (python version = 3.13.0, NVR = mock-5.9-1.git.3831.cdc2b58.fc41), args: /usr/libexec/mock/mock --chain -r epel-10-x86_64 /tmp/python-responses/python-responses-0.18.0-1.el9.src.rpm /tmp/python-freezegun/python-freezegun-1.2.2-9.fc42.src.rpm /tmp/python-humanize/python-humanize-4.9.0-2.fc42.src.rpm /home/praiskup/rh/packages/copr-cli/copr-cli-2.0-1.el10_0.src.rpm
Start(bootstrap): init plugins
INFO: tmpfs initialized
INFO: selinux enabled
INFO: chroot_scan: initialized
Finish(bootstrap): init plugins
Start: init plugins
INFO: tmpfs initialized
INFO: selinux enabled
INFO: chroot_scan: initialized
Finish: init plugins
INFO: Signal handler active
Start: run
INFO: chroot_scan: 3 files copied to /var/lib/mock/centos-stream+epel-10-x86_64/result/chroot_scan
INFO: /var/lib/mock/centos-stream+epel-10-x86_64/root/var/log/dnf.log
/var/lib/mock/centos-stream+epel-10-x86_64/root/var/log/dnf.librepo.log
/var/lib/mock/centos-stream+epel-10-x86_64/root/var/log/dnf.rpm.log
Traceback (most recent call last):
  File "/usr/libexec/mock/mock", line 1135, in <module>
    exitStatus = main()
  File "/usr/lib/python3.13/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 887, in main
    result = run_command(options, args, config_opts, commands, buildroot)
  File "/usr/lib/python3.13/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 930, in run_command
    commands.init(do_log=True)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.13/site-packages/mockbuild/backend.py", line 156, in init
    self.buildroot.resetLogging()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/mockbuild/trace_decorator.py", line 93, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.13/site-packages/mockbuild/buildroot.py", line 654, in resetLogging
    fh = logging.FileHandler(fullPath, "a+")
  File "/usr/lib64/python3.13/logging/__init__.py", line 1218, in __init__
    StreamHandler.__init__(self, self._open())
                                 ~~~~~~~~~~^^
  File "/usr/lib64/python3.13/logging/__init__.py", line 1247, in _open
    return open_func(self.baseFilename, self.mode,
                     encoding=self.encoding, errors=self.errors)
PermissionError: [Errno 13] Permission denied: '/var/lib/mock/centos-stream+epel-10-x86_64/result/state.log'

Caused by root ownership:

$ ls -alh /var/lib/mock/centos-stream+epel-10-x86_64/result/
total 12K
drwxrwxr-x. 3 root     root 4.0K říj 23 12:29 .
drwxrwxr-x. 4 root     mock 4.0K říj 23 12:29 ..
drwxrwxr-x. 3 praiskup mock 4.0K říj 23 12:29 chroot_scan
@github-project-automation github-project-automation bot moved this to Needs triage in CPT Kanban Oct 23, 2024
@nikromen nikromen moved this from Needs triage to In 3 months in CPT Kanban Oct 25, 2024
praiskup added a commit to praiskup/mock that referenced this issue Nov 30, 2024
In the real one now, also for the --chain method which is changing the
buildroot.resultdir for every single package.  Previously, chroot_scan/
was (re)created for every --chain package in the basedir:

    /var/lib/mock/fedora-41-x86_64/result/chroot_scan

Now, chroot_scan/ files are written into a package-specific resultdir,
for example:

    /var/tmp/mock-chain-root-28259-ie_33sdi/results/default/copr-cli-2.0-1.git.15.526473b.fc41/chroot_scan
    /var/tmp/mock-chain-root-28259-ie_33sdi/results/default/python-copr-2.0-1.git.20.526473b.fc41/chroot_scan

This in turn fixes a --chain build, because it - together with the
`chroo_scan` directory it created also `chroot_scan/..` directory,
mistakenly root-owned.

Fixes: rpm-software-management#1490
@praiskup
Copy link
Member Author

The problem was that the plugin's resultdir was crated globally in /var/lib/mock//result, not in the per-package resultdir like /var/tmp/mock-chain-root-23693-8id_zl19/results/.

nikromen pushed a commit that referenced this issue Dec 2, 2024
In the real one now, also for the --chain method which is changing the
buildroot.resultdir for every single package.  Previously, chroot_scan/
was (re)created for every --chain package in the basedir:

    /var/lib/mock/fedora-41-x86_64/result/chroot_scan

Now, chroot_scan/ files are written into a package-specific resultdir,
for example:

    /var/tmp/mock-chain-root-28259-ie_33sdi/results/default/copr-cli-2.0-1.git.15.526473b.fc41/chroot_scan
    /var/tmp/mock-chain-root-28259-ie_33sdi/results/default/python-copr-2.0-1.git.20.526473b.fc41/chroot_scan

This in turn fixes a --chain build, because it - together with the
`chroo_scan` directory it created also `chroot_scan/..` directory,
mistakenly root-owned.

Fixes: #1490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant