#!/bin/bash # Bootstrap base system into $TARGET via xbps-install. # shellcheck source=common.sh source "$(dirname "${BASH_SOURCE[0]}")/common.sh" bootstrap_base() { step "Bootstrapping base system into $TARGET (this takes a while)" local TARGET="${TARGET:-/mnt}" local pkg_list=() mapfile -t pkg_list < <(grep -vE '^\s*(#|$)' "${PKG_LIST_FILE:-/usr/local/share/installer/packages.list}") mkdir -p "$TARGET/var/db/xbps/keys" cp -a /var/db/xbps/keys/* "$TARGET/var/db/xbps/keys/" 2>/dev/null || \ warn "could not copy xbps keys (running outside Void live env?)" # Use the caching proxy during install if available; fall back to real repo. # The proxy URL (if set) is only used during installation — the installed # system's xbps.d always gets the real REPO_URL. local _repo="${INSTALL_REPO_URL:-$REPO_URL}" local _nonfree="${_repo%/current}/current/nonfree" local _multilib="${_repo%/current}/current/multilib" local _multilib_nonfree="${_repo%/current}/current/multilib/nonfree" # Normalise: if _repo doesn't end in /current the above substitution # leaves it unchanged; append nonfree/multilib paths directly. [[ "$_repo" == */current ]] || { _nonfree="${_repo}/nonfree" _multilib="${_repo}/multilib" _multilib_nonfree="${_repo}/multilib/nonfree" } log "install repo: $_repo (proxy=${INSTALL_REPO_URL:-none})" # Bootstrap base-system via proxy/repo. XBPS_ARCH="$ARCH" xbps-install -y -S -r "$TARGET" -R "$_repo" base-system ok "base-system installed" # Enable extra repos in target xbps.d — always write the REAL URLs so the # installed system never depends on the proxy. mkdir -p "$TARGET/etc/xbps.d" cat > "$TARGET/etc/xbps.d/00-repository-main.conf" < "$TARGET/etc/xbps.d/00-repository-main.conf" </dev/null 2>&1; then xgenfstab -U "$TARGET" > "$TARGET/etc/fstab" else # fallback minimal generator (uses BTRFS_SUBVOLS array from install.conf) : > "$TARGET/etc/fstab" local uuid entry sv mp pass uuid=$(blkid -s UUID -o value "$ROOT_PART") for entry in "${BTRFS_SUBVOLS[@]}"; do sv="${entry%%:*}" mp="${entry##*:}" # root gets fsck pass 1, others 2 pass=2; [[ "$mp" == "/" ]] && pass=1 printf 'UUID=%s %-12s btrfs %s,subvol=%s 0 %d\n' \ "$uuid" "$mp" "$BTRFS_MOUNT_OPTS" "$sv" "$pass" >> "$TARGET/etc/fstab" done local efi_uuid efi_uuid=$(blkid -s UUID -o value "$EFI_PART") printf 'UUID=%s /boot/efi vfat defaults,noatime,umask=0077 0 2\n' "$efi_uuid" >> "$TARGET/etc/fstab" printf 'tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n' >> "$TARGET/etc/fstab" fi ok "fstab generated" } mount_pseudo_fs() { local TARGET="${TARGET:-/mnt}" step "Mounting pseudo-filesystems for chroot" for d in dev proc sys run; do mkdir -p "$TARGET/$d" mount --rbind "/$d" "$TARGET/$d" mount --make-rslave "$TARGET/$d" done # /dev/shm must be a real tmpfs for python multiprocessing (sem_open) # used by xbps-reconfigure → compileall. Without it the byte-compile # step fails with FileNotFoundError on every python package. mkdir -p "$TARGET/dev/shm" mountpoint -q "$TARGET/dev/shm" || mount -t tmpfs -o nosuid,nodev tmpfs "$TARGET/dev/shm" 2>/dev/null || true if is_uefi; then mkdir -p "$TARGET/sys/firmware/efi/efivars" mount -t efivarfs efivarfs "$TARGET/sys/firmware/efi/efivars" 2>/dev/null || true fi # Make DNS work inside the chroot (needed for VS Code download, etc.). if [[ -r /etc/resolv.conf ]]; then install -Dm644 /etc/resolv.conf "$TARGET/etc/resolv.conf" 2>/dev/null \ || cp /etc/resolv.conf "$TARGET/etc/resolv.conf" 2>/dev/null || true fi } unmount_target() { local TARGET="${TARGET:-/mnt}" step "Unmounting $TARGET" sync umount -R "$TARGET" 2>/dev/null || warn "lazy umount fallback" umount -lR "$TARGET" 2>/dev/null || true }