add debian/ directory
authorFelix Fietkau <[email protected]>
Tue, 14 Oct 2025 09:03:37 +0000 (09:03 +0000)
committerFelix Fietkau <[email protected]>
Tue, 14 Oct 2025 10:16:49 +0000 (10:16 +0000)
Support building debian packages

Signed-off-by: Felix Fietkau <[email protected]>
15 files changed:
.gitignore
CMakeLists.txt
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/default-acl.json [new file with mode: 0644]
debian/generate-changelog.sh [new file with mode: 0755]
debian/libubus-dev.install [new file with mode: 0644]
debian/libubus.install [new file with mode: 0644]
debian/lintian-overrides [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/source/format [new file with mode: 0644]
debian/ubus.install [new file with mode: 0644]
debian/ubus.postinst [new file with mode: 0644]
debian/ubus.postrm.debhelper [new file with mode: 0644]
debian/ubus.ubusd.service [new file with mode: 0644]

index 551b024fd813b5be0bcd0c69a78fc4d798bd7fc1..3f43659b3c80d6f3a601873761d758c920ffa723 100644 (file)
@@ -10,3 +10,13 @@ examples/client
 ubusd
 ubus
 install_manifest.txt
+debian/.debhelper/
+debian/debhelper-build-stamp
+debian/*.debhelper.log
+debian/*.substvars
+debian/files
+debian/libubus/
+debian/libubus-dev/
+debian/ubus/
+debian/changelog
+debian/tmp/
index 03c30129030d70413d843cf8e1dfcc012dfc50be..1ede30d4932f9dd141eb913db6ec876f0ba552d1 100644 (file)
@@ -83,3 +83,11 @@ INSTALL(TARGETS ubusd
 )
 
 INSTALL(FILES ubusmsg.h ubus_common.h libubus.h DESTINATION include)
+
+ADD_CUSTOM_TARGET(debian
+       COMMAND ${CMAKE_COMMAND} -E echo "Generating debian/changelog from git..."
+       COMMAND ${CMAKE_SOURCE_DIR}/debian/generate-changelog.sh
+       COMMAND dpkg-buildpackage -b -uc -us
+       WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+       COMMENT "Building Debian package"
+)
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..3b83a82
--- /dev/null
@@ -0,0 +1,47 @@
+Source: ubus
+Maintainer: Felix Fietkau <[email protected]>
+Section: libs
+Priority: optional
+Standards-Version: 4.5.0
+Rules-Requires-Root: no
+Build-Depends: debhelper-compat (= 12), cmake, pkgconf, libjson-c-dev, libubox-dev
+Homepage: https://git.openwrt.org/project/ubus.git
+Vcs-Browser: https://git.openwrt.org/project/ubus.git
+Vcs-Git: https://git.openwrt.org/project/ubus.git
+
+Package: libubus
+Architecture: any
+Multi-Arch: same
+Pre-Depends: ${misc:Pre-Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Section: libs
+Description: OpenWrt RPC client library
+ Ubus is the OpenWrt micro bus architecture for inter-process communication
+ (IPC). It provides a system-wide message bus that allows different
+ processes to communicate with each other using a simple API.
+ .
+ This package contains the libubus shared library.
+
+Package: libubus-dev
+Architecture: any
+Multi-Arch: same
+Depends: libubus (= ${binary:Version}), libc6-dev|libc-dev, libjson-c-dev, libubox-dev, ${misc:Depends}
+Section: libdevel
+Description: Development files for libubus
+ Ubus is the OpenWrt micro bus architecture for inter-process communication
+ (IPC). It provides a system-wide message bus that allows different
+ processes to communicate with each other using a simple API.
+ .
+ This package contains the development files (headers, static libraries,
+ and symlinks) for libubus.
+
+Package: ubus
+Architecture: any
+Multi-Arch: foreign
+Depends: libubus (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: OpenWrt RPC daemon and CLI
+ Ubus is the OpenWrt micro bus architecture for inter-process communication
+ (IPC). It provides a system-wide message bus that allows different
+ processes to communicate with each other using a simple API.
+ .
+ This package contains the ubusd daemon and the ubus command-line tool.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..4b5dd57
--- /dev/null
@@ -0,0 +1,19 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: ubus
+Source: https://git.openwrt.org/project/ubus.git
+
+Files: *
+Copyright: 2010- Felix Fietkau <[email protected]>
+License: ISC
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/debian/default-acl.json b/debian/default-acl.json
new file mode 100644 (file)
index 0000000..e8e9ccd
--- /dev/null
@@ -0,0 +1,12 @@
+{
+       "group": "ubus",
+       "access": {
+               "*": {
+                       "methods": [ "*" ]
+               }
+       },
+       "publish": [ "*" ],
+       "subscribe": [ "*" ],
+       "listen": [ "*" ],
+       "send": [ "*" ]
+}
diff --git a/debian/generate-changelog.sh b/debian/generate-changelog.sh
new file mode 100755 (executable)
index 0000000..1d7cbb3
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+cd "$(dirname "$0")/.."
+
+COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y%m%d' 2>/dev/null || echo '00000000')
+COMMIT_HASH=$(git log -1 --format='%h' 2>/dev/null || echo 'unknown')
+COMMIT_TIMESTAMP=$(git log -1 --format='%cd' --date=rfc2822 2>/dev/null || date -R)
+
+cat > debian/changelog <<EOF
+ubus (0.0.${COMMIT_DATE}) unstable; urgency=medium
+
+  * Latest version (${COMMIT_HASH})
+
+ -- Felix Fietkau <[email protected]>  ${COMMIT_TIMESTAMP}
+EOF
diff --git a/debian/libubus-dev.install b/debian/libubus-dev.install
new file mode 100644 (file)
index 0000000..a03212d
--- /dev/null
@@ -0,0 +1,4 @@
+usr/include/ubusmsg.h
+usr/include/ubus_common.h
+usr/include/libubus.h
+usr/lib/libubus.so
diff --git a/debian/libubus.install b/debian/libubus.install
new file mode 100644 (file)
index 0000000..1dc43f5
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/libubus.so.*
diff --git a/debian/lintian-overrides b/debian/lintian-overrides
new file mode 100644 (file)
index 0000000..7662288
--- /dev/null
@@ -0,0 +1 @@
+no-manual-page
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..43b05a4
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+
+BUILD_DIR = obj-$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+
+%:
+       dh $@ --builddirectory=$(BUILD_DIR)
+
+override_dh_auto_clean:
+       dh_auto_clean --builddirectory=$(BUILD_DIR)
+       rm -rf $(BUILD_DIR)
+
+override_dh_auto_configure:
+       cmake -S . -B $(BUILD_DIR) \
+               -DCMAKE_INSTALL_PREFIX=/usr \
+               -DCMAKE_BUILD_TYPE=None \
+               -DCMAKE_VERBOSE_MAKEFILE=ON \
+               -DABIVERSION=$(shell dpkg-parsechangelog | sed -rne 's/^Version: 0\.0\.([0-9]+).*$$/\1/p') \
+               -DBUILD_LUA=OFF \
+               -DBUILD_EXAMPLES=OFF
+
+override_dh_installsystemd:
+       dh_installsystemd --name=ubusd
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..89ae9db
--- /dev/null
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/debian/ubus.install b/debian/ubus.install
new file mode 100644 (file)
index 0000000..1631774
--- /dev/null
@@ -0,0 +1,3 @@
+usr/bin/ubus
+usr/sbin/ubusd
+debian/default-acl.json usr/share/acl.d/
diff --git a/debian/ubus.postinst b/debian/ubus.postinst
new file mode 100644 (file)
index 0000000..bb6d685
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+    configure)
+        if ! getent group ubus >/dev/null; then
+            addgroup --system ubus
+        fi
+        ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+        ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+        ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/ubus.postrm.debhelper b/debian/ubus.postrm.debhelper
new file mode 100644 (file)
index 0000000..fce3fd7
--- /dev/null
@@ -0,0 +1,12 @@
+# Automatically added by dh_installsystemd/13.24.2ubuntu1
+if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
+       systemctl --system daemon-reload >/dev/null || true
+fi
+# End automatically added section
+# Automatically added by dh_installsystemd/13.24.2ubuntu1
+if [ "$1" = "purge" ]; then
+       if [ -x "/usr/bin/deb-systemd-helper" ]; then
+               deb-systemd-helper purge 'ubusd.service' >/dev/null || true
+       fi
+fi
+# End automatically added section
diff --git a/debian/ubus.ubusd.service b/debian/ubus.ubusd.service
new file mode 100644 (file)
index 0000000..bafb64f
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=OpenWrt micro bus daemon
+Documentation=https://git.openwrt.org/project/ubus.git
+DefaultDependencies=no
+Before=basic.target
+After=local-fs.target
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/ubusd
+Restart=always
+RestartSec=5
+RuntimeDirectory=ubus
+RuntimeDirectoryMode=0755
+
+[Install]
+WantedBy=sysinit.target