]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/pakfire/lib/functions.pl
Pakfire: fix upstream proxy usage
[people/pmueller/ipfire-2.x.git] / src / pakfire / lib / functions.pl
index 61787757eb5e46bcb22996a135161fc667845601..17a420c33c1f2d8228241aed775195ca85758270 100644 (file)
@@ -70,6 +70,9 @@ my $bfile;
 my %pakfiresettings = ();
 &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
 
+# Make version
+$Conf::version = &make_version();
+
 sub message {
        my $message = shift;
                
@@ -158,10 +161,10 @@ sub fetchfile {
                if ($proxysettings{'UPSTREAM_PROXY'}) {
                        logger("DOWNLOAD INFO: Upstream proxy: \"$proxysettings{'UPSTREAM_PROXY'}\"");
                        if ($proxysettings{'UPSTREAM_USER'}) {
-                               $ua->proxy([["http", "https"] => "http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$proxysettings{'UPSTREAM_PROXY'}/"]);
+                               $ua->proxy(["http", "https"], "http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$proxysettings{'UPSTREAM_PROXY'}/");
                                logger("DOWNLOAD INFO: Logging in with: \"$proxysettings{'UPSTREAM_USER'}\" - \"$proxysettings{'UPSTREAM_PASSWORD'}\"");
                        } else {
-                               $ua->proxy([["http", "https"] => "http://$proxysettings{'UPSTREAM_PROXY'}/"]);
+                               $ua->proxy(["http", "https"], "http://$proxysettings{'UPSTREAM_PROXY'}/");
                        }
                }
 
@@ -765,6 +768,12 @@ sub upgradecore {
        getcoredb("noforce");
        eval(`grep "core_" $Conf::dbdir/lists/core-list.db`);
        if ("$core_release" > "$Conf::core_mine") {
+               # Safety check for lazy testers:
+               # Before we upgrade to the latest release, we re-install the previous release
+               # to make sure that the tester has always been on the latest version.
+               my $tree = &get_tree();
+               $Conf::core_mine-- if ($tree eq "testing" || $tree eq "unstable");
+
                message("CORE UPGR: Upgrading from release $Conf::core_mine to $core_release");
                
                my @seq = `seq $Conf::core_mine $core_release`;
@@ -946,4 +955,57 @@ sub status {
        exit 1;
 }
 
+sub get_arch() {
+       # Append architecture
+       my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();
+
+       # We only support armv5tel for all 32 bit arches
+       if ($machine =~ m/armv[567]/) {
+               return "armv5tel";
+
+       # We only support i586 for 32 bit x86
+       } elsif ($machine =~ m/i[0-9]86/) {
+               return "i586";
+       }
+
+       return $machine;
+}
+
+sub get_tree() {
+       # Return stable if nothing is set
+       return "stable" unless (defined $pakfiresettings{'TREE'});
+
+       return $pakfiresettings{'TREE'};
+}
+
+sub make_version() {
+       my $version = "";
+
+       # Open /etc/system-release
+       open(RELEASE, "</etc/system-release");
+       my $release = <RELEASE>;
+       close(RELEASE);
+
+       # Add the main relase
+       if ($release =~ m/IPFire ([\d\.]+)/) {
+               $version .= $1;
+       }
+
+       # Append suffix for tree
+       my $tree = &get_tree();
+       if ($tree eq "testing") {
+               $version .= ".1";
+       } elsif ($tree eq "unstable") {
+               $version .= ".2";
+       }
+
+       # Append architecture
+       my $arch = &get_arch();
+       if ($arch ne "i586") {
+               $version .= "-${arch}";
+       }
+
+       return $version;
+}
+
 1;