How to prevent build system from overwriting changes?

I am trying to figure out the best way to do small changes to OpenWrt source code prior to building. As far as I understand, the build steps for any package are: download, prepare, compile, install. Download grabe the source, prepare untars it into a build directory, compile builds it, and install moves it/packages it. However I am finding that the compile phase also triggers another prepare.

What I have taken to doing is making the changed source files immutable and then ignoring errors during compile (because the compile will fail as it tries to do another prepare):

  • make package/kernel/mt76/download
  • make package/kernel/mt76/prepare
  • make my changes
  • sudo chattr +i <builddir>/mt76/eeprom.c
  • make -i package/kernel/mt76/compile <--- -i or else it will fail out when it tries to prepare again
  • make world

Is there a way to do a compile that doesn't automatically redo a prepare?


Work with patches, and with your own downstream branch which you periodically rebase on top of upstream OpenWrt.


So the answer is no, there is no way to have the build system not perform a fresh prepare when it compiles.

Yes, I have seen the instructions for patches/quilt. I just hoped there was an easier way for quick and dirty and/or iterative changes. The whole edit, diff, copy patch, tell OpenWrt about it, then compile is not a naturally tenable way to develop.

Perhaps I'm missing something on how to do this easily. The main repository doesn't itself have the majority of the packages. Packages are in their own repositories. And those repositories don't actually have the package code. That is somewhere else yet. Sometimes in other upstream git, or other repositories, sometimes tarballs sitting somewhere. Something unique for every package. So to do this, I would have to fork the main repository, and all the relevant feed repositories, then fork every package I want to work with, change its makefile to change the location of where it downloads its actual code from, then download or fork that, change that code, then sic the build system on all that...

I'm thinking of a tool to automate the patch/quilt process. Something where you clone OpenWrt and then just type: odtool clone package/<packagename> inside openwrt/. It then does a make package/<package>/download,prepare, and copies out the resultant openwrt build folder to somewhere local. You work inside that to make whatever changes you want, then odtool compile to create a diff against the openwrt prepared package, install the patch, and then compile the package.

I think a tool like this would lower the total-cost-of-ownership (as it were) for people to make small changes or customizations.

"tell OpenWrt about it" = ?
Why do you think that you need this step for testing patches?

Because that's what the instructions say? Every time I create a patch, I have to tell the openwrt build system about it with "quilt import" or create it blank with "quilt new". It doesn't pick up patches automatically.