From 43dd0062229170747dcbee0a2a87b8e5ee2f09d6 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Thu, 12 Apr 2018 10:36:54 +0200 Subject: build system: fix parallel building issue The files generated by the include/config/MARKER target are in the dependency list for applets/applet_tables. If applets/applet_tables is created first during applets_dir then it will be created again later as part of $(busybox-dirs). As a result include/applet_tables.h is created again. This time while other build commands may need it. Let applets_dir depend on include/config/MARKER to avoid this particular race condition and create the header files atomically to ensure that the compiler never sees incomplete files. Signed-off-by: Michael Olbrich Signed-off-by: Denys Vlasenko --- applets/applet_tables.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'applets') diff --git a/applets/applet_tables.c b/applets/applet_tables.c index ef911a43b..e3d10c83f 100644 --- a/applets/applet_tables.c +++ b/applets/applet_tables.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ static int str_isalnum_(const char *s) int main(int argc, char **argv) { int i, j; + char tmp1[PATH_MAX], tmp2[PATH_MAX]; // In find_applet_by_name(), before linear search, narrow it down // by looking at N "equidistant" names. With ~350 applets: @@ -84,7 +86,8 @@ int main(int argc, char **argv) if (!argv[1]) return 1; - i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666); + snprintf(tmp1, PATH_MAX, "%s.%u.new", argv[1], (int) getpid()); + i = open(tmp1, O_WRONLY | O_TRUNC | O_CREAT, 0666); if (i < 0) return 1; dup2(i, 1); @@ -209,12 +212,21 @@ int main(int argc, char **argv) // fclose(fp); // } // if (strcmp(line_old, line_new) != 0) { - fp = fopen(argv[2], "w"); + snprintf(tmp2, PATH_MAX, "%s.%u.new", argv[2], (int) getpid()); + fp = fopen(tmp2, "w"); if (!fp) return 1; fputs(line_new, fp); + if (fclose(fp)) + return 1; // } } + if (fclose(stdout)) + return 1; + if (rename(tmp1, argv[1])) + return 1; + if (rename(tmp2, argv[2])) + return 1; return 0; } -- cgit v1.2.3-55-g6feb From 296381ff4f69715ed880adcce7d5ce608153e767 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Sun, 15 Apr 2018 10:55:30 +0200 Subject: applets/install: don't try to install nothing Commit 952d5a6024e7 (applets/install: accept more than one install option) changed the way we handle install options: before that commit, a missing install type would mean to install nothing; after, we would iterate over options, so we would never notice there was a mising option. Fix that by introducing an explicit --none option to specify to install nothing. Reported-by: Aaro Koskinen Cc: Aaro Koskinen Cc: Denys Vlasenko Signed-off-by: Yann E. MORIN Signed-off-by: Denys Vlasenko --- Makefile.custom | 3 +++ applets/install.sh | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'applets') diff --git a/Makefile.custom b/Makefile.custom index 28d0ef7bc..6f679c4e1 100644 --- a/Makefile.custom +++ b/Makefile.custom @@ -11,6 +11,9 @@ busybox.cfg.nosuid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autocon $(Q)-SUID="DROP" $(SHELL) $^ > $@ .PHONY: install +ifeq ($(CONFIG_INSTALL_APPLET_DONT),y) +INSTALL_OPTS:= --none +endif ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y) INSTALL_OPTS:= --symlinks endif diff --git a/applets/install.sh b/applets/install.sh index c75a78e9d..9aede0f53 100755 --- a/applets/install.sh +++ b/applets/install.sh @@ -5,7 +5,9 @@ export LC_CTYPE=POSIX prefix=$1 if [ -z "$prefix" ]; then - echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]" + echo "usage: applets/install.sh DESTINATION TYPE [OPTS ...]" + echo " TYPE is one of: --symlinks --hardlinks --binaries --scriptwrapper --none" + echo " OPTS is one or more of: --cleanup --noclobber" exit 1 fi shift # Keep only remaining options @@ -32,7 +34,7 @@ while [ ${#} -gt 0 ]; do --sw-sh-sym) scriptwrapper="y"; linkopts="-fs";; --cleanup) cleanup="1";; --noclobber) noclobber="1";; - "") h="";; + --none) h="";; *) echo "Unknown install option: $1"; exit 1;; esac shift -- cgit v1.2.3-55-g6feb