Hello mailing list,

i found (the hard way) that scripts/gen_build_files.sh is making unsafe assumptions about the nature of /bin/sh; it appears to be presuming that it's bash or dash or something:
--
  GEN     runit/Kbuild
/usr/src/install/busybox-1.26.2/scripts/gen_build_files.sh[23]: local: not found [No such file or directory]
  GEN     runit/Config.in
  HOSTCC  scripts/basic/fixdep
/usr/src/install/busybox-1.26.2/scripts/gen_build_files.sh[23]: local: not found [No such file or directory]
sed: can't read : No such file or directory
sed: can't read : No such file or directory
  GEN
mv: cannot rename .tmp to : No such file or directory
/usr/src/install/busybox-1.26.2/scripts/gen_build_files.sh[23]: local: not found [No such file or directory]
sed: can't read : No such file or directory
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/split-include
sed: can't read : No such file or directory
  GEN
mv: cannot rename .tmp to : No such file or directory
/usr/src/install/busybox-1.26.2/scripts/gen_build_files.sh[23]: local: not found [No such file or directory] /usr/src/install/busybox-1.26.2/scripts/gen_build_files.sh[23]: local: not found [No such file or directory]
--

and so on. attached is a patch which fixes this script and thus allows busybox to build. while i was in scripts/ i also noticed that the "trylink" script is making the same wrong assumption, so i went ahead and patched it as well to be safe, and i've attached that also.

thanks.
J
--- scripts/gen_build_files.sh.orig	Sat Jan 21 21:37:15 2017
+++ scripts/gen_build_files.sh	Sat Jan 21 21:39:55 2017
@@ -20,14 +20,14 @@
 generate()
 {
 	# NB: data to be inserted at INSERT line is coming on stdin
-	local src="$1" dst="$2" header="$3"
+	_src="$1" _dst="$2" _header="$3"
 	#chk "${dst}"
 	{
 		# Need to use printf: different shells have inconsistent
 		# rules re handling of "\n" in echo params.
-		printf "%s\n" "${header}"
+		printf "%s\n" "${_header}"
 		# print everything up to INSERT line
-		sed -n '/^INSERT$/ q; p' "${src}"
+		sed -n '/^INSERT$/ q; p' "${_src}"
 		# copy stdin to stdout
 		cat
 		# print everything after INSERT line
@@ -36,13 +36,13 @@
 		    n
 		    p
 		    bl
-		}' "${src}"
-	} >"${dst}.tmp"
-	if ! cmp -s "${dst}" "${dst}.tmp"; then
-		gen "${dst}"
-		mv "${dst}.tmp" "${dst}"
+		}' "${_src}"
+	} >"${_dst}.tmp"
+	if ! cmp -s "${_dst}" "${_dst}.tmp"; then
+		gen "${_dst}"
+		mv "${_dst}.tmp" "${_dst}"
 	else
-		rm -f "${dst}.tmp"
+		rm -f "${_dst}.tmp"
 	fi
 }
 
--- scripts/trylink.orig	Sat Jan 21 21:41:30 2017
+++ scripts/trylink	Sat Jan 21 21:43:12 2017
@@ -46,23 +46,23 @@
 }
 
 check_cc() {
-    local tempname="$(mktemp tmp.XXXXXXXXXX)"
-    local r
-    echo "int main(int argc,char**argv){return argv?argc:0;}" >"$tempname".c
+    cc_tempname="$(mktemp tmp.XXXXXXXXXX)"
+    cc_r
+    echo "int main(int argc,char**argv){return argv?argc:0;}" >"$cc_tempname".c
     # Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :(
     # Was using "-xc /dev/null", but we need a valid C program.
     # "eval" may be needed if CFLAGS can contain
     # '... -D"BB_VER=KBUILD_STR(1.N.M)" ...'
     # and we need shell to process quotes!
-    $CC $CFLAGS $LDFLAGS $1 "$tempname".c -o "$tempname" >/dev/null 2>&1
-    r=$?
-    rm -f "$tempname" "$tempname".c "$tempname".o
-    return $r
+    $CC $CFLAGS $LDFLAGS $1 "$cc_tempname".c -o "$cc_tempname" >/dev/null 2>&1
+    cc_r=$?
+    rm -f "$cc_tempname" "$cc_tempname".c "$cc_tempname".o
+    return $cc_r
 }
 
 check_libc_is_glibc() {
-    local tempname="$(mktemp tmp.XXXXXXXXXX)"
-    local r
+    lig_tempname="$(mktemp tmp.XXXXXXXXXX)"
+    lig_r
     echo "\
 	#include <stdlib.h>
 	/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
@@ -69,11 +69,11 @@
 	#if defined(__GLIBC__) && !defined(__UCLIBC__)
 	syntax error here
 	#endif
-	" >"$tempname".c
-    ! $CC $CFLAGS "$tempname".c -c -o "$tempname".o >/dev/null 2>&1
-    r=$?
-    rm -f "$tempname" "$tempname".c "$tempname".o
-    return $r
+	" >"$lig_tempname".c
+    ! $CC $CFLAGS "$lig_tempname".c -c -o "$lig_tempname".o >/dev/null 2>&1
+    lig_r=$?
+    rm -f "$lig_tempname" "$lig_tempname".c "$lig_tempname".o
+    return $lig_r
 }
 
 EXE="$1"
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to