Bug 799639 - RFE: mock should backup result directory when clean
RFE: mock should backup result directory when clean
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Clark Williams
Fedora Extras Quality Assurance
: Reopened
Depends On:
  Show dependency treegraph
Reported: 2012-03-03 13:29 EST by Sergio Monteiro Basto
Modified: 2015-07-02 17:01 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-07-02 17:01:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
prototype for adding a backup mechanism (3.25 KB, patch)
2013-03-15 13:40 EDT, Clark Williams
no flags Details | Diff
Updated prototype for result backup code (3.80 KB, patch)
2013-03-18 13:26 EDT, Clark Williams
no flags Details | Diff
backup_dstdir_use_root_name_instead_config_name.patch (569 bytes, patch)
2015-06-13 18:54 EDT, Sergio Monteiro Basto
no flags Details | Diff

  None (edit)
Description Sergio Monteiro Basto 2012-03-03 13:29:23 EST
Description of problem:

mock -r fedora-rawhide-x86_64 --rebuild SRPMS/package.src.rpm
cleans all 

Version-Release number of selected component (if applicable):

How reproducible:
build package packageone 
mock -r fedora-rawhide-x84 --rebuild SRPMS/packageone.fc16.src.rpm
finish ok with
INFO: Results and/or logs in: /var/lib/mock/fedora-rawhide-x86_64/results

build package packagetwo 
mock -r fedora-rawhide-x84 --rebuild SRPMS/packagetwo.fc16.src.rpm

results of packageone in /var/lib/mock/fedora-rawhide-x86_64/results  has 

Actual results:
results of packageone in /var/lib/mock/fedora-rawhide-x86_64/results  has 

Expected results:
keep results of previous good build.

Additional info:
Since results are indepent of root , I think just clean /var/lib/mock/fedora-rawhide-x86_64/root is much more productive.

second, if you don't agree with it , just tell me how, I just clean root , in mock code, to apply and modify my mock builder. 

Comment 1 Sergio Monteiro Basto 2012-03-07 17:37:02 EST
I mean not clean /var/lib/mock/fedora-rawhide-x86_64/result/*rpm , but truncate logs if it possible .
Comment 2 Sergio Monteiro Basto 2012-03-07 18:00:58 EST
hi, and when we use mock --no-clean , *log should be clean before starting building ... please .
Comment 3 Sergio Monteiro Basto 2012-03-14 13:16:28 EDT
a better idea , was backup result dir with logs and rpm before clean it.
Comment 4 devurandom 2012-04-18 05:42:31 EDT
I have the same issue on SL 6.2 using mock-1.1.21-1.el6.
Comment 5 Clark Williams 2012-04-18 16:31:02 EDT
the default action of mock is to clean both the chroot and the result directory so that you will have just the results of the last build in the results directory. If you add the --no-clean option it will not clean out the results directory. If you don't want to use the --no-clean directory then you need to copy out the rpms from the results directory before invoking mock again.
Comment 6 Sergio Monteiro Basto 2012-04-18 16:49:01 EDT
(In reply to comment #5)
> the default action of mock is to clean both the chroot and the result directory

OK , I changed to an RFE (request for enhancements), I think the better solution is backup results when is perform an clean.
Comment 7 Sergio Monteiro Basto 2012-04-18 16:52:19 EDT
BTW, please tell me where is the code of clean root , in
mock code, to patch my mock builder. 

Comment 8 Clark Williams 2012-04-21 10:57:56 EDT
You probably want to look at either clean() or _unlock_and_rm_chroot(), which are both methods of the Root object in the file py/mockbuild/backend.py. The clean() method is the entry point to the clean logic and _unlock_and_rm_chroot() where the actual chroot dir (both result and root) get removed.
Comment 9 Sergio Monteiro Basto 2012-10-14 13:42:37 EDT
another way to fix this , is inspired on fedpkg mockbuild

mock -r fedora-17-x86_64 --resultdir /home/sergio/fedora-scm/libkdcraw/results_libkdcraw/4.9.50/2.fc17 --rebuild /home/sergio/fedora-scm/libkdcraw/libkdcraw-4.9.50-2.fc17.src.rpm

Which is write mock results in other directory not under /var/lib/mock/fedora-17-x86_64 ...
for example : /home/sergio/mock_results/$pkg$datime .
Any way to do this in mock.cfg ? 

Comment 10 Clark Williams 2012-10-19 09:55:09 EDT
hmmm, that might work. We'll need to add something in the .cfg file to indicate where results should be written. Maybe even tar everything up, compress it and write it to the specified result dir. 

I'm on the road right now but will be back monday so if I can dig out from under the email, I'll try and get something going next week.
Comment 11 Sergio Monteiro Basto 2012-11-01 00:47:02 EDT
Comment 12 Sergio Monteiro Basto 2013-03-02 14:23:48 EST
Hi, the mock --clean shouldn't clean built packages, this is important , the exercise to build a 2nd package that depends on a build of first, is insane , because mock clean all or don't clean nothing .
Comment 13 Clark Williams 2013-03-05 10:55:39 EST
Ah sorry, got pulled off to work on other stuff. I'm back on this now.
Comment 14 Sergio Monteiro Basto 2013-03-05 13:04:07 EST
Hi , I need a way to backup results dir automatically with mock , I can do a 

cp /var/lib/mock/fedora-18-x86_64/result/*rpm ~/rpmbuild/results/ 

after every sucefully build, but sometimes I forgot .... 
also have logs of failure builds could help out sometimes .

Comment 15 Clark Williams 2013-03-15 13:40:07 EDT
Created attachment 710780 [details]
prototype for adding a backup mechanism

Try this and see if it does what you want. Turn it on in a config file with:

     config_opts['backup_on_clean'] = True

The backup directory will be /var/lib/mock/backup/<config>
Comment 16 Clark Williams 2013-03-18 13:26:37 EDT
Created attachment 712138 [details]
Updated prototype for result backup code

Missed a commit when generating the previous patch
Comment 17 Sergio Monteiro Basto 2013-03-18 14:42:22 EDT
(In reply to comment #16)
> Created attachment 712138 [details]
> Updated prototype for result backup code
> Missed a commit when generating the previous patch

Hi, looks good, simple and safe, many thanks to work on this . 
I build my self mock-1.1.29-2 with this patch , but haven't test it effectively  
Comment 18 Miroslav Suchý 2014-07-23 02:57:12 EDT
mock-1.1.41 (which should contain this fix) is in stable
Comment 19 Sergio Monteiro Basto 2015-06-13 18:54:06 EDT
Created attachment 1038453 [details]


It is just an minor improve .

I had always use: 

config_opts['backup_on_clean'] = True

and i was very useful thanks, 

I use mock -r fedora-21-x86_64 , mock -r fedora-21-x86_64-rpmfusion_free or even default (just mock), when mock make the cleanup, backup dir name use config name i.e. fedora-21-x86_64-rpmfusion_free or fedora-21-x86_64 when root is the same (fedora-21-x86_64). So I prefer the backup directory have root name instead config named.
It is a very simple patch . 

One motivation was fedora-review which backup things on default and, for me, is more logic that backup things in fedora-rawhide-x86_64 
see my backup dir, which is not the best optimization : 
ls /var/lib/mock/backup/ -1
Comment 20 Sergio Monteiro Basto 2015-06-13 18:57:11 EDT
Errata :
and it was very useful thanks,

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