Skip to content

Commit

Permalink
Merge branch 'jb53061_save_history_on_signal' into 'master'
Browse files Browse the repository at this point in the history
Write history on SIGHUP and use git formatting for all patches

See merge request mer-core/busybox!32
  • Loading branch information
Matti Kosola committed Feb 17, 2021
2 parents e1fc2ac + 19036f9 commit 2dd54be
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 34 deletions.
@@ -1,4 +1,4 @@
From 26fec4283c54d71eb96153e8e8cd0a3bf0e6dc8b Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kalle Jokiniemi <kalle.jokiniemi@jolla.com>
Date: Thu, 16 Jul 2015 11:46:16 +0300
Subject: [PATCH] Copy extended attributes if -p flag is provided to cp, mv.
Expand All @@ -23,13 +23,13 @@ Signed-off-by: Igor Zhbanov <igor.zhbanov@jolla.com>
include/libbb.h | 3 +
libbb/Config.src | 6 ++
libbb/Kbuild.src | 2 +
libbb/copy_file.c | 8 +++
libbb/copy_file.c | 7 +++
libbb/copy_file_attr.c | 125 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 144 insertions(+)
5 files changed, 143 insertions(+)
create mode 100644 libbb/copy_file_attr.c

diff --git a/include/libbb.h b/include/libbb.h
index d4ba031df..3c257c000 100644
index 021100db1..4cbd04382 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -429,6 +429,9 @@ extern int remove_file(const char *path, int flags) FAST_FUNC;
Expand Down Expand Up @@ -67,10 +67,10 @@ index 8c9ba8cca..89be6e86d 100644
+
+lib-$(CONFIG_XATTR) += copy_file_attr.o
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 1b8befd65..279e4a6e4 100644
index 2d6557cd4..23bc1c0f1 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -434,6 +435,13 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
@@ -434,6 +434,13 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
source_stat.st_mode &= ~(S_ISUID | S_ISGID);
bb_perror_msg("can't preserve %s of '%s'", "ownership", dest);
}
Expand Down Expand Up @@ -216,5 +216,5 @@ index 000000000..180b0311e
+ return ret;
+}
--
2.19.1
2.29.2

13 changes: 6 additions & 7 deletions rpm/0002-applets-Busybox-in-usr-bin-instead-of-bin.patch
@@ -1,14 +1,14 @@
From 473e5c4022bc0e3c793063ed5002b40fca988ee3 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= <tomi.leppanen@jolla.com>
Date: Fri, 16 Aug 2019 11:51:33 +0300
Subject: [PATCH] applets: Busybox in /usr/bin instead of /bin

---
applets/install.sh | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
applets/install.sh | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/applets/install.sh b/applets/install.sh
index 415896893..2b73f1a02 100755
index 415896893..04f0526c8 100755
--- a/applets/install.sh
+++ b/applets/install.sh
@@ -60,8 +60,8 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ x"$DO_INSTALL_LIBS" != x"n" ]; then
Expand Down Expand Up @@ -61,9 +61,8 @@ index 415896893..2b73f1a02 100755
bb_path="busybox"
;;
- /sbin)
- bb_path="../bin/busybox"
+ /usr/sbin)
+ bb_path="../bin/busybox"
bb_path="../bin/busybox"
;;
- /usr/bin | /usr/sbin)
- bb_path="../../bin/busybox"
Expand All @@ -73,5 +72,5 @@ index 415896893..2b73f1a02 100755
*)
echo "Unknown installation directory: $appdir"
--
2.21.0
2.29.2

@@ -1,8 +1,11 @@
commit 0972a8d9725e1fa65fdfb87a5d0509cb8bef0bde (HEAD)
Author: Boleslaw Tokarski <boleslaw.tokarski@jollamobile.com>
Date: Tue Aug 4 15:22:35 2020 +0100
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Boleslaw Tokarski <boleslaw.tokarski@jollamobile.com>
Date: Thu, 11 Feb 2021 16:01:11 +0200
Subject: [PATCH] Align watch with what is in procps-ng

Align watch with what is in procps-ng
---
procps/watch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/procps/watch.c b/procps/watch.c
index 059eb1dda..3ea55fd81 100644
Expand All @@ -17,3 +20,6 @@ index 059eb1dda..3ea55fd81 100644

//kbuild:lib-$(CONFIG_WATCH) += watch.o

--
2.29.2

@@ -1,4 +1,4 @@
From d192ebbee237f3a89f1fe50f092e4b43c1dd6ac5 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <bjorn.bidar@jolla.com>
Date: Thu, 3 Sep 2020 16:00:07 +0300
Subject: [PATCH] ash: Load $ENV file also if $SSH_CLIENT/SSH2_CLIENT is preset
Expand All @@ -15,10 +15,10 @@ Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index ecb9b132b..797763187 100644
index e3bbac9a0..88a3ee6f8 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14467,7 +14467,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
@@ -14360,7 +14360,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
#ifndef linux
getuid() == geteuid() && getgid() == getegid() &&
#endif
Expand All @@ -28,5 +28,5 @@ index ecb9b132b..797763187 100644
const char *shinit = lookupvar("ENV");
if (shinit != NULL && *shinit != '\0')
--
2.28.0
2.29.2

@@ -1,4 +1,4 @@
From 73514579b4bb1668b17075440dfaa2f882a79c96 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <bjorn.bidar@jolla.com>
Date: Fri, 30 Oct 2020 12:18:01 +0200
Subject: [PATCH] ash: job: option to restore term io after job is
Expand All @@ -17,12 +17,12 @@ Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index ecb9b132b..97bf55994 100644
index 88a3ee6f8..fabecdfe0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -77,6 +77,14 @@
@@ -72,6 +72,14 @@
//config: default y
//config: depends on SHELL_ASH
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config:
+//config:config ASH_JOB_RESTORE_TERM_IOS
+//config: bool "Restore termio"
Expand All @@ -35,15 +35,15 @@ index ecb9b132b..97bf55994 100644
//config:config ASH_ALIAS
//config: bool "Alias support"
//config: default y
@@ -3796,7 +3804,7 @@ static unsigned njobs; //4
/* current job */
static struct job *curjob; //lots
@@ -3758,7 +3766,7 @@ static struct job *curjob; //lots
/* number of presumed living untracked jobs */
static int jobless; //4

-#if 0
+#if ENABLE_ASH_JOB_RESTORE_TERM_IOS
/* Bash has a feature: it restores termios after a successful wait for
* a foreground job which had at least one stopped or sigkilled member.
* The probable rationale is that SIGSTOP and SIGKILL can preclude task from
--
2.29.1
2.29.2

67 changes: 67 additions & 0 deletions rpm/0006-ash-Write-history-on-SIGHUP.patch
@@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= <tomi.leppanen@jolla.com>
Date: Thu, 11 Feb 2021 18:08:59 +0200
Subject: [PATCH] ash: Write history on SIGHUP
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If FEATURE_EDITING_SAVE_ON_EXIT is enabled, then write history on
SIGHUP. This should allow most terminals to save history when closing
window. Works also on SSH connection.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
---
shell/ash.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/shell/ash.c b/shell/ash.c
index fabecdfe0..917b93fec 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3626,6 +3626,19 @@ signal_handler(int signo)
return;
}

+#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
+ if (signo == SIGHUP) {
+ /*
+ * Terminal was closed, call exitshell() to write history etc.
+ * unless there is a trap set, in which case just save the history
+ */
+ if (!trap[SIGHUP])
+ exitshell();
+ else if (iflag && line_input_state)
+ save_history(line_input_state);
+ }
+#endif
+
gotsig[signo - 1] = 1;
pending_sig = signo;

@@ -3698,6 +3711,14 @@ setsignal(int signo)
if (signo == SIGCHLD)
new_act = S_CATCH;

+#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
+ /*
+ * Catch SIGHUP to write history on terminal close
+ */
+ if (signo == SIGHUP && iflag)
+ new_act = S_CATCH;
+#endif
+
t = &sigmode[signo - 1];
cur_act = *t;
if (cur_act == 0) {
@@ -9545,6 +9566,7 @@ setinteractive(int on)
setsignal(SIGINT);
setsignal(SIGQUIT);
setsignal(SIGTERM);
+ setsignal(SIGHUP);
if (is_interactive > 1) {
#if !ENABLE_FEATURE_SH_EXTRA_QUIET
/* Looks like they want an interactive shell */
--
2.29.2

9 changes: 5 additions & 4 deletions rpm/busybox.spec
Expand Up @@ -10,9 +10,10 @@ Source3: busybox-sailfish.config
Source4: set_ps1.sh
Patch0: 0001-Copy-extended-attributes-if-p-flag-is-provided-to-cp.patch
Patch1: 0002-applets-Busybox-in-usr-bin-instead-of-bin.patch
Patch2: 0003-applets-watch-in-usr-bin.patch
Patch3: 0001-ash-Load-ENV-file-also-if-SSH_CLIENT-SSH2_CLIENT-is-.patch
Patch4: 0001-ash-job-option-to-restore-term-io-after-job-is-stopp.patch
Patch2: 0003-Align-watch-with-what-is-in-procps-ng.patch
Patch3: 0004-ash-Load-ENV-file-also-if-SSH_CLIENT-SSH2_CLIENT-is-.patch
Patch4: 0005-ash-job-option-to-restore-term-io-after-job-is-stopp.patch
Patch5: 0006-ash-Write-history-on-SIGHUP.patch
URL: https://git.sailfishos.org/mer-core/busybox
BuildRequires: glibc-static
BuildRequires: libselinux-static libsepol-static
Expand Down Expand Up @@ -299,8 +300,8 @@ mkdir -p %{buildroot}/usr/bin
install -m 755 busybox %{buildroot}/usr/bin/busybox
install -m 644 -D %{SOURCE1} %{buildroot}%{_unitdir}/udhcpd.service
applets/install.sh %{buildroot} --symlinks
rm -f %{buildroot}/sbin/udhcpc
# Cleanup some symlinks
rm -f %{buildroot}/sbin/udhcpc
rm -f %{buildroot}/bin/base64

install -m 644 -D %{SOURCE4} %{buildroot}/%{_sysconfdir}/profile.d/set_ps1.sh
Expand Down

0 comments on commit 2dd54be

Please sign in to comment.