diff --git a/tools/bldr b/tools/bldr index 9ecbdb0..c98ff51 100755 --- a/tools/bldr +++ b/tools/bldr @@ -1,4 +1,4 @@ -#!/usr/bin/env /bin/sh +#!/bin/sh # bldr - build a binary package from an Everest package file pkgs=("${@}") @@ -19,6 +19,23 @@ usage_small() { printf "usage: ${0} [-h] [-v] [-b] PACKAGE\n" } +load_config() { + if [ -f "/etc/bldr.conf" ]; then + source /etc/bldr.conf + elif [ -f "${HOME}/.config/bldr.conf"]; then + source ${HOME}/.config/bldr.conf + elif [ -f "$(pwd)/bldr.conf" ]; then + source $(pwd)/bldr.conf + else + printf "No valid bldr.conf found\n" + printf "Valid files are:\n" + printf "/etc/bldr.conf" + printf "${HOME}/.config/bldr.conf" + printf "$(pwd)/bldr.conf" + exit 1 + fi +} + check_if_input_is_blank() { if [[ "${@}" == "" ]]; then printf "No package(s) specified.\n" @@ -43,6 +60,13 @@ mkpkg() { done } +clean_after_failed() { + printf "${0} failed to build packages.\n" + printf "exiting...\n" + cd .. && rm -rf /tmp/bldr-workspace + exit 1 +} + case $1 in -h|--help) usage "$@" @@ -54,10 +78,22 @@ case $1 in exit 0 ;; -b|--build) + load_config "$@" shift check_if_input_is_blank "$@" + mkdir /tmp/bldr-workspace + cd /tmp/bldr-workspace get_pkg_sources "$@" + pwd + if [ "$?" != 0 ]; then + clean_after_failed "$@" + exit 1 + fi mkpkg "$@" + if [ "$?" != 0 ]; then + clean_after_failed "$@" + exit 1 + fi ;; *) usage_small "$@" diff --git a/tools/bldr.conf b/tools/bldr.conf new file mode 100644 index 0000000..63555c4 --- /dev/null +++ b/tools/bldr.conf @@ -0,0 +1,15 @@ +# +# bldr.conf - settings for bldr +# + +# Which directory bldr will output packages to +export BLDR_OUT_DIR="/home/arco/Projects/bldr-pkgs" + +# Compilation flags +export CFLAGS="-O2 -fstack-protector-strong -static -pie" +export CXXFLAGS="${CFLAGS}" +export LDFLAGS="-static" + +# +# end bldr.conf +#