I was looking over one of the "main" function for me, tce-load. I re-aranged and commented a little the script, so it seems more compacted and quick tree logic from first words/test.ex: instead of
copyInstall() {
[ -d /mnt/test ] || sudo /bin/mkdir -p /mnt/test
sudo /bin/mount $1 /mnt/test -t squashfs -o loop,ro
if [ "$?" == 0 ]; then
if [ "$(ls -A /mnt/test)" ]; then
yes "$FORCE" | sudo /bin/cp -ai /mnt/test/. / 2>/dev/null
[ -n "`find /mnt/test/ -type d -name modules`" ] && MODULES=TRUE
fi
sudo /bin/umount -d /mnt/test
fi
[ "$BOOTING" ] || rmdir /mnt/test
}
I wrote it like# $1=THISAPP, ex: abc.tcz; mount it on /mnt/test; then copy its files into / ; eventualy set flag MODULES
_copyInstall() {
[ -d /mnt/test ] || sudo /bin/mkdir -p /mnt/test
[ "$(sudo /bin/mount $1 /mnt/test -t squashfs -o loop,ro)" ] && ( [ "$BOOTING" ] || rmdir /mnt/test ) || break
[ "$(ls -A /mnt/test)" ] ( yes "$FORCE" | sudo /bin/cp -ai /mnt/test/. / 2>/dev/null || ( [ -n "`find /mnt/test/ -type d -name modules`" ] && MODULES=TRUE )
sudo /bin/umount -d /mnt/test
}
same for
update_system() {
if [ "$BOOTING" ]; then
[ "$MODULES" ] && sudo /bin/touch /etc/sysconfig/newmodules
else
[ "$THISAPP" != "$EXTENSION" ] || [ "$DOWNLOAD_ONLY" ] || [ "$LOAD_ONLY" ] || echo "$THISAPP" >> ../$ONBOOTNAME
if [ "$MODULES" ]; then
sudo /sbin/depmod -a 2>/dev/null
sudo /sbin/udevadm trigger
fi
sudo /sbin/ldconfig 2>/dev/null
fi
if [ -x "$TCEINSTALLED"/$2 ]; then
if [ "$BOOTING" ] ; then
echo "$TCEINSTALLED"/$2 >> /tmp/setup.lst
else
sudo "$TCEINSTALLED"/$2
fi
else
touch "$TCEINSTALLED"/$2
fi
}
which became like this# $1=THISAPP; $2=THISAPP_without_EXTENSION; $BOOTING is used one time only
update_system() {
if [ "$BOOTING" ]; then
[ "$MODULES" ] && sudo /bin/touch /etc/sysconfig/newmodules
[ -x "$TCEINSTALLED"/$2 ] && echo "$TCEINSTALLED"/$2 >> /tmp/setup.lst
else
sudo /sbin/ldconfig 2>/dev/null
[ "$MODULES" ] && (sudo /sbin/depmod -a 2>/dev/null || sudo /sbin/udevadm trigger)
[ -x "$TCEINSTALLED"/$2 ] && sudo "$TCEINSTALLED"/$2
touch "$TCEINSTALLED"/$2
[ "$THISAPP" != "$EXTENSION" ] || [ "$DOWNLOAD_ONLY" ] || [ "$LOAD_ONLY" ] || echo "$THISAPP" >> ../$ONBOOTNAME
fi
}
for example I can quickly see what $BOOTING will do in update_system(), or what copyInstall() is about.
The original functions are already fast, so is not about extra speed. Any chance that this type of main tree and branches to be used in TC14?