summaryrefslogtreecommitdiff
path: root/packages/initscripts
diff options
context:
space:
mode:
authorMatthias Hentges <oe@hentges.net>2006-05-03 12:44:07 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-05-03 12:44:07 +0000
commit1d95c117acc204d97154c7f8a70ec2400d4cbdbb (patch)
tree62d1aa381623518f6cf641cbd7845199b6b20dbe /packages/initscripts
parent47ce31c955a0f4c800daa8d5546ef03a4e206ebc (diff)
initscripts: Speed up populate-volatiles.sh by caching the command produced by the script. Run times on an idle system:
old version: 7.6s new version: 4.5s (no chache) new version: 0.9s (with cache)
Diffstat (limited to 'packages/initscripts')
-rwxr-xr-xpackages/initscripts/initscripts-1.0/populate-volatile.sh63
-rw-r--r--packages/initscripts/initscripts_1.0.bb2
2 files changed, 47 insertions, 18 deletions
diff --git a/packages/initscripts/initscripts-1.0/populate-volatile.sh b/packages/initscripts/initscripts-1.0/populate-volatile.sh
index bf498084e4..f22bf2fdfe 100755
--- a/packages/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/packages/initscripts/initscripts-1.0/populate-volatile.sh
@@ -8,6 +8,35 @@ COREDEF="00_core"
[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
+create_file() {
+ EXEC="
+ touch \"$1\"
+ chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1
+ chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
+
+ test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache
+
+ eval $EXEC &
+}
+
+mk_dir() {
+ EXEC="
+ mkdir -p \"$1\"
+ chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1
+ chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
+
+ test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache
+
+ eval $EXEC &
+}
+
+link_file() {
+ EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1"
+
+ test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache
+
+ eval $EXEC &
+}
check_requirements() {
@@ -72,22 +101,21 @@ apply_cfgfile() {
cat ${CFGFILE} | grep -v "^#" | \
while read LINE; do
- TTYPE=`echo ${LINE} | cut -d " " -f 1`
- TUSER=`echo ${LINE} | cut -d " " -f 2`
- TGROUP=`echo ${LINE} | cut -d " " -f 3`
- TMODE=`echo ${LINE} | cut -d " " -f 4`
- TNAME=`echo ${LINE} | cut -d " " -f 5`
+
+ # This is a hell of a lot faster than using cut or awk 5 times
+ eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
+
[ "${TTYPE}" = "l" ] && {
[ -e "${TNAME}" ] && {
echo "Cannot create link over existing -${TNAME}-." >&2
} || {
- TSOURCE=`echo ${LINE} | cut -d " " -f 6`
+ TSOURCE="$TLTARGET"
[ -L "${TNAME}" ] || {
[ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
- ln -s "${TSOURCE}" "${TNAME}"
+ link_file "${TSOURCE}" "${TNAME}" &
}
}
continue
@@ -112,10 +140,10 @@ apply_cfgfile() {
case "${TTYPE}" in
"f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
- touch "${TNAME}"
+ create_file "${TNAME}" &
;;
"d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
- mkdir -p "${TNAME}"
+ mk_dir "${TNAME}" &
# Add check to see if there's an entry in fstab to mount.
;;
*) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
@@ -123,9 +151,6 @@ apply_cfgfile() {
;;
esac
- chown ${TUSER} ${TNAME} || echo "Failed to set owner -${TUSER}- for -${TNAME}-." >&2
- chgrp ${TGROUP} ${TNAME} || echo "Failed to set group -${TGROUP}- for -${TNAME}-." >&2
- chmod ${TMODE} ${TNAME} || echo "Failed to set mode -${TMODE}- for -${TNAME}-." >&2
done
@@ -133,8 +158,12 @@ apply_cfgfile() {
}
-
-for file in `ls -1 "${CFGDIR}" | sort`; do
- apply_cfgfile "${CFGDIR}/${file}"
- done
-
+if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes"
+then
+ sh /etc/volatile.cache
+else
+ rm -f /etc/volatile.cache
+ for file in `ls -1 "${CFGDIR}" | sort`; do
+ apply_cfgfile "${CFGDIR}/${file}"
+ done
+fi
diff --git a/packages/initscripts/initscripts_1.0.bb b/packages/initscripts/initscripts_1.0.bb
index 29886d0ac0..b3c0bfb9ab 100644
--- a/packages/initscripts/initscripts_1.0.bb
+++ b/packages/initscripts/initscripts_1.0.bb
@@ -6,7 +6,7 @@ DEPENDS = "makedevs"
DEPENDS_openzaurus = "makedevs virtual/kernel"
RDEPENDS = "makedevs"
LICENSE = "GPL"
-PR = "r71"
+PR = "r72"
SRC_URI = "file://halt \
file://ramdisk \