]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
fix changelog url for pve repository
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Aug 2013 09:35:48 +0000 (11:35 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Aug 2013 09:35:48 +0000 (11:35 +0200)
To make it compatible with 'apt-get changelog'

PVE/API2/APT.pm
PVE/API2/Subscription.pm
PVE/API2Tools.pm

index 4626e75179abc129a65226f2a8918477795fdd00..ff7408ece81841cb4626b90006fbcdb0c1a0c265 100644 (file)
@@ -84,7 +84,7 @@ my $get_pkgfile = sub {
 };
 
 my $get_changelog_url =sub {
-    my ($pkgname, $info, $pkgver, $origin) = @_;
+    my ($pkgname, $info, $pkgver, $origin, $component) = @_;
 
     my $changelog_url;
     my $base = dirname($info->{FileName});
@@ -95,8 +95,13 @@ my $get_changelog_url =sub {
            $changelog_url = "http://packages.debian.org/changelogs/$base/" . 
                "${srcpkg}_${pkgver}/changelog";
        } elsif ($origin eq 'Proxmox') {
-           $changelog_url = "http://download.proxmox.com/changelogs/${pkgname}/" . 
-               "${pkgname}_${pkgver}_changelog";
+           if ($component eq 'pve-enterprise') {
+               $changelog_url = "https://enterprise.proxmox.com/debian/$base/" . 
+                   "${srcpkg}_${pkgver}.changelog";
+           } else {
+               $changelog_url = "http://download.proxmox.com/debian/$base/" .
+                   "${srcpkg}_${pkgver}.changelog";
+           }
        }
     }
 
@@ -113,9 +118,9 @@ my $assemble_pkginfo = sub {
     };
 
     if (my $pkgfile = &$get_pkgfile($candidate_ver)) {
-       my $origin = $pkgfile->{Origin};
-       $data->{Origin} = $origin;
-       if (my $changelog_url = &$get_changelog_url($pkgname, $info, $candidate_ver->{VerStr}, $origin)) {
+       $data->{Origin} = $pkgfile->{Origin};
+       if (my $changelog_url = &$get_changelog_url($pkgname, $info, $candidate_ver->{VerStr}, 
+                                                   $pkgfile->{Origin}, $pkgfile->{Component})) {
            $data->{ChangeLogUrl} = $changelog_url;
        }
     }
@@ -366,7 +371,7 @@ __PACKAGE__->register_method({
        my $url;
 
        die "changelog for '${pkgname}_$ver->{VerStr}' not available\n"
-           if !($pkgfile && ($url = &$get_changelog_url($pkgname, $info, $ver->{VerStr}, $pkgfile->{Origin})));
+           if !($pkgfile && ($url = &$get_changelog_url($pkgname, $info, $ver->{VerStr}, $pkgfile->{Origin}, $pkgfile->{Component})));
 
        my $data = "";
 
@@ -377,13 +382,27 @@ __PACKAGE__->register_method({
        $ua->agent("PVE/1.0");
        $ua->timeout(10);
        $ua->max_size(1024*1024);
-  
+       $ua->ssl_opts(verify_hostname => 0); # don't care for changelogs
+
        if ($proxy) {
-           $ua->proxy(['http'], $proxy);
+           $ua->proxy(['http', 'https'], $proxy);
        } else {
            $ua->env_proxy;
        }
 
+       my $username;
+       my $pw;
+
+       if ($pkgfile->{Origin} eq 'Proxmox' && $pkgfile->{Component} eq 'pve-enterprise') {
+           my $info = PVE::INotify::read_file('subscription');
+           if ($info->{status} eq 'Active') {
+               $username = $info->{key};
+               $pw = PVE::API2Tools::get_hwaddress();
+               $ua->credentials("enterprise.proxmox.com:443", 'pve-enterprise-repository', 
+                                $username, $pw);
+           }
+       }
+
        my $response = $ua->get($url);
 
         if ($response->is_success) {
index 64d33f7a46aca7c7374319873c4ee2062287ffe7..a491add31ca3ecb2f61ba20de3b7ae9f8a0859d5 100644 (file)
@@ -35,18 +35,6 @@ my $localkeydays = 15;
 my $allowcheckfaildays = 5;
 
 my $shared_key_data = "kjfdlskfhiuewhfk947368";
-my $hwaddress;
-
-sub get_hwaddress {
-    
-    return $hwaddress if defined ($hwaddress);
-
-    my $fn = '/etc/ssh/ssh_host_rsa_key.pub';
-    my $sshkey = PVE::Tools::file_get_contents($fn);
-    $hwaddress = uc(md5_hex($sshkey));
-
-    return $hwaddress;
-}
 
 sub get_sockets {
     my $info = PVE::ProcFSTools::read_cpuinfo();
@@ -147,7 +135,7 @@ sub read_etc_pve_subscription {
            die "checksum failure\n" if $csum ne $newcsum;
 
            my $req_sockets = get_sockets();
-           my $server_id = get_hwaddress();
+           my $server_id = PVE::API2Tools::get_hwaddress();
 
            check_fields($localinfo, $server_id, $req_sockets);
 
@@ -176,8 +164,8 @@ sub read_etc_pve_subscription {
 sub write_apt_auth {
     my $key = shift;
 
-    my $server_id = get_hwaddress();
-    my $auth = { 'enterprise.proxmox.com' => { login => $key, password => get_hwaddress() } };
+    my $server_id = PVE::API2Tools::get_hwaddress();
+    my $auth = { 'enterprise.proxmox.com' => { login => $key, password => $server_id } };
     PVE::INotify::update_file('apt-auth', $auth);
 
 }
@@ -208,7 +196,7 @@ sub check_subscription {
 
     my $uri = "$whmcsurl/modules/servers/licensing/verify.php";
  
-    my $server_id = get_hwaddress();
+    my $server_id = PVE::API2Tools::get_hwaddress();
 
     my $req_sockets = get_sockets();
 
@@ -297,7 +285,7 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       my $server_id = get_hwaddress();
+       my $server_id = PVE::API2Tools::get_hwaddress();
 
        my $info = PVE::INotify::read_file('subscription');
        if (!$info) {
@@ -384,7 +372,7 @@ __PACKAGE__->register_method ({
        };
 
        my $req_sockets = get_sockets();
-       my $server_id = get_hwaddress();
+       my $server_id = PVE::API2Tools::get_hwaddress();
 
        check_fields($info, $server_id, $req_sockets);
 
index 533c2afa695698b891bb22fc4e847533e025c5f7..8208745fc28fe491fb5e52da857f9314cc1248c8 100644 (file)
@@ -2,6 +2,21 @@ package PVE::API2Tools;
 
 use strict;
 use warnings;
+use PVE::Tools;
+use Digest::MD5 qw(md5_hex);
+
+my $hwaddress;
+
+sub get_hwaddress {
+    
+    return $hwaddress if defined ($hwaddress);
+
+    my $fn = '/etc/ssh/ssh_host_rsa_key.pub';
+    my $sshkey = PVE::Tools::file_get_contents($fn);
+    $hwaddress = uc(md5_hex($sshkey));
+
+    return $hwaddress;
+}
 
 sub extract_node_stats {
     my ($node, $members, $rrd) = @_;