OPNsense Forum

English Forums => Development and Code Review => Topic started by: acik on December 16, 2016, 02:24:59 pm

Title: Building tools architecture
Post by: acik on December 16, 2016, 02:24:59 pm
Hi
I achieved to build a cdrom image today. But I'm a little bit confused about building steps.
These are my steps.

1. I cloned the following repos and checkout to proper branches or tags. (stable/16.7, 16.7.11)

2. Run make base and builded base binaries successfully.

3. Run make kernel and got ctfconvert errors for all objects. I made a little research and added nomakeoptions WITH_CTF to kernel's config file SMP. And it is builded successfully.

4. Run make ports, got ERROR 1 somewhere and run it again. After hours, it is builded successfully.

5. Run make core with no problem.

5. Finally run make cdrom and got the cdrom image seamlessly. I installed and played it and didn't see any problem.

Now, my questions,
1. I wanted to add a custom port to my cdrom image. (mysql56-server)
I added a "databases/mysql56-server" entry to the ports.conf file and run make ports and make cdrom again. I see it is builded and packaged in /tmp/sets/package* file but doesn't seem in the image. I see the variable "CORE_DEPENDS" that has a package list in the core repo's Makefile and added mysql56-server to there. Committed with git and run make core and make cdrom again but the result is the same. I didn't appear.
Are my inferences and order of steps right? What should I do to add a port?

2. I didn't see any log file after builds. For instance, when It is broken while building ports, I wanted to see the error clearly. At which port? Which reason etc.  Should I define it in the configuration files or use script tool or something?

Thanks in advance.
Regards.
Title: Re: Building tools architecture
Post by: franco on December 16, 2016, 04:13:02 pm
Hi there,

Looks good so far, nice!

cftconvert errors are not fatal, it builds either way.

The ports ERROR 1 is likely from Python. We currently build two parallel versions and the ports framework has some issues with a single batch run. The big plan is to move to FreeBSD's poudriere tool eventually, but for now we would rather have the basics fully covered than jumping into unknowns like this. :)

The *make plugins* step was missing, but not overly important for the cdrom build unless you want to add plugins to the initial cdrom image. That's possible nowadays, too.

In general, the build tries to keep track of progress in the way that "make" itself works, so every completed stage is skipped. In your case you modified ports.conf, so *make ports* needs to be rerun.

# make ports-force

"force" or CSV like "vim-lite,libressl" etc. forces a rebuild, actually attempting to delete the packages given. If you want to rebuild or add one that is the way to go. This also works for plugins.

The ports stage also automatically clears the progress for plugins and core, so that you can add a proper dependency in /usr/core/Makefile and then it's automatically rebuilt. The arguments for core are way different, however: if given, it checks out a clean git copy of the branch or tag. For our releases we use "core-master,stable/16.7,16.7.11" which produces all three packages opnsense, opnsense-stable and opnsense-devel on their respective commits.

CORE_DEPENDS is simply a list of package names, so appending "mysql56-server" will do the trick nicely.

Finally, logs are what you see, it's KISS (keep it simple and stupid). If you need "logs logs" you can use a scrollable buffer console (screen, tmux) or use the tee(1) command. The build tools are meant for a jenkins/buildbot integration where all output is captured and neatly stored. No need to make it more complicated.

It's also important to know that the make errors at the end do not help for two reasons:

The context is not make itself, it runs thousands of scripts and programs so a bit of buffer history is required to troubleshoot. The stage is often not clear. Running "cdrom" will run all required steps, but when it stops suddently it's impossible to tell where with at least a little bit of context. :)

There is also the VERBOSE flag, it dumps all commands being run by our scripts in order to see exactly what is going on:

make cdrom VERBOSE=1


Cheers,
Franco
Title: Re: Building tools architecture
Post by: acik on December 16, 2016, 06:01:26 pm
Quote
Quote
In your case you modified ports.conf, so *make ports* needs to be rerun.
I already dit it and said here

I wasn't clear, sorry: it needs to be rerun, but that means forcing a rerun, because "make ports" is a cached operation and will try to skip if it can. :)

Quote
What I understand is I edit and commit core/Makefile, but when I run make core, it checkouts to https://github.com/opnsense/core/blob/stable/16.7/Makefile state. Am I wrong?

The "make core" without arguments will copy the checked out version including manual adjustments. Nothing is reset or changed. That's why there is a difference for the argument version we use for the official repositories. You are good with "make core" here.

Not everything needs to be rerun, just do:

# make ports-mysql56-server cdrom-again

It should produce a new image with all your modifications.


Cheers,
Franco
Title: Re: Building tools architecture
Post by: acik on December 17, 2016, 07:35:05 am
I achieved! Thanks for your assist  :)

I went back to my snapshot where I built kernel last night, made my modifications and run make ports make core make cdrom again. It is done.

And I could use this options to clear cache. Right?
Quote
A couple of build machine cleanup helpers are available via the clean script:

# make clean-<option>[,...]

Available clean options are:

    base: remove base set
    distfiles: remove distfiles set
    cdrom: remove cdrom image
    core: remove core from packages set
    images: remove all images
    kernel: remove kernel set
    nano: remove nano image
    obj: remove all object directories
    packages: remove packages set
    plugins: remove plugins from packages set
    ports: alias for "packages" option
    release: remove release set
    serial: remove serial image
    sets: remove all sets
    src: reset kernel/base build directory
    stage: reset main staging area
    vga: remove vga image
    vm: remove vm image
    xtools: remove xtools set


Regards.
Title: Re: Building tools architecture
Post by: franco on December 18, 2016, 10:24:56 am
Hi acik,

Yes, *make clean* works, but it fully cleans the cache.

# make clean-ports
# make ports

Takes a few hours because you cleared all packages.

# make ports-mysql56-server

Takes a few minutes because you told it to only redo one package.


Cheers,
Franco
Title: Re: Building tools architecture
Post by: acik on December 18, 2016, 04:48:31 pm
Thanks again franco. Now I need to learn advanced shell scripting and Makefile structure. :)

Regards.
Title: Re: Building tools architecture
Post by: franco on December 19, 2016, 12:50:26 am
Of course, let us know if you need further help :)