Compare commits

..

2 Commits

Author SHA1 Message Date
25c317c4d0 More reset fixes 2023-02-16 13:30:40 -05:00
42cbbd43c3 Improve askok 2023-02-16 13:16:27 -05:00

View File

@@ -368,7 +368,7 @@ getImageBuilder() {
echo "Downloading Image Builder archive using $DL_TOOL" echo "Downloading Image Builder archive using $DL_TOOL"
debug "$DL_TOOL -o $IB_ARCHIVE $url" debug "$DL_TOOL -o $IB_ARCHIVE $url"
"$DL_TOOL" -o "$IB_ARCHIVE" "$url" execute "$DL_TOOL" "-o" "$IB_ARCHIVE" "$url"
} }
@@ -438,7 +438,7 @@ makeImages() {
# Reuse the existing output # Reuse the existing output
if [[ -d "$BINDIR" ]]; then if [[ -d "$BINDIR" ]]; then
if askOk "$BINDIR exists. Rebuild?"; then if askOk "$BINDIR exists. Rebuild?"; then
rm -rf "$BINDIR" execute rm -rf "$BINDIR"
else else
return 0 return 0
fi fi
@@ -663,10 +663,10 @@ fromSource() {
# Generic helpers # Generic helpers
debug() { (( DEBUG )) && echo "Debug: $*"; } debug() { (( DEBUG )) && echo "Debug: $*"; }
askOk() { askOk() {
local _response local r
read -r -p "$* [y/N]" _response read -r -p "$* [y/N]" r
_response=${_response,,} r=${r,,}
[[ "$_response" =~ ^(yes|y)$ ]] [[ "$r" =~ ^(yes|y)$ ]]
} }
extract() { extract() {
debug "${FUNCNAME[0]}" debug "${FUNCNAME[0]}"
@@ -758,13 +758,15 @@ main() {
declare -g GITDIR="$BUILDROOT/src/openwrt" declare -g GITDIR="$BUILDROOT/src/openwrt"
if (( RESET )); then if (( RESET )); then
for d in "$BUILDDIR" "$SOURCEDIR" "$BINDIR"; do if [[ -d $SOURCEDIR ]] && askOk "Remove $SOURCEDIR?"; then
askOk "Remove $d?" && execute rm -rf "$d" execute git worktree remove --force "$SOURCEDIR"
done execute rm -rf "$SOURCEDIR"
fi
if [[ -d $BUILDDIR ]] && askOk "Remove $BUILDDIR?"; then
execute rm -rf "$BUILDDIR"
fi
fi fi
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
if [[ "$RELEASE" == "snapshot" ]]; then if [[ "$RELEASE" == "snapshot" ]]; then
declare url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET" declare url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
declare url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.xz" declare url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.xz"
@@ -811,6 +813,7 @@ main() {
if (( FROM_SOURCE )); then if (( FROM_SOURCE )); then
fromSource || return $? fromSource || return $?
else else
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
getImageBuilder "$ib_url" && getImageBuilder "$ib_url" &&
getImageBuilderChecksum && getImageBuilderChecksum &&
verify "$IB_ARCHIVE" "$IB_SHA256_FILE" && verify "$IB_ARCHIVE" "$IB_SHA256_FILE" &&