From 47b93e57015fc9857733f27ee9bdd4dded82d0f5 Mon Sep 17 00:00:00 2001 From: rcitach Date: Mon, 11 Nov 2024 13:50:32 +0800 Subject: [PATCH] add version get and add busybox inittab --- .../patches/1.35.0/01_adapt_smart.diff | 455 ++++++------------ repo/packages/b/busybox/port/1.35.0/inittab | 9 + repo/packages/b/busybox/scripts/deploy.lua | 9 +- repo/packages/b/busybox/xmake.lua | 2 +- tools/scripts/tasks/smart-rootfs/on_run.lua | 6 +- 5 files changed, 170 insertions(+), 311 deletions(-) create mode 100644 repo/packages/b/busybox/port/1.35.0/inittab diff --git a/repo/packages/b/busybox/patches/1.35.0/01_adapt_smart.diff b/repo/packages/b/busybox/patches/1.35.0/01_adapt_smart.diff index b0ddae1..b6b6675 100644 --- a/repo/packages/b/busybox/patches/1.35.0/01_adapt_smart.diff +++ b/repo/packages/b/busybox/patches/1.35.0/01_adapt_smart.diff @@ -1,27 +1,21 @@ -diff --git a/archival/bbunzip.c b/archival/bbunzip.c -index 0ac059c19..d0356b090 100644 ---- a/archival/bbunzip.c -+++ b/archival/bbunzip.c -@@ -132,10 +132,12 @@ int FAST_FUNC bbunpack(char **argv, +diff --ignore-all-space -urN a/archival/bbunzip.c busybox-1.35.0/archival/bbunzip.c +--- a/archival/bbunzip.c 2024-11-08 13:29:16.684496786 +0800 ++++ busybox-1.35.0/archival/bbunzip.c 2024-11-08 13:35:07.025095805 +0800 +@@ -132,8 +132,10 @@ xfunc_die(); } - if (!(option_mask32 & BBUNPK_OPT_STDOUT)) -- xclose(STDOUT_FILENO); /* with error check! */ + if (!(option_mask32 & BBUNPK_OPT_STDOUT)) { -+ xclose(STDOUT_FILENO); /* with error check! */ + xclose(STDOUT_FILENO); /* with error check! */ + xclose(STDIN_FILENO); + } -- if (filename) { -+ if (filename) { + if (filename) { char *del = new_name; - - if (status >= 0) { -diff --git a/coreutils/ls.c b/coreutils/ls.c -index 48f5eb482..1c8699279 100644 ---- a/coreutils/ls.c -+++ b/coreutils/ls.c +diff --ignore-all-space -urN a/coreutils/ls.c busybox-1.35.0/coreutils/ls.c +--- a/coreutils/ls.c 2024-11-08 13:29:16.680496621 +0800 ++++ busybox-1.35.0/coreutils/ls.c 2024-11-08 13:35:07.025095805 +0800 @@ -185,7 +185,7 @@ # define IF_NOT_FEATURE_LS_TIMESTAMPS(...) #endif @@ -31,7 +25,7 @@ index 48f5eb482..1c8699279 100644 enum { TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */ -@@ -1066,6 +1066,9 @@ int ls_main(int argc UNUSED_PARAM, char **argv) +@@ -1066,6 +1066,9 @@ unsigned dnfiles; unsigned dndirs; unsigned i; @@ -41,31 +35,26 @@ index 48f5eb482..1c8699279 100644 #if ENABLE_FEATURE_LS_COLOR /* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */ /* coreutils 6.10: -@@ -1198,10 +1201,16 @@ int ls_main(int argc UNUSED_PARAM, char **argv) +@@ -1198,9 +1201,15 @@ } argv += optind; -- if (!argv[0]) -- *--argv = (char*)"."; -- -- if (argv[1]) + value = stat(list_buff, &stat_buf); + if (!value) { + if (!argv[0]) + *--argv = list_buff; + } + else { -+ if (!argv[0]) -+ *--argv = (char *)"."; + if (!argv[0]) + *--argv = (char*)"."; +- + } -+ if (argv[1]) + if (argv[1]) G.show_dirname = 1; /* 2 or more items? label directories */ - /* stuff the command line file names into a dnode array */ -diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c -index f7fcd88bf..98670f567 100644 ---- a/e2fsprogs/tune2fs.c -+++ b/e2fsprogs/tune2fs.c +diff --ignore-all-space -urN a/e2fsprogs/tune2fs.c busybox-1.35.0/e2fsprogs/tune2fs.c +--- a/e2fsprogs/tune2fs.c 2024-11-08 13:29:16.700497446 +0800 ++++ busybox-1.35.0/e2fsprogs/tune2fs.c 2024-11-08 13:35:07.025095805 +0800 @@ -36,7 +36,7 @@ //usage: "Adjust filesystem options on ext[23] filesystems" @@ -75,54 +64,31 @@ index f7fcd88bf..98670f567 100644 #include "bb_e2fs_defs.h" enum { -diff --git a/editors/patch.c b/editors/patch.c -index 110176630..28e53b949 100644 ---- a/editors/patch.c -+++ b/editors/patch.c -@@ -163,7 +163,8 @@ static void finish_oldfile(void) +diff --ignore-all-space -urN a/editors/patch.c busybox-1.35.0/editors/patch.c +--- a/editors/patch.c 2024-11-08 13:29:16.688496951 +0800 ++++ busybox-1.35.0/editors/patch.c 2024-11-08 13:35:07.025095805 +0800 +@@ -163,6 +163,7 @@ if (!ENABLE_LONG_OPTS || TT.tempname[0]) { /* not --dry-run? */ temp = xstrdup(TT.tempname); temp[strlen(temp) - 6] = '\0'; -- rename(TT.tempname, temp); + xunlink(temp); -+ rename(TT.tempname, temp); + rename(TT.tempname, temp); free(temp); free(TT.tempname); - } -diff --git a/include/libbb.h b/include/libbb.h -index a48782832..fb8860ca6 100644 ---- a/include/libbb.h -+++ b/include/libbb.h -@@ -2248,7 +2248,7 @@ extern const char bb_path_wtmp_file[] ALIGN1; - - /* Busybox mount uses either /proc/mounts or /etc/mtab to - * get the list of currently mounted filesystems */ --#define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts") -+#define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/etc/mtab") - - #define bb_path_passwd_file _PATH_PASSWD - #define bb_path_group_file _PATH_GROUP -diff --git a/init/halt.c b/init/halt.c -index fe3cb9e75..a039708ae 100644 ---- a/init/halt.c -+++ b/init/halt.c -@@ -222,9 +222,12 @@ int halt_main(int argc UNUSED_PARAM, char **argv) - /* talk to init */ - if (!ENABLE_FEATURE_CALL_TELINIT) { - /* bbox init assumed */ -+ #if 0 +diff --ignore-all-space -urN a/init/halt.c busybox-1.35.0/init/halt.c +--- a/init/halt.c 2024-11-08 13:29:16.680496621 +0800 ++++ busybox-1.35.0/init/halt.c 2024-11-08 13:35:17.307550683 +0800 +@@ -225,6 +225,7 @@ rc = kill(1, signals[which]); if (init_was_not_there()) rc = kill(1, signals[which]); -+ #endif + rc = reboot(magic[which]); } else { /* SysV style init assumed */ /* runlevels: -diff --git a/init/init.c b/init/init.c -index efab5dcb4..a62f1e8df 100644 ---- a/init/init.c -+++ b/init/init.c +diff --ignore-all-space -urN a/init/init.c busybox-1.35.0/init/init.c +--- a/init/init.c 2024-11-08 13:29:16.680496621 +0800 ++++ busybox-1.35.0/init/init.c 2024-11-08 13:35:07.029097073 +0800 @@ -131,7 +131,7 @@ #include "common_bufsiz.h" #include @@ -132,15 +98,13 @@ index efab5dcb4..a62f1e8df 100644 # include #endif #include "reboot.h" /* reboot() constants */ -diff --git a/libbb/copyfd.c b/libbb/copyfd.c -index 7f9d92ea9..e88c62e5a 100644 ---- a/libbb/copyfd.c -+++ b/libbb/copyfd.c -@@ -84,7 +84,14 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size) +diff --ignore-all-space -urN a/libbb/copyfd.c busybox-1.35.0/libbb/copyfd.c +--- a/libbb/copyfd.c 2024-11-08 13:29:16.696497281 +0800 ++++ busybox-1.35.0/libbb/copyfd.c 2024-11-08 13:35:07.029097073 +0800 +@@ -84,6 +84,13 @@ } } #endif -- rd = safe_read(src_fd, buffer, + char tmpstr[10]; + if (buffer[0] != NULL && !strcmp(applet_name, "zcat")) { + memset(buffer, '\0', sizeof(buffer)); @@ -148,15 +112,13 @@ index 7f9d92ea9..e88c62e5a 100644 + sprintf(tmpstr, "%c", buffer[0]); + break; + } -+ rd = safe_read(src_fd, buffer, + rd = safe_read(src_fd, buffer, size > buffer_size ? buffer_size : size); if (rd < 0) { - bb_simple_perror_msg(bb_msg_read_error); -diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c -index fe13f7211..8bddb20f1 100644 ---- a/libbb/find_pid_by_name.c -+++ b/libbb/find_pid_by_name.c -@@ -85,16 +85,19 @@ pid_t* FAST_FUNC find_pid_by_name(const char *procName) +diff --ignore-all-space -urN a/libbb/find_pid_by_name.c busybox-1.35.0/libbb/find_pid_by_name.c +--- a/libbb/find_pid_by_name.c 2024-11-08 13:29:16.696497281 +0800 ++++ busybox-1.35.0/libbb/find_pid_by_name.c 2024-11-08 13:35:07.029097073 +0800 +@@ -85,16 +85,19 @@ procps_status_t* p = NULL; pidList = xzalloc(sizeof(*pidList)); @@ -177,10 +139,9 @@ index fe13f7211..8bddb20f1 100644 ) { pidList = xrealloc_vector(pidList, 2, i); pidList[i++] = p->pid; -diff --git a/libbb/loop.c b/libbb/loop.c -index cb8fa2442..58677486b 100644 ---- a/libbb/loop.c -+++ b/libbb/loop.c +diff --ignore-all-space -urN a/libbb/loop.c busybox-1.35.0/libbb/loop.c +--- a/libbb/loop.c 2024-11-08 13:29:16.696497281 +0800 ++++ busybox-1.35.0/libbb/loop.c 2024-11-08 13:35:07.029097073 +0800 @@ -8,14 +8,194 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ @@ -378,11 +339,10 @@ index cb8fa2442..58677486b 100644 typedef struct loop_info64 bb_loop_info; # define BB_LOOP_SET_STATUS LOOP_SET_STATUS64 # define BB_LOOP_GET_STATUS LOOP_GET_STATUS64 -diff --git a/libbb/wfopen.c b/libbb/wfopen.c -index 1c7f7f3d7..a3f255b0c 100644 ---- a/libbb/wfopen.c -+++ b/libbb/wfopen.c -@@ -12,7 +12,7 @@ FILE* FAST_FUNC fopen_or_warn(const char *path, const char *mode) +diff --ignore-all-space -urN a/libbb/wfopen.c busybox-1.35.0/libbb/wfopen.c +--- a/libbb/wfopen.c 2024-11-08 13:29:16.696497281 +0800 ++++ busybox-1.35.0/libbb/wfopen.c 2024-11-08 13:35:07.029097073 +0800 +@@ -12,7 +12,7 @@ { FILE *fp = fopen(path, mode); if (!fp) { @@ -391,11 +351,9 @@ index 1c7f7f3d7..a3f255b0c 100644 //errno = 0; /* why? */ } return fp; -diff --git a/miscutils/devmem2.c b/miscutils/devmem2.c -new file mode 100644 -index 000000000..8a9cf44fd ---- /dev/null -+++ b/miscutils/devmem2.c +diff --ignore-all-space -urN a/miscutils/devmem2.c busybox-1.35.0/miscutils/devmem2.c +--- a/miscutils/devmem2.c 1970-01-01 08:00:00.000000000 +0800 ++++ busybox-1.35.0/miscutils/devmem2.c 2024-11-08 13:35:07.029097073 +0800 @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) @@ -582,10 +540,9 @@ index 000000000..8a9cf44fd + + return EXIT_SUCCESS; +} -diff --git a/miscutils/partprobe.c b/miscutils/partprobe.c -index 0fb1927b7..5a2915ef5 100644 ---- a/miscutils/partprobe.c -+++ b/miscutils/partprobe.c +diff --ignore-all-space -urN a/miscutils/partprobe.c busybox-1.35.0/miscutils/partprobe.c +--- a/miscutils/partprobe.c 2024-11-08 13:29:16.688496951 +0800 ++++ busybox-1.35.0/miscutils/partprobe.c 2024-11-08 13:35:07.029097073 +0800 @@ -14,7 +14,7 @@ //kbuild:lib-$(CONFIG_PARTPROBE) += partprobe.o @@ -595,10 +552,9 @@ index 0fb1927b7..5a2915ef5 100644 #include "libbb.h" #ifndef BLKRRPART # define BLKRRPART _IO(0x12,95) -diff --git a/networking/ftpd.c b/networking/ftpd.c -index 0d6a289c7..358b5aae1 100644 ---- a/networking/ftpd.c -+++ b/networking/ftpd.c +diff --ignore-all-space -urN a/networking/ftpd.c busybox-1.35.0/networking/ftpd.c +--- a/networking/ftpd.c 2024-11-08 13:29:16.692497116 +0800 ++++ busybox-1.35.0/networking/ftpd.c 2024-11-08 13:35:07.029097073 +0800 @@ -131,6 +131,7 @@ #define STR1(s) #s #define STR(s) STR1(s) @@ -607,7 +563,7 @@ index 0d6a289c7..358b5aae1 100644 /* Convert a constant to 3-digit string, packed into uint32_t */ enum { /* Shift for Nth decimal digit */ -@@ -154,6 +155,8 @@ enum { +@@ -154,6 +155,8 @@ #define MSG_OK "Operation successful\r\n" #define MSG_ERR "Error\r\n" @@ -616,29 +572,25 @@ index 0d6a289c7..358b5aae1 100644 struct globals { int pasv_listen_fd; -@@ -327,26 +330,133 @@ static void +@@ -327,25 +330,132 @@ handle_pwd(void) { char *cwd, *response; - -- cwd = xrealloc_getcwd_or_warn(NULL); + int cwd_len = 0; + int response_len = 0; + int basedir_len = 0; + basedir_len = strlen(basedir); -+ cwd = xrealloc_getcwd_or_warn(NULL); + cwd = xrealloc_getcwd_or_warn(NULL); if (cwd == NULL) cwd = xstrdup(""); -- /* We have to promote each " to "" */ + cwd_len = strlen(cwd); -+ /* We have to promote each " to "" */ + /* We have to promote each " to "" */ response = escape_text(" \"", cwd, ('"' << 8) + '"'); -- free(cwd); -- cmdio_write(STRNUM32(FTP_PWDOK), response); -- free(response); + response_len = strlen(response); -+ free(cwd); + free(cwd); +- cmdio_write(STRNUM32(FTP_PWDOK), response); + char buff[response_len]; + memset(buff, sizeof(buff), response_len); + if (cwd_len <= basedir_len) { @@ -653,17 +605,12 @@ index 0d6a289c7..358b5aae1 100644 + buff[response_len - basedir_len] = '\0'; + cmdio_write(STRNUM32(FTP_PWDOK), buff); + } -+ free(response); + free(response); } static void handle_cwd(void) { -- if (!G.ftp_arg || chdir(G.ftp_arg) != 0) { -- WRITE_ERR(FTP_FILEFAIL); -- return; -- } -- WRITE_OK(FTP_CWDOK); + char buff[500]; + char buff_path[500]; + int len_basedir = 0; @@ -723,12 +670,12 @@ index 0d6a289c7..358b5aae1 100644 + WRITE_ERR(FTP_FILEFAIL); + return; + } -+ if (!G.ftp_arg || chdir(G.ftp_arg) != 0) { + if (!G.ftp_arg || chdir(G.ftp_arg) != 0) { + memset(list_buff, 0, sizeof(list_buff)); + memcpy(list_buff, buff, strlen(buff)); -+ WRITE_ERR(FTP_FILEFAIL); -+ return; -+ } + WRITE_ERR(FTP_FILEFAIL); + return; + } + memset(list_buff, 0, sizeof(list_buff)); + buff_len = strlen(buff); + memcpy(list_buff, buff, buff_len); @@ -757,55 +704,40 @@ index 0d6a289c7..358b5aae1 100644 + return; + } + -+ WRITE_OK(FTP_CWDOK); + WRITE_OK(FTP_CWDOK); } - static void -@@ -754,15 +864,20 @@ handle_dir_common(int opts) +@@ -754,11 +864,16 @@ FILE *ls_fp; char *line; int ls_fd; + int number = 0; -- if (!(opts & USE_CTRL_CONN) && !port_or_pasv_was_seen()) -+ if (!(opts & USE_CTRL_CONN) && !port_or_pasv_was_seen()) + if (!(opts & USE_CTRL_CONN) && !port_or_pasv_was_seen()) return; /* port_or_pasv_was_seen emitted error response */ ls_fd = popen_ls((opts & LONG_LISTING) ? "-lA" : "-1A"); -- ls_fp = xfdopen_for_read(ls_fd); + if (ls_fd < 0) { + WRITE_OK(FTP_TRANSFEROK); + return; + } -+ ls_fp = xfdopen_for_read(ls_fd); + ls_fp = xfdopen_for_read(ls_fd); /* FIXME: filenames with embedded newlines are mishandled */ -- if (opts & USE_CTRL_CONN) { -+ if (opts & USE_CTRL_CONN) { - /* STAT */ - cmdio_write_raw(STR(FTP_STATFILE_OK)"-File status:\r\n"); - while (1) { -@@ -783,7 +898,10 @@ handle_dir_common(int opts) +@@ -783,6 +898,9 @@ while (1) { unsigned len; -- line = xmalloc_fgets(ls_fp); + if (number >= totalnum) + break; + number++; -+ line = xmalloc_fgets(ls_fp); + line = xmalloc_fgets(ls_fp); if (!line) break; - /* I've seen clients complaining when they -@@ -902,21 +1020,55 @@ handle_mkd(void) +@@ -902,20 +1020,54 @@ static void handle_rmd(void) { -- if (!G.ftp_arg || rmdir(G.ftp_arg) != 0) { -- WRITE_ERR(FTP_FILEFAIL); -- return; -- } -- WRITE_OK(FTP_RMDIROK); + char buff[200]; + int basedir_len = 0; + int arg_len = 0; @@ -822,22 +754,18 @@ index 0d6a289c7..358b5aae1 100644 + } + } + else { -+ if (!G.ftp_arg || rmdir(G.ftp_arg) != 0) { -+ WRITE_ERR(FTP_FILEFAIL); -+ return; -+ } + if (!G.ftp_arg || rmdir(G.ftp_arg) != 0) { + WRITE_ERR(FTP_FILEFAIL); + return; + } + } -+ WRITE_OK(FTP_RMDIROK); + WRITE_OK(FTP_RMDIROK); } static void handle_dele(void) { - if (!G.ftp_arg || unlink(G.ftp_arg) != 0) { -- WRITE_ERR(FTP_FILEFAIL); -- return; -- } -- WRITE_OK(FTP_DELEOK); + char buff[200]; + int basedir_len = 0; + int arg_len = 0; @@ -849,9 +777,9 @@ index 0d6a289c7..358b5aae1 100644 + strncpy(buff + basedir_len, G.ftp_arg, arg_len); + buff[basedir_len + arg_len] = '\0'; + if (!G.ftp_arg || rmdir(buff) != 0) { -+ WRITE_ERR(FTP_FILEFAIL); -+ return; -+ } + WRITE_ERR(FTP_FILEFAIL); + return; + } + } + else { + if (!G.ftp_arg || rmdir(G.ftp_arg) != 0) { @@ -859,11 +787,10 @@ index 0d6a289c7..358b5aae1 100644 + return; + } + } -+ WRITE_OK(FTP_DELEOK); + WRITE_OK(FTP_DELEOK); } - static void -@@ -1169,6 +1321,53 @@ enum { +@@ -1169,6 +1321,53 @@ OPT_w = (1 << (BIT_A + 3)) * ENABLE_FEATURE_FTPD_WRITE, }; @@ -917,17 +844,15 @@ index 0d6a289c7..358b5aae1 100644 int ftpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ftpd_main(int argc UNUSED_PARAM, char **argv) { -@@ -1180,7 +1379,8 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv) +@@ -1180,6 +1379,7 @@ unsigned verbose_S; smallint opts; -- INIT_G(); + int value = 0; -+ INIT_G(); + INIT_G(); abs_timeout = 1 * 60 * 60; - verbose_S = 0; -@@ -1296,13 +1496,14 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv) +@@ -1296,13 +1496,14 @@ #endif argv += optind; if (argv[0]) { @@ -944,112 +869,38 @@ index 0d6a289c7..358b5aae1 100644 #if !BB_MMU else { close(G.root_fd); -@@ -1362,50 +1563,49 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv) +@@ -1362,9 +1563,9 @@ * respectively." */ -- while (1) { -- uint32_t cmdval = cmdio_get_cmd_and_arg(); ++ memcpy(list_buff, basedir, strlen(basedir)); + while (1) { + uint32_t cmdval = cmdio_get_cmd_and_arg(); - -- if (cmdval == const_QUIT) { -- WRITE_OK(FTP_GOODBYE); -- return 0; -- } -- else if (cmdval == const_USER) -- /* This would mean "ok, now give me PASS". */ -- /*WRITE_OK(FTP_GIVEPWORD);*/ -- /* vsftpd can be configured to not require that, -- * and this also saves one roundtrip: -- */ -- WRITE_OK(FTP_LOGINOK); -- else if (cmdval == const_PASS) -- WRITE_OK(FTP_LOGINOK); -- else if (cmdval == const_NOOP) -- WRITE_OK(FTP_NOOPOK); -- else if (cmdval == const_TYPE) -- WRITE_OK(FTP_TYPEOK); -- else if (cmdval == const_STRU) -- WRITE_OK(FTP_STRUOK); -- else if (cmdval == const_MODE) -- WRITE_OK(FTP_MODEOK); -- else if (cmdval == const_ALLO) -- WRITE_OK(FTP_ALLOOK); -- else if (cmdval == const_SYST) -- cmdio_write_raw(STR(FTP_SYSTOK)" UNIX Type: L8\r\n"); -- else if (cmdval == const_PWD || cmdval == const_XPWD) -- handle_pwd(); -- else if (cmdval == const_CWD) -- handle_cwd(); -- else if (cmdval == const_CDUP) /* cd .. */ -- handle_cdup(); -- /* HELP is nearly useless, but we can reuse FEAT for it */ -- /* lftp uses FEAT */ -- else if (cmdval == const_HELP || cmdval == const_FEAT) + if (cmdval == const_QUIT) { + WRITE_OK(FTP_GOODBYE); + return 0; +@@ -1399,12 +1600,11 @@ + /* HELP is nearly useless, but we can reuse FEAT for it */ + /* lftp uses FEAT */ + else if (cmdval == const_HELP || cmdval == const_FEAT) - handle_feat(cmdval == const_HELP - ? STRNUM32(FTP_HELP) - : STRNUM32(FTP_STATOK) - ); - else if (cmdval == const_LIST) /* ls -l */ -- handle_list(); -- else if (cmdval == const_NLST) /* "name list", bare ls */ -+ memcpy(list_buff, basedir, strlen(basedir)); -+ while (1) { -+ uint32_t cmdval = cmdio_get_cmd_and_arg(); -+ if (cmdval == const_QUIT) { -+ WRITE_OK(FTP_GOODBYE); -+ return 0; -+ } -+ else if (cmdval == const_USER) -+ /* This would mean "ok, now give me PASS". */ -+ /*WRITE_OK(FTP_GIVEPWORD);*/ -+ /* vsftpd can be configured to not require that, -+ * and this also saves one roundtrip: -+ */ -+ WRITE_OK(FTP_LOGINOK); -+ else if (cmdval == const_PASS) -+ WRITE_OK(FTP_LOGINOK); -+ else if (cmdval == const_NOOP) -+ WRITE_OK(FTP_NOOPOK); -+ else if (cmdval == const_TYPE) -+ WRITE_OK(FTP_TYPEOK); -+ else if (cmdval == const_STRU) -+ WRITE_OK(FTP_STRUOK); -+ else if (cmdval == const_MODE) -+ WRITE_OK(FTP_MODEOK); -+ else if (cmdval == const_ALLO) -+ WRITE_OK(FTP_ALLOOK); -+ else if (cmdval == const_SYST) -+ cmdio_write_raw(STR(FTP_SYSTOK) " UNIX Type: L8\r\n"); -+ else if (cmdval == const_PWD || cmdval == const_XPWD) -+ handle_pwd(); -+ else if (cmdval == const_CWD) -+ handle_cwd(); -+ else if (cmdval == const_CDUP) /* cd .. */ -+ handle_cdup(); -+ /* HELP is nearly useless, but we can reuse FEAT for it */ -+ /* lftp uses FEAT */ -+ else if (cmdval == const_HELP || cmdval == const_FEAT) + handle_feat(cmdval == const_HELP ? STRNUM32(FTP_HELP) : STRNUM32(FTP_STATOK)); + else if (cmdval == const_LIST) { /* ls -l */ + GetTheNumberOfCurrentPath(); -+ handle_list(); + handle_list(); + } -+ else if (cmdval == const_NLST) /* "name list", bare ls */ + else if (cmdval == const_NLST) /* "name list", bare ls */ handle_nlst(); /* SIZE is crucial for wget's download indicator etc */ - /* Mozilla, lftp use MDTM (presumably for caching) */ -@@ -1472,5 +1672,5 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv) - #endif - cmdio_write_raw(STR(FTP_BADCMD)" Unknown command\r\n"); - } -- } -+ } - } -diff --git a/networking/ping.c b/networking/ping.c -index 86d8088de..a7d96f589 100644 ---- a/networking/ping.c -+++ b/networking/ping.c -@@ -530,6 +530,38 @@ static void sendping_tail(void (*sp)(int), int size_pkt) +diff --ignore-all-space -urN a/networking/ping.c busybox-1.35.0/networking/ping.c +--- a/networking/ping.c 2024-11-08 13:29:16.692497116 +0800 ++++ busybox-1.35.0/networking/ping.c 2024-11-08 13:35:07.033098340 +0800 +@@ -530,6 +530,38 @@ bb_simple_error_msg_and_die(bb_msg_write_error); if (pingcount == 0 || G.ntransmitted < pingcount) { @@ -1088,7 +939,7 @@ index 86d8088de..a7d96f589 100644 /* Didn't send all pings yet - schedule next in -i SEC interval */ struct itimerval i; signal(SIGALRM, sp); -@@ -539,6 +571,7 @@ static void sendping_tail(void (*sp)(int), int size_pkt) +@@ -539,6 +571,7 @@ i.it_value.tv_sec = G.interval_us / 1000000; i.it_value.tv_usec = G.interval_us % 1000000; setitimer(ITIMER_REAL, &i, NULL); @@ -1096,7 +947,7 @@ index 86d8088de..a7d96f589 100644 } else { /* -c NN, and all NN are sent */ /* Wait for the last ping to come back. * -W timeout: wait for a response in seconds. -@@ -801,7 +834,7 @@ static void ping4(len_and_sockaddr *lsa) +@@ -801,7 +834,7 @@ c = recvfrom(pingsock, G.rcv_packet, G.sizeof_rcv_packet, 0, (struct sockaddr *) &from, &fromlen); if (c < 0) { @@ -1105,11 +956,10 @@ index 86d8088de..a7d96f589 100644 bb_simple_perror_msg("recvfrom"); continue; } -diff --git a/procps/top.c b/procps/top.c -index 4cd545c69..56c54ee03 100644 ---- a/procps/top.c -+++ b/procps/top.c -@@ -596,7 +596,7 @@ static unsigned long display_header(int scr_width, int *lines_rem_p) +diff --ignore-all-space -urN a/procps/top.c busybox-1.35.0/procps/top.c +--- a/procps/top.c 2024-11-08 13:29:16.680496621 +0800 ++++ busybox-1.35.0/procps/top.c 2024-11-08 13:35:07.033098340 +0800 +@@ -596,7 +596,7 @@ open_read_close("loadavg", buf, sizeof(scrbuf) - sizeof("Load average: ")); scrbuf[scr_width - 1] = '\0'; strchrnul(buf, '\n')[0] = '\0'; @@ -1118,7 +968,7 @@ index 4cd545c69..56c54ee03 100644 (*lines_rem_p)--; return meminfo[MI_MEMTOTAL]; -@@ -621,7 +621,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) +@@ -621,7 +621,7 @@ /* what info of the processes is shown */ printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width, @@ -1127,7 +977,7 @@ index 4cd545c69..56c54ee03 100644 IF_FEATURE_TOP_SMP_PROCESS(" CPU") IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") " COMMAND"); -@@ -700,11 +700,11 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) +@@ -700,11 +700,11 @@ smart_ulltoa5(s->vsz, vsz_str_buf, " mgtpezy"); /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ col = snprintf(line_buf, scr_width, @@ -1141,17 +991,18 @@ index 4cd545c69..56c54ee03 100644 s->state, vsz_str_buf, SHOW_STAT(pmem) IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu) -diff --git a/shell/ash.c b/shell/ash.c -index 827643808..d98d58ec9 100644 ---- a/shell/ash.c -+++ b/shell/ash.c -@@ -5600,20 +5600,20 @@ openredirect(union node *redir) +diff --ignore-all-space -urN a/shell/ash.c busybox-1.35.0/shell/ash.c +--- a/shell/ash.c 2024-11-08 13:29:16.644495139 +0800 ++++ busybox-1.35.0/shell/ash.c 2024-11-08 13:35:07.033098340 +0800 +@@ -5600,20 +5600,20 @@ static int savefd(int from) { - int newfd; - int err; -- ++ // int newfd; ++ // int err; + - newfd = fcntl(from, F_DUPFD_CLOEXEC, 10); - err = newfd < 0 ? errno : 0; - if (err != EBADF) { @@ -1161,11 +1012,6 @@ index 827643808..d98d58ec9 100644 - if (F_DUPFD_CLOEXEC == F_DUPFD) - close_on_exec_on(newfd); - } -- -- return newfd; -+ // int newfd; -+ // int err; -+ + // newfd = fcntl(from, F_DUPFD_CLOEXEC, 10); + // err = newfd < 0 ? errno : 0; + // if (err != EBADF) { @@ -1175,16 +1021,16 @@ index 827643808..d98d58ec9 100644 + // if (F_DUPFD_CLOEXEC == F_DUPFD) + // close_on_exec_on(newfd); + // } -+ + +- return newfd; + return from; } static int dup2_or_raise(int from, int to) -diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c -index 1c2a7d683..9004a06d8 100644 ---- a/util-linux/fdisk.c -+++ b/util-linux/fdisk.c -@@ -2969,6 +2969,7 @@ open_list_and_close(const char *device, int user_specified) +diff --ignore-all-space -urN a/util-linux/fdisk.c busybox-1.35.0/util-linux/fdisk.c +--- a/util-linux/fdisk.c 2024-11-08 13:29:16.704497610 +0800 ++++ busybox-1.35.0/util-linux/fdisk.c 2024-11-08 13:35:07.033098340 +0800 +@@ -2969,6 +2969,7 @@ static int is_whole_disk(const char *disk) { unsigned len; @@ -1192,7 +1038,7 @@ index 1c2a7d683..9004a06d8 100644 int fd = open(disk, O_RDONLY); if (fd != -1) { -@@ -2978,6 +2979,7 @@ static int is_whole_disk(const char *disk) +@@ -2978,6 +2979,7 @@ if (!err) return (geometry.start == 0); } @@ -1200,11 +1046,10 @@ index 1c2a7d683..9004a06d8 100644 /* Treat "nameN" as a partition name, not whole disk */ /* note: mmcblk0 should work from the geometry check above */ -diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c -index 4c30f31f8..a152d3a73 100644 ---- a/util-linux/fdisk_gpt.c -+++ b/util-linux/fdisk_gpt.c -@@ -108,7 +108,7 @@ gpt_list_table(int xtra UNUSED_PARAM) +diff --ignore-all-space -urN a/util-linux/fdisk_gpt.c busybox-1.35.0/util-linux/fdisk_gpt.c +--- a/util-linux/fdisk_gpt.c 2024-11-08 13:29:16.704497610 +0800 ++++ busybox-1.35.0/util-linux/fdisk_gpt.c 2024-11-08 13:35:07.037099608 +0800 +@@ -108,7 +108,7 @@ int i; char numstr6[6]; @@ -1213,10 +1058,9 @@ index 4c30f31f8..a152d3a73 100644 printf("Disk %s: %llu sectors, %s\n", disk_device, (unsigned long long)total_number_of_sectors, numstr6); -diff --git a/util-linux/fsfreeze.c b/util-linux/fsfreeze.c -index 6e2ff0a54..6ba039890 100644 ---- a/util-linux/fsfreeze.c -+++ b/util-linux/fsfreeze.c +diff --ignore-all-space -urN a/util-linux/fsfreeze.c busybox-1.35.0/util-linux/fsfreeze.c +--- a/util-linux/fsfreeze.c 2024-11-08 13:29:16.700497446 +0800 ++++ busybox-1.35.0/util-linux/fsfreeze.c 2024-11-08 13:35:07.037099608 +0800 @@ -21,7 +21,7 @@ //usage: "Flush and halt writes to MOUNTPOINT" @@ -1226,10 +1070,9 @@ index 6e2ff0a54..6ba039890 100644 #ifndef FIFREEZE # define FIFREEZE _IOWR('X', 119, int) -diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c -index 6d673002f..1f0ba5066 100644 ---- a/util-linux/fstrim.c -+++ b/util-linux/fstrim.c +diff --ignore-all-space -urN a/util-linux/fstrim.c busybox-1.35.0/util-linux/fstrim.c +--- a/util-linux/fstrim.c 2024-11-08 13:29:16.700497446 +0800 ++++ busybox-1.35.0/util-linux/fstrim.c 2024-11-08 13:35:07.037099608 +0800 @@ -26,7 +26,7 @@ //usage: "\n -v Print number of discarded bytes" @@ -1239,10 +1082,9 @@ index 6d673002f..1f0ba5066 100644 #ifndef FITRIM struct fstrim_range { -diff --git a/util-linux/mount.c b/util-linux/mount.c -index 4e65b6b46..258ec69b2 100644 ---- a/util-linux/mount.c -+++ b/util-linux/mount.c +diff --ignore-all-space -urN a/util-linux/mount.c busybox-1.35.0/util-linux/mount.c +--- a/util-linux/mount.c 2024-11-08 13:29:16.704497610 +0800 ++++ busybox-1.35.0/util-linux/mount.c 2024-11-08 13:35:07.037099608 +0800 @@ -255,9 +255,9 @@ * CONFIG_EXTRA_LDLIBS="tirpc" */ @@ -1256,7 +1098,7 @@ index 4e65b6b46..258ec69b2 100644 #endif -@@ -806,7 +806,13 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero +@@ -806,7 +806,13 @@ update_mtab_entry_on_move(mp); else #endif @@ -1270,7 +1112,7 @@ index 4e65b6b46..258ec69b2 100644 endmntent(mountTable); if (ENABLE_FEATURE_CLEAN_UP) { -@@ -818,6 +824,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero +@@ -818,6 +824,7 @@ return rc; } @@ -1278,7 +1120,7 @@ index 4e65b6b46..258ec69b2 100644 #if ENABLE_FEATURE_MOUNT_NFS /* -@@ -1912,6 +1919,8 @@ static int nfsmount(struct mntent *mp, unsigned long vfsflags, char *filteropts) +@@ -1912,6 +1919,8 @@ #endif // !ENABLE_FEATURE_MOUNT_NFS @@ -1287,7 +1129,7 @@ index 4e65b6b46..258ec69b2 100644 // Find "...,NAME=NUM,..." in the option string, remove "NAME=NUM" option // and return NUM. // Return 0 if not found. -@@ -2089,6 +2098,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) +@@ -2089,6 +2098,7 @@ } // Might this be an NFS filesystem? @@ -1295,7 +1137,7 @@ index 4e65b6b46..258ec69b2 100644 if (!(vfsflags & (MS_BIND | MS_MOVE)) && (!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs")) ) { -@@ -2102,6 +2112,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) +@@ -2102,6 +2112,7 @@ goto report_error; } } @@ -1303,7 +1145,7 @@ index 4e65b6b46..258ec69b2 100644 // Look at the file. (Not found isn't a failure for remount, or for // a synthetic filesystem like proc or sysfs.) -@@ -2151,6 +2162,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) +@@ -2151,6 +2162,7 @@ // If we know the fstype (or don't need to), jump straight // to the actual mount. if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) { @@ -1311,11 +1153,10 @@ index 4e65b6b46..258ec69b2 100644 char *next; for (;;) { next = mp->mnt_type ? strchr(mp->mnt_type, ',') : NULL; -diff --git a/util-linux/umount.c b/util-linux/umount.c -index 23da32868..18d5dea67 100644 ---- a/util-linux/umount.c -+++ b/util-linux/umount.c -@@ -169,6 +169,8 @@ int umount_main(int argc UNUSED_PARAM, char **argv) +diff --ignore-all-space -urN a/util-linux/umount.c busybox-1.35.0/util-linux/umount.c +--- a/util-linux/umount.c 2024-11-08 13:29:16.700497446 +0800 ++++ busybox-1.35.0/util-linux/umount.c 2024-11-08 13:35:07.037099608 +0800 +@@ -169,6 +169,8 @@ argv++; path = xmalloc_realpath(zapit); if (path) { diff --git a/repo/packages/b/busybox/port/1.35.0/inittab b/repo/packages/b/busybox/port/1.35.0/inittab new file mode 100644 index 0000000..15d6f65 --- /dev/null +++ b/repo/packages/b/busybox/port/1.35.0/inittab @@ -0,0 +1,9 @@ +# Copyright (c) 2006-2024, RT-Thread Development Team +# +# SPDX-License-Identifier: Apache-2.0 + +# Run getty & login +# console::respawn:/sbin/getty 115200 /dev/console + +# or without login, a direct access to shell +console::respawn:-/bin/ash \ No newline at end of file diff --git a/repo/packages/b/busybox/scripts/deploy.lua b/repo/packages/b/busybox/scripts/deploy.lua index 74a91ed..c4f1588 100644 --- a/repo/packages/b/busybox/scripts/deploy.lua +++ b/repo/packages/b/busybox/scripts/deploy.lua @@ -22,7 +22,7 @@ -- import("rt.rt_utils") -function main(rootfs, installdir) +function main(rootfs, installdir, version) for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do local filename = path.filename(filepath) rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename)) @@ -42,4 +42,11 @@ function main(rootfs, installdir) local filename = path.filename(filepath) rt_utils.cp_with_symlink(filepath, path.join(rootfs, "sbin", filename)) end + + for _, filepath in ipairs(os.files(path.join(os.scriptdir():match(".*/"), "port", version) .. "/*")) do + if not filepath:match("%.config$") then + local filename = path.filename(filepath) + rt_utils.cp_with_symlink(filepath, path.join(rootfs, "etc", filename)) + end + end end diff --git a/repo/packages/b/busybox/xmake.lua b/repo/packages/b/busybox/xmake.lua index df2bfcd..4ab560d 100644 --- a/repo/packages/b/busybox/xmake.lua +++ b/repo/packages/b/busybox/xmake.lua @@ -30,7 +30,7 @@ do add_versions("1.35.0", "faeeb244c35a348a334f4a59e44626ee870fb07b6884d68c10ae8bc19f83a694") add_patches("1.35.0", path.join(os.scriptdir(), "patches", "1.35.0", "01_adapt_smart.diff"), - "a72603138d08b1280efca029b940434a4a56c5c2a8d75e1280f69c6bacf91cde") + "ffef807f51f8a417c65d2a27894045c6a8c2d7869ac9a3c2636058ff986b0e6e") on_install("cross@linux", function(package) import("rt.private.build.rtflags") diff --git a/tools/scripts/tasks/smart-rootfs/on_run.lua b/tools/scripts/tasks/smart-rootfs/on_run.lua index 06f4419..45305f3 100644 --- a/tools/scripts/tasks/smart-rootfs/on_run.lua +++ b/tools/scripts/tasks/smart-rootfs/on_run.lua @@ -19,7 +19,8 @@ -- Date Author Notes -- ------------ ---------- ----------------------------------------------- -- 2023-05-09 xqyjlj initial version --- +-- 2024-11-11 rcitach add version get + import("core.project.config") import("core.project.project") import("core.base.option") @@ -69,6 +70,7 @@ function deploy_package(rootfs) local repo = instance:repo() local packagename = requireinfo.originstr local installdir = instance:installdir() + local version = instance:version_str() local repodir = repo:url() local reponame = repo:name() if string.find(packagename, "%s") then @@ -78,7 +80,7 @@ function deploy_package(rootfs) path.join(repodir, "packages", packagename:sub(1, 1), packagename, "scripts", "deploy.lua") if os.isfile(deploy_script) then vprint("run script => '%s'", deploy_script) - import("deploy", {rootdir = path.directory(deploy_script)}).main(rootfs, installdir) + import("deploy", {rootdir = path.directory(deploy_script)}).main(rootfs, installdir, version) end local package_rootfs = path.join(repodir, "packages", packagename:sub(1, 1), packagename, "rootfs") if os.isdir(package_rootfs) then