Bug 1471593

Summary: mockbuild couldn't support cross compilation
Product: [Fedora] Fedora Reporter: Mikhail <mikhail.v.gavrilov>
Component: fedpkgAssignee: cqi
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: bochecha, cqi, dennis, lsedlar, mikhail.v.gavrilov, pbabinca, s
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-21 02:14:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mikhail 2017-07-17 03:01:22 UTC
Description of problem:
$ fedpkg mockbuild
not supported --arch parameter, so impossible on x86_64 system freate packager for i686 or arm.

$ fedpkg local support --arch parameter, but all dependencies in this case needed resolve manually.

mockbuild is more convenient for building packages.

Expected results:

$ fedpkg mockbuild --arch i686
successfully build packages for i686 architecture.

Comment 1 cqi 2017-07-17 03:07:31 UTC
mockbuild has this option

  --root CONFIG, --mock-config CONFIG
                        Override mock configuration (like mock -r)

E.g.

fedpkg mockbuild --mock-config fedora-26-i386

Comment 2 Mikhail 2017-07-17 14:54:00 UTC
Thanks, it works for i386, but what about arm?

$ fedpkg mockbuild --mock-config fedora-26-arm
/usr/lib/python2.7/site-packages/fedora/client/bodhi.py:48: DeprecationWarning: fedora.client.bodhi has been deprecated. Please use bodhi.client.bindings instead.
  DeprecationWarning)


Wrote: /home/mikhail/mutter/mutter-3.24.3-2.fc26.src.rpm
You are attempting to run "mock" which requires administrative
privileges, but more information is needed in order to do so.
Authenticating as "root"
Password: 
ERROR: Could not find required config file: /etc/mock/fedora-26-arm.cfg
ERROR:   If you're trying to specify a path, include the .cfg extension, e.g. -r ./target.cfg
Could not execute mockbuild: Command '['mock', '-r', 'fedora-26-arm', '--resultdir', u'/home/mikhail/mutter/results_mutter/3.24.3/2.fc26', '--rebuild', u'/home/mikhail/mutter/mutter-3.24.3-2.fc26.src.rpm']' returned non-zero exit status 1

For me not worked for arm architecture.

Comment 3 cqi 2017-07-17 15:07:25 UTC
Looks like your user account is not in mock group. Maybe you need https://fedoraproject.org/wiki/Using_Mock_to_test_package_builds#How_do_I_use_Mock.3F

I'm not familiar with building package in arm arch. I find /etc/mock/fedora-26-armhfp, not sure if it's the config for arm. mockbuild actually runs mock and value passed to --root or --mock-config is just passed to -r option of mock.

Comment 4 Lubomír Sedlář 2017-07-17 17:03:03 UTC
Look at what config files there are. I don't have fedora-26-arm.cfg, but there is fedora-26-armhfp.cfg which might work for you.

$ ls /etc/mock/fedora-26-*
/etc/mock/fedora-26-aarch64.cfg  /etc/mock/fedora-26-ppc64le.cfg
/etc/mock/fedora-26-armhfp.cfg   /etc/mock/fedora-26-s390x.cfg
/etc/mock/fedora-26-i386.cfg     /etc/mock/fedora-26-x86_64.cfg
/etc/mock/fedora-26-ppc64.cfg
$ rpm -q mock
mock-1.4.2-1.fc25.noarch

Comment 5 Mikhail 2017-07-18 05:04:12 UTC
$ fedpkg mockbuild --mock-config fedora-26-armhfp
/usr/lib/python2.7/site-packages/fedora/client/bodhi.py:48: DeprecationWarning: fedora.client.bodhi has been deprecated. Please use bodhi.client.bindings instead.
  DeprecationWarning)


Wrote: /home/mikhail/mutter/mutter-3.24.3-2.fc26.src.rpm
You are attempting to run "mock" which requires administrative
privileges, but more information is needed in order to do so.
Authenticating as "root"
Password: 
ERROR: Cannot build target armv7hl on arch x86_64, because it is not listed in legal_host_arches armv7l
Could not execute mockbuild: Command '['mock', '-r', 'fedora-26-armhfp', '--resultdir', u'/home/mikhail/mutter/results_mutter/3.24.3/2.fc26', '--rebuild', u'/home/mikhail/mutter/mutter-3.24.3-2.fc26.src.rpm']' returned non-zero exit status 6


What is legal_host_arches?

Comment 6 cqi 2017-07-18 05:49:20 UTC
> What is legal_host_arches?

I have no knowledge about this. I do some research and find

# When host system architecture is not in 'legal_host_arches' list, mock will refuse to switch to
# 'target_arch' and will raise error.

from https://github.com/rpm-software-management/mock/blob/devel/etc/mock/site-defaults.cfg#L300

and

only armv7l is listed in legal_host_arches in /etc/mock/fedora-26-armhfp.cfg, which is installed in my system.

config_opts['legal_host_arches'] = ('armv7l')

My understand is arm packages has to be built with mock on an ARM machine.

Comment 7 Mikhail 2017-07-19 18:50:39 UTC
So it's  impossible build for arm arch on x86?
If this is true, then this issue can be closed, although I would like it to become possible in the future.

And last question:

My typical workflow for testing upstream fix look like:
1. $ fedpkg clone -a geany // Get package
2. $ cd geany
3. $ fedpkg prep           // Get sources, extract and apply existing patches
Here I applied patches changes from upstream, or make changes by self
4. $ fedpkg patch orig     // If I make changes by self then I need create patch
5. $ rpmdev-bumpspec -c "check upstream fix" geany.spec  // Update build number and add change log
6. $ fedpkg mockbuild --mock-config fedora-26-i386 // Here build package for target architecture

So question is existing some tool for automatically adding new patch in spec  between steps 4 and 5? If this tool not existed can I ask to make this utility?
This would save me from editing manually spec file at all (it save my time).
Thanks.

Comment 8 cqi 2017-07-20 02:25:28 UTC
(In reply to Mikhail from comment #7)
> So it's  impossible build for arm arch on x86?

From what I learned, I guess it is. But, I have no idea of why and any other background about this. I recommend  you could try to consult mock developer or a wider range of Fedora packagers, probably devel mailing list.
 
> So question is existing some tool for automatically adding new patch in spec
> between steps 4 and 5? If this tool not existed can I ask to make this
> utility?
> This would save me from editing manually spec file at all (it save my time).
> Thanks.

Sorry, I don't know which tool can do this. Also, suggest you to ask in wider range of Fedora packagers.

Comment 9 cqi 2017-07-20 09:58:19 UTC
If you have no any further questions, I'm going to close this bug.

Comment 10 Mikhail 2017-07-20 19:15:52 UTC
I asked my question in IRC channel #fedora-devel, but there was no one who would be well versed in the cross compilation.
I've been advised use the koji instead.
But when I tryed scratch build package with koji occurred another issue.
It seems that I'm not the only one who has encountered such a problem
https://bugzilla.redhat.com/show_bug.cgi?id=1472348

Can you invite here someone who well known cross compiling for arm arc?

Comment 11 cqi 2017-07-21 02:14:34 UTC
Hi Mikhail, I don't know who is experienced on cross compiling from arm arch. Bug 1472348 you mentioned belongs to Koji not fedpkg, so please follow up that bug.

Comment 12 Dennis Gilmore 2017-07-31 22:15:59 UTC
cross compilation is not supported in mock.