Patch for package with "only files directory"

How to create a patch for files in the "files directory" that some packages use?
e.g. adblock

Clone the feed repo to your local disk. Change feeds .conf to point to file://. Go edit the file. Commit your changes, then scripts/feeds update -a.

Then you keep the repo up to date by doing a git fetch and a git merge. Just make sure you have the right branch of the feed repo specified in the feeds.conf and that you make your changes on the right branch.

If it's not a feed and part of the base system, just go edit the file in the relevant packages directory.

If you're just trying to have your own version of a file (without caring about updating and such), you can just add it to your openwrt directory using the files folder. Whatever is there will overwrite what has been installed when building/installing packages.

For example, if you create a file in


This file will overwrite the default file from the adblock package in your firmware.

If you do that, just keep an eye on the format of the original file you're overwriting when moving to newer branches in case of important changes in format.

Custom Files - from Build System

Thanks for your replies.

I think it is still not possible to overwrite build in feeds with user-specified feeds.

The problem is, the package only contains a Make file that pulls the "files" directory from the repo while the build process is running. But when doing the "patch prepare procedure" the directory stays empty, so it is not possible to create a patch.
The "files" directory is never copied over to the build directory. This is the case with all packages.
For example, it is also not possible to patch the dnsmasq init script because it resides in the "files" directory of the package.

Currently, I keep a local copy of the file on my system (patched). On every firmware upgrade I have to check the file again and patch if needed then copy it over to the router.
By using this method the last step gets redundant but I'm looking for a complete solution.

Of course it's possible. I do this all the time. You just need to make sure that your feeds.conf points to the git repo on your local disk. You can even extend this with your own custom feeds.

Can you please post the Makefile for the package you're trying to modify

Maybe this was changed?

I am not sure if you think that in a too complicated way:

Adblock pulls no sources during the build. All sources are the whole time in your local feed repo. Including the files in files/

You just need to edit those files in your local repo before the build (in feeds/packages).
There should be no need to create a special patch for the app.

Or do I understand your intention wrongly?

1 Like

Ok, so it is adblock. I thought this was just an example.

So, do something like this

$ mkdir -p /opt/openwrt/feeds
$ cd /opt/openwrt/feeds
$ git clone
$ cd packages
$ git checkout openwrt-19.07 [if you're using 19.07]
$ cd net/adblock/files

make your edits

$ cd /opt/openwrt/feeds/packages
$ git add net/adblock
$ git commit -m "adblock: <description of changes>"

now go to your main openwrt build root. Edit the file feeds.conf. Remove the line for the packages feed and add the following one

src-git packages file:///opt/openwrt/feeds/packages;openwrt-19.07

Now remove the existing package feed and pull the packages from your local repo

$ rm -fr feeds/packages*
$ scripts/feeds update -a
$ scripts/feeds install -a

It will pull from your local repo and it will get the changes you made. Every time you make another change in the repo, commit the edit as above and redo the scripts/feeds commands

Thank you!
I will try this later and report back!

Then as you move forward, you just need to remember rebasing (possibly avoid merging for history clarity) your changes when you want to build from a different branch in packages.

Is there are a way to track the changing in the scripts/feeds folder with git?
Without creating a custom feed?
For dnsmasq it works (it is included in the main repo?), the changes are picked up.
Is there are way to make this work with all packages?

That scripts/feeds is just a script to update the feeds, which are already git by default.
Each feed is a separate git repo.

Just cd to feeds/packages and check.
Or to feeds/luci

feeds/packages contains a clone of the original packages git repo from GitHub

perus@ub2004:/Openwrt/r7800$ cd feeds/packages
perus@ub2004:/Openwrt/r7800/feeds/packages$ git log --oneline | head
6002d160a p11-kit: remove pointless --as-needed parameter
1e65c4b7e libevdev: fix compilation with old kernels
6594961f6 Merge pull request #11959 from neheb/ipfs
2fadd0279 acme: Add acl_depends annotations to luci-app-acme
3c34b151f mwan3: fix whitespace issue
85d14aa21 Merge pull request #11975 from br101/websocketpp-0.8.2
04b27feb4 websocketpp: Update to version 0.8.2
1f8c2af5d Merge pull request #11970 from jefferyto/python-target-build-tools
9f81ab895 python3: Fix host build tool names recorded in target files
3c9dbc142 zstd: remove lto and as-needed flags

Same in original GitHub repo:

1 Like

you can setup feeds.conf to point to a specific part of your feed independently of the default branch (or the currrently checked out branch in your local repo). For example, you could have it point to a specific commit you have made in your local (or github) repo.

You can use the following syntax (using the public repo here, same applies to file:// notation):

src-git packages;openwrt-18.06
src-git packages^f85dd8b96576ddedbddad581e7b1845a2f5eace7

The first one will follow the openwrt-18.06 branch aka get the latest each time your update.
The second one will stay at a specific commit (f85dd8b965...) and never move (for example, the commit with your changes).

See here for more info:

Thanks for all your answers.
But I think, I'm going for hnyman solution.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.