summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initscripts
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 14:26:10 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 14:44:49 +0000
commit2180cc32b9a6d434c319292c1a636fb8e4d23899 (patch)
treec6d2960429cf7a4476f515aad4ca4c5c65e86207 /meta/recipes-core/initscripts
parent56bc2bb95ac51cd1c0a962d65b0eae8568139a06 (diff)
downloadpoky-2180cc32b9a6d434c319292c1a636fb8e4d23899.tar.gz
initiscripts: Fix populate-volatiles.sh whitespace
(From OE-Core rev: d69935fbef2b5a8b187e58ac5ade0ffb9f95f803) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/initscripts')
-rwxr-xr-xmeta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh207
1 files changed, 97 insertions, 110 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 d2175d7a7c..ab3af70430 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -17,17 +17,17 @@ COREDEF="00_core"
17[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems." 17[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
18 18
19create_file() { 19create_file() {
20 EXEC=" 20 EXEC="
21 touch \"$1\"; 21 touch \"$1\";
22 chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 22 chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
23 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " 23 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
24 24
25 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build 25 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
26 26
27 [ -e "$1" ] && { 27 [ -e "$1" ] && {
28 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." 28 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
29 } || { 29 } || {
30 eval $EXEC & 30 eval $EXEC &
31 } 31 }
32} 32}
33 33
@@ -38,11 +38,10 @@ mk_dir() {
38 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " 38 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
39 39
40 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build 40 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
41
42 [ -e "$1" ] && { 41 [ -e "$1" ] && {
43 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." 42 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
44 } || { 43 } || {
45 eval $EXEC 44 eval $EXEC
46 } 45 }
47} 46}
48 47
@@ -52,121 +51,109 @@ link_file() {
52 test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build 51 test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build
53 52
54 [ -e "$2" ] && { 53 [ -e "$2" ] && {
55 echo "Cannot create link over existing -${TNAME}-." >&2 54 echo "Cannot create link over existing -${TNAME}-." >&2
56 } || { 55 } || {
57 eval $EXEC & 56 eval $EXEC &
58 } 57 }
59} 58}
60 59
61check_requirements() { 60check_requirements() {
62 61 cleanup() {
63 cleanup() { 62 rm "${TMP_INTERMED}"
64 rm "${TMP_INTERMED}" 63 rm "${TMP_DEFINED}"
65 rm "${TMP_DEFINED}" 64 rm "${TMP_COMBINED}"
66 rm "${TMP_COMBINED}" 65 }
67 } 66
68 67 CFGFILE="$1"
69 CFGFILE="$1" 68 [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
70 69
71 [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0 70 TMP_INTERMED="${TMPROOT}/tmp.$$"
72 71 TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
73 TMP_INTERMED="${TMPROOT}/tmp.$$" 72 TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
74 TMP_DEFINED="${TMPROOT}/tmpdefined.$$" 73
75 TMP_COMBINED="${TMPROOT}/tmpcombined.$$" 74 cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
76 75 cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}"
77 76 cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
78 cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" 77 NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
79 cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}" 78 NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
80 cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" 79
81 80 [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
82 NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" 81 echo "Undefined users:"
83 NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`" 82 diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
84 83 cleanup
85 [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && { 84 return 1
86 echo "Undefined users:" 85 }
87 diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
88 cleanup
89 return 1
90 }
91 86
92 87
93 cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" 88 cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
94 cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}" 89 cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}"
95 cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" 90 cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
96 91
97 NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`" 92 NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
98 NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`" 93 NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
99 94
100 [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && { 95 [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
101 echo "Undefined groups:" 96 echo "Undefined groups:"
102 diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" 97 diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
103 cleanup 98 cleanup
104 return 1 99 return 1
105 } 100 }
106 101
107 # Add checks for required directories here 102 # Add checks for required directories here
108 103
109 cleanup 104 cleanup
110 return 0 105 return 0
111 } 106}
112 107
113apply_cfgfile() { 108apply_cfgfile() {
109 CFGFILE="$1"
110
111 check_requirements "${CFGFILE}" || {
112 echo "Skipping ${CFGFILE}"
113 return 1
114 }
114 115
115 CFGFILE="$1" 116 cat ${CFGFILE} | grep -v "^#" | \
116 117 while read LINE; do
117 check_requirements "${CFGFILE}" || { 118 eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
118 echo "Skipping ${CFGFILE}" 119 [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
119 return 1 120
120 } 121 [ "${TTYPE}" = "l" ] && {
121 122 TSOURCE="$TLTARGET"
122 cat ${CFGFILE} | grep -v "^#" | \ 123 [ -L "${TNAME}" ] || {
123 while read LINE; do 124 [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
124 125 link_file "${TSOURCE}" "${TNAME}" &
125 eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` 126 }
126 127 continue
127 [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." 128 }
128 129
129 130 [ -L "${TNAME}" ] && {
130 [ "${TTYPE}" = "l" ] && { 131 [ "${VERBOSE}" != "no" ] && echo "Found link."
131 TSOURCE="$TLTARGET" 132 NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'`
132 [ -L "${TNAME}" ] || { 133 echo ${NEWNAME} | grep -v "^/" >/dev/null && {
133 [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." 134 TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}"
134 link_file "${TSOURCE}" "${TNAME}" & 135 [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
135 } 136 } || {
136 continue 137 TNAME="${NEWNAME}"
137 } 138 [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
138 139 }
139 [ -L "${TNAME}" ] && { 140 }
140 [ "${VERBOSE}" != "no" ] && echo "Found link." 141
141 NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'` 142 case "${TTYPE}" in
142 echo ${NEWNAME} | grep -v "^/" >/dev/null && { 143 "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
143 TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}" 144 create_file "${TNAME}" &
144 [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." 145 ;;
145 } || { 146 "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
146 TNAME="${NEWNAME}" 147 mk_dir "${TNAME}"
147 [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-." 148 # Add check to see if there's an entry in fstab to mount.
148 } 149 ;;
149 } 150 *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
150 151 continue
151 case "${TTYPE}" in 152 ;;
152 "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-." 153 esac
153 create_file "${TNAME}" & 154 done
154 ;; 155 return 0
155 "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-." 156}
156 mk_dir "${TNAME}"
157 # Add check to see if there's an entry in fstab to mount.
158 ;;
159 *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
160 continue
161 ;;
162 esac
163
164
165 done
166
167 return 0
168
169 }
170 157
171clearcache=0 158clearcache=0
172exec 9</proc/cmdline 159exec 9</proc/cmdline