2023-04-28 10:39:14 -04:00
|
|
|
#!/bin/sh
|
2023-04-27 08:14:01 -04:00
|
|
|
# bldr - build a binary package from an Everest package file
|
|
|
|
|
|
|
|
pkgs=("${@}")
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
printf "${0} - Build a binary package from an Everest package file\n"
|
|
|
|
printf "usage: ${0} [-h] [-v] [-b] PACKAGE\n"
|
|
|
|
printf "\n"
|
|
|
|
printf "${0} {-h --help} Show this message\n"
|
|
|
|
printf "${0} {-v --version} Show the current version\n"
|
|
|
|
printf "${0} {-b --build} Build specified packages\n"
|
|
|
|
printf "\n"
|
|
|
|
printf "bldr is free software.\n"
|
|
|
|
printf "See the GNU GPL version 3 for details.\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
usage_small() {
|
|
|
|
printf "usage: ${0} [-h] [-v] [-b] PACKAGE\n"
|
|
|
|
}
|
|
|
|
|
2023-04-28 10:39:14 -04:00
|
|
|
load_config() {
|
|
|
|
if [ -f "/etc/bldr.conf" ]; then
|
|
|
|
source /etc/bldr.conf
|
2023-04-28 13:59:21 -04:00
|
|
|
elif [ -f "${HOME}/.config/bldr.conf" ]; then
|
2023-04-28 10:39:14 -04:00
|
|
|
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"
|
2023-04-28 13:59:21 -04:00
|
|
|
printf "/etc/bldr.conf\n"
|
|
|
|
printf "${HOME}/.config/bldr.conf\n"
|
|
|
|
printf "$(pwd)/bldr.conf\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_for_toolchain() {
|
|
|
|
if [ -d "${TOOLCHAIN_PATH}" ]; then
|
|
|
|
printf "Toolchain found, adding to temporary PATH...\n"
|
|
|
|
PATH=${PATH}:${TOOLCHAIN_PATH}/bin
|
|
|
|
else
|
|
|
|
printf "Toolchain not found. Use the following command to download:\n"
|
|
|
|
printf "curl -O -J https://musl.cc/$(uname -m)-linux-musl-cross.tgz\n"
|
2023-04-28 10:39:14 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-04-27 08:14:01 -04:00
|
|
|
check_if_input_is_blank() {
|
|
|
|
if [[ "${@}" == "" ]]; then
|
|
|
|
printf "No package(s) specified.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_pkg_sources() {
|
|
|
|
pkgs=("${@}")
|
|
|
|
for p in $pkgs; do
|
|
|
|
source ${p}
|
|
|
|
getsource
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
mkpkg() {
|
|
|
|
pkgs=("${@}")
|
|
|
|
for p in $pkgs; do
|
|
|
|
source ${p}
|
|
|
|
buildpkg
|
|
|
|
installpkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-04-28 10:39:14 -04:00
|
|
|
clean_after_failed() {
|
|
|
|
printf "${0} failed to build packages.\n"
|
|
|
|
printf "exiting...\n"
|
|
|
|
cd .. && rm -rf /tmp/bldr-workspace
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-04-27 08:14:01 -04:00
|
|
|
case $1 in
|
|
|
|
-h|--help)
|
|
|
|
usage "$@"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-v|--version)
|
|
|
|
printf "bldr v1.0.0\n"
|
|
|
|
printf "everest-build-tools v1.0.0\n"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-b|--build)
|
2023-04-28 10:39:14 -04:00
|
|
|
load_config "$@"
|
2023-04-28 13:59:21 -04:00
|
|
|
check_for_toolchain "$@"
|
|
|
|
if [ "$?" != 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-04-27 08:14:01 -04:00
|
|
|
shift
|
|
|
|
check_if_input_is_blank "$@"
|
2023-04-28 10:39:14 -04:00
|
|
|
mkdir /tmp/bldr-workspace
|
|
|
|
cd /tmp/bldr-workspace
|
2023-04-27 08:14:01 -04:00
|
|
|
get_pkg_sources "$@"
|
2023-04-28 10:39:14 -04:00
|
|
|
pwd
|
|
|
|
if [ "$?" != 0 ]; then
|
|
|
|
clean_after_failed "$@"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-04-27 08:14:01 -04:00
|
|
|
mkpkg "$@"
|
2023-04-28 10:39:14 -04:00
|
|
|
if [ "$?" != 0 ]; then
|
|
|
|
clean_after_failed "$@"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-04-28 14:10:41 -04:00
|
|
|
printf "Finished.\n"
|
|
|
|
exit 0
|
2023-04-27 08:14:01 -04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage_small "$@"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
usage_small "$@"
|
|
|
|
exit 1
|