فهرست منبع

install_headers.sh: detect a case when kernel headers are already
installed in target dir, and dont try to copy them again

Denis Vlasenko 17 سال پیش
والد
کامیت
d37cbbd021
1فایلهای تغییر یافته به همراه26 افزوده شده و 20 حذف شده
  1. 26 20
      extra/scripts/install_headers.sh

+ 26 - 20
extra/scripts/install_headers.sh

@@ -50,7 +50,8 @@ done
 
 
 # Just copy (no sanitization) some kernel headers.
 # Just copy (no sanitization) some kernel headers.
 eval `grep ^KERNEL_HEADERS "$top_builddir/.config"`
 eval `grep ^KERNEL_HEADERS "$top_builddir/.config"`
-if ! test -d "$KERNEL_HEADERS/asm" \
+if ! test "$KERNEL_HEADERS" \
+|| ! test -d "$KERNEL_HEADERS/asm" \
 || ! test -d "$KERNEL_HEADERS/asm-generic" \
 || ! test -d "$KERNEL_HEADERS/asm-generic" \
 || ! test -d "$KERNEL_HEADERS/linux" \
 || ! test -d "$KERNEL_HEADERS/linux" \
 ; then
 ; then
@@ -58,25 +59,30 @@ if ! test -d "$KERNEL_HEADERS/asm" \
 	echo "Check KERNEL_HEADERS= in your .config file."
 	echo "Check KERNEL_HEADERS= in your .config file."
 	exit 1
 	exit 1
 fi
 fi
-# NB: source or target files and directories may be symlinks,
+# Do the copying only if src and dst dirs are not the same
-# and for all we know, good reasons.
+# Be thorough: do not settle just for textual compare,
-# We must work correctly in these cases. This includes "do not replace
+# and guard against "pwd" being handled as shell builtin
-# target symlink with real directory" rule. So, no rm -rf here please.
+if test `(cd "$KERNEL_HEADERS"; env pwd)` != `(cd "$2"; env pwd)`; then
-mkdir -p "$2/asm"         2>/dev/null
+	# NB: source or target files and directories may be symlinks,
-mkdir -p "$2/asm-generic" 2>/dev/null
+	# and for all we know, good reasons.
-mkdir -p "$2/linux"       2>/dev/null
+	# We must work correctly in these cases. This includes "do not replace
-# Exists, but is not a dir? That's bad, bail out
+	# target symlink with real directory" rule. So, no rm -rf here please.
-die_if_not_dir "$2/asm" "$2/asm-generic" "$2/linux"
+	mkdir -p "$2/asm"         2>/dev/null
-# cp -HL creates regular destination files even if sources are symlinks.
+	mkdir -p "$2/asm-generic" 2>/dev/null
-# This is intended.
+	mkdir -p "$2/linux"       2>/dev/null
-# (NB: you need busybox 1.11.x for this. earlier ones are slightly buggy)
+	# Exists, but is not a dir? That's bad, bail out
-cp -RHL "$KERNEL_HEADERS/asm"/*         "$2/asm"         || exit 1
+	die_if_not_dir "$2/asm" "$2/asm-generic" "$2/linux"
-cp -RHL "$KERNEL_HEADERS/asm-generic"/* "$2/asm-generic" || exit 1
+	# cp -HL creates regular destination files even if sources are symlinks.
-cp -RHL "$KERNEL_HEADERS/linux"/*       "$2/linux"       || exit 1
+	# This is intended.
-if ! test -f "$2/linux/version.h"; then
+	# (NB: you need busybox 1.11.x for this. earlier ones are slightly buggy)
-	echo "Warning: '$KERNEL_HEADERS/linux/version.h' is not found"
+	cp -RHL "$KERNEL_HEADERS/asm"/*         "$2/asm"         || exit 1
-	echo "in kernel headers directory specified in .config."
+	cp -RHL "$KERNEL_HEADERS/asm-generic"/* "$2/asm-generic" || exit 1
-	echo "Some programs won't like that. Consider fixing it by hand."
+	cp -RHL "$KERNEL_HEADERS/linux"/*       "$2/linux"       || exit 1
+	if ! test -f "$2/linux/version.h"; then
+		echo "Warning: '$KERNEL_HEADERS/linux/version.h' is not found"
+		echo "in kernel headers directory specified in .config."
+		echo "Some programs won't like that. Consider fixing it by hand."
+	fi
 fi
 fi