summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Gherzan <andrei@gherzan.ro>2020-07-24 18:12:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-07 21:20:21 +0100
commita8b8418baed1ff8628d1b9b773b57b4c489ce667 (patch)
treec023d32a924ed7a6cab29b31db7ad792ab417c78
parent9b3ac3e898f4a7cb55f7abe86d62c7a570aa3c59 (diff)
downloadpoky-a8b8418baed1ff8628d1b9b773b57b4c489ce667.tar.gz
initscripts: Fix populate-volatile.sh bug when file/dir exists
The blocks which test for entry exitence (file or directory) use a `A && B || C` syntax. This form is not behaving as a if-then-else block even the code logic assumes that. C may run when A is true which breaks the case where VERBOSE is 'no' but the file/directory exists. Along with fixing these specific issues, this patch fixes the other instances where blocks of form `A && B || C` are used as if-then-else. (From OE-Core rev: 471094f8afa57548e9ff3fd7a99306f58b87d478) Signed-off-by: Andrei Gherzan <andrei@gherzan.ro> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 1b9ea22acb66554925720e04cf24100664234574) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xmeta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh24
1 files changed, 12 insertions, 12 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 3a265329f0..f21f48dd30 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -26,15 +26,15 @@ COREDEF="00_core"
26 26
27create_file() { 27create_file() {
28 EXEC="" 28 EXEC=""
29 [ -z "$2" ] && { 29 if [ -z "$2" ]; then
30 EXEC=" 30 EXEC="
31 touch \"$1\"; 31 touch \"$1\";
32 " 32 "
33 } || { 33 else
34 EXEC=" 34 EXEC="
35 cp \"$2\" \"$1\"; 35 cp \"$2\" \"$1\";
36 " 36 "
37 } 37 fi
38 EXEC=" 38 EXEC="
39 ${EXEC} 39 ${EXEC}
40 chown ${TUSER}:${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 40 chown ${TUSER}:${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
@@ -42,9 +42,9 @@ create_file() {
42 42
43 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build 43 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
44 44
45 [ -e "$1" ] && { 45 if [ -e "$1" ]; then
46 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." 46 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
47 } || { 47 else
48 if [ -z "$ROOT_DIR" ]; then 48 if [ -z "$ROOT_DIR" ]; then
49 eval "$EXEC" 49 eval "$EXEC"
50 else 50 else
@@ -54,7 +54,7 @@ create_file() {
54 # run on target to set up the correct files and directories. 54 # run on target to set up the correct files and directories.
55 eval "$EXEC" > /dev/null 2>&1 55 eval "$EXEC" > /dev/null 2>&1
56 fi 56 fi
57 } 57 fi
58} 58}
59 59
60mk_dir() { 60mk_dir() {
@@ -64,9 +64,9 @@ mk_dir() {
64 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " 64 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
65 65
66 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build 66 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
67 [ -e "$1" ] && { 67 if [ -e "$1" ]; then
68 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." 68 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
69 } || { 69 else
70 if [ -z "$ROOT_DIR" ]; then 70 if [ -z "$ROOT_DIR" ]; then
71 eval "$EXEC" 71 eval "$EXEC"
72 else 72 else
@@ -74,7 +74,7 @@ mk_dir() {
74 # not be logged. 74 # not be logged.
75 eval "$EXEC" > /dev/null 2>&1 75 eval "$EXEC" > /dev/null 2>&1
76 fi 76 fi
77 } 77 fi
78} 78}
79 79
80link_file() { 80link_file() {
@@ -188,13 +188,13 @@ apply_cfgfile() {
188 [ -L "${TNAME}" ] && { 188 [ -L "${TNAME}" ] && {
189 [ "${VERBOSE}" != "no" ] && echo "Found link." 189 [ "${VERBOSE}" != "no" ] && echo "Found link."
190 NEWNAME=$(ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/') 190 NEWNAME=$(ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/')
191 echo "${NEWNAME}" | grep -v "^/" >/dev/null && { 191 if echo "${NEWNAME}" | grep -v "^/" >/dev/null; then
192 TNAME="$(echo "${TNAME}" | sed -e 's@\(.*\)/.*@\1@')/${NEWNAME}" 192 TNAME="$(echo "${TNAME}" | sed -e 's@\(.*\)/.*@\1@')/${NEWNAME}"
193 [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." 193 [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
194 } || { 194 else
195 TNAME="${NEWNAME}" 195 TNAME="${NEWNAME}"
196 [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-." 196 [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
197 } 197 fi
198 } 198 }
199 199
200 case "${TTYPE}" in 200 case "${TTYPE}" in