DevelopmentEnvironmentHowTo

Jo-Philipp Wich edited this page Jan 15, 2016 · 3 revisions

Table of Contents

HowTo: Setting up a Development Environment

The recommended way to develop LuCI is to edit it on a real OpenWrt system in conjunction with an editor or IDE which supports remotely editing files via the SCP or SFTP protocol.

There are various ways to run OpenWrt, it can be either installed on real hardware or deployed within a virtual machine. Using an OpenWrt x86 image in Qemu (or Qemu-KVM / Virt-Manager) is a good choice to develop LuCI, refer to OpenWrt on Qemu for details.

Required Software

Once the base OpenWrt system is up and running and SSH authentification is set up, make sure that LuCI is installed and accessible in the browser. If not preset already, install it with `opkg update; opkg install luci`. Afterwards ensure that the web server is enabled and started with `/etc/init.d/uhttpd enable; /etc/init.d/uhttpd start`.

Proceed with installing the `openssh-sftp-server` package in order to make OpenWrts root filesystem available via SFTP. Point your IDE or editor to the IP address of the OpenWrt system, provide the root credentials and make sure you can access the filesystem contents.

Filesystem paths

Most LuCI code resides in /usr/lib/lua/luci while web assets (JavaScript, CSS, etc.) are located in the `/www` directory on the target system.

Modifying code

All files can be usually edited directly on the system. Note that the LuCI framework caches precompiled variants of its Lua libraries in the `/tmp` directory, it is recommended to use `uci set luci.ccache.enable=0; uci commit luci` in order to disable the code caching for development purposes.

Integrating changes

Once done, copy the files from the target system into your local git clone and commit them. Files from `/usr/lib/lua` belong into the `luasrc/` directories of the corresponding repository component, files from `/www` belong into `htdocs/` and anything else into the `root/` directory. Take a look at existing modules to get an idea of the general structure.