So, you’ve got some LuCi modules packaged up, and you can build them via the OpenWRT build root, and you can install them with opkg, and you can edit the final files in /usr/lib/lua/luci/{controller,views,etc}
and the changes take effect immediately, but you don’t like working on the target router. You don’t get to use the editors you want, it’s hard to integrate into your version control to see what you’ve been doing. You’ve seen this page about a “local development environment”, but it didn’t help as much as you had hoped?
Here’s a few things that worked for me, based on lots of advice and snippets from jow_laptop and some experimentation.
First, I’m assuming you’ve got luci trunk checked out, and I’m going to refer to that directory as [LUCI_DIR]
. I’m assuming that your working luci package, which has the OpenWRT opkg Makefile, and a luasrc and htdocs directory are in [YOUR_PKG]
.
Now, the opkg Makefile that does a great job of building your package normally isn’t going to cut it for running inside luci. Make a new directory in [LUCI_DIR]/applications/your_name
and add a Makefile with the following contents
include ../../build/config.mk include ../../build/module.mk
That’s it. Now, you need the luasrc/htdocs etc directories from your project. This is a touch tedious…
[LUCI_DIR]/applications/your_name$ ln -s [YOUR_PKG]/luasrc
[LUCI_DIR]/applications/your_name$ ln -s [YOUR_PKG]/htdocs
At this point, [LUCI_DIR]$ make runuhttpd
will churn away, and copy things all over the place, and you should have your package working locally.
I had problems where controllers were simply not detected, with the page’s “entry” links simply returning a 404 “No page is registered at blah/wop” As best I can tell, this was a problem in the fast indexer, and editing [LUCI_DIR]/libs/web/dispatcher.lua
, in the createindex
function, to use the plain indexing instead of the fast indexing meant that all my controllers showed up properly. The controllers were all working perfectly on the target mind you.
So, with this, I don’t have to fiddle around with sshfs, and I can easily use things like git diff
to see what I’ve actually done recently. However, because of the way make runuhttpd
works, by copying all the files first into a dist
directory, then copying that into the [LUCI_DIR]/host/
tree, you have to continually stop and start the server after any changes. A project for another day….
Leave a Comment