summaryrefslogtreecommitdiffstats
path: root/core/modules/busybox
diff options
context:
space:
mode:
authorSimon Rettberg2020-08-26 15:36:04 +0200
committerSimon Rettberg2020-08-26 15:36:04 +0200
commit784b6581d9478ce2cc73f47317350a596bb08cc3 (patch)
tree904019bf87ab35dab0a85f4c6086b6e87a7f7d63 /core/modules/busybox
parent[run-virt] Fix load order of includes (diff)
downloadmltk-784b6581d9478ce2cc73f47317350a596bb08cc3.tar.gz
mltk-784b6581d9478ce2cc73f47317350a596bb08cc3.tar.xz
mltk-784b6581d9478ce2cc73f47317350a596bb08cc3.zip
[busybox] Fix rtcwake patch, add timeout backwars compat patch
Diffstat (limited to 'core/modules/busybox')
-rw-r--r--core/modules/busybox/module.build17
-rw-r--r--core/modules/busybox/rtcwake-compat.patch59
-rw-r--r--core/modules/busybox/timeout-compat.patch14
3 files changed, 54 insertions, 36 deletions
diff --git a/core/modules/busybox/module.build b/core/modules/busybox/module.build
index fc4a28d0..9b83e1e7 100644
--- a/core/modules/busybox/module.build
+++ b/core/modules/busybox/module.build
@@ -5,15 +5,22 @@ fetch_source() {
git clone --depth 1 "${REQUIRED_GIT}" --branch "$REQUIRED_BRANCH" src || perror "Could not clone busybox git"
fi
cde src
- git apply "${MODULE_DIR}/1_31_1-stime.patch" || perror "Could not apply stime patch for 1.31.1"
+ # Needed for newer glibc
+ if ! grep -q 'OPT_SET.*clock_settime.*CLOCK_REALTIME' "coreutils/date.c"; then
+ git apply "${MODULE_DIR}/1_31_1-stime.patch" || perror "Could not apply stime patch for 1.31.1"
+ fi
+ # Hack for backwards compat to old busybox which required -t (timeout -t [SECS] [PROG...])
+ if ! grep -q 'getopt32.*"t"' "coreutils/timeout.c"; then
+ git apply "${MODULE_DIR}/timeout-compat.patch" || perror "Could not apply timeout backwards compat patch"
+ fi
# Patch background filling if not patched yet
if ! grep -q "bfill_background" "miscutils/fbsplash.c"; then
git apply "${MODULE_DIR}/fbsplash-fillbg.patch" || perror "Could not apply busybox patch for fbsplash background filling"
fi
- # TODO fix this patch
- #if ! grep -q 'suspend.*"no"' "util-linux/rtcwake.c"; then
- # git apply "${MODULE_DIR}/rtcwake-compat.patch" || perror "Could not apply busybox patch for rtcwake compat with util-linux"
- #fi
+ # Add support for just manipulating alarm, without any standby/hibernation
+ if ! grep -q 'suspend.*"no"' "util-linux/rtcwake.c"; then
+ git apply "${MODULE_DIR}/rtcwake-compat.patch" || perror "Could not apply busybox patch for rtcwake compat with util-linux"
+ fi
# make sure Makefile allows a preset CC
if [ -n "$CC" ]; then
sed -i -r 's/^CC\s*=\s*(\S)/CC ?= \1/' Makefile || perror "Could not patch Makefile"
diff --git a/core/modules/busybox/rtcwake-compat.patch b/core/modules/busybox/rtcwake-compat.patch
index 5b6ca615..54cb02d7 100644
--- a/core/modules/busybox/rtcwake-compat.patch
+++ b/core/modules/busybox/rtcwake-compat.patch
@@ -1,8 +1,8 @@
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c
-index 8aee0cf..6d6e168 100644
+index 29c440b..1bdf906 100644
--- a/util-linux/rtcwake.c
+++ b/util-linux/rtcwake.c
-@@ -122,7 +122,7 @@ int rtcwake_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+@@ -132,7 +132,7 @@ int rtcwake_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rtcwake_main(int argc UNUSED_PARAM, char **argv)
{
unsigned opt;
@@ -11,7 +11,7 @@ index 8aee0cf..6d6e168 100644
const char *suspend = "standby";
const char *opt_seconds;
const char *opt_time;
-@@ -134,6 +134,9 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+@@ -144,6 +144,9 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
int utc = -1;
int fd;
@@ -21,19 +21,16 @@ index 8aee0cf..6d6e168 100644
#if ENABLE_LONG_OPTS
static const char rtcwake_longopts[] ALIGN1 =
"auto\0" No_argument "a"
-@@ -147,9 +150,10 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
- applet_long_options = rtcwake_longopts;
+@@ -157,7 +160,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
#endif
- /* Must have -s or -t, exclusive */
-- opt_complementary = "s:t:s--t:t--s";
-+ opt_complementary = "s--t:t--s";
- opt = getopt32(argv, "alud:m:s:t:", &rtcname, &suspend, &opt_seconds, &opt_time);
+ opt = getopt32long(argv,
+ /* Must have -s or -t, exclusive */
+- "^alud:m:s:t:" "\0" "s:t:s--t:t--s", rtcwake_longopts,
++ "^alud:m:s:t:" "\0" "s--t:t--s", rtcwake_longopts,
+ &rtcname, &suspend, &opt_seconds, &opt_time);
-+
/* this is the default
- if (opt & RTCWAKE_OPT_AUTO)
- utc = -1;
-@@ -159,13 +163,16 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+@@ -169,13 +172,16 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
if (opt & RTCWAKE_OPT_SECONDS) {
/* alarm time, seconds-to-sleep (relative) */
seconds = xatou(opt_seconds);
@@ -52,7 +49,7 @@ index 8aee0cf..6d6e168 100644
}
if (utc == -1)
-@@ -177,43 +184,51 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+@@ -187,43 +193,51 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
/* this RTC must exist and (if we'll sleep) be wakeup-enabled */
fd = rtc_xopen(&rtcname, O_RDONLY);
@@ -71,7 +68,21 @@ index 8aee0cf..6d6e168 100644
+ if (strcmp(suspend, "on") != 0)
+ if (!may_wakeup(rtcname))
+ bb_error_msg_and_die("%s not enabled for wakeup events", rtcname);
-+
+
+- if (opt & RTCWAKE_OPT_TIME) {
+- /* Correct for RTC<->system clock difference */
+- alarm_time += rtc_time - sys_time;
+- if (alarm_time < rtc_time)
+- /*
+- * Compat message text.
+- * I'd say "RTC time is already ahead of ..." instead.
+- */
+- bb_error_msg_and_die("time doesn't go backward to %s", ctime(&alarm_time));
+- } else
+- alarm_time = rtc_time + seconds + 1;
+-
+- setup_alarm(fd, &alarm_time, rtc_time);
+- sync();
+ /* relative or absolute alarm time, normalized to time_t */
+ sys_time = time(NULL);
+ {
@@ -93,21 +104,7 @@ index 8aee0cf..6d6e168 100644
+ alarm_time = rtc_time + seconds + 1;
+
+ is_general_alarm = (rtc_time + (24 * 60 * 60)) > alarm_time;
-
-- if (opt & RTCWAKE_OPT_TIME) {
-- /* Correct for RTC<->system clock difference */
-- alarm_time += rtc_time - sys_time;
-- if (alarm_time < rtc_time)
-- /*
-- * Compat message text.
-- * I'd say "RTC time is already ahead of ..." instead.
-- */
-- bb_error_msg_and_die("time doesn't go backward to %s", ctime(&alarm_time));
-- } else
-- alarm_time = rtc_time + seconds + 1;
--
-- setup_alarm(fd, &alarm_time, rtc_time);
-- sync();
++
+ setup_alarm(fd, &alarm_time, rtc_time);
+ sync();
#if 0 /*debug*/
@@ -136,7 +133,7 @@ index 8aee0cf..6d6e168 100644
/* "fake" suspend ... we'll do the delay ourselves */
unsigned long data;
-@@ -224,10 +239,27 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
+@@ -234,10 +248,27 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv)
break;
}
} while (!(data & RTC_AF));
diff --git a/core/modules/busybox/timeout-compat.patch b/core/modules/busybox/timeout-compat.patch
new file mode 100644
index 00000000..200cb007
--- /dev/null
+++ b/core/modules/busybox/timeout-compat.patch
@@ -0,0 +1,14 @@
+diff --git a/coreutils/timeout.c b/coreutils/timeout.c
+index 8b7bc2e..974854d 100644
+--- a/coreutils/timeout.c
++++ b/coreutils/timeout.c
+@@ -63,7 +63,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
+
+ /* -t SECONDS; -p PARENT_PID */
+ /* '+': stop at first non-option */
+- getopt32(argv, "+s:" USE_FOR_NOMMU("p:+"), &opt_s, &parent);
++ getopt32(argv, "+s:" USE_FOR_NOMMU("p:+") "t", &opt_s, &parent);
+ /*argv += optind; - no, wait for bb_daemonize_or_rexec! */
+
+ signo = get_signum(opt_s);
+