diff -ru apt-setup-0.166/generators/50mirror apt-setup-0.166-new/generators/50mirror
--- apt-setup-0.166/generators/50mirror	2020-07-05 14:34:06.000000000 -0500
+++ apt-setup-0.166-new/generators/50mirror	2021-08-24 00:00:00.000000000 -0500
@@ -47,7 +47,7 @@
 	if [ -e /cdrom/.disk/cd_type ]; then
 		cd_type=$(cat /cdrom/.disk/cd_type)
 	fi
-	cd_count=$(grep "^deb cdrom:" $ROOT/etc/apt/sources.list.new | wc -l)
+	cd_count=$(grep -c "^deb cdrom:" $ROOT/etc/apt/sources.list.new)
 
 	no_network=
 	if db_get netcfg/dhcp_options && \
@@ -166,10 +166,12 @@
 db_get mirror/$protocol/hostname
 hostname="$RET"
 db_get mirror/$protocol/directory
-directory="/${RET#/}"
+directory="$RET"
 if [ -z "$hostname" ] || [ -z "$directory" ]; then
 	exit 1
 fi
+directory="${directory#/}"
+directory="${directory%/}"
 
 STATE=1
 while true; do
@@ -204,9 +206,9 @@
 	esac
 
 	if db_go; then
-		STATE=$(($STATE + 1))
+		STATE=$((STATE + 1))
 	else
-		STATE=$(($STATE - 1))
+		STATE=$((STATE - 1))
 	fi
 done
 if [ $STATE -eq 0 ]; then
@@ -232,7 +234,8 @@
 	db_get mirror/$protocol/hostname
 	hostname="$RET"
 	db_get mirror/$protocol/directory
-	directory="/${RET#/}"
+	directory="${RET#/}"
+	directory="${directory%/}"
 
 	case $protocol in
 	    http|https)
@@ -246,11 +249,11 @@
 		;;
 	esac
 
-	echo "deb $protocol://$hostname$directory $codename $dists" > $file
+	echo "deb $protocol://$hostname/$directory $codename $dists" > $file
 	if [ -n "${use_unreleased}" ]; then
-		echo "deb $protocol://$hostname$directory unreleased main" >> $file
+		echo "deb $protocol://$hostname/$directory unreleased main" >> $file
 	fi
-	
+
 	if apt-setup-verify --from $PROGRESS_FROM --to $PROGRESS_TO $file; then
 		done=1
 	else
@@ -273,8 +276,8 @@
 	deb_src="# deb-src"
 fi
 
-echo "$deb_src $protocol://$hostname$directory $codename $dists" >> $file
+echo "$deb_src $protocol://$hostname/$directory $codename $dists" >> $file
 if [ -n "${use_unreleased}" ]; then
 	echo "# 'unreleased' does not support sources yet" >> $file
-	echo "# $deb_src $protocol://$hostname$directory unreleased main" >> $file
+	echo "# $deb_src $protocol://$hostname/$directory unreleased main" >> $file
 fi
diff -ru apt-setup-0.166/generators/50mirror.ubuntu apt-setup-0.166-new/generators/50mirror.ubuntu
--- apt-setup-0.166/generators/50mirror.ubuntu	2018-08-10 14:20:36.000000000 -0500
+++ apt-setup-0.166-new/generators/50mirror.ubuntu	2021-08-24 00:00:00.000000000 -0500
@@ -21,7 +21,7 @@
 
 	# Set default if no value (see Debian mirror generator)
 	db_get apt-setup/use_mirror
-	[ "$RET" ] || db_set apt-setup/use_mirror true 
+	[ "$RET" ] || db_set apt-setup/use_mirror true
 
 	# Text is variable for Debian
 	db_metaget apt-setup/use/netinst_old description
@@ -75,9 +75,9 @@
 	esac
 
 	if db_go; then
-		STATE=$(($STATE + 1))
+		STATE=$((STATE + 1))
 	else
-		STATE=$(($STATE - 1))
+		STATE=$((STATE - 1))
 	fi
 done
 if [ $STATE -eq 0 ]; then
@@ -97,7 +97,8 @@
 db_get mirror/$protocol/hostname
 hostname="$RET"
 db_get mirror/$protocol/directory
-directory="/${RET#/}"
+directory="${RET#/}"
+directory="${directory%/}"
 
 deb_src="deb-src"
 db_get apt-setup/enable-source-repositories
@@ -109,7 +110,7 @@
 # archive.ubuntu.com, not ports.ubuntu.com.
 if [ "$hostname" = ports.ubuntu.com ]; then
 	srchostname=archive.ubuntu.com
-	srcdirectory=/ubuntu
+	srcdirectory=ubuntu
 else
 	srchostname="$hostname"
 	srcdirectory="$directory"
@@ -131,20 +132,20 @@
 PROPOSED="$RET"
 
 cat >> $file <<EOF
-deb $protocol://$hostname$directory $codename $dists
-$deb_src $protocol://$srchostname$srcdirectory $codename $dists
+deb $protocol://$hostname/$directory $codename $dists
+$deb_src $protocol://$srchostname/$srcdirectory $codename $dists
 
 ## Major bug fix updates produced after the final release of the
 ## distribution.
-deb $protocol://$hostname$directory $codename-updates $dists
-$deb_src $protocol://$srchostname$srcdirectory $codename-updates $dists
+deb $protocol://$hostname/$directory $codename-updates $dists
+$deb_src $protocol://$srchostname/$srcdirectory $codename-updates $dists
 EOF
 if [ "$PROPOSED" = true ]; then
 	cat >> $file <<EOF
 
 ## Proposed updates undergoing testing.
-deb $protocol://$hostname$directory $codename-proposed $dists
-$deb_src $protocol://$srchostname$srcdirectory $codename-proposed $dists
+deb $protocol://$hostname/$directory $codename-proposed $dists
+$deb_src $protocol://$srchostname/$srcdirectory $codename-proposed $dists
 EOF
 fi
 
@@ -167,21 +168,21 @@
 ## your rights to use the software. Also, please note that software in
 ## universe WILL NOT receive any review or updates from the Ubuntu security
 ## team.
-${DEB} $protocol://$hostname$directory $codename universe
-${DEB_SRC} $protocol://$srchostname$srcdirectory $codename universe
+${DEB} $protocol://$hostname/$directory $codename universe
+${DEB_SRC} $protocol://$srchostname/$srcdirectory $codename universe
 EOF
 
 # Multiverse is different, don't write anything unless enabled.
 if db_get apt-setup/multiverse && [ "$RET" = true ]; then
 	cat >> $file <<EOF
 
-## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
-## team, and may not be under a free licence. Please satisfy yourself as to 
-## your rights to use the software. Also, please note that software in 
+## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+## team, and may not be under a free licence. Please satisfy yourself as to
+## your rights to use the software. Also, please note that software in
 ## multiverse WILL NOT receive any review or updates from the Ubuntu
 ## security team.
-deb $protocol://$hostname$directory $codename multiverse
-$deb_src $protocol://$srchostname$srcdirectory $codename multiverse
+deb $protocol://$hostname/$directory $codename multiverse
+$deb_src $protocol://$srchostname/$srcdirectory $codename multiverse
 EOF
 fi
 
@@ -205,8 +206,8 @@
 ## newer versions of some applications which may provide useful features.
 ## Also, please note that software in backports WILL NOT receive any review
 ## or updates from the Ubuntu security team.
-${DEB} $protocol://$hostname$directory $codename-backports main restricted universe multiverse
-${DEB_SRC} $protocol://$srchostname$srcdirectory $codename-backports main restricted universe multiverse
+${DEB} $protocol://$hostname/$directory $codename-backports main restricted universe multiverse
+${DEB_SRC} $protocol://$srchostname/$srcdirectory $codename-backports main restricted universe multiverse
 EOF
 
 if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
diff -ru apt-setup-0.166/generators/91security apt-setup-0.166-new/generators/91security
--- apt-setup-0.166/generators/91security	2019-11-17 15:17:25.000000000 -0600
+++ apt-setup-0.166-new/generators/91security	2021-08-24 00:00:00.000000000 -0500
@@ -36,7 +36,11 @@
 esac
 
 # Don't test mirror if no network selected in netcfg
-echo "deb http://$host/debian-security $security_codename $dists" >> $file
+if [ "$host" = "security.debian.org" ]; then
+	echo "deb http://$host $security_codename $dists" >> $file
+else
+	echo "deb http://$host/debian-security $security_codename $dists" >> $file
+fi
 if db_get netcfg/dhcp_options && \
    [ "$RET" = "Do not configure the network at this time" ]; then
 	CODE=9
@@ -59,6 +63,10 @@
 	deb_src="# deb-src"
 fi
 
-echo "$deb_src http://$host/debian-security $security_codename $dists" >> $file
+if [ "$host" = "security.debian.org" ]; then
+	echo "$deb_src http://$host $security_codename $dists" >> $file
+else
+	echo "$deb_src http://$host/debian-security $security_codename $dists" >> $file
+fi
 
 exit $CODE
diff -ru apt-setup-0.166/generators/92updates apt-setup-0.166-new/generators/92updates
--- apt-setup-0.166/generators/92updates	2020-11-01 04:15:39.000000000 -0600
+++ apt-setup-0.166-new/generators/92updates	2021-08-24 00:00:00.000000000 -0500
@@ -12,20 +12,17 @@
 
 if db_get mirror/codename && [ "$RET" ]; then
 	codename="$RET"
-	db_get mirror/suite
-	suite="$RET"
 
 	db_get mirror/protocol
 	protocol="$RET"
 	db_get mirror/$protocol/hostname
 	host="$RET"
 	db_get mirror/$protocol/directory
-	directory="/${RET#/}"
+	directory="${RET#/}"
+	directory="${directory%/}"
 else
 	db_get cdrom/codename
 	codename="$RET"
-	db_get cdrom/suite
-	suite="$RET"
 fi
 
 # To determine if non-free and contrib should be included, grep
@@ -42,13 +39,13 @@
 echo "# see https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_updates_and_backports" >> $file
 
 if  [ -n "$protocol" ] && [ -n "$host" ]; then
-	echo "deb $protocol://${host}${directory} ${codename}-updates $dists" >> $file
+	echo "deb $protocol://${host}/${directory} ${codename}-updates $dists" >> $file
 else
 	echo "# A network mirror was not selected during install.  The following entries" >> $file
 	echo "# are provided as examples, but you should amend them as appropriate" >> $file
 	echo "# for your mirror of choice." >> $file
 	echo "#" >> $file
-	echo "# deb http://deb.debian.org/debian/ ${codename}-updates $dists" >> $file
+	echo "# deb http://deb.debian.org/debian ${codename}-updates $dists" >> $file
 fi
 if db_get netcfg/dhcp_options && \
    [ "$RET" = "Do not configure the network at this time" ]; then
@@ -77,9 +74,9 @@
 fi
 
 if [ -n "$protocol" ] && [ -n "$host" ]; then
-	echo "$deb_src $protocol://${host}${directory} ${codename}-updates $dists" >> $file
+	echo "$deb_src $protocol://${host}/${directory} ${codename}-updates $dists" >> $file
 else
-	echo "# deb-src http://deb.debian.org/debian/ ${codename}-updates $dists" >> $file
+	echo "# deb-src http://deb.debian.org/debian ${codename}-updates $dists" >> $file
 fi
 
 exit $CODE
diff -ru apt-setup-0.166/generators/93backports apt-setup-0.166-new/generators/93backports
--- apt-setup-0.166/generators/93backports	2018-08-10 14:20:36.000000000 -0500
+++ apt-setup-0.166-new/generators/93backports	2021-08-24 00:00:00.000000000 -0500
@@ -12,20 +12,17 @@
 
 if db_get mirror/codename && [ "$RET" ]; then
 	codename="$RET"
-	db_get mirror/suite
-	suite="$RET"
 
 	db_get mirror/protocol
 	protocol="$RET"
 	db_get mirror/$protocol/hostname
 	host="$RET"
 	db_get mirror/$protocol/directory
-	directory="/${RET#/}"
+	directory="${RET#/}"
+	directory="${directory%/}"
 else
 	db_get cdrom/codename
 	codename="$RET"
-	db_get cdrom/suite
-	suite="$RET"
 fi
 
 # To determine if non-free and contrib should be included, grep
@@ -41,13 +38,13 @@
 
 # Don't test mirror if no network selected in netcfg
 if  [ -n "$protocol" ] && [ -n "$host" ]; then
-	echo "deb $protocol://${host}${directory} ${codename}-backports $dists" >> $file
+	echo "deb $protocol://${host}/${directory} ${codename}-backports $dists" >> $file
 else
 	echo "# A network mirror was not selected during install.  The following entries" >> $file
 	echo "# are provided as examples, but you should amend them as appropriate" >> $file
 	echo "# for your mirror of choice." >> $file
 	echo "#" >> $file
-	echo "# deb http://deb.debian.org/debian/ ${codename}-backports $dists" >> $file
+	echo "# deb http://deb.debian.org/debian ${codename}-backports $dists" >> $file
 fi
 if db_get netcfg/dhcp_options && \
    [ "$RET" = "Do not configure the network at this time" ]; then
@@ -76,9 +73,9 @@
 fi
 
 if [ -n "$protocol" ] && [ -n "$host" ]; then
-	echo "$deb_src $protocol://${host}${directory} ${codename}-backports $dists" >> $file
+	echo "$deb_src $protocol://${host}/${directory} ${codename}-backports $dists" >> $file
 else
-	echo "# deb-src http://deb.debian.org/debian/ ${codename}-backports $dists" >> $file
+	echo "# deb-src http://deb.debian.org/debian ${codename}-backports $dists" >> $file
 fi
 
 exit $CODE
