Skip to content

Commit

Permalink
Add retries to pacstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
bill88t committed Oct 2, 2024
1 parent d7b6d80 commit 205a73b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,40 @@ arches=(aarch64 armv7h x86_64)

# Ensure we have arch-install-scripts qemu-user-static and binfmt-qemu-static installed
sudo pacman -S --noconfirm --needed arch-install-scripts qemu-user-static qemu-user-static-binfmt

# Define packages as space-separated strings
base="base sed gzip archlinux-keyring bredos-mirrorlist bredos-keyring bredos-logo bred-os-release sudo arch-install-scripts nano base-devel"
armv7h_packages="archlinuxarm-keyring $base"
aarch64_packages="archlinuxarm-keyring bredos-multilib $base"
x86_64_packages="$base"

script_dir=$(dirname "$(readlink -f "$0")")

# build for arch lulw
# Build for arch function
build_arch() {
local arch=$1
rm -rf "$script_dir/build/rootfs" || true
sudo mkdir -pv "$script_dir/build/rootfs"
sudo cp -rv "$script_dir/rootfs/$arch/"* "$script_dir/build/rootfs"
sudo cp -rv "$script_dir/rootfs/common/"* "$script_dir/build/rootfs"

# Reference the correct package variable based on the architecture
local packages_var="${arch}_packages"
sudo pacstrap -c -C "$script_dir/pacman.conf.$arch" -G -M "$script_dir/build/rootfs" ${!packages_var}
local packages="${!packages_var}" # Expand the string containing the packages

# Construct the pacstrap command
strap_cmd="sudo pacstrap -c -C \"$script_dir/pacman.conf.$arch\" -G -M \"$script_dir/build/rootfs\" $packages"

retries=0
max_retries=10
while ! eval "$strap_cmd"; do
retries=$((retries+1))
if [ "$retries" -ge "$max_retries" ]; then
echo "Failed to pacstrap after $retries attempts."
exit 1
fi
echo "Retrying... ($retries/$max_retries)"
done
}

# Chek for arg
Expand Down

0 comments on commit 205a73b

Please sign in to comment.