Refactor profiles and loosen requires

This commit is contained in:
2022-02-23 16:02:51 -05:00
parent bd8a102b4d
commit 80f17733bf
2 changed files with 61 additions and 27 deletions

View File

@@ -154,7 +154,7 @@ installHostDependencies() {
getImageBuilder() {
debug "${FUNCNAME[0]}"
local _url _filename
local _url _filename _dl_tool
if [[ "${P_ARR[release]}" == "snapshot" ]]; then
_filename="openwrt-imagebuilder-${P_ARR[target]//\//-}.Linux-x86_64.tar.xz"
@@ -175,9 +175,20 @@ getImageBuilder() {
# Make sources directory if it does not exist
[[ ! -d "$BUILDDIR/sources" ]] && mkdir -p "$BUILDDIR/sources"
if hash axel &>/dev/null; then
_dl_tool="axel"
elif hash curl &>/dev/null; then
_dl_tool="curl"
else
echo "Downloading the ImageBuilder requires axel or curl!"
return 1
fi
echo "Downloading imagebuilder archive"
debug "axel -o ${P_ARR[source_archive]} $_url"
if ! axel -o "${P_ARR[source_archive]}" "$_url" > /dev/null 2>&1; then
debug "$_dl_tool -o ${P_ARR[source_archive]} $_url"
if ! "$_dl_tool" -o "${P_ARR[source_archive]}" "$_url" > /dev/null 2>&1; then
echo "Could not download imagebuilder archive"
exit 1
fi
@@ -209,29 +220,6 @@ addRepos() {
}
makeImage() {
debug "${FUNCNAME[0]}"
# Reuse the existing output
if [[ -d "${P_ARR[out_bin_dir]}" ]]; then
if askOk "${P_ARR[out_bin_dir]} exists. Rebuild?"; then
rm -rf "${P_ARR[out_bin_dir]}"
else
return 0
fi
fi
[[ ! -d "${P_ARR[out_bin_dir]}" ]] && mkdir -p "${P_ARR[out_bin_dir]}"
# build image
debug "make -j4 image BIN_DIR=${P_ARR[out_bin_dir]} PROFILE=${P_ARR[profile]} PACKAGES=${P_ARR[packages]} FILES=$FILESDIR --directory=${P_ARR[source_dir]} > make.log"
if ! make image BIN_DIR="${P_ARR[out_bin_dir]}" PROFILE="${P_ARR[profile]}" PACKAGES="${P_ARR[packages]}" FILES="$FILESDIR" --directory="${P_ARR[source_dir]}" > make.log; then
echo "Make image failed!"
exit 1
fi
}
sshBackup() {
debug "${FUNCNAME[0]}"
@@ -268,6 +256,29 @@ sshBackup() {
}
makeImage() {
debug "${FUNCNAME[0]}"
# Reuse the existing output
if [[ -d "${P_ARR[out_bin_dir]}" ]]; then
if askOk "${P_ARR[out_bin_dir]} exists. Rebuild?"; then
rm -rf "${P_ARR[out_bin_dir]}"
else
return 0
fi
fi
[[ ! -d "${P_ARR[out_bin_dir]}" ]] && mkdir -p "${P_ARR[out_bin_dir]}"
# build image
debug "make -j4 image BIN_DIR=${P_ARR[out_bin_dir]} PROFILE=${P_ARR[profile]} PACKAGES=${P_ARR[packages]} FILES=$FILESDIR --directory=${P_ARR[source_dir]} > make.log"
if ! make image BIN_DIR="${P_ARR[out_bin_dir]}" PROFILE="${P_ARR[profile]}" PACKAGES="${P_ARR[packages]}" FILES="$FILESDIR" --directory="${P_ARR[source_dir]}" > make.log; then
echo "Make image failed!"
exit 1
fi
}
flashImage() {
debug "${FUNCNAME[0]}"
@@ -328,7 +339,7 @@ sshUpgrade() {
}
debug() { (( DEBUG )) && echo "Running: " "$@" ; }
debug() { (( DEBUG )) && echo "Running: $*"; }
askOk() {