AMX / prplOS development environment: from source to a Docker base image
Grow through practice
No need to finish reading — test nowOne line: build the base environment once; examples compile on top of it. This article covers libubox/ubus/AMX/amxrt and the ubus ACL; examples get their own articles.
Scope
This article only builds “an environment that can run AMX”:
libubox + ubus
+ libamxc / amxp / amxd / amxb / amxs / amxo / amxj / amxrt
+ amxrt app / amxb_ubus
+ ubus ACL (for non-root)
It contains no examples (wait_for, cpu-info, greeter…). Example articles only do:
git clone <example>
make
and run on this environment.
Option A: PC source build
For local debugging. Dependencies (Ubuntu 22.04):
sudo apt install -y \
build-essential cmake pkg-config git bison flex \
libjson-c-dev libcap-dev libcap-ng-dev libevent-dev \
liburiparser-dev libyajl-dev libssl-dev libxml2-dev \
liblua5.3-dev libncurses-dev libreadline-dev
1) libubox + ubus
git clone https://github.com/openwrt/libubox.git
cmake -S libubox -B libubox/build \
-DBUILD_LUA=OFF -DBUILD_EXAMPLES=OFF \
-DCMAKE_INSTALL_PREFIX=/usr
cmake --build libubox/build -j"$(nproc)"
sudo cmake --install libubox/build
git clone https://github.com/openwrt/ubus.git
cmake -S ubus -B ubus/build -DBUILD_LUA=OFF -DCMAKE_INSTALL_PREFIX=/usr
cmake --build ubus/build -j"$(nproc)"
sudo cmake --install ubus/build
2) AMX libraries
Order matters (libamxo needs libamxs, libamxs needs libamxb):
for r in libamxc libamxp libamxd libamxb libamxs libamxo libamxj libamxrt; do
git clone https://gitlab.com/prpl-foundation/components/ambiorix/libraries/$r.git
make -C $r -j"$(nproc)"
sudo make -C $r install
done
3) amxrt app + ubus backend
git clone https://gitlab.com/prpl-foundation/components/ambiorix/applications/amxrt.git
make -C amxrt -j"$(nproc)" && sudo make -C amxrt install
git clone https://gitlab.com/prpl-foundation/components/ambiorix/modules/amxb_backends/amxb_ubus.git
make -C amxb_ubus -j"$(nproc)" && sudo make -C amxb_ubus install
sudo ldconfig
Verify:
amxrt -V
ls /usr/bin/mods/amxb/mod-amxb-ubus.so
Option B: Docker base image
Same source, automated. Repo: amx-greeter-demo
git clone https://github.com/zishuowang696/amx-greeter-demo.git
cd amx-greeter-demo
./build-base.sh
This produces amx-base:ubuntu (~189 MB). base/Dockerfile has build + base stages:
- build: Ubuntu 22.04 + toolchain, compiling in the order above;
- base: runtime libs +
ubusd/ubus/amxrt+mods/amxb+ headers (for examples).
If Docker Hub is inconvenient:
BASE_OS_IMAGE=docker.m.daocloud.io/library/ubuntu:22.04 ./build-base.sh
ubus ACL: the key to non-root
By default, ubusd denies publish from non-root clients; amxb_ubus swallows the ubus_add_object failure, so ubus list is just empty.
The base image creates a demo user and an ACL:
{
"user": "demo",
"publish": ["*"],
"subscribe": ["*"],
"access": {
"*": { "methods": ["*"] }
}
}
Start:
ubusd -A /etc/ubus-acl -s /var/run/ubus/ubus.sock
Trap: ACL file permissions
ubusd only loads ACL files that are root:root and not group/other writable.
The first version was 664, and the result was:
DEBUG ubus_add_object(Greeter) = 2
2 = UBUS_STATUS_INVALID_ARGUMENT. After 644, demo publish works.
0644 works, 664 does not. Hit this once in the base environment, and examples do not have to.
How examples plug in
An example image only does two things:
FROM amx-base:ubuntu AS build
RUN git clone <example> /src/example && make -C /src/example
Compilation reuses the base headers/libs; the runtime layer copies only ODL/.so, and does not rebuild AMX.
All example articles start from amx-base, ordered by size:
- 01 wait_for: one C file; runtime/bus first
- 02 amx-scheduler: 2 C + 2 ODL; the smallest data model
- 03 cpu-info: 8 C + 3 ODL; instances/actions/volatile
- 04 greeter_app: app vs plugin; ftab binding
- 05 localagent_threshold: a real TR-181 object
- 06 greeter_plugin: the full data model (instances/transactions/events/persistence)
For ODL syntax first, then come back: ODL parsing (1) · ODL parsing (2) · ODL reference.
Verification status
- ✅ Docker base build: Ubuntu 22.04,
amx-base:ubuntu~189 MB; - ✅ non-root + ACL:
amxrtruns asdemo;ubus list/_set/saypass in the example; - ⚠️ PC source commands: same source as the Dockerfile, not re-run step by step on a clean machine this session;
- ❓ productionization: the base still carries headers and the
demouser; a real image should split-devfrom a minimal runtime layer.
One sentence
The base environment owns “having AMX”; examples own “using AMX”; the ACL owns “non-root can use it”. Get this article working first; every example then is just
git clone + make.
Repo: amx-greeter-demo Examples: 01 wait_for · 02 amx-scheduler · 03 cpu-info · 04 greeter_app · 05 localagent_threshold · 06 greeter_plugin Series: Inside prplOS: AMX Runtime (Guide).
Comments 0
No comments yet — be the first!