无法为 buildroot makedevs 工具应用补丁
Unable to apply a patch for the buildroot makedevs tool
我正在使用 buildroot 框架。我为 makedevs 工具打了一个补丁,它提供了一个新的 'x' 选项,允许递归地设置目录权限而不修改常规文件的权限。该补丁名为 'makedevs-0001-custom-opts-exclude-regular-files.patch'(见下文),位于 package/makedevs/ 目录中。当我尝试重新构建框架时,出现此错误:
# make all
>>> host-makedevs Patching
Applying makedevs-0001-custom-opts-exclude-regular-files.patch using patch:
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -purN makedevs.orig/makedevs.c makedevs/makedevs.c
|--- makedevs.orig/makedevs.c 2021-04-15 14:40:03.439990661 +0000
|+++ makedevs/makedevs.c 2021-04-15 14:40:46.128006533 +0000
--------------------------
No file to patch. Skipping patch.
3 out of 3 hunks ignored
package/pkg-generic.mk:187: recipe for target '/usr/local/share/buildroot/output/build/host-makedevs/.stamp_patched' failed
make: *** [/usr/local/share/buildroot/output/build/host-makedevs/.stamp_patched] Error 1
我能够在目标上正确应用 运行 的其他补丁,但此工具在主机上编译为 运行,并且 makedevs.mk 规则编译 makedevs.c 源文件而不在 output/build 上部署它,我认为这是主要问题,但我不完全确定。
你能解释一下为什么这个补丁没有正确应用吗?为这个位于 buildroot 框架内的 makedevs 工具应用补丁的正确方法应该是什么?
谢谢!
# cat makedevs-0001-mypath.patch
diff -purN makedevs.orig/makedevs.c makedevs/makedevs.c
--- makedevs.orig/makedevs.c 2021-04-15 14:40:03.439990661 +0000
+++ makedevs/makedevs.c 2021-04-15 14:40:46.128006533 +0000
@@ -404,7 +404,8 @@ void bb_show_usage(void)
fprintf(stderr, "Where name is the file name, type can be one of:\n");
fprintf(stderr, " f A regular file\n");
fprintf(stderr, " d Directory\n");
- fprintf(stderr, " r Directory recursively\n");
+ fprintf(stderr, " r Directory recursively including regular files\n");
+ fprintf(stderr, " x Directory recursively excluding regular files\n");
fprintf(stderr, " c Character special device file\n");
fprintf(stderr, " b Block special device file\n");
fprintf(stderr, " p Fifo (named pipe)\n");
@@ -437,6 +438,26 @@ void bb_show_usage(void)
exit(1);
}
+int xx_recursive(const char *fpath, const struct stat *sb,
+ int tflag, struct FTW *ftwbuf){
+
+ if (chown(fpath, recursive_uid, recursive_gid) == -1) {
+ bb_perror_msg("chown failed for %s", fpath);
+ return -1;
+ }
+
+ if (tflag == 1) {
+ if (recursive_mode != -1) {
+ if (chmod(fpath, recursive_mode) < 0) {
+ bb_perror_msg("chmod failed for %s", fpath);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
int bb_recursive(const char *fpath, const struct stat *sb,
int tflag, struct FTW *ftwbuf){
@@ -599,7 +620,17 @@ int main(int argc, char **argv)
ret = EXIT_FAILURE;
goto loop;
}
- } else
+ } else if (type == 'x') {
+ recursive_uid = uid;
+ recursive_gid = gid;
+ recursive_mode = mode;
+ if (nftw(full_name, xx_recursive, 20, FTW_MOUNT | FTW_PHYS) < 0) {
+ bb_perror_msg("line %d: xx_recursive failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
+ }
+ else
{
dev_t rdev;
unsigned i;
在 buildroot 邮件列表中提出这个问题并获得有效答案:
http://lists.busybox.net/pipermail/buildroot/2021-April/308390.html
希望这对以后的其他人有所帮助!
我正在使用 buildroot 框架。我为 makedevs 工具打了一个补丁,它提供了一个新的 'x' 选项,允许递归地设置目录权限而不修改常规文件的权限。该补丁名为 'makedevs-0001-custom-opts-exclude-regular-files.patch'(见下文),位于 package/makedevs/ 目录中。当我尝试重新构建框架时,出现此错误:
# make all
>>> host-makedevs Patching
Applying makedevs-0001-custom-opts-exclude-regular-files.patch using patch:
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -purN makedevs.orig/makedevs.c makedevs/makedevs.c
|--- makedevs.orig/makedevs.c 2021-04-15 14:40:03.439990661 +0000
|+++ makedevs/makedevs.c 2021-04-15 14:40:46.128006533 +0000
--------------------------
No file to patch. Skipping patch.
3 out of 3 hunks ignored
package/pkg-generic.mk:187: recipe for target '/usr/local/share/buildroot/output/build/host-makedevs/.stamp_patched' failed
make: *** [/usr/local/share/buildroot/output/build/host-makedevs/.stamp_patched] Error 1
我能够在目标上正确应用 运行 的其他补丁,但此工具在主机上编译为 运行,并且 makedevs.mk 规则编译 makedevs.c 源文件而不在 output/build 上部署它,我认为这是主要问题,但我不完全确定。
你能解释一下为什么这个补丁没有正确应用吗?为这个位于 buildroot 框架内的 makedevs 工具应用补丁的正确方法应该是什么?
谢谢!
# cat makedevs-0001-mypath.patch
diff -purN makedevs.orig/makedevs.c makedevs/makedevs.c
--- makedevs.orig/makedevs.c 2021-04-15 14:40:03.439990661 +0000
+++ makedevs/makedevs.c 2021-04-15 14:40:46.128006533 +0000
@@ -404,7 +404,8 @@ void bb_show_usage(void)
fprintf(stderr, "Where name is the file name, type can be one of:\n");
fprintf(stderr, " f A regular file\n");
fprintf(stderr, " d Directory\n");
- fprintf(stderr, " r Directory recursively\n");
+ fprintf(stderr, " r Directory recursively including regular files\n");
+ fprintf(stderr, " x Directory recursively excluding regular files\n");
fprintf(stderr, " c Character special device file\n");
fprintf(stderr, " b Block special device file\n");
fprintf(stderr, " p Fifo (named pipe)\n");
@@ -437,6 +438,26 @@ void bb_show_usage(void)
exit(1);
}
+int xx_recursive(const char *fpath, const struct stat *sb,
+ int tflag, struct FTW *ftwbuf){
+
+ if (chown(fpath, recursive_uid, recursive_gid) == -1) {
+ bb_perror_msg("chown failed for %s", fpath);
+ return -1;
+ }
+
+ if (tflag == 1) {
+ if (recursive_mode != -1) {
+ if (chmod(fpath, recursive_mode) < 0) {
+ bb_perror_msg("chmod failed for %s", fpath);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
int bb_recursive(const char *fpath, const struct stat *sb,
int tflag, struct FTW *ftwbuf){
@@ -599,7 +620,17 @@ int main(int argc, char **argv)
ret = EXIT_FAILURE;
goto loop;
}
- } else
+ } else if (type == 'x') {
+ recursive_uid = uid;
+ recursive_gid = gid;
+ recursive_mode = mode;
+ if (nftw(full_name, xx_recursive, 20, FTW_MOUNT | FTW_PHYS) < 0) {
+ bb_perror_msg("line %d: xx_recursive failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
+ }
+ else
{
dev_t rdev;
unsigned i;
在 buildroot 邮件列表中提出这个问题并获得有效答案:
http://lists.busybox.net/pipermail/buildroot/2021-April/308390.html
希望这对以后的其他人有所帮助!