OPNsense Forum

English Forums => Development and Code Review => Topic started by: Maurice on August 02, 2023, 11:52:17 pm

Title: Building a specific OPNsense version (Git tag)
Post by: Maurice on August 02, 2023, 11:52:17 pm
Hello everyone,

I've recently built lots of OPNsense images. Took me a while to understand targets, devices, extras etc., but I think I've got it now. With one exception: versions. I'm struggling to reproducibly build a specific OPNsense version (like Git tag 23.7).

According to the opnsense/tools readme:

   VERSION: a version tag

So building a 23.7 DVD should work like this:

Code: [Select]
# cd /usr
# git clone https://github.com/opnsense/tools
# cd tools
# make update dvd VERSION=23.7

The resulting image is named OPNsense-23.7-dvd-amd64.iso, but identifies as OPNsense 23.7_15. And make info says:

Code: [Select]
tools /usr/tools 23.7_1 5616784d9 master
src /usr/src 23.7_6 6cf2e77cb stable/23.7
ports /usr/ports 23.7_81 e9b5a0ed7 master
plugins /usr/plugins 23.7 f183c06d8 stable/23.7
core /usr/core 23.7_15 0ff09cab7 stable/23.7

It seems the heads of the master and stable/23.7 branches are used, not the tag 23.7. Probably a pebkac, maybe someone can shed some light on this.

Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on August 03, 2023, 09:15:58 am
Hi Maurice,

Well in general the build works only with the checked out (and appropriately tagged) repositories in place. VERSION is an override that offers multiple interpretations depending on which build step is being invoked.

That being said you want to check out each repository to show the appropriate tag or the nearest one below it...

# make update
[...]
# make info
tools /usr/tools 23.7_1 5616784d9 master
src /usr/src 23.7_6 6cf2e77cb stable/23.7
ports /usr/ports 23.7_81 e9b5a0ed7 master
plugins /usr/plugins 23.7 f183c06d8 stable/23.7
core /usr/core 23.7_15 0ff09cab7 stable/23.7

And here comes the important bit which is sadly undocumented because I don't personally use it although I thought it would be helpful...

# make rewind VERSION=23.7
[...]
# make info
tools /usr/tools 23.7 fc7960e36 master
src /usr/src 23.7 f223233ee stable/23.7
ports /usr/ports 23.7 dc1e7fe65 master
plugins /usr/plugins 23.7 f183c06d8 stable/23.7
core /usr/core 23.7 b35678139 stable/23.7

While rewind does tag approximation I'm not sure if it's perfect just yet. :)

After that you stay away from update and VERSION use until the correct version has been built.


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on August 04, 2023, 08:03:37 pm
Thanks a lot Franco, rewind was the missing step! I would have never figured this out.

VERSION is an override that offers multiple interpretations depending on which build step is being invoked.

So rewind seems to be the only build step where VERSION is actually interpreted as a Git tag?

And here comes the important bit which is sadly undocumented because I don't personally use it

Which makes me curious what your process is. Tag the latest commits in the Git branches, then immediately build the images before any other commits are being made?

After that you stay away from update and VERSION use until the correct version has been built.

I get staying away from update because it doesn't care about Git tags and would pull the branch heads again. But what's wrong with running make dvd VERSION=23.7 after rewinding? This seems to work fine for me:

Code: [Select]
make update rewind dvd VERSION=23.7
Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on August 08, 2023, 02:30:59 pm
So rewind seems to be the only build step where VERSION is actually interpreted as a Git tag?

More or less, yes. VERSION is just a tool for when you don't want to steer the VERSION from an automatically generated date-based version (images) or Git tag (sets).

Which makes me curious what your process is. Tag the latest commits in the Git branches, then immediately build the images before any other commits are being made?

Yes, I do have the benefit that I'm the one tagging so my Git repos are mostly the top commits anyway. ;)

I get staying away from update because it doesn't care about Git tags and would pull the branch heads again. But what's wrong with running make dvd VERSION=23.7 after rewinding? This seems to work fine for me:

Code: [Select]
make update rewind dvd VERSION=23.7

Nothing wrong with that except when you are on a tag mismatch you overwrite the set names with VERSION leading to a state misrepresenting the actual tags that would have been used.

Looking at your command: maybe we should fold "rewind" into "update" when VERSION is explicitly set?


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on August 08, 2023, 02:37:08 pm
PS: The composite targets "distribution" and "factory" do offer some insight in how VERSION is intended to be used with images to set the correct file name.
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on August 08, 2023, 03:00:08 pm
Yes, I do have the benefit that I'm the one tagging so my Git repos are mostly the top commits anyway. ;)

Understandable, though not using your own tools can have its downsides.

Looking at your command: maybe we should fold "rewind" into "update" when VERSION is explicitly set?

Yes, that would be nice and exactly how I originally assumed update would behave. My bad. Never assume anything. Someday I'll learn. Maybe.

The composite targets "distribution" and "factory" do offer some insight in how VERSION is intended to be used with images to set the correct file name.

Nothing says "well documented" like "just look at the code". ;D
Just kidding. I did take a look at factory before, but not distribution. Thanks for the pointer!

Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on August 08, 2023, 03:09:55 pm
I made a reminder ticket https://github.com/opnsense/tools/issues/373

In the case of rewind it's difficult to use it, because it breaks when building the OPNsense release with development packages added as it requires EXTRABRANCHES which screws with checking out a specific tag... ;)


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on August 09, 2023, 03:13:37 pm
Thanks a lot Franco, amazingly quick!

Which brings me to the next question: src doesn't have tags for all OPNsense releases, e.g. there are no 23.1.9, 23.1.10 or 23.7.1 tags. Do these builds use the previous Git tag or do they include some untagged commits, too?

Code: [Select]
root@freebsd:/usr/tools # make update VERSION=23.7.1
[...]
root@freebsd:/usr/tools # make info
tools /usr/tools 23.7.1 d83d6ab91 master
src /usr/src 23.7 f223233ee stable/23.7
ports /usr/ports 23.7.1 e220eb52d master
plugins /usr/plugins 23.7.1 cc4ed826f stable/23.7
core /usr/core 23.7.1 2c6483500 stable/23.7

So it would use src tag 23.7 for a 23.7.1 build. Is that how it's supposed to be?

Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on August 09, 2023, 05:56:55 pm
Well, src.git 23.7.1 wasn't pushed properly it seems so I fixed that. Thanks for noticing!

In general that's what I meant by "tag approximation" in terms of why "rewind" existed and why it's a bit more complicated. It selects the nearest historic tag. In this case 23.7 which was correct at least from the technical perspective at the time the tag 23.7.1 wasn't there.


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on August 09, 2023, 06:59:35 pm
Thanks for fixing!
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on September 27, 2023, 05:34:16 am
Franco, could you please push the 23.7.5 tags to GitHub?

Thanks!
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on September 27, 2023, 07:45:11 am
Sure, forgot it yesterday :)


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on October 11, 2023, 09:13:19 pm
23.7.6 tags, pleeease. ;-) I'd like to build the aarch64 packages over night.

Generaly speaking, is there an established timeline for binary releases vs. git tags?

Thanks
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on October 11, 2023, 09:32:41 pm
Pushed. I normally push them after publishing the release notes but haven't been on a roll in this regard lately. Sorry!


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on October 11, 2023, 10:16:18 pm
No worries! Build underway.

Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on October 26, 2023, 03:36:47 pm
@fichtner, thanks for the timely 23.7.7 tags!
I just looked into building 23.7.7_1, but the stable/23.7 branch hasn't been updated yet. You might have forgotten to cherry pick from master?
I know, I know... the complaining never stops. ;D

Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on October 26, 2023, 03:59:54 pm
_1 are not tags... they are commits from master, but only from core perspective. This one has been a little messy for wider reasons.

Update core.git:stable/23.7 to HEAD (that's 23.7.7_1)

When you have the final packages done you need to update the ports.git:master to HEAD and do:

# make hotfix-opnsense-update,mpd5

It will bring in revision updates for both these packages. There's also a hotfix for os-wireguard. Pulling this in is similar to core/ports updating plugins.git:stable/23.7 to HEAD and doing

# make plugins-os-wireguard


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on October 26, 2023, 04:40:53 pm
I'm not sure I understand. Building os-wireguard 2.4_1 was not an issue, I already did that yesterday by updating plugins.git:stable/23.7 to HEAD.

But the same doesn't work for opnsense 23.7.7_1 because the last commit to core.git:stable/23.7 was two days ago, so updating to HEAD won't do anything:

https://github.com/opnsense/core/commits/stable/23.7

Cheers
Maurice
Title: Re: Building a specific OPNsense version (Git tag)
Post by: franco on October 26, 2023, 05:07:31 pm
Yeah, the usual. Sorry it has been (too) busy.


Cheers,
Franco
Title: Re: Building a specific OPNsense version (Git tag)
Post by: Maurice on October 26, 2023, 10:03:36 pm
As always, no worries! And thanks for the hint how to hotfix opnsense-update and mpd5. All good now.

Cheers
Maurice