Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions libs/faux/Makefile
Original file line number Diff line number Diff line change
@@ -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 <dharmikparmar2004@yahoo.com>
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))
79 changes: 79 additions & 0 deletions utils/klish3/Makefile
Original file line number Diff line number Diff line change
@@ -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 <dharmikparmar2004@yahoo.com>
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
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title contains a capitalization typo: SHell should be Shell.

Suggested change
TITLE:=Kommand Line Interface SHell v3
TITLE:=Kommand Line Interface Shell v3

Copilot uses AI. Check for mistakes.
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/
Comment on lines +62 to +68
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klish3 currently ships multiple shared libraries/plugins in the main utilities package. In OpenWrt packaging, shared libs are typically split into dedicated lib* packages (e.g., libklish3, potentially libtinyrl3, and plugin subpackages) so other packages can depend on them without pulling in the CLI/daemon, and to reduce image footprint. Consider introducing separate library/plugin packages and having Package/klish3 depend on them.

Copilot uses AI. Check for mistakes.

$(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))
12 changes: 12 additions & 0 deletions utils/klish3/files/etc/klish/klish.conf
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions utils/klish3/files/etc/klish/klishd.conf
Original file line number Diff line number Diff line change
@@ -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.
Comment on lines +1 to +5
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammar issues in comments reduce clarity (e.g., It's used by klishd daemon and The klishd uses UNIX domain socket). Consider adjusting to It is used by the klishd daemon and klishd uses a UNIX domain socket.

Suggested change
# 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.
# Template for config file /etc/klish/klishd.conf. It is used by the klishd daemon.
# klishd uses a UNIX domain socket to receive connections. It will create a
# filesystem entry to allow clients to find the connection point. By default,
# klishd uses the /tmp/klish-unix-socket path.

Copilot uses AI. Check for mistakes.
#UnixSocketPath=/tmp/klish-unix-socket

DBs=libxml2
DB.libxml2.XMLPath=/etc/klish/xml/
56 changes: 56 additions & 0 deletions utils/klish3/files/etc/klish/xml/example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<KLISH
xmlns="https://klish.libcode.org/klish3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://src.libcode.org/pkun/klish/src/master/klish.xsd">
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xsi:schemaLocation must contain pairs of (namespaceURI, schemaLocation). As written it only provides a single URI, which is invalid and can break schema-aware tooling. Fix by providing both the namespace (xmlns) and a schema location (ideally pointing to the locally installed /usr/share/klish/klish.xsd, or a stable URL), e.g. xsi:schemaLocation=\"https://klish.libcode.org/klish3 /usr/share/klish/klish.xsd\".

Suggested change
xsi:schemaLocation="https://src.libcode.org/pkun/klish/src/master/klish.xsd">
xsi:schemaLocation="https://klish.libcode.org/klish3 /usr/share/klish/klish.xsd">

Copilot uses AI. Check for mistakes.

<PLUGIN name="klish"/>

<PLUGIN name="script"/>


<PTYPE name="STRING">
<ACTION sym="STRING@klish"/>
</PTYPE>


<VIEW name="main">

<HOTKEY key="^Z" cmd="exit"/>

<PROMPT name="prompt">
<ACTION sym="prompt">%u@%h&gt; </ACTION>
</PROMPT>

<COMMAND name="exit" help="Exit view">
<ACTION sym="nav">pop</ACTION>
<ACTION sym="printl">Exiting klish session</ACTION>
</COMMAND>

<COMMAND name="cmd" help="Clear settings">
<COMMAND name="first" help="Clear settings"/>
<ACTION sym="printl">test</ACTION>
</COMMAND>

<COMMAND name="comm" value="command" help="Clear settings">
<ACTION sym="printl">test2</ACTION>
</COMMAND>

<COMMAND name="ls" help="List path">
<PARAM name="path" ptype="/STRING" help="Path"/>
<ACTION sym="script">
echo ""
ls ""
Comment on lines +42 to +43
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ls command declares a path parameter but the script ignores it (ls \"\"). This makes the example misleading. Either use the parameter in the script (per klish variable substitution rules) or remove the unused <PARAM> to keep the example coherent.

Suggested change
echo ""
ls ""
echo "${path}"
ls "${path}"

Copilot uses AI. Check for mistakes.
</ACTION>
</COMMAND>

<COMMAND name="pytest" help="Test for Python script">
<ACTION sym="script">#!/usr/bin/python3
import os
print('ENV', os.getenv("KLISH_COMMAND"))
</ACTION>
</COMMAND>

</VIEW>

</KLISH>
26 changes: 26 additions & 0 deletions utils/klish3/patches/100-fix-stdio-macro-collision.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/klish/ksession/kcontext.c
+++ b/klish/ksession/kcontext.c
@@ -5,6 +5,10 @@
#include <sys/types.h>
#include <unistd.h>

+#undef stdin
+#undef stdout
+#undef stderr
+
#include <faux/str.h>
#include <faux/conv.h>
#include <faux/list.h>
--- a/klish/ksession/kexec.c
+++ b/klish/ksession/kexec.c
@@ -15,6 +15,10 @@
#include <signal.h>
#include <errno.h>

+#undef stdin
+#undef stdout
+#undef stderr
+
#include <faux/list.h>
#include <faux/buf.h>
#include <faux/eloop.h>
Loading