mirror of
https://github.com/linuxboot/heads.git
synced 2025-01-25 21:59:17 +00:00
eda24d85bf
Busybox no longer has CONFIG_BASH since we are deploying bash on most boards. We also should clearly indicate which scripts cannot use bashisms. Change shebang in x230-flash.init, t430-flash.init, flash.sh to /bin/ash. Execute /bin/sh for interactive shells. Move key functions needed by those scripts to initrd/etc/ash_functions. Source ash_functions instead of functions in those scripts, so any bashisms in other functions won't break parsing of the script in ash. Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
50 lines
1.0 KiB
Bash
50 lines
1.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Core shell functions that do not require bash. These functions are used with
|
|
# busybox ash on legacy-flash boards, and with bash on all other boards.
|
|
|
|
die() {
|
|
echo >&2 "$*";
|
|
sleep 2;
|
|
exit 1;
|
|
}
|
|
|
|
warn() {
|
|
echo >&2 "$*";
|
|
sleep 1;
|
|
}
|
|
|
|
DEBUG() {
|
|
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ];then
|
|
echo "DEBUG: $*" | tee -a /tmp/debug.log >&2;
|
|
fi
|
|
}
|
|
|
|
DO_WITH_DEBUG() {
|
|
DEBUG "$@"
|
|
"$@"
|
|
}
|
|
|
|
TRACE() {
|
|
if [ "$CONFIG_ENABLE_FUNCTION_TRACING_OUTPUT" = "y" ];then
|
|
echo "TRACE: $*" | tee -a /tmp/debug.log >&2;
|
|
fi
|
|
}
|
|
|
|
preserve_rom() {
|
|
TRACE "Under /etc/functions:preserve_rom"
|
|
new_rom="$1"
|
|
old_files=`cbfs -t 50 -l 2>/dev/null | grep "^heads/"`
|
|
|
|
for old_file in `echo $old_files`; do
|
|
new_file=`cbfs.sh -o $1 -l | grep -x $old_file`
|
|
if [ -z "$new_file" ]; then
|
|
echo "+++ Adding $old_file to $1"
|
|
cbfs -t 50 -r $old_file >/tmp/rom.$$ \
|
|
|| die "Failed to read cbfs file from ROM"
|
|
cbfs.sh -o $1 -a $old_file -f /tmp/rom.$$ \
|
|
|| die "Failed to write cbfs file to new ROM file"
|
|
fi
|
|
done
|
|
}
|