[PATCH] Makefile.am: add a rule to create debian package

25 views
Skip to first unread message

Konstantin Kharlamov

unread,
Dec 23, 2020, 3:26:22 AM12/23/20
to klis...@googlegroups.com
Signed-off-by: Konstantin Kharlamov <Hi-A...@yandex.ru>
---
Makefile.am | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 8f3573e..499167f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,3 +25,19 @@ EXTRA_DIST = \
include $(top_srcdir)/faux/Makefile.am
include $(top_srcdir)/utils/Makefile.am
include $(top_srcdir)/testc/Makefile.am
+
+define CONTROL
+PACKAGE: faux
+Version: $(PACKAGE_VERSION)
+Architecture: amd64
+Maintainer: pkun
+Description: Various auxiliary functions
+Homepage: https://src.libcode.org/pkun/faux
+endef
+
+export CONTROL
+deb: all
+ mkdir -p deb/DEBIAN
+ echo "$$CONTROL" > deb/DEBIAN/control
+ DESTDIR=$(shell pwd)/deb make install
+ dpkg-deb --build deb/ faux_$(PACKAGE_VERSION).deb
--
2.29.2

Yagamy Light

unread,
Dec 23, 2020, 3:27:52 AM12/23/20
to klish-dev
Sorry, I must mention: this is for `faux` project. I have a similar patch for `klish` too, but I figured I need to make some changes there, so I'll probably send it later in a series with other changes.

Serj Kalichev

unread,
Dec 23, 2020, 5:30:17 AM12/23/20
to klis...@googlegroups.com
Applied. Thanks!
It's not a problem but faux has its own site and mailing list
http://groups.google.com/group/libfaux

May be it's better to implement full-blown debian support. I mean
/debian dir with config files etc. What do you think about it?

23.12.2020 11:26, Konstantin Kharlamov пишет:

Hi-Angel

unread,
Dec 23, 2020, 6:13:33 AM12/23/20
to klis...@googlegroups.com
On Wed, 23 Dec 2020 at 13:30, Serj Kalichev <serj.k...@gmail.com> wrote:
>
> Applied. Thanks!
> It's not a problem but faux has its own site and mailing list
> http://groups.google.com/group/libfaux
>
> May be it's better to implement full-blown debian support. I mean
> /debian dir with config files etc. What do you think about it?

Well, right now, given a file "control" is the only debian-specific
thing project has, I'm not sure there's much point in keeping it in a
separate directory… But that's my purely subjective opinion ¯\_(ツ)_/¯
I can do it if you want, it is a trivial change.

Hi-Angel

unread,
Dec 23, 2020, 6:26:03 AM12/23/20
to klis...@googlegroups.com
On the second thought, I realized: control file is auto-generated :) I
mean, it has to be, because the field `Version` gets extracted from
elsewhere. So we can't even create a dedicated "debian" directory in
the repo, because it would be empty, and git does not allow empty
directories.

Serj Kalichev

unread,
Dec 23, 2020, 7:20:50 AM12/23/20
to klis...@googlegroups.com
I mean /debian dir with content like this:
changelog
compat
control
copyright
klish-dev.install
klish.dirs
klish.install
klish.postinst
rules
source

Configure script can process templates and add version to the specified
place.




23.12.2020 14:25, Hi-Angel пишет:

Hi-Angel

unread,
Dec 23, 2020, 7:27:14 AM12/23/20
to klis...@googlegroups.com
On Wed, 23 Dec 2020 at 15:20, Serj Kalichev <serj.k...@gmail.com> wrote:
>
> I mean /debian dir with content like this:
> changelog
> compat
> control
> copyright
> klish-dev.install
> klish.dirs
> klish.install
> klish.postinst
> rules
> source
>
> Configure script can process templates and add version to the specified
> place.

Ah, alright… Well, I'm not even sure what to put in all these files 😄
Well, if you think, they're necessary, then yeah, why not…

Serj Kalichev

unread,
Dec 23, 2020, 7:37:02 AM12/23/20
to klis...@googlegroups.com
It's not really necessary now. If you don't need full debian support
like source packages etc the existent implementation is enough.

23.12.2020 15:27, Hi-Angel пишет:

Konstantin Kharlamov

unread,
Dec 23, 2020, 9:39:33 AM12/23/20
to klis...@googlegroups.com
Signed-off-by: Konstantin Kharlamov <Hi-A...@yandex.ru>
---
Makefile.am | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 5a81725..a94cb35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,3 +48,20 @@ include $(top_srcdir)/bin/module.am
include $(top_srcdir)/plugins/module.am
include $(top_srcdir)/libc/module.am
include $(top_srcdir)/doc/module.am
+
+define CONTROL
+PACKAGE: klish
+Version: $(PACKAGE_VERSION)
+Architecture: amd64
+Depends: faux
+Maintainer: pkun
+Description: The klish is a framework for implementing a CISCO-like CLI on a UNIX systems. It is configurable by XML files
+Homepage: http://klish.libcode.org
+endef
+
+export CONTROL
+deb: all
+ mkdir -p deb/DEBIAN
+ echo "$$CONTROL" > deb/DEBIAN/control
+ DESTDIR=$(shell pwd)/deb make install
+ dpkg-deb --build deb/ klish_$(PACKAGE_VERSION).deb
--
2.29.2

Konstantin Kharlamov

unread,
Dec 23, 2020, 9:39:33 AM12/23/20
to klis...@googlegroups.com
From: Konstantin Kharlamov <k.kha...@npobaum.ru>

Signed-off-by: Konstantin Kharlamov <k.kha...@npobaum.ru>
---
tinyrl/tinyrl.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tinyrl/tinyrl.c b/tinyrl/tinyrl.c
index 4319daf..b786361 100644
--- a/tinyrl/tinyrl.c
+++ b/tinyrl/tinyrl.c
@@ -369,7 +369,7 @@ static bool_t tinyrl_key_up(tinyrl_t * this, int key)
}
if (entry) {
/* display the entry moving the insertion point
- * to the end of the line
+ * to the end of the line
*/
this->line = tinyrl_history_entry__get_line(entry);
this->point = this->end = strlen(this->line);
@@ -396,7 +396,7 @@ static bool_t tinyrl_key_down(tinyrl_t * this, int key)
this->line = tinyrl_history_entry__get_line(entry);
}
/* display the entry moving the insertion point
- * to the end of the line
+ * to the end of the line
*/
this->point = this->end = strlen(this->line);
result = BOOL_TRUE;
@@ -1077,7 +1077,7 @@ static char *internal_readline(tinyrl_t * this,
lub_string_free(tmp);
}
/*
- * duplicate the string for return to the client
+ * duplicate the string for return to the client
* we have to duplicate as we may be referencing a
* history entry or our internal buffer
*/
@@ -1203,7 +1203,7 @@ bool_t tinyrl_insert_text(tinyrl_t * this, const char *text)
}

/*----------------------------------------------------------------------- */
-/*
+/*
* A convenience function for displaying a list of strings in columnar
* format on Readline's output stream. matches is the list of strings,
* in argv format, such as a list of completion matches. len is the number
@@ -1314,11 +1314,11 @@ bool_t tinyrl_bind_key(tinyrl_t * this, int key, tinyrl_key_func_t * fn)
* returned array is the substitution for text. The remaining entries
* are the possible completions. The array is terminated with a NULL pointer.
*
- * entry_func is a function of two args, and returns a char *.
+ * entry_func is a function of two args, and returns a char *.
* The first argument is text. The second is a state argument;
* it is zero on the first call, and non-zero on subsequent calls.
- * entry_func returns a NULL pointer to the caller when there are no
- * more matches.
+ * entry_func returns a NULL pointer to the caller when there are no
+ * more matches.
*/
char **tinyrl_completion(tinyrl_t * this,
const char *line, unsigned int start, unsigned int end,
--
2.29.2

Konstantin Kharlamov

unread,
Dec 23, 2020, 9:39:34 AM12/23/20
to klis...@googlegroups.com
From: Konstantin Kharlamov <k.kha...@npobaum.ru>

Pressing Ctrl+d to exit a shell if input field has no text is a common
shortcut supported by most shells. Well, except klish, till now. This
commit adds support to klish as well.

Signed-off-by: Konstantin Kharlamov <k.kha...@npobaum.ru>
---
tinyrl/tinyrl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tinyrl/tinyrl.c b/tinyrl/tinyrl.c
index b786361..794b9e3 100644
--- a/tinyrl/tinyrl.c
+++ b/tinyrl/tinyrl.c
@@ -960,7 +960,8 @@ static char *internal_readline(tinyrl_t * this,
key = tinyrl_getchar(this);

/* Error || EOF || Timeout */
- if (key < 0) {
+ if (key < 0 ||
+ (key == KEY_EOT && this->end == 0) /* ^D signal to exit */ ) {
if ((VT100_TIMEOUT == key) &&
!this->timeout_fn(this))
continue;
--
2.29.2

Serj Kalichev

unread,
Dec 25, 2020, 4:00:53 AM12/25/20
to klis...@googlegroups.com
Applied. Thanks!

23.12.2020 17:39, Konstantin Kharlamov пишет:

Serj Kalichev

unread,
Dec 25, 2020, 4:05:35 AM12/25/20
to klis...@googlegroups.com
Applied. Thanks!

23.12.2020 17:39, Konstantin Kharlamov пишет:

Serj Kalichev

unread,
Dec 25, 2020, 4:32:00 AM12/25/20
to klis...@googlegroups.com
I think it's not good to hardcode behavior that can be implemented using
settings and configuration.
Klish has HOTKEY tag. It allows to define command to execute when hotkey
is pressed.

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

In this example "exit" and "show" is a klish commands defined within XML.
The command to exit klish can be implemented like this:
<------><COMMAND name="disable" help="Exit">
<------><------><ACTION builtin="clish_close"/>
<------></COMMAND>


23.12.2020 17:39, Konstantin Kharlamov пишет:

Hi-Angel

unread,
Dec 25, 2020, 7:13:30 AM12/25/20
to klis...@googlegroups.com
Thank you!

Okay, sorry, this is a bit uncomfortable… I didn't know you were going
to apply to 2.2 the deb package creation. I thought the patch is gonna
go master, so I put in `Depends` field the `faux` package. For 2.2
branch the "Depends" line probably should not be present, similarly to
the commit in `faux`.
> --
> You received this message because you are subscribed to the Google Groups "klish-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to klish-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/klish-dev/530ce046-89a3-5b93-4162-b41400a4ebd6%40gmail.com.

Hi-Angel

unread,
Dec 25, 2020, 7:17:34 AM12/25/20
to klis...@googlegroups.com
Amazing, thanks! I will use it, please disregard then the patch
> --
> You received this message because you are subscribed to the Google Groups "klish-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to klish-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/klish-dev/8dce19c0-4ad5-a97c-6f76-94f49857d73a%40gmail.com.

Hi-Angel

unread,
Dec 25, 2020, 7:19:12 AM12/25/20
to klis...@googlegroups.com
Oh, btw, I'm not quite clear: do you want a patch for such
configuration (i.e. through a xml), or not?

Hi-Angel

unread,
Dec 25, 2020, 7:52:49 AM12/25/20
to klis...@googlegroups.com
On Fri, 25 Dec 2020 at 12:32, Serj Kalichev <serj.k...@gmail.com> wrote:
>
> I think it's not good to hardcode behavior that can be implemented using
> settings and configuration.
> Klish has HOTKEY tag. It allows to define command to execute when hotkey
> is pressed.
>
> <HOTKEY key="^Z" cmd="exit"/>
> <HOTKEY key="^@" cmd="show"/>
>
> In this example "exit" and "show" is a klish commands defined within XML.
> The command to exit klish can be implemented like this:
> <------><COMMAND name="disable" help="Exit">
> <------><------><ACTION builtin="clish_close"/>
> <------></COMMAND>

Hmm, wait, IIUC, this would cause clish to always exit on pressing ^D.
This is a bit unusual behavior, because ^D should only cause shell to
exit if there is no text currently in the prompt.

Serj Kalichev

unread,
Dec 25, 2020, 8:01:02 AM12/25/20
to klis...@googlegroups.com
Oh, I didn't notice the dependence.
Stable klish has full-blown /debian dir with config files but I thought
your "make deb" is easy way to create debs for testing purposes etc. So
let it be.
Dependence is removed now. Fixed.

master branch is totally incompleted for such changes. However I will
apply patch.

25.12.2020 15:13, Hi-Angel пишет:

Serj Kalichev

unread,
Dec 25, 2020, 8:11:56 AM12/25/20
to klis...@googlegroups.com
Yes.
But you can write a plugin or special function in C for standard klish's
"internal" plugin that implements behavior you like. Function can
inspect currenly active command line and close klish if command line is
empty and do nothing if it's not empty.
Then you can use your special function as 'builtin'.

<ACTION builtin="clish_close_if_empty_cmd"/>


25.12.2020 15:52, Hi-Angel пишет:

Serj Kalichev

unread,
Dec 25, 2020, 8:20:10 AM12/25/20
to klis...@googlegroups.com
If you write a function for standard klish plugin (see plugins/clish
dir) with special behavior on Ctrl^D, I will apply it to repository.

25.12.2020 15:18, Hi-Angel пишет:
Reply all
Reply to author
Forward
0 new messages