Bug 799639 - RFE: mock should backup result directory when clean
Summary: RFE: mock should backup result directory when clean
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Clark Williams
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-03 18:29 UTC by Sergio Basto
Modified: 2015-07-02 21:01 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-07-02 21:01:03 UTC
Type: ---
Embargoed:


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

Description Sergio Basto 2012-03-03 18:29:23 UTC
Description of problem:

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

Version-Release number of selected component (if applicable):
mock-1.1.21-1.fc16.noarch

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 
gone 

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


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. 

Thanks,

Comment 1 Sergio Basto 2012-03-07 22:37:02 UTC
I mean not clean /var/lib/mock/fedora-rawhide-x86_64/result/*rpm , but truncate logs if it possible .

Comment 2 Sergio Basto 2012-03-07 23:00:58 UTC
hi, and when we use mock --no-clean , *log should be clean before starting building ... please .

Comment 3 Sergio Basto 2012-03-14 17:16:28 UTC
a better idea , was backup result dir with logs and rpm before clean it.

Comment 4 Dennis Schridde 2012-04-18 09:42:31 UTC
I have the same issue on SL 6.2 using mock-1.1.21-1.el6.

Comment 5 Clark Williams 2012-04-18 20:31:02 UTC
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 Basto 2012-04-18 20:49:01 UTC
(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 Basto 2012-04-18 20:52:19 UTC
BTW, please tell me where is the code of clean root , in
mock code, to patch my mock builder. 

Thanks,

Comment 8 Clark Williams 2012-04-21 14:57:56 UTC
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 Basto 2012-10-14 17:42:37 UTC
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 ? 

Thanks,

Comment 10 Clark Williams 2012-10-19 13:55:09 UTC
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 Basto 2012-11-01 04:47:02 UTC
ping

Comment 12 Sergio Basto 2013-03-02 19:23:48 UTC
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 15:55:39 UTC
Ah sorry, got pulled off to work on other stuff. I'm back on this now.

Comment 14 Sergio Basto 2013-03-05 18:04:07 UTC
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 .

Thanks,

Comment 15 Clark Williams 2013-03-15 17:40:07 UTC
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 17:26:37 UTC
Created attachment 712138 [details]
Updated prototype for result backup code

Missed a commit when generating the previous patch

Comment 17 Sergio Basto 2013-03-18 18:42:22 UTC
(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  
Thanks,

Comment 18 Miroslav Suchý 2014-07-23 06:57:12 UTC
mock-1.1.41 (which should contain this fix) is in stable

Comment 19 Sergio Basto 2015-06-13 22:54:06 UTC
Created attachment 1038453 [details]
backup_dstdir_use_root_name_instead_config_name.patch

Hi,

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
default
fedora-20-i386
fedora-20-x86_64
fedora-21-x86_64
fedora-21-x86_64-rpmfusion_free
fedora-21-x86_64-rpmfusion_nonfree
fedora-22-x86_64
fedora-22-x86_64-rpmfusion_free
fedora-rawhide-x86_64

Comment 20 Sergio Basto 2015-06-13 22:57:11 UTC
Errata :
and it was very useful thanks,


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