Compile different package versions into firmware

Hi

I made a post very similar post to this one but the topic drifted off to diagnosing a bug with UPnP, and that thread can be found here Is It Possible to Compile miniupnpd v18.06.7 with OpenWrt v19.0.7.1 Firmware?.

To cut a long story short, the UPnP package from 18.06.7 works on the 19.07.1 firmware but the version of UPnP shipped with 19.07.1 simply doesn't work.

The UPnP versions are as follows

  • v18.06.7 = 2.1-1
  • v19.07.1 = 2.1.20190408-2

At the moment I am Git cloning the two versions of OpenWrt into separate directories on my Linux PC, copying the files from 18.06.7 for UPnP and overwriting the ones in v19.07.1. This method does work but I was wondering is there an official or more streamlined way I can build OpenWrt v19.07.1 as normal but bake a specific v18.06.7 package into the final firmware?

Many thanks

Will

I have been looking at the packages documentation on the Wiki and I've rediscovered the makefile. I already know that UPnP version 2.1-1 which derives from the v18.06.7 firmware works with my v19.07.1 firmware. I did this by downloading the v18.06.7 package from GitHub into a different working directory and then copying the contents to my v19.07.1 directory and compiling as normal.

In regards to the makefile I was thinking of tweaking this file to streamline using different package versions into the 'to be compiled firmware'. I do remember modifying a makefile before to use the latest version of the mwlwifi driver in which I was instructed to changed the PKG_SOURCE_VERSION to the commit version of the master.

However, I couldn't see this parameter in the makefile to the miniupnpd package.
From looking through that file I did see the download source for the file

PKG_SOURCE_URL:=https://miniupnp.tuxfamily.org/files

and so I had a look on the website to see what the latest version which appears to be miniupnpd-2.1.20200329.tar.gz With that in mind I changed the PKG_VERSION:= in the makefile to 2.1.20200329.

I've then tried to compile with verbose on and I get quite a few error messages relating miniupnpd hence why I've come back onto the forums to ask for further help.

Can anyone help here please?

P.S I will post the screenshot of the error messages I took on my laptop later on and update this post.

UPDATE
Screenshot showing errors:

It's somewhat surprising that the one on 19.07 does not work for you, as the versions are both v2.1 and according to the changelog of minupnpd, the changes I can see are minimal really, and should not break functionality.

I would suspect more an issue with firewall chains or hotplug scripts than anything in miniupnpd being broken.

However, if you insist on changing to the previous version, you can fairly easily change package versions by editing the makefile.

Before I give the more general explanation, the quickest and easiest way to do this (in which case you can ignore everything below this paragraph), is to delete the contents of feeds/packages/net/miniupnpd in your 19.07 tree and replace it with the one from your 18.06 tree then do a rebuild.

That said, if you want to learn about how to more generally accomplish what you're trying to do, then here is the process you'd typically follow, with specific reference to miniupnpd.

Replacing package versions won't always work for some packages where there is a functionality change or an ABI change or a dependency on a version of Openwrt, so your mileage may vary.

Miniupnpd interacts with different systems in Openwrt, both firewall and hotplug, so once you've done the change you need to verify that it works properly. No guarantees there...

First read the following to give you better understanding of the structure of the Openwrt makefiles.

https://openwrt.org/docs/guide-developer/packages
https://openwrt.org/docs/guide-developer/package-policies

Then, having read this, you will need to update PKG_VERSION in the Makefile to reflect the version you want. This will break the hash used to validate that the source is downloaded correctly, but you get around that by removing the value for PKG_HASH and instead putting in PKG_HASH:=skip.

You will use the build system to update this hash value when you're satisfied that it compiles properly.

Comparing the two makefiles, there's no difference in the files that get installed, so you should not need to worry about the rest of the Makefile as it's largely identical between versions.

You will need to manage the patches found in the patches directory as well. You can't just edit the makefile, change the version and not update the patches, as they're specific to the exact version of the software you are compiling.

More info here: https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem

You'll need to take the patches from patches directory in the 18.06 version and move it to the patches directory in the 19.07 build tree you've created, deleting any existing patches in the 19.07 build tree. If you don't do this, the patches will likely fail and it will error out.

There are also a bunch of config files in the files directory. I'm not sure if they have changed much between the two versions, but you'll need to look at these and assess the differences and see if any are specific to either the two versions or to the version of Openwrt (notably firewall and hotplug)

I surmise you will want to keep the contents of the files directory in the 19.07 build tree intact and not replace them with the version from the 18.06 build tree, but from your original post it seems the files from the 18.06 tree actually work on the 19.07 tree, so replace them with the older versions if you prefer.

Once your package compiles correctly, you'll update the hash value by make package/miniupnpd/check V=s FIXUP=1. You will also probably need to force reinstall it on your live system, unless you bump the PKG_RELEASE number by one.

So, that is more or less the generalized recipe for manually changing versions of software in a package Makefile.

Thank you for the very informative reply. It's very helpful. I'm sorry If I didn't make myself clear but I'm looking to compile the actual OpenWrt firmware with this updated package.

Where do I apply the make package/miniupnpd/check V=s FIXUP=1 command before I run make? I would like to update that hash value for the package and then compile OpenWrt with it in. Hope that makes sense?

Update

I have just ran these commands

make package/miniupnpd/download
make package/miniupnpd/check V=s FIXUP=1

and then gone back into the makefile and the PKG_HASH value has been filled in now. I'm now going to compile the firmware as normal and post back.