]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
pakfire: Allow pinning Pakfire to one mirror server
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Oct 2021 19:01:49 +0000 (19:01 +0000)
committerArne Fitzenreiter <arne_f@ipfire.org>
Tue, 19 Oct 2021 11:28:39 +0000 (11:28 +0000)
This patch adds a new $mirror option to the configuration file which
will cause Pakfire to only use this one to download any files.

This feature is disabled by default but useful for development.

Fixes: #12706
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
src/pakfire/lib/functions.pl
src/pakfire/pakfire.conf

index f46c9acc138032301df5cffa0865f34deb6b43c6..4d9854a6fd9ce3b53d71959702d3a70ad078bfa5 100644 (file)
@@ -30,6 +30,7 @@ use HTTP::Headers;
 use HTTP::Message;
 use HTTP::Request;
 use Net::Ping;
+use URI;
 
 use Switch;
 
@@ -297,6 +298,17 @@ sub valid_signature($) {
 }
 
 sub selectmirror {
+       if (defined ${Conf::mirror}) {
+               my $uri = URI->new("${Conf::mirror}");
+
+               # Only accept HTTPS mirrors
+               if ($uri->scheme eq "https") {
+                       return ("HTTPS", $uri->host, $uri->path . "/" . ${Conf::version});
+               } else {
+                       message("MIRROR ERROR: Unsupported mirror: " . ${Conf::mirror});
+               }
+       }
+
        ### Check if there is a current server list and read it.
        #   If there is no list try to get one.
        my $count = 0;
index 9930f3771bd42ff57a2df302425c489cf8b7d116..bc54dcff4e462e0727ea025eb0a5492b2a010185 100644 (file)
@@ -23,6 +23,9 @@ package Conf;
 
 $mainserver = "pakfire.ipfire.org";
 
+# Only use this mirror
+#$mirror = "https://mirror1.ipfire.org/pakfire2";
+
 $cachedir = "/opt/pakfire/cache";
 $dbdir = "/opt/pakfire/db";
 $coredir = "/opt/pakfire/db/core";