OPNsense Forum

English Forums => Development and Code Review => Topic started by: dcol on March 08, 2018, 07:43:44 pm

Title: Patching a commit into OPNsense
Post by: dcol on March 08, 2018, 07:43:44 pm
When I see a commit on github that I want to install, other than a manual edit of the file(s), is there a way to easily 'patch' the commit into OPNsense from the shell? Or do we have to ask for a patch first?
Title: Re: Patching a commit into OPNsense
Post by: mimugmail on March 08, 2018, 08:39:55 pm
man opnsense-patch :)
Title: Re: Patching a commit into OPNsense
Post by: dcol on March 08, 2018, 11:01:08 pm
So how do you use, lets say, commit e12345b with that command?
Title: Re: Patching a commit into OPNsense
Post by: mimugmail on March 09, 2018, 05:47:31 am
Just
 
opnsense-patch xxxxxxx

You can revert the patch when type it again. It's only important that this patch is in core repo.
If not, e.g. plugins, you have to add -c plugins. And if it's your own repo, you have to add -a username.

So when I fork plugins and add a patch and want to test it, I can do:

opnsense-patch xxxxxxx -c plugins -a mimugmail

Title: Re: Patching a commit into OPNsense
Post by: franco on March 09, 2018, 12:13:51 pm
So, opnsense-patch uses patch(1) and GitHub to fetch them, so if a commit is there you can patch it as long as the code is mostly in sync. A bit of magic allows to select different accounts, projects, types, etc as describe in the manual page.

Command line options are evaluated before commit hashes:

# opnsense-patch -m my_option -n another_option COMMITHASH1 COMMITHASH2 ...

If patching does fail, even if partially this is a safe thing to do:

# opnsense-revert opnsense

It will rewrite the core package (unless you patch plugins, give it the plugin name os-... )


Cheers,
Franco
Title: Re: Patching a commit into OPNsense
Post by: dcol on March 09, 2018, 03:58:40 pm
So I want to install a plugin patch for monit

# opnsense-patch -c plugins e94878b
worked ok
Title: Re: Patching a commit into OPNsense
Post by: franco on March 09, 2018, 05:07:26 pm
Yeah, Michael posted the wrong order. That's why I answered and said "Command line options are evaluated before commit hashes".


Cheers,
Franco
Title: Re: Patching a commit into OPNsense
Post by: siegfried on May 14, 2018, 10:59:32 am
patch installed, works fine again.
Thanks!