diff --git a/libs/faux/Makefile b/libs/faux/Makefile new file mode 100644 index 0000000000000..4cf17a1c1104e --- /dev/null +++ b/libs/faux/Makefile @@ -0,0 +1,71 @@ +# +# Copyright (C) 2026 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=faux +PKG_VERSION:=2.2.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://src.libcode.org/download/faux +PKG_HASH:=f58a73f6543785fe353d23691d9dc023bfdc0ed46d4ff41a560df867d42efbd0 + +PKG_MAINTAINER:=Dharmik Parmar +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENCE + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libfaux + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Auxiliary utility library used by klish3 + URL:=https://src.libcode.org/pkun/faux + DEPENDS:=+libpthread +endef + +define Package/libfaux/description + The faux library contains assorted helper APIs for memory, strings, + event loops, async I/O and utility wrappers. +endef + +define Package/faux-utils + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Utilities from faux library + URL:=https://src.libcode.org/pkun/faux + DEPENDS:=+libfaux +endef + +define Package/faux-utils/description + Utility binaries shipped by the faux project. +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/faux $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfaux.so* $(1)/usr/lib/ +endef + +define Package/libfaux/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfaux.so* $(1)/usr/lib/ +endef + +define Package/faux-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/faux-file2c $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/faux-getch $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,libfaux)) +$(eval $(call BuildPackage,faux-utils)) diff --git a/utils/klish3/Makefile b/utils/klish3/Makefile new file mode 100644 index 0000000000000..2e533c5805c09 --- /dev/null +++ b/utils/klish3/Makefile @@ -0,0 +1,79 @@ +# +# Copyright (C) 2026 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=klish3 +PKG_VERSION:=3.2.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=klish-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://src.libcode.org/download/klish +PKG_HASH:=8d9be7e7b51efd4dd1b128a74be090986e76eac1b86da7495ca46ba5ea071e25 + +PKG_BUILD_DIR:=$(BUILD_DIR)/klish-$(PKG_VERSION) +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +PKG_MAINTAINER:=Dharmik Parmar +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENCE + +include $(INCLUDE_DIR)/package.mk + +define Package/klish3 + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Shells + TITLE:=Kommand Line Interface SHell v3 + URL:=https://src.libcode.org/pkun/klish + DEPENDS:=+libfaux +libxml2 +libpthread + CONFLICTS:=klish klish-xml-files +endef + +define Package/klish3/description + Klish v3 is a framework for implementing Cisco-like or Juniper-like + command line interfaces. + This package ships the klish and klishd binaries along with required + runtime libraries and plugins. +endef + +CONFIGURE_ARGS += \ + --with-libxml2=yes \ + --with-roxml=no \ + --with-expat=no \ + --with-lua=no + +define Package/klish3/conffiles +/etc/klish/klish.conf +/etc/klish/klishd.conf +/etc/klish/xml/example.xml +endef + +define Package/klish3/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/klish $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/klishd $(1)/usr/bin/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libklish.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libtinyrl.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libklish-db-ischeme.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libklish-db-libxml2.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libklish-plugin-klish.so* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libklish-plugin-script.so* $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/etc/klish/xml + $(INSTALL_CONF) ./files/etc/klish/klish.conf $(1)/etc/klish/ + $(INSTALL_CONF) ./files/etc/klish/klishd.conf $(1)/etc/klish/ + $(INSTALL_CONF) ./files/etc/klish/xml/example.xml $(1)/etc/klish/xml/ + + $(INSTALL_DIR) $(1)/usr/share/klish + $(INSTALL_DATA) $(PKG_BUILD_DIR)/klish.xsd $(1)/usr/share/klish/ +endef + +$(eval $(call BuildPackage,klish3)) diff --git a/utils/klish3/files/etc/klish/klish.conf b/utils/klish3/files/etc/klish/klish.conf new file mode 100644 index 0000000000000..817cf5b4f1c46 --- /dev/null +++ b/utils/klish3/files/etc/klish/klish.conf @@ -0,0 +1,12 @@ +# OpenWrt default config for /etc/klish/klish.conf. +# Used by the klish client utility. + +# Default Unix socket used to reach klishd. +#UnixSocketPath=/tmp/klish-unix-socket + +# BusyBox less does not support GNU less flags like -I -X -K -R. +# Keep pager defaults compatible with OpenWrt base images. +Pager="/usr/bin/less -EFN~" + +# Enable or disable pager usage globally. +#UsePager=y diff --git a/utils/klish3/files/etc/klish/klishd.conf b/utils/klish3/files/etc/klish/klishd.conf new file mode 100644 index 0000000000000..08bc39f5452de --- /dev/null +++ b/utils/klish3/files/etc/klish/klishd.conf @@ -0,0 +1,9 @@ +# Template for config file /etc/klish/klishd.conf. It's used by klishd daemon. + +# The klishd uses UNIX domain socket to receive connections. It will create an +# filesystem entry to allow clients to find connection point. By default klishd +# uses /tmp/klish-unix-socket path. +#UnixSocketPath=/tmp/klish-unix-socket + +DBs=libxml2 +DB.libxml2.XMLPath=/etc/klish/xml/ \ No newline at end of file diff --git a/utils/klish3/files/etc/klish/xml/example.xml b/utils/klish3/files/etc/klish/xml/example.xml new file mode 100644 index 0000000000000..d868645147216 --- /dev/null +++ b/utils/klish3/files/etc/klish/xml/example.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + +%u@%h> + + + +pop +Exiting klish session + + + + +test + + + +test2 + + + + + +echo "" +ls "" + + + + +#!/usr/bin/python3 +import os +print('ENV', os.getenv("KLISH_COMMAND")) + + + + + + \ No newline at end of file diff --git a/utils/klish3/patches/100-fix-stdio-macro-collision.patch b/utils/klish3/patches/100-fix-stdio-macro-collision.patch new file mode 100644 index 0000000000000..02b12470ea727 --- /dev/null +++ b/utils/klish3/patches/100-fix-stdio-macro-collision.patch @@ -0,0 +1,26 @@ +--- a/klish/ksession/kcontext.c ++++ b/klish/ksession/kcontext.c +@@ -5,6 +5,10 @@ + #include + #include + ++#undef stdin ++#undef stdout ++#undef stderr ++ + #include + #include + #include +--- a/klish/ksession/kexec.c ++++ b/klish/ksession/kexec.c +@@ -15,6 +15,10 @@ + #include + #include + ++#undef stdin ++#undef stdout ++#undef stderr ++ + #include + #include + #include