--- debootstrap.orig	2024-12-29 13:30:24.000000000 -0500
+++ debootstrap	2026-04-19 13:20:26.855001000 -0400
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/local/bin/bash
 set -e
 
 VERSION='@VERSION@'
@@ -14,7 +14,7 @@
 	if [ -x /debootstrap/debootstrap ]; then
 		DEBOOTSTRAP_DIR=/debootstrap
 	else
-		DEBOOTSTRAP_DIR=/usr/share/debootstrap
+		DEBOOTSTRAP_DIR=/usr/local/share/debootstrap
 	fi
 fi
 
@@ -382,8 +382,8 @@
 		shift
 		;;
 	    --keyring|--keyring=?*)
-		if ! gpgv --version >/dev/null 2>&1; then
-			error 1 NEEDGPGV "gpgv not installed, but required for Release verification"
+		if ! gpgv2 --version >/dev/null 2>&1; then
+			error 1 NEEDGPGV "gpgv2 not installed, but required for Release verification"
 		fi
 		if [ "$1" = "--keyring" ] && [ -n "$2" ]; then
 			KEYRING="$2"
@@ -539,13 +539,7 @@
 
 ###########################################################################
 
-if in_path dpkg && \
-     dpkg --print-architecture >/dev/null 2>&1; then
-	HOST_ARCH=$(/usr/bin/dpkg --print-architecture)
-elif in_path udpkg && \
-     udpkg --print-architecture >/dev/null 2>&1; then
-	HOST_ARCH=$(/usr/bin/udpkg --print-architecture)
-elif [ -e "$DEBOOTSTRAP_DIR/arch" ]; then
+if [ -e "$DEBOOTSTRAP_DIR/arch" ]; then
 	HOST_ARCH=$(cat "$DEBOOTSTRAP_DIR/arch")
 fi
 HOST_OS="$HOST_ARCH"
@@ -564,7 +558,18 @@
 		FreeBSD*)
 			HOST_OS=freebsd
 		;;
+		MidnightBSD*)
+			HOST_OS=midnightbsd
+		;;
 	esac
+fi
+
+if [ "$HOST_OS" = "midnightbsd" -a -z "$HOST_ARCH" ]; then
+	HOST_ARCH=`/sbin/sysctl -n hw.machine_arch`
+	if [ "$HOST_ARCH" = "aarch64" ]; then
+		HOST_ARCH=arm64
+	fi
+	EXTRACTOR_OVERRIDE=ar
 fi
 
 if [ -z "$ARCH" ]; then
@@ -576,7 +581,7 @@
 
 fi
 
-if [ "$HOST_OS" = "kfreebsd" ] || [ "$HOST_OS" = "freebsd" ]; then
+if [ "$HOST_OS" = "kfreebsd" ] || [ "$HOST_OS" = "midnightbsd" ]; then
 	for module in linprocfs fdescfs tmpfs linsysfs; do
 		kldstat -m "$module" > /dev/null 2>&1 || warning SANITYCHECK "Probably required module %s is not loaded" "$module"
 	done
