Skip to content

Commit

Permalink
Rework mc (midnight commander)
Browse files Browse the repository at this point in the history
- SynoCommunity#3834 add sftp support and hence add cross/libssh2
- SynoCommunity#3783/ SynoCommunity#3258 fix mouse handling
- replace usage of ncurses by slang
- add patch to fix subshell for /bin/sh shell linked to /bin/bash (subshell for /bin/sh is not supported)
- add new mc icon
- update synocli-file with reworked mc
  • Loading branch information
hgy59 committed Dec 30, 2019
1 parent 5fe26a5 commit f495225
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 44 deletions.
4 changes: 3 additions & 1 deletion cross/glib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ COMMENT = General-purpose utility library
LICENSE = GPLv2

GNU_CONFIGURE = 1
CONFIGURE_ARGS = --disable-modular-tests --disable-gtk-doc-html --disable-man --disable-libmount
CONFIGURE_ARGS = --disable-gtk-doc --disable-man --disable-libmount
CONFIGURE_ARGS += glib_cv_long_long_format=ll glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes
CONFIGURE_ARGS += GLIB_GENMARSHAL=$(WORK_DIR)/../../../native/glib/work-native/$(PKG_DIR)/gobject/glib-genmarshal
CONFIGURE_ARGS += GLIB_COMPILE_SCHEMAS=$(WORK_DIR)/../../../native/glib/work-native/$(PKG_DIR)/gio/glib-compile-schemas
CONFIGURE_ARGS += GLIB_COMPILE_RESOURCES=$(WORK_DIR)/../../../native/glib/work-native/$(PKG_DIR)/gio/glib-compile-resources

ADDITIONAL_CFLAGS = -Wno-unused-value

include ../../mk/spksrc.cross-cc.mk
2 changes: 1 addition & 1 deletion cross/glib/PLIST
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bin:bin/glib-compile-resources
bin:bin/glib-compile-schemas
rsc:bin/glib-genmarshal
rsc:bin/glib-gettextize
bin:bin/glib-mkenums
rsc:bin/glib-mkenums
bin:bin/gobject-query
bin:bin/gresource
bin:bin/gsettings
Expand Down
17 changes: 17 additions & 0 deletions cross/libssh2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PKG_NAME = libssh2
PKG_VERS = 1.9.0
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://www.libssh2.org/download/
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/openssl

HOMEPAGE = https://www.libssh2.org
COMMENT = libssh2 is a client-side C library implementing the SSH2 protocol.
LICENSE = https://www.libssh2.org/license.html

GNU_CONFIGURE = 1
CONFIGURE_ARGS = --disable-examples-build

include ../../mk/spksrc.cross-cc.mk
3 changes: 3 additions & 0 deletions cross/libssh2/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lnk:lib/libssh2.so
lnk:lib/libssh2.so.1
lib:lib/libssh2.so.1.0.1
3 changes: 3 additions & 0 deletions cross/libssh2/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
libssh2-1.9.0.tar.gz SHA1 21e98282b103307a16792e5e2d4c99beaf0b3b9c
libssh2-1.9.0.tar.gz SHA256 d5fb8bd563305fd1074dda90bd053fb2d29fc4bce048d182f96eaa466dfadafd
libssh2-1.9.0.tar.gz MD5 1beefafe8963982adc84b408b2959927
4 changes: 2 additions & 2 deletions cross/mc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = http://www.midnight-commander.org/downloads
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/glib cross/ncursesw cross/slang
DEPENDS = cross/glib cross/slang cross/libssh2

HOMEPAGE = http://www.midnight-commander.org
COMMENT = GNU Midnight Commander is a visual file manager. It\'s a feature rich full-screen text mode application that allows you to copy, move and delete files and whole directory trees, search for files and run commands in the subshell. Internal viewer and editor are included.
LICENSE = GNU GPL

GNU_CONFIGURE = 1
CONFIGURE_ARGS = fu_cv_sys_stat_statfs2_bsize=yes --with-screen=ncurses
CONFIGURE_ARGS = fu_cv_sys_stat_statfs2_bsize=yes --with-screen=slang
ADDITIONAL_CFLAGS = -O3

include ../../mk/spksrc.cross-cc.mk
85 changes: 85 additions & 0 deletions cross/mc/patches/3689-bash-subshell.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
dnl original patch provided by alllexx88 as 3689-bash-subshell-V3.patch
dnl https://midnight-commander.org/ticket/3689

--- src/subshell/common.c.org 2019-06-16 17:49:31.000000000 +0000
+++ src/subshell/common.c 2019-12-29 17:28:33.049619129 +0000
@@ -369,7 +369,7 @@
switch (mc_global.shell->type)
{
case SHELL_BASH:
- execl (mc_global.shell->path, "bash", "-rcfile", init_file, (char *) NULL);
+ execl (mc_global.shell->path, mc_global.shell->name, "-rcfile", init_file, (char *) NULL);
break;

case SHELL_ZSH:
--- lib/shell.c.org 2019-06-16 17:49:31.000000000 +0000
+++ lib/shell.c 2019-12-29 17:34:32.741113924 +0000
@@ -33,6 +33,8 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>

#include "global.h"
#include "util.h"
@@ -191,16 +193,56 @@
mc_shell->type = SHELL_NONE;
}

+/* ---------------------------------------------------------------------------------------------
+ This function returns TRUE for a shell if it has an internal variable with respective name.
+ We unset environmental variable of the same name in the child fork to make sure it's internal.
+ --------------------------------------------------------------------------------------------- */
+static gboolean
+mc_shell_internal_variable_isset (mc_shell_t * mc_shell, const char * name)
+{
+ pid_t cpid, w;
+ int status;
+ char *command;
+
+ command = g_strdup_printf ("([ -z \"${%s+x}\" ] && exit 1) || exit 0", name);
+
+ cpid = fork();
+ if (cpid == -1) {
+ /* failed to fork */
+ g_free (command);
+ return FALSE;
+ }
+
+ if (cpid == 0) { /* Code executed by child */
+ unsetenv(name);
+ execl(mc_shell->path, mc_shell->path, "-c", command, (char *) NULL);
+ /* execl failed */
+ exit(1);
+ } else { /* Code executed by parent */
+ g_free (command);
+ do {
+ w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
+ if (w == -1) {
+ /* waitpid error */
+ return FALSE;
+ }
+ } while (!WIFEXITED(status) && !WIFSIGNALED(status));
+
+ return (WIFEXITED(status)) && (WEXITSTATUS(status) == 0);
+ }
+}
+
/* --------------------------------------------------------------------------------------------- */

static void
mc_shell_recognize_path (mc_shell_t * mc_shell)
{
- /* If shell is not symlinked to busybox, it is safe to assume it is a real shell */
- if (strstr (mc_shell->path, "/bash") != NULL || getenv ("BASH") != NULL)
+ /* If shell is not symlinked to busybox, it is safe to assume it is a real shell
+ Let's assume shell is bash if BASH internal variable is set */
+ if (mc_shell_internal_variable_isset (mc_shell, "BASH"))
{
mc_shell->type = SHELL_BASH;
- mc_shell->name = "bash";
+ mc_shell->name = mc_shell->path;
}
else if (strstr (mc_shell->path, "/sh") != NULL || getenv ("SH") != NULL)
{
2 changes: 1 addition & 1 deletion cross/pcre/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LICENSE = BSD

GNU_CONFIGURE = 1
# enable UTF-8 support
# pcre is used by: mc, sshfs, irssi, bitlbee, museek-plus
# pcre is used by glib and dependents: mc, sshfs, irssi, bitlbee, museek-plus, rmlint
CONFIGURE_ARGS = --enable-utf --enable-unicode-properties

include ../../mk/spksrc.cross-cc.mk
10 changes: 2 additions & 8 deletions diyspk/mc/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPK_NAME = mc
SPK_VERS = 4.8.23
SPK_REV = 6
SPK_REV = 7
SPK_ICON = src/mc.png

DEPENDS = cross/mc
Expand All @@ -11,17 +11,11 @@ DESCRIPTION_FRE = Midnight Commander est une application en mode texte. L\'inter
RELOAD_UI = no
DISPLAY_NAME = Midnight Commander
STARTABLE = no
CHANGELOG = Update to 4.8.23
CHANGELOG = "1. Add sftp support<br>2. Fix subshell for /bin/sh as link to /bin/bash<br>3. Fix mouse support<br>4. Fix mcedit, mcview and mcdiff"

HOMEPAGE = http://www.midnight-commander.org
LICENSE = GNU GPL

SERVICE_SETUP = src/service-setup.sh

POST_STRIP_TARGET = mc_extra_install

include ../../mk/spksrc.spk.mk

.PHONY: mc_extra_install
mc_extra_install:
install -m 755 ../../spk/synocli-file/src/mc-utf8 $(STAGING_DIR)/bin/mc-utf8
Binary file modified diyspk/mc/src/mc.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 16 additions & 10 deletions diyspk/mc/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
COMMANDS="mc mcedit mcdiff mcview"

service_postinst ()
{
# Use the mc-utf8 command for mc
ln -s ${SYNOPKG_PKGDEST}/bin/mc-utf8 /usr/local/bin/mc
ln -s ${SYNOPKG_PKGDEST}/bin/mc-utf8 /usr/local/bin/mcedit
ln -s ${SYNOPKG_PKGDEST}/bin/mc-utf8 /usr/local/bin/mcdiff
ln -s ${SYNOPKG_PKGDEST}/bin/mc-utf8 /usr/local/bin/mcview
for cmd in $COMMANDS
do
if [ -e "${SYNOPKG_PKGDEST}/bin/$cmd" ]; then
ln -s "${SYNOPKG_PKGDEST}/bin/$cmd" "/usr/local/bin/$cmd"
fi
done
}

service_postuninst ()
{
# Remove symlinks
rm -f /usr/local/bin/mc
rm -f /usr/local/bin/mcedit
rm -f /usr/local/bin/mcdiff
rm -f /usr/local/bin/mcview
for cmd in $COMMANDS
do
if [ -L "/usr/local/bin/$cmd" ]; then
if [ "$(readlink /usr/local/bin/$cmd)" == "${SYNOPKG_PKGDEST}/bin/$cmd" ]; then
rm -f "/usr/local/bin/$cmd"
fi
fi
done
}
2 changes: 1 addition & 1 deletion spk/synocli-disk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ STARTABLE = no
CHANGELOG = "1. Initial release"

HOMEPAGE = https://github.com/SynoCommunity/spksrc/wiki/FAQ-SynoCliDisk
LICENSE = Each tool is licensed under its respective license.
LICENSE = Each tool is licensed under it\'s respective license.

SERVICE_SETUP = src/service-setup.sh

Expand Down
19 changes: 6 additions & 13 deletions spk/synocli-file/Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
SPK_NAME = synocli-file
SPK_VERS = 1.0
SPK_REV = 1
SPK_REV = 2
SPK_ICON = src/synocli-file.png

include ../../mk/spksrc.common.mk

DEPENDS = cross/less cross/tree cross/ncdu cross/jdupes cross/rhash cross/mc cross/nano cross/file
DEPENDS += cross/detox cross/rmlint
ifneq ($(findstring $(ARCH), powerpc ppc824x ppc853x ppc854x $(ARM5_ARCHES)),$(ARCH))
# to build rnm, GCC >= 4.8 is required, but not contained in older toolchains.
DEPENDS += cross/rnm
endif

MAINTAINER = SynoCommunity
DISPLAY_NAME = SynoCli File Tools
ifneq ($(findstring $(ARCH), powerpc ppc824x ppc853x ppc854x $(ARM5_ARCHES)),$(ARCH))
# to build rnm, GCC >= 4.8 is required, but not contained in older toolchains.
DEPENDS += cross/rnm
DESCRIPTION = "SynoCli File Tools provides a set of small command-line utilities: less, tree, ncdu, jdupes, rhash, mc \(midnight commander\), nano, file, detox, rmlint, rnm."
else
DESCRIPTION = "SynoCli File Tools provides a set of small command-line utilities: less, tree, ncdu, jdupes, rhash, mc \(midnight commander\), nano, file, detox, rmlint."
endif

STARTABLE = no
CHANGELOG = "1. Initial release"
CHANGELOG = "Midnight-Commander: add sftp support; Fix subshell; fix mouse handling; fix mcedit, mcview and mcdiff"

HOMEPAGE = https://github.com/SynoCommunity/spksrc/wiki/FAQ-SynoCliFile
LICENSE = Each tool is licensed by it\'s own.
HOMEPAGE = https://github.com/SynoCommunity/spksrc/wiki/FAQ-SynoCliFile
LICENSE = Each tool is licensed under it\'s respective license.

SERVICE_SETUP = src/service-setup.sh

POST_STRIP_TARGET = synoclifile_extra_install

include ../../mk/spksrc.spk.mk

.PHONY: synoclifile_extra_install
synoclifile_extra_install:
install -m 755 src/mc-utf8 $(STAGING_DIR)/bin/mc-utf8
5 changes: 0 additions & 5 deletions spk/synocli-file/src/mc-utf8

This file was deleted.

4 changes: 2 additions & 2 deletions spk/synocli-net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ DISPLAY_NAME = SynoCli Network Tools
STARTABLE = no
CHANGELOG = "1. Add rsync"

HOMEPAGE = https://github.com/SynoCommunity/spksrc/wiki/FAQ-SynoCliNet
LICENSE = Mixed
HOMEPAGE = https://github.com/SynoCommunity/spksrc/wiki/FAQ-SynoCliNet
LICENSE = Each tool is licensed under it\'s respective license.

SERVICE_SETUP = src/service-setup.sh

Expand Down

0 comments on commit f495225

Please sign in to comment.