52e8393 rpmbuild: clarify and encapsulate Provider's directories

Authored and Committed by praiskup 6 months ago
    rpmbuild: clarify and encapsulate Provider's directories
    Before we had outdir, workdir and resultdir, and all of them were used a
    weird way while it wasn't clear what is used for what purpose - these
    were mostly clashing with others.
    Newly there are these directories:
     real_resultdir = /var/lib/copr-rpmbuild/resultdir
     workspace      = /var/lib/copr-rpmbuild/workspace
     workdir        = /var/lib/copr-rpmbuild/workspace/workdir-XXXX
     safe_resultdir = /var/lib/copr-rpmbuild/workspace/safe-resultdir-XXXX
    The workspace and real_resultdir are configurable (workspace/resultdir
    config options).
    First main directory is `real_resultdir`, that's where copr-backend
    searches for the build results and logs.  The second is `workdir`, it is
    directory with generated name and that's the place all the heavy-lifting
    Then there's a helper directory named `safe_resultdir` which is useful
    if the method is not entirely safe, and can run as privileged user e.g.
    and thus e.g. create files that can not be deleted by non-privileged
    user.  We don't create this directory when it is not needed (currently
    only make_srpm needs it).   We copy out the stuff in safe_resultdir to
    resultdir at the end of the day, but the file ownership is corrected.
    All the directories are now in /var/lib/copr-rpmbuild by default, before
    we had outdir in /tmp and it caused problems (issue#1734).
    The `wokdir` and `safe_resultdir` with generated names are automatically
    removed when Provider.cleanup() is called, and when it is reasonably
    possible (it may because of permissions, and then copr-builder-cleanup
    is our friend).
    The fact that there's a clear distinction between real_resultdir and
    safe_resultdir, and we use them appropriately - there's no need to keep
    large uploaded source RPM on two places (before we had it in outdir, and
    then copied it to resultdir).  This caused troubles like (#1734).  So
    newly, we store the large source RPM directly into resultdir (as long as
    it is reasonably safe).
    Another benefit is that the logic behind directories is encapsulated in
    one class, not scattered around whole the code base.
    Fixes: #1734
    Relates: #534
file modified
+2 -0
file modified
+13 -26
file modified
+26 -4
file modified
+6 -5
file modified
+40 -29
file modified
+6 -4
file modified
+45 -19
file modified
+13 -12