# Building armv5 pkgs under amd64



## balanga (Apr 27, 2019)

Is it possible to build armv5 pkgs under amd64? 

I assume it is since I built FreeBSD 11.1 for ARM under amd64 following instructions here, and have built a few pkgs under it, but it is a painfully slow process.

Apologies for starting another thread for asking the same. The last one Thread 70499 lead me down a poudriere rabbit hole which went nowhere.   I'm hoping that there is some sort of facility - environment variable or /etc/make.conf option where I can set *TARGET_ARCH=arm* and then just run make...


----------



## hukadan (Apr 27, 2019)

balanga said:


> I assume it is since I built FreeBSD 11.1 for ARM


I am confused. In another thread you said you could only run 11.0-RELEASE without problem. Did you find out a way to improve the situation or did I misunderstood ?



balanga said:


> lead me down a poudriere rabbit hole which went nowhere.


Have you tried the method I gave you to get out of this rabbit hole ? I think the solution could be applied to 11.1-RELEASE if this is what you use now. I was able to build packages for armv5 that way (to be honest, it was slower than I expected even knowing it was cross compiling).


----------



## acheron (Apr 27, 2019)

Have you built the native-xtools (-x option to poudriere)?


----------



## balanga (Apr 27, 2019)

hukadan said:


> I am confused. In another thread you said you could only run 11.0-RELEASE without problem. Did you find out a way to improve the situation or did I misunderstood ?



I was able to _build _11.0 but had no success building pkgs.

With 11.1 I did eventually sort out the build errors  see Thread 70467. Not sure how I stumbled across that solution... 




> Have you tried the method I gave you to get out of this rabbit hole ? I think the solution could be applied to 11.1-RELEASE if this is what you use now. I was able to build packages for armv5 that way (to be honest, it was slower than I expected even knowing it was cross compiling).



I have established a working build environment for FreeBSD itself, I just want to be able to build pkgs. I've looked at poudriere() but my eyes just glaze over after a while...

If I just wanted to build misc/mc, what do I need to run?
`poudriere mc -o misc/mc -j jailname`


----------



## hukadan (Apr 28, 2019)

balanga said:


> what do I need to run?


You have to create a ports tree (see : poudriere-ports(8)). Since you will use a non supported version of FreeBSD (assuming you run 11.0-RELEASE or 11.1-RELEASE), you will have to take an old enough version of the ports tree (or add `ALLOW_UNSUPPORTED_SYSTEM=yes` to your make.conf file and cross your fingers). If you want to use the ports tree already present in your system, please read : https://github.com/freebsd/poudriere/wiki/use_system_ports_tree

Once you have a ports tree, you just need the following command :
`poudriere bulk -p ${YOURPORTSTREENAME} -j ${YOURJAILNAME} misc/mc`

That's it.


----------



## hukadan (Apr 28, 2019)

acheron said:


> Have you built the native-xtools (-x option to poudriere)?


Thank you. I was not aware of this option. The improvement is quite noticeable. I have yet to read what it does exactly and I am not even sure I can understand. For the moment, I just consider it black magic.


----------



## balanga (Apr 28, 2019)

hukadan said:


> Once you have a ports tree, you just need the following command :
> `poudriere bulk -p ${YOURPORTSTREENAME} -j ${YOURJAILNAME} misc/mc`
> 
> That's it.



I think I need to do this in small byte size chunks because of the number of options which make learning the process difficult and error prone... I've set up the jail, which is easy enough, but am unsure about ports.

If I just want, as an exmple to use the existing ports tree under /usr/ports and build under the host OS 12.0-RELEASE for amd64 and build editors/nano what do I run?

`poudriere bulk -p default -j FreeBSD-12_0-RELEASEx64 editors/nano`

Later I will want to use ftp://ftp.fi.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE/ports.txz for my ports tree and build the same for FreeBSD 11.1-RELEASE  on armv5


----------



## hukadan (Apr 29, 2019)

balanga said:


> as an exmple to use the existing ports tree under /usr/ports


As shown in the link I provided `poudriere ports -c -m null -M /usr/ports -p default`.


balanga said:


> and build under the host OS 12.0-RELEASE for amd64 and build editors/nano what do I run?
> `poudriere bulk -p default -j FreeBSD-12_0-RELEASEx64 editors/nano`


Yes.


balanga said:


> Later I will want to use ftp://ftp.fi.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE/ports.txz for my ports tree and build the same for FreeBSD 11.1-RELEASE on armv5


Then, you create a new ports tree with the PATH pointing to where you extracted ports.txz and use the corresponding jail to build your packages.


----------



## acheron (Apr 29, 2019)

hukadan said:


> Thank you. I was not aware of this option. The improvement is quite noticeable. I have yet to read what it does exactly and I am not even sure I can understand. For the moment, I just consider it black magic.


It builds static amd64 binaries for some tools, so you don't have to emulate them.


----------



## balanga (Apr 29, 2019)

hukadan said:


> As shown in the link I provided `poudriere ports -c -m null -M /usr/ports -p default`.
> 
> Yes.



I'm obviously missing something fundamental since I just ran the above and got:-

```
No package built, but repository needs to be created
Creating pkg repository
Error: Unable to extract pkg.
```

I think I'd best delete the whole thing and start again...


----------



## hukadan (Apr 29, 2019)

The only occurence of this message in the poudriere source code is associated to the `bulk` command. So I have serious doubts about the fact that you ran the command you said you ran.


----------



## balanga (Apr 29, 2019)

hukadan said:


> So I have serious doubts about the fact that you ran the command you said you ran.



My bad. You were right to have serious doubts about the command I ran. After a few more attempts to run what you suggested I did manage to create the pkg.... but not yet sure how to install it.


----------



## hukadan (Apr 30, 2019)

balanga said:


> but not yet sure how to install it


Please, read the point 10 of the following post:








						Pkg package repository using ports-mgmt/poudriere. With or without ZFS.
					

This is a HOWTO on how to build your own ports-mgmt/pkg packages in a jail using ports-mgmt/poudriere.  Few notes about notation:  First few mentions of a ported program will be a "port link", like net/mtr. I will not repeat the link too many times however. I will use a link to a manual page...




					forums.freebsd.org
				



By the way you will learn a lot reading carefully the two first posts. Actually, to be honest, I think you should have started by reading it before posting on the forum about how to build packages using poudriere.


----------



## balanga (Apr 30, 2019)

hukadan said:


> Actually, to be honest, I think you should have started by reading it before posting on the forum about how to build packages using poudriere.



I was never really interested in trying to use poudriere initially, it seemed far too complicated with a large number of options specifically designd to trip me up . My focus was on building pkgs for armv5. I had read around poudriere but didn't really understand how it worked, that's why I asked here. The HowTo you linked to has 71 posts which is no mean amount especially fo someone trying to get an overview as to how it works.

I am now able to build amd64 pkgs using FreeBSD 12.0, but still not sure about armv5 pkgs under FreeBSD 11.1.

I tried 
`poudriere jail -c -j 11_1-RELEASE-arm -v 11.1-RELEASE -a arm`

but am told

```
[00:00:00] Cross-building ports for arm on amd64 requires QEMU
[00:00:00] Error: You need to install the qemu-user-static package or setup an emulator with binmiscctl(8) for arm
```

According to https://lists.freebsd.org/pipermail/freebsd-arm/2019-April/019797.html



> qmeu-statoc supports armv[67] only, but not older armv5 which lacks atomic
> ops instructions and has to emulate them with RAS sequences. qemu doesn't
> work with them.



Looking at binmiscctl()  it's not clear to me how to install it into a poudriere environment, and from the comment above I'm not at all sure if it will work.


----------



## hukadan (Apr 30, 2019)

balanga said:


> I tried
> `poudriere jail -c -j 11_1-RELEASE-arm -v 11.1-RELEASE -a arm`
> but am told



This bring us back to the following post that was given to you by T-Daemon few days ago: https://forums.freebsd.org/threads/building-arm-packages-with-poudriere-the-simple-way.52994/



balanga said:


> According to https://lists.freebsd.org/pipermail/freebsd-arm/2019-April/019797.html


I am a bit surprised because I used poudriere(8) in that context few days ago (see here). I am at work at the moment so I cannot further check. Interesting anyway.


----------



## acheron (Apr 30, 2019)

balanga said:


> ```
> [00:00:00] Cross-building ports for arm on amd64 requires QEMU
> [00:00:00] Error: You need to install the qemu-user-static package or setup an emulator with binmiscctl(8) for arm
> ```


You probably forgot to start the 'qemu-user service' `service qemu_user_static onestart`


----------



## balanga (Apr 30, 2019)

acheron said:


> You probably forgot to start the 'qemu-user service' `service qemu_user_static onestart`



Actually I forgot to install it on the system I'm currently using... I decided to start again from scratch on another system....

Now after running:-
`poudriere jail -c -j 11_1-RELEASE-arm -v 11.1-RELEASE -a arm`

I get `Fetching MANIFEST for FreeBSD 11.1-RELEASE arm`
...except it doesn't work since there is no such file. I've tried -a arm and -a arm.arm but neither work. 
Am I supposed to specify -a armv6?


----------



## balanga (Apr 30, 2019)

hukadan said:


> This bring us back to the following post that was given to you by T-Daemon few days ago: https://forums.freebsd.org/threads/building-arm-packages-with-poudriere-the-simple-way.52994/



I'm trying to follow this but it is taking a long time. Will check back when it has finished.


----------



## acheron (May 1, 2019)

balanga said:


> Now after running:-
> `poudriere jail -c -j 11_1-RELEASE-arm -v 11.1-RELEASE -a arm`
> 
> I get `Fetching MANIFEST for FreeBSD 11.1-RELEASE arm`
> ...


It has to be built from source: -m svn+https


----------



## balanga (May 1, 2019)

acheron said:


> It has to be built from source: -m svn+https


How do I do that? 

I have built FreeBSD 11.1 for ARM from ftp://ftp.fi.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE/src.txz in a FreeBSD 11.1 jail, but don't know how to get poudriere to build it.


----------



## hukadan (May 1, 2019)

acheron said:


> It has to be built from source: -m svn+https


I think he cannot. His host system is running 12.0-RELEASE so he will have a problem when compiling due to lint removal.



balanga said:


> How do I do that?


As already explained in another thread, you have to download the source, modify it so it compiles without lint (two lines to modify) and then use this modified source to build your jail. See this post : https://forums.freebsd.org/threads/building-arm-pkgs-on-amd64.70499/#post-424906


----------



## acheron (May 1, 2019)

hukadan said:


> I think he cannot. His host system is running 12.0-RELEASE so he will have a problem when compiling due to lint removal.
> 
> 
> As already explained in another thread, you have to download the source, modify it so it compiles without lint (two lines to modify) and then use this modified source to build your jail. See this post : https://forums.freebsd.org/threads/building-arm-pkgs-on-amd64.70499/#post-424906


You can apply a patch on top of the src tree, I don't have poudriere installed here, so can't check the manpages, but it's possible (been there)


----------



## hukadan (May 1, 2019)

acheron said:


> You can apply a patch on top of the src tree


Yep, you are right :


> -P patch     Apply the specified patch to the source tree before building
> the jail.


But in that case the patch does not exist yet (at least I haven't seen one).


----------



## acheron (May 1, 2019)

hukadan said:


> Yep, you are right :
> 
> But in that case the patch does not exist yet (at least I haven't seen one).


You have it in your github https://gist.github.com/Hukadan/b295a04267c216e499409b56fe7f2bfd


----------



## hukadan (May 1, 2019)

This is for 11.0-RELEASE, he is trying to build 11.1-RELEASE. The patch is dead simple so may be it applies to both, but I have not tested.


----------



## balanga (May 4, 2019)

I'm trying to document the steps I need to get poudriere to build 11.1-RELEASE.

AIUI I need to run something along the lines of:

```
poudriere jail -c -j 11_1-RELEASE-ARM -v 11.1-RELEASE
```

I've include 

`FREEBSD_HOST=ftp://ftp.fi.freebsd.org`
in /usr/local/etc/poudriere.conf to pull in the lates available source for 11.1.

Presumably I can use the  patch mentioned above to build FreeBSD in a jail without lint but not sure how to proceed.

Do I run make buildworld/make buildkernel within the above jail?


----------



## balanga (May 5, 2019)

When I run `poudriere jail -c -j 111arm -a arm.arm -m svn+http -v releng/11.1`
pourdriere seems to grab the src and attempt to build FreeBSD and fails because of the missing lint. How can I include the required patch before it starts building? is there something like a pre-processing step I can use to apply the patch?


----------



## malavon (May 6, 2019)

balanga said:


> When I run `poudriere jail -c -j 111arm -a arm.arm -m svn+http -v releng/11.1`
> pourdriere seems to grab the src and attempt to build FreeBSD and fails because of the missing lint. How can I include the required patch before it starts building? is there something like a pre-processing step I can use to apply the patch?


From your other post I'm guessing you managed to set it up, but to the lazy reader I'd like to suggest that there's more useful information in this thread to be found:



acheron said:


> Have you built the native-xtools (-x option to poudriere)?





hukadan said:


> -P patch     Apply the specified patch to the source tree before building
> the jail.


or alternatively


> -S srcpath   Use the specified srcpath as the FreeBSD source tree mounted
> inside the jail or from the host for -m null.



And I'd like to add the most important part of this post, in the spirit of teaching a man to fish instead of giving him welfare fish: poudriere(8)
The full command line, only visible to those who replied or thanked me: 


__
				Revealed content
				
		


`poudriere jail -c -x -j 111arm -a arm.arm -m svn+http -P <patchfile> -v releng/11.1`


----------

