summaryrefslogtreecommitdiffstats
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rw-r--r--build.sh48
1 files changed, 24 insertions, 24 deletions
diff --git a/build.sh b/build.sh
index 9123a0f..a81264a 100644
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,5 @@
steps="system packages user config ufs font uzip ramdisk boot image"
-pwdir="$(realpath $(dirname "$0"))"
+pwdir="$(realpath "$(dirname "$0")")"
system () {
install -o root -g wheel -m 755 -d "${root}"
@@ -35,11 +35,11 @@ user () {
#!/bin/sh
set -x
for user in liveuser; do
- pw add user \$user -G wheel -s /bin/tcsh -M 755
- chpass -p '' \$user
- install -o \$user -g \$user -m 755 -d /home/\$user
- echo 'limit coredumpsize 0' > /home/\$user/.login
- chown \$user:\$user /home/\$user/.login
+ pw add user "\$user" -G wheel -s /bin/tcsh -M 755
+ chpass -p '' "\$user"
+ install -o "\$user" -g "\$user" -m 755 -d "/home/\$user"
+ echo 'limit coredumpsize 0' > "/home/\$user/.login"
+ chown "\$user:\$user" "/home/\$user/.login"
done
EOF
chmod 755 "${root}/users"
@@ -111,23 +111,23 @@ image () {
}
-if [ "`id -u`" '!=' "0" ]; then
- echo "Sorry, you are not root ..."
+if [ "$(id -u)" '!=' '0' ]; then
+ echo 'Sorry, you are not root ...'
exit 1
fi
# This check cannot be done reliably, but it should be able to catch the
# most common mistake.
-if [ "$(basename "$0")" = "build.sh" ] && [ "${pwdir}" = "$(realpath $(pwd))" ]; then
- echo "This script cannot be run directly."
- echo "Please create a wrapper script that sources this file instead."
- echo "You can use build-release.sh and build-debug.sh as examples."
+if [ "$(basename "$0")" = 'build.sh' ] && [ "${pwdir}" = "$(realpath "$(pwd)")" ]; then
+ echo 'This script cannot be run directly.'
+ echo 'Please create a wrapper script that sources this file instead.'
+ echo 'You can use build-release.sh and build-debug.sh as examples.'
exit 1
fi
# Check whether required variables are defined.
assert_dir_or_file () {
- if [ -z "$2" ] || [ "$(realpath "$2" 2>/dev/null)" = "/" ]; then
+ if [ -z "$2" ] || [ "$(realpath "$2" 2>/dev/null)" = '/' ]; then
echo "Variable '$1' is unset or set to the root directory."
exit 1
fi
@@ -162,39 +162,39 @@ if [ "${#vol}" -gt "31" ]; then
exit 1
fi
-printf "All steps: \033[1;33m%s\033[m\n" "${steps}"
-printf "(E)dit or (R)un? "
-read edit_or_run
+printf 'All steps: \033[1;33m%s\033[m\n' "${steps}"
+printf '(E)dit or (R)un? '
+read -r edit_or_run
case "${edit_or_run}" in
E*|e*)
- printf "New steps: "
- read steps
+ printf 'New steps: '
+ read -r steps
;;
R*|r*)
;;
*)
- echo "Unknown action ..."
+ echo 'Unknown action ...'
exit 1
;;
esac
for task in ${steps}; do
if type "${task}" >/dev/null 2>/dev/null; then :; else
- printf "==> Task \033[1;31m%s\033[m not found\n" "${task}"
+ printf '==> Task \033[1;31m%s\033[m not found\n' "${task}"
exit 1
fi
done
for task in ${steps}; do
- printf "==> Running task \033[1;33m%s\033[m\n" "${task}"
+ printf '==> Running task \033[1;33m%s\033[m\n' "${task}"
set -x
- if ${task}; then
+ if "${task}"; then
set +x
- printf "=> Task \033[1;32m%s\033[m OK\n" "${task}"
+ printf '=> Task \033[1;32m%s\033[m OK\n' "${task}"
else
set +x
- printf "=> Task \033[1;31m%s\033[m failed\n" "${task}"
+ printf '=> Task \033[1;31m%s\033[m failed\n' "${task}"
exit 1
fi
done