Bug 1312677 - [abrt] mock: shutil.py:108:copyfile:FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/mock//fedora-23-x86_64/result/kicad-4.0.2-1.fc23.src.rpm'
[abrt] mock: shutil.py:108:copyfile:FileNotFoundError: [Errno 2] No such file...
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
23
x86_64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Suchý
Fedora Extras Quality Assurance
https://retrace.fedoraproject.org/faf...
abrt_hash:9c9c622032fefd856b0ca078ce3...
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-28 13:08 EST by Niki Guldbrand
Modified: 2016-10-21 01:08 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-06-02 10:50:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
File: backtrace (2.28 KB, text/plain)
2016-02-28 13:08 EST, Niki Guldbrand
no flags Details
File: environ (212 bytes, text/plain)
2016-02-28 13:08 EST, Niki Guldbrand
no flags Details

  None (edit)
Description Niki Guldbrand 2016-02-28 13:08:03 EST
Description of problem:
I tried to build a package with mock, and the *.src.rpm file disaperred after I started the execution.

Version-Release number of selected component:
mock-1.2.15-1.fc23

Additional info:
reporter:       libreport-2.6.4
cmdline:        /usr/bin/python3 -tt /usr/sbin/mock --rebuild -r fedora-23-x86_64 /var/lib/mock//fedora-23-x86_64/result/kicad-4.0.2-1.fc23.src.rpm
executable:     /usr/sbin/mock
kernel:         4.3.5-300.fc23.x86_64
runlevel:       N 5
type:           Python3
uid:            1000

Truncated backtrace:
shutil.py:108:copyfile:FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/mock//fedora-23-x86_64/result/kicad-4.0.2-1.fc23.src.rpm'

Traceback (most recent call last):
  File "/usr/sbin/mock", line 849, in <module>
    main()
  File "/usr/lib/python3.4/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 663, in main
    run_command(options, args, config_opts, commands, buildroot, state)
  File "/usr/lib/python3.4/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 746, in run_command
    do_rebuild(config_opts, commands, buildroot, args)
  File "/usr/lib/python3.4/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 504, in do_rebuild
    post=post_build, clean=clean)
  File "/usr/lib/python3.4/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 448, in rebuild_generic
    ret = cmd(item)
  File "/usr/sbin/mock", line 484, in build
    check=config_opts['check'])
  File "/usr/lib/python3.4/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.4/site-packages/mockbuild/backend.py", line 208, in build
    srpm = self.copy_srpm_into_chroot(srpm)
  File "/usr/lib/python3.4/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.4/site-packages/mockbuild/backend.py", line 368, in copy_srpm_into_chroot
    shutil.copy2(srpm_path, dest)
  File "/usr/lib64/python3.4/shutil.py", line 245, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib64/python3.4/shutil.py", line 108, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/mock//fedora-23-x86_64/result/kicad-4.0.2-1.fc23.src.rpm'

Local variables in innermost frame:
src: '/var/lib/mock//fedora-23-x86_64/result/kicad-4.0.2-1.fc23.src.rpm'
fn: '/var/lib/mock/fedora-23-x86_64/root/builddir/build/originals/kicad-4.0.2-1.fc23.src.rpm'
follow_symlinks: True
dst: '/var/lib/mock/fedora-23-x86_64/root/builddir/build/originals/kicad-4.0.2-1.fc23.src.rpm'
Comment 1 Niki Guldbrand 2016-02-28 13:08:11 EST
Created attachment 1131297 [details]
File: backtrace
Comment 2 Niki Guldbrand 2016-02-28 13:08:13 EST
Created attachment 1131298 [details]
File: environ
Comment 3 Miroslav Suchý 2016-05-12 11:14:17 EDT
I cannot reproduce it.
 1) Can you try it with mock-1.2.17?
 2) Can you post your site-defaults.cfg if there is any customizacion?
Comment 4 Miroslav Suchý 2016-06-02 10:50:49 EDT
I believe this is fixed in mock-1.2.17 as we recently fixed very similar bug.
If you happen to reproduce it with mock-1.2.17, then please reopen.
Comment 5 Andrew Toskin 2016-10-06 19:43:27 EDT
I don't have privileges to change the status on this bug report, but I believe I'm experiencing this same issue, with mock 1.2.21 on Fedora 24, while working on an experimental package of Firefox Developer Edition. Last time I worked on this package, I still hadn't gotten it to compile all the way; however, it never deleted the SRPM before.

When I resumed work on the package today, building the SRPM executed without errors. But then trying to build the binary fails, and suddenly the SRPM is gone:

$ mock --rebuild /var/lib/mock/fedora-24-x86_64/result/firefox-dev-51.0a2.20161006-1.fc24.src.rpm

INFO: mock.py version 1.2.21 starting (python version = 3.5.1)...
Start: init plugins
INFO: selinux enabled
Finish: init plugins
Start: run
INFO: Start(/var/lib/mock/fedora-24-x86_64/result/firefox-dev-51.0a2.20161006-1.fc24.src.rpm)  Config(fedora-24-x86_64)
Start: clean chroot
Finish: clean chroot
Start: chroot init
INFO: calling preinit hooks
INFO: enabled root cache
Start: unpacking root cache
Finish: unpacking root cache
INFO: enabled dnf cache
Start: cleaning dnf metadata
Finish: cleaning dnf metadata
Mock Version: 1.2.21
INFO: Mock Version: 1.2.21
Start: dnf update
Last metadata expiration check: 0:00:01 ago on Thu Oct  6 16:14:50 2016.
Dependencies resolved.
====================================================================
 Package               Arch      Version        Repository     Size
====================================================================
Upgrading:
 systemd-libs          x86_64    229-16.fc24    updates       456 k

Transaction Summary
====================================================================
Upgrade  1 Package

Total size: 456 k
Downloading Packages:
[SKIPPED] systemd-libs-229-16.fc24.x86_64.rpm: Already downloaded
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Upgrading   : systemd-libs-229-16.fc24.x86_64      1/2
  Cleanup     : systemd-libs-229-15.fc24.x86_64      2/2
  Verifying   : systemd-libs-229-16.fc24.x86_64      1/2
  Verifying   : systemd-libs-229-15.fc24.x86_64      2/2

Upgraded:
  systemd-libs.x86_64 229-16.fc24

Complete!
Finish: dnf update
Finish: chroot init
Start: build phase for firefox-dev-51.0a2.20161006-1.fc24.src.rpm
Start: build setup for firefox-dev-51.0a2.20161006-1.fc24.src.rpm
ERROR: Exception(/var/lib/mock/fedora-24-x86_64/result/firefox-dev-51.0a2.20161006-1.fc24.src.rpm) Config(fedora-24-x86_64) 1 minutes 30 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-24-x86_64/result
Traceback (most recent call last):
  File "/usr/sbin/mock", line 844, in <module>
    main()
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 663, in main
    run_command(options, args, config_opts, commands, buildroot, state)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 745, in run_command
    do_rebuild(config_opts, commands, buildroot, args)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 504, in do_rebuild
    post=post_build, clean=clean)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 449, in rebuild_generic
    ret = cmd(item)
  File "/usr/sbin/mock", line 485, in build
    check=config_opts['check'])
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.5/site-packages/mockbuild/backend.py", line 208, in build
    srpm = self.copy_srpm_into_chroot(srpm)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.5/site-packages/mockbuild/backend.py", line 360, in copy_srpm_into_chroot
    shutil.copyfile(srpm_path, os.path.join(dest, srpmFilename))
  File "/usr/lib64/python3.5/shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/mock/fedora-24-x86_64/result/firefox-dev-51.0a2.20161006-1.fc24.src.rpm'
Comment 6 Andrew Toskin 2016-10-17 19:28:56 EDT
Bump.

Anyone have any idea about what's going on here? I'm not finding too many matches, besides this thread, when I google the error message.
Comment 7 Miroslav Suchý 2016-10-18 04:21:07 EDT
This is because you have SRPM located in /var/lib/mock/fedora-24-x86_64/result/.
At the beginning the chroot (/var/lib/mock/fedora-24-x86_64/) is wiped. Including the result dir. This is expected behaviour.
If you do not want to wipe it, then either:
1) move your SRPM to other location (prefered solution) or
2) pass --no-clean to mock
Comment 8 Andrew Toskin 2016-10-18 19:42:18 EDT
(In reply to Miroslav Suchý from comment #7)

But *by default*, the source RPM is placed in /var/lib/mock/fedora-24-x86_64/ (or equivalent, depending on the target architecture). And building the binary RPM requires the source RPM as input. Putting the source RPM in a directory that will get wiped upon running `--rebuild` seems, um, kind of silly.

If not a bug in mock itself, then I would argue that this is at the very least a hole in the mock documentation. As someone new to the process of RPM packaging, I found the "expected behavior" here rather surprising. Based on Niki's original post, it seems I'm not the only one confused either.

Currently, the manual does say the chroot gets "cleaned," but before stumbling across this bugzilla thread, I'd thought that meant something like removing temporary files and restoring default environment variables -- not deleting all the work done by the previous mock command. If I understand things correctly now, when creating the binary RPM, it is *mandatory* to either move the source RPM or use `--no-clean`; the manual, however, makes `--no-clean` seem *optional*, and does not mention moving the generated SRPM at all. If moving the SRPM between running the two mock commands is the preferred solution, then perhaps the man page should add a line to the `--rebuild` section suggesting that users first rescue their SRPM.

Or, what might be better is to change the default location of the SRPM to be in the current working directory. Possibly also add a command line option to specify the SRPM destination.

If I'm missing something that would help make sense of mock's current behavior, please let me know.
Comment 9 Miroslav Suchý 2016-10-20 10:03:48 EDT
(In reply to terrycloth from comment #8)
> But *by default*, the source RPM is placed in
> /var/lib/mock/fedora-24-x86_64/

But this is output for SRPM (and RPMs)!

> And building the binary RPM requires the source RPM as input.

But that SRPM can be anywhere. Usually in ~/ or in /tmp.

For me this was very basic knowledge. And I'm very surprised that someone is trying to *put* SRPM in /var/lib/mock/fedora-24-x86_64/
I now see your problem and I agree that for newcomer it can be confused. I will modify man page.

Done in commit:
* f71e2fc man: clarify chroot cleanups
Comment 10 Andrew Toskin 2016-10-21 01:08:20 EDT
Taking another look at the man page, I see that there actually already is the `--resultdir` option. I read your updates to the man page, and it's a bit better now. I think things could still be clarified some more, but this time I think I can help; I'll send a pull request for this :)

Just one more question, as long as we're talking about documentation: I'm a little confused about the `--copyin` and `--copyout` options. I assume "sources" refers to the source files for the RPM package being built. But those source files are necessarily going to be read during the build anyway, so what would be the use case for actually copying them in or out of the chroot?

Note You need to log in before you can comment on or make changes to this bug.