OPNsense Forum
English Forums => Development and Code Review => Topic started by: mihak on March 01, 2021, 02:57:08 am
-
I tried to follow the Hello World example from the OPNSense developers guide - and I am stuck at the last step where I would like to get plugin.txz package generated from the files I stuck into /usr/plugins/devel/*. I did install OPNsense tools and have Makefile created - just like the guide says.
When I run make plugins in my plugin directory, it complains that it doesn't know how to.
When I run make plugins from /usr/tools directory, it grinds for a long time and generated tons of .txz packages in /usr/obj/usr/tools/config/21.1/OpenSSL:amd64/.pkg/Latest - but my plugin is not among them. As part of debugging, I switched to helloworld and tried to make a proven example. Trying to re-run the make plugins after I modified Makefile of helloworld, the response is: "Plugins are up to date" and nothing is generated.
What am I doing wrong? Is my source path /usr/plugins/devel/helloworld/src/ incorrect and not captured by build process? Are there additional parameters to pass to build plugins? Should I run it from a specific location?
-
I flushed the whole /usr/plugins structure and pulled it again from github. Now it works...
Here is my feeble result: https://github.com/mihakralj/opnsense-speedtest (https://github.com/mihakralj/opnsense-speedtest)
Install it with
sudo pkg install -y libidn2
sudo pkg add https://github.com/mihakralj/opnsense-speedtest/raw/main/work/pkg/os-speedtest-devel-0.11_2.txz
-
You can also go into your plugins directory like /usr/plugins/devel/speedtest and type "make upgrade".
This would install it locally (if you do this on a OPNsense instance) or type "make package" to build a pkg
-
Michael: yes, I figured the options through (I think) the verbose output from the make command...
We should update that part of Helloworld guide to help other klutzes like me. :)
-
Now I discovered that my plugin has a dependency on libidn2. I can put the dependency declaration into Makefile:
PLUGIN_DEPENDS= libidn2
...but this will create a package that will refuse to be installed unless dependency is met.
What is the process to let the pkg process install all dependencies required by a package? I don't want to play dirty and put "pkg install" statements into +POST_INSTALL file...
-
Just use make package in plugin dir. It will not add a second pkg and use the one of OPNsense
-
Check my shoddy work here: https://github.com/mihakralj/opnsense-speedtest/ 8)
I made a package. It installs. But it needs libidn2 to run - and pkg add command doesn't auto-fix dependencies...
sudo pkg install -y libidn2
sudo pkg add https://github.com/mihakralj/opnsense-speedtest/raw/main/work/pkg/os-speedtest-devel-0.11_2.txz
if package would be available through a repo, dependencies would be auto-resolved through pkg install... Now, pkg add just complains and stops.
-
You can also go into your plugins directory like /usr/plugins/devel/speedtest and type "make upgrade".
This would install it locally (if you do this on a OPNsense instance) or type "make package" to build a pkg
I was able to create my own package using make package, and it installs and works in OPNsense as well (as expected).
Is there any way to convert this package and add it to a custom repository?
Something like what is available at https://github.com/mimugmail/opn-repo (https://github.com/mimugmail/opn-repo) or at https://www.routerperformance.net/opnsense-repo/
I would like to include my created package above (os-blocky-xxx.pkg) into a custom repo that can then be installed through OPNsense Firmware Plugin GUI.
What I am looking is guidance as to how to create a custom repository and adding an existing .pkg file to it?
Thanks for your help...
-
That's pretty straight forward. You need a freebsd or opnsense, create a folder in there, put the .pkg files you want in it.
Then you invoke pkg repo .
in that folder.
Then you need a web server to serve this path. For the exact path where to put stuff, check out my current github with the repo-conf and the actual repository with the ABI link (also on github). Just replicate that. Though make sure to put the weight of the repo between 1 to 11.
I upload the repo to github, and then clone it into a plesk server that serves the https. For me that was the easiest way cause I had that ready.
Repo: https://github.com/Monviech/os-caddy-plugin/tree/main/os-caddy-plugin/FreeBSD%3A13%3Aamd64
Webserver with Repo in it: https://os-caddy-plugin.pischem.com/os-caddy-plugin/FreeBSD%3A13%3Aamd64/
Repo Config: https://github.com/Monviech/os-caddy-plugin/blob/main/repo-config/os-caddy-plugin.conf
Repo config is imported to client to /usr/local/etc/pkg/repos/repo-name.conf
Edit:
- Make empty folder in opnsense
- put .pkg files in it
- pkg repo .
- get this folder served with http/https somewhere (maybe with caddy? :)
- import the repo conf to the opnsense
-
That's pretty straight forward. You need a freebsd or opnsense, create a folder in there, put the .pkg files you want in it.
Then you invoke pkg repo .
in that folder.
Then you need a web server to serve this path. For the exact path where to put stuff, check out my current github with the repo-conf and the actual repository with the ABI link (also on github). Just replicate that. Though make sure to put the weight of the repo between 1 to 11.
I upload the repo to github, and then clone it into a plesk server that serves the https. For me that was the easiest way cause I had that ready.
Repo: https://github.com/Monviech/os-caddy-plugin/tree/main/os-caddy-plugin/FreeBSD%3A13%3Aamd64
Webserver with Repo in it: https://os-caddy-plugin.pischem.com/os-caddy-plugin/FreeBSD%3A13%3Aamd64/
Repo Config: https://github.com/Monviech/os-caddy-plugin/blob/main/repo-config/os-caddy-plugin.conf
Repo config is imported to client to /usr/local/etc/pkg/repos/repo-name.conf
Edit:
- Make empty folder in opnsense
- put .pkg files in it
- pkg repo .
- get this folder served with http/https somewhere (maybe with caddy? :)
- import the repo conf to the opnsense
Awesome… got it all working for my Blocky DNS plugin.
Many many thanks….
-
You can also go into your plugins directory like /usr/plugins/devel/speedtest and type "make upgrade".
This would install it locally (if you do this on a OPNsense instance) or type "make package" to build a pkg
I was able to create my own package using make package, and it installs and works in OPNsense as well (as expected).
Is there any way to convert this package and add it to a custom repository?
Something like what is available at https://github.com/mimugmail/opn-repo (https://github.com/mimugmail/opn-repo) or at https://www.routerperformance.net/opnsense-repo/
I would like to include my created package above (os-blocky-xxx.pkg) into a custom repo that can then be installed through OPNsense Firmware Plugin GUI.
What I am looking is guidance as to how to create a custom repository and adding an existing .pkg file to it?
Thanks for your help...
Great, we can also add to the community repo if you like :)