Commit dab54677 authored by Dietmar Maurer's avatar Dietmar Maurer

fix changelog url for pve repository

To make it compatible with 'apt-get changelog'
parent 787217cd
...@@ -84,7 +84,7 @@ my $get_pkgfile = sub { ...@@ -84,7 +84,7 @@ my $get_pkgfile = sub {
}; };
my $get_changelog_url =sub { my $get_changelog_url =sub {
my ($pkgname, $info, $pkgver, $origin) = @_; my ($pkgname, $info, $pkgver, $origin, $component) = @_;
my $changelog_url; my $changelog_url;
my $base = dirname($info->{FileName}); my $base = dirname($info->{FileName});
...@@ -95,8 +95,13 @@ my $get_changelog_url =sub { ...@@ -95,8 +95,13 @@ my $get_changelog_url =sub {
$changelog_url = "http://packages.debian.org/changelogs/$base/" . $changelog_url = "http://packages.debian.org/changelogs/$base/" .
"${srcpkg}_${pkgver}/changelog"; "${srcpkg}_${pkgver}/changelog";
} elsif ($origin eq 'Proxmox') { } elsif ($origin eq 'Proxmox') {
$changelog_url = "http://download.proxmox.com/changelogs/${pkgname}/" . if ($component eq 'pve-enterprise') {
"${pkgname}_${pkgver}_changelog"; $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 { ...@@ -113,9 +118,9 @@ my $assemble_pkginfo = sub {
}; };
if (my $pkgfile = &$get_pkgfile($candidate_ver)) { if (my $pkgfile = &$get_pkgfile($candidate_ver)) {
my $origin = $pkgfile->{Origin}; $data->{Origin} = $pkgfile->{Origin};
$data->{Origin} = $origin; if (my $changelog_url = &$get_changelog_url($pkgname, $info, $candidate_ver->{VerStr},
if (my $changelog_url = &$get_changelog_url($pkgname, $info, $candidate_ver->{VerStr}, $origin)) { $pkgfile->{Origin}, $pkgfile->{Component})) {
$data->{ChangeLogUrl} = $changelog_url; $data->{ChangeLogUrl} = $changelog_url;
} }
} }
...@@ -366,7 +371,7 @@ __PACKAGE__->register_method({ ...@@ -366,7 +371,7 @@ __PACKAGE__->register_method({
my $url; my $url;
die "changelog for '${pkgname}_$ver->{VerStr}' not available\n" 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 = ""; my $data = "";
...@@ -377,13 +382,27 @@ __PACKAGE__->register_method({ ...@@ -377,13 +382,27 @@ __PACKAGE__->register_method({
$ua->agent("PVE/1.0"); $ua->agent("PVE/1.0");
$ua->timeout(10); $ua->timeout(10);
$ua->max_size(1024*1024); $ua->max_size(1024*1024);
$ua->ssl_opts(verify_hostname => 0); # don't care for changelogs
if ($proxy) { if ($proxy) {
$ua->proxy(['http'], $proxy); $ua->proxy(['http', 'https'], $proxy);
} else { } else {
$ua->env_proxy; $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); my $response = $ua->get($url);
if ($response->is_success) { if ($response->is_success) {
......
...@@ -35,18 +35,6 @@ my $localkeydays = 15; ...@@ -35,18 +35,6 @@ my $localkeydays = 15;
my $allowcheckfaildays = 5; my $allowcheckfaildays = 5;
my $shared_key_data = "kjfdlskfhiuewhfk947368"; 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 { sub get_sockets {
my $info = PVE::ProcFSTools::read_cpuinfo(); my $info = PVE::ProcFSTools::read_cpuinfo();
...@@ -147,7 +135,7 @@ sub read_etc_pve_subscription { ...@@ -147,7 +135,7 @@ sub read_etc_pve_subscription {
die "checksum failure\n" if $csum ne $newcsum; die "checksum failure\n" if $csum ne $newcsum;
my $req_sockets = get_sockets(); my $req_sockets = get_sockets();
my $server_id = get_hwaddress(); my $server_id = PVE::API2Tools::get_hwaddress();
check_fields($localinfo, $server_id, $req_sockets); check_fields($localinfo, $server_id, $req_sockets);
...@@ -176,8 +164,8 @@ sub read_etc_pve_subscription { ...@@ -176,8 +164,8 @@ sub read_etc_pve_subscription {
sub write_apt_auth { sub write_apt_auth {
my $key = shift; my $key = shift;
my $server_id = get_hwaddress(); my $server_id = PVE::API2Tools::get_hwaddress();
my $auth = { 'enterprise.proxmox.com' => { login => $key, password => get_hwaddress() } }; my $auth = { 'enterprise.proxmox.com' => { login => $key, password => $server_id } };
PVE::INotify::update_file('apt-auth', $auth); PVE::INotify::update_file('apt-auth', $auth);
} }
...@@ -208,7 +196,7 @@ sub check_subscription { ...@@ -208,7 +196,7 @@ sub check_subscription {
my $uri = "$whmcsurl/modules/servers/licensing/verify.php"; 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(); my $req_sockets = get_sockets();
...@@ -297,7 +285,7 @@ __PACKAGE__->register_method ({ ...@@ -297,7 +285,7 @@ __PACKAGE__->register_method ({
code => sub { code => sub {
my ($param) = @_; my ($param) = @_;
my $server_id = get_hwaddress(); my $server_id = PVE::API2Tools::get_hwaddress();
my $info = PVE::INotify::read_file('subscription'); my $info = PVE::INotify::read_file('subscription');
if (!$info) { if (!$info) {
...@@ -384,7 +372,7 @@ __PACKAGE__->register_method ({ ...@@ -384,7 +372,7 @@ __PACKAGE__->register_method ({
}; };
my $req_sockets = get_sockets(); my $req_sockets = get_sockets();
my $server_id = get_hwaddress(); my $server_id = PVE::API2Tools::get_hwaddress();
check_fields($info, $server_id, $req_sockets); check_fields($info, $server_id, $req_sockets);
......
...@@ -2,6 +2,21 @@ package PVE::API2Tools; ...@@ -2,6 +2,21 @@ package PVE::API2Tools;
use strict; use strict;
use warnings; 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 { sub extract_node_stats {
my ($node, $members, $rrd) = @_; my ($node, $members, $rrd) = @_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment