基于busybox V1.35.0
修改方法
创建 my_utils/hello.c
//usage:#define hello_trivial_usage
//usage: "[-fF]"
//usage:#define hello_full_usage "\n\n"
//usage: "This is some description about your tools\n"
//usage: "\n -h help"
//config:config HELLO
//config: bool "hello"
//config: default y
//applet:IF_HELLO(APPLET(hello, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_HELLO) += hello.o
#include "libbb.h"
int hello_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int hello_main(int argc UNUSED_PARAM, char **argv)
{
printf("Hello World!\n");
return 0;
}
修改 Makefile,找到 libs-y
libs-y += my_utils
修改 Config.in,在末尾添加
source my_utils/Config.in
结果
假设添加的自定义菜单为 “My Utilities”,添加的自定义命令为 “hello”,效果如下:
运行命令: