From 174bcdb41d961c49e5f94553d1e34d3d7b9dec56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luis=20Guzm=C3=A1n?= <ark@switnet.org>
Date: Sun, 17 Jul 2022 09:04:02 +0000
Subject: [PATCH] choose-mirror: integrate udeb from debian upstream

---
 helpers/DATA/choose-mirror/rev_Makefile.patch | 14 ++++++++++
 .../rev_choose-mirror-bin.templates-in.patch  | 22 +++++++++++++++
 helpers/make-choose-mirror                    | 28 ++++++++++++-------
 3 files changed, 54 insertions(+), 10 deletions(-)
 create mode 100644 helpers/DATA/choose-mirror/rev_Makefile.patch
 create mode 100644 helpers/DATA/choose-mirror/rev_choose-mirror-bin.templates-in.patch

diff --git a/helpers/DATA/choose-mirror/rev_Makefile.patch b/helpers/DATA/choose-mirror/rev_Makefile.patch
new file mode 100644
index 00000000..eab1a6da
--- /dev/null
+++ b/helpers/DATA/choose-mirror/rev_Makefile.patch
@@ -0,0 +1,14 @@
+diff -ru choose-mirror-2.78ubuntu7+10.0trisquel3/Makefile choose-mirror-2.111/Makefile
+--- choose-mirror-2.78ubuntu7+10.0trisquel3/Makefile	2021-02-26 15:22:56.000000000 -0600
++++ choose-mirror-2.111/Makefile	2021-06-04 12:09:55.000000000 -0500
+@@ -33,8 +33,8 @@
+ STRIP=strip
+ 
+ # Derivative distributions may want to change these.
+-#MIRRORLISTURL=https://anonscm.debian.org/git/mirror/mirror-masterlist.git/plain/Mirrors.masterlist
+-MASTERLIST=Mirrors.masterlist.trisquel
++MIRRORLISTURL=https://salsa.debian.org/mirror-team/masterlist/raw/master/Mirrors.masterlist
++MASTERLIST=Mirrors.masterlist
+ 
+ ifdef DEBUG
+ CFLAGS:=$(CFLAGS) -DDODEBUG
diff --git a/helpers/DATA/choose-mirror/rev_choose-mirror-bin.templates-in.patch b/helpers/DATA/choose-mirror/rev_choose-mirror-bin.templates-in.patch
new file mode 100644
index 00000000..2638a729
--- /dev/null
+++ b/helpers/DATA/choose-mirror/rev_choose-mirror-bin.templates-in.patch
@@ -0,0 +1,22 @@
+diff -ru choose-mirror-2.78ubuntu7+10.0trisquel3/debian/choose-mirror-bin.templates-in choose-mirror-2.111/debian/choose-mirror-bin.templates-in
+--- choose-mirror-2.78ubuntu7+10.0trisquel3/debian/choose-mirror-bin.templates-in	2021-02-26 15:22:56.000000000 -0600
++++ choose-mirror-2.111/debian/choose-mirror-bin.templates-in	2021-02-08 06:52:03.000000000 -0600
+@@ -12,10 +12,14 @@
+ Type: select
+ Choices-C: ${CHOICES-C}
+ Choices: ${CHOICES}
+-Default: nabia
+-Description: Trisquel version to install:
+- In Trisquel, this question is never asked, and is only for preseeding.
+- Caveat emptor.
++# :sl2:
++_Description: Debian version to install:
++ Debian comes in several flavors. Stable is well-tested and rarely changes.
++ Unstable is untested and frequently changing. Testing is a middle ground,
++ that receives many of the new versions from unstable if they are not too
++ buggy.
++ .
++ Only flavors available on the selected mirror are listed.
+ 
+ Template: mirror/codename
+ Type: string
diff --git a/helpers/make-choose-mirror b/helpers/make-choose-mirror
index 29afc701..6953a852 100644
--- a/helpers/make-choose-mirror
+++ b/helpers/make-choose-mirror
@@ -1,5 +1,6 @@
 #!/bin/sh
 #
+#    Copyright (C) 2022 Luis Guzmán <ark@switnet.org>
 #    Copyright (C) 2009-2018  Ruben Rodriguez <ruben@gnu.org>
 #
 #    This program is free software; you can redistribute it and/or modify
@@ -17,20 +18,27 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=3
+VERSION=4
+EXTERNAL='deb-src http://ftp.debian.org/debian stable main'
+REPOKEY=648ACFD622F3D138
 NETINST=true
 . ./config
 
-sed s/ubuntu/trisquel/g -i Makefile
-rpl archive.ubuntu.com archive.trisquel.org . -R
-rpl ports.ubuntu.com archive.trisquel.org . -R
-rpl ubuntu-ports trisquel-ports . -R
-rpl Ubuntu Trisquel . -R
-rpl /ubuntu/ /trisquel/ . -R
-rpl $UPSTREAM $CODENAME . -R
-rpl Mirrors.masterlist.ubuntu Mirrors.masterlist.trisquel . -R
+patch -R -p1 < $DATA/rev_Makefile.patch
+patch -R -p1 < $DATA/rev_choose-mirror-bin.templates-in.patch
 
-rm Mirrors.masterlist.ubuntu
+sed -i '/oldstable/d;
+        /testing/d;
+        /unstable/d;' mirrors.h
+sed -i "s|stable|$CODENAME|" mirrors.h
+
+replace "deb.debian.org" "archive.trisquel.org" .
+replace "debian.org" "trisquel.org" .
+replace "Debian" "Trisquel" .
+replace "/debian/" "/trisquel/" .
+sed -i 's|Mirrors.masterlist|Mirrors.masterlist.trisquel|' mirrorlist
+
+rm Mirrors.masterlist
 wget https://archive.trisquel.org/trisquel/Mirrors.masterlist -o /dev/null -O Mirrors.masterlist.trisquel
 
 changelog "Rebranded and adapted for Trisquel"
-- 
GitLab