summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rwxr-xr-xbuild55
1 files changed, 16 insertions, 39 deletions
diff --git a/build b/build
index a539322f..80ee1827 100755
--- a/build
+++ b/build
@@ -11,7 +11,7 @@ set -u -e
. "include/err.sh"
. "include/option.sh"
-eval "$(setvars "" mode option aur_notice tmpdir)"
+eval "$(setvars "" option aur_notice tmpdir)"
tmpdir_was_set="y"
set | grep TMPDIR 1>/dev/null 2>/dev/null || tmpdir_was_set="n"
@@ -39,8 +39,10 @@ buildpath="./script/${linkname}"
main()
{
xx_ id -u 1>/dev/null 2>/dev/null
- initialise_command $@
- shift 2
+ [ $# -lt 1 ] && fail "Too few arguments. Try: ${0} help"
+ [ "${1}" = "dependencies" ] && xx_ install_packages $@ && lbmk_exit 0
+
+ initialise_command $@ && shift 1
check_git
check_project "fail"
@@ -51,22 +53,13 @@ main()
initialise_command()
{
- [ $# -lt 1 ] && fail "Too few arguments. Try: ${0} help"
-
- mode="${1}"
- [ "${mode}" != "dependencies" ] || xx_ install_packages $@
[ "$(id -u)" != "0" ] || fail "this command as root is not permitted"
- [ "${mode}" = "help" ] && usage ${0} && lbmk_exit 0
- if [ "${mode}" = "list" ]; then
- listitems "${buildpath}"
- lbmk_exit 0
- elif [ $# -lt 2 ]; then
- usage ${0}
- lbmk_exit 1
- fi
-
- option="${2}"
+ case "${1}" in
+ help) usage ${0} && lbmk_exit 0 ;;
+ list) items "${buildpath}" && lbmk_exit 0 ;;
+ esac
+ option="${1}"
}
install_packages()
@@ -83,23 +76,13 @@ install_packages()
. "config/dependencies/${2}"
xx_ ${pkg_add} ${pkglist}
- [ "${aur_notice}" = "" ] || \
- printf "You must install AUR packages: %s\n" "${aur_notice}" 1>&2
-
- lbmk_exit 0
+ [ -z "${aur_notice}" ] && return 0
+ printf "You must install AUR packages: %s\n" "${aur_notice}" 1>&2
}
execute_command()
{
- if [ "${option}" = "list" ]; then
- xx_ listitems "${buildpath}/${mode}"
- lbmk_exit 0
- fi
- lbmkcmd="${buildpath}/${mode}/${option}"
- [ "${lbmkcmd}" = "./script/build/boot/roms" ] && \
- printf "NOTE: ./build boot roms now: ./build fw coreboot\n" 1>&2
- [ "${lbmkcmd%/*}" = "./script/update/blobs" ] && \
- printf "NOTE: ./update blobs is now: ./update vendor\n" 1>&2
+ lbmkcmd="${buildpath}/${option}"
[ -f "${lbmkcmd}" ] || fail "Invalid command. Run: ${linkpath} help"
"${lbmkcmd}" $@ || fail "execute_command: ${lbmkcmd} ${@}"
}
@@ -108,16 +91,10 @@ usage()
{
progname=${0}
cat <<- EOF
- USAGE: ${progname} <MODE> <OPTION>
-
- possible values for 'mode':
- $(listitems "${buildpath}")
-
- For each of the above modes, you may also do:
- ${progname} <MODE> list
+ USAGE: ${progname} <OPTION>
- Example: ./build fw list, which would yield:
- $(./build fw list)
+ possible values for 'OPTION':
+ $(items "${buildpath}")
Refer to ${projectname} documentation for more info.
EOF