From patchwork Thu Oct 14 19:01:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 4788 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4HVf0C0lJNz3wcZ for ; Thu, 14 Oct 2021 19:02:03 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4HVf0915Fkz1Nl; Thu, 14 Oct 2021 19:02:01 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4HVf085rQtz2yVC; Thu, 14 Oct 2021 19:02:00 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4HVf075FG1z2xGC for ; Thu, 14 Oct 2021 19:01:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4HVf0712ZgzRC; Thu, 14 Oct 2021 19:01:59 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1634238119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PKlb+hQQWEUJycMfQAuP5DXFj/xvk8On1UkCZNxRq5g=; b=azrO67XbaebefBa3P7NcGGASiQ4et32gF7mvVhTp/b2uSothh+QPdJ+adz9hCpe+pVGm7y NKFIwsHWSTYFRQCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1634238119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PKlb+hQQWEUJycMfQAuP5DXFj/xvk8On1UkCZNxRq5g=; b=gHnjNDdubz4O7I7Cj61e1ZXUpqm21ofO+9PUVfYecOyNQIE2hk0VTj0Y/bLMvRqvI6GHX5 wWLWjw3S8WV73Oi7I3arD09m6QVNxX+qN7Et7EAg5zCTrdsUvTjhTKZoyRvAcZ9s/rQDtM 0TfgE5rOEsV9kfvDDyGdxwkDsEOZmfzNmlzkWd10ItDYmeZEKRbOP2whd2Eb3Y0WZ3VrOt FlHub6S24I4irSW0RDyeKcHkf1geUXIl2kTKowyvThwI4SreEdvr1G+jpB1q9qhZm3Ua7e aswPJz8v+pJHBKLQf3j/BmQVZUHaJhL4cgqr0u6jcnAylabXr43vSN4yOC+o7g== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] pakfire: Allow pinning Pakfire to one mirror server Date: Thu, 14 Oct 2021 19:01:49 +0000 Message-Id: <20211014190149.20704-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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 --- src/pakfire/lib/functions.pl | 12 ++++++++++++ src/pakfire/pakfire.conf | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index f46c9acc1..4d9854a6f 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -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; diff --git a/src/pakfire/pakfire.conf b/src/pakfire/pakfire.conf index 9930f3771..bc54dcff4 100644 --- a/src/pakfire/pakfire.conf +++ b/src/pakfire/pakfire.conf @@ -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";