Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package perl-Net-OBS-Client for 
openSUSE:Factory checked in at 2024-03-28 13:55:37
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Net-OBS-Client (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Net-OBS-Client.new.1905 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Net-OBS-Client"

Thu Mar 28 13:55:37 2024 rev:5 rq:1163298 version:0.1.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Net-OBS-Client/perl-Net-OBS-Client.changes  
2023-11-30 22:05:58.139512842 +0100
+++ 
/work/SRC/openSUSE:Factory/.perl-Net-OBS-Client.new.1905/perl-Net-OBS-Client.changes
        2024-03-28 14:33:05.430822776 +0100
@@ -1,0 +2,6 @@
+Thu Mar 28 11:18:18 UTC 2024 - Frank Schreiner <[email protected]>
+
+- updated to 0.1.2
+   see /usr/share/doc/packages/perl-Net-OBS-Client/Changes
+
+-------------------------------------------------------------------

Old:
----
  Net-OBS-Client-0.1.1.tar.gz

New:
----
  Net-OBS-Client-0.1.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Net-OBS-Client.spec ++++++
--- /var/tmp/diff_new_pack.aXmayw/_old  2024-03-28 14:33:12.611083744 +0100
+++ /var/tmp/diff_new_pack.aXmayw/_new  2024-03-28 14:33:12.611083744 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-Net-OBS-Client
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %define cpan_name Net-OBS-Client
 Name:           perl-Net-OBS-Client
-Version:        0.1.1
+Version:        0.1.2
 Release:        0
 License:        Artistic-2.0
 Summary:        Simple OBS API calls
@@ -30,6 +30,7 @@
 BuildRequires:  perl-macros
 BuildRequires:  perl(Config::INI::Reader)
 BuildRequires:  perl(Config::Tiny)
+BuildRequires:  perl(Const::Fast)
 BuildRequires:  perl(HTTP::Cookies)
 BuildRequires:  perl(HTTP::Request)
 BuildRequires:  perl(LWP::UserAgent)
@@ -42,6 +43,7 @@
 BuildRequires:  perl(XML::Structured)
 Requires:       perl(Config::INI::Reader)
 Requires:       perl(Config::Tiny)
+Requires:       perl(Const::Fast)
 Requires:       perl(HTTP::Cookies)
 Requires:       perl(HTTP::Request)
 Requires:       perl(LWP::UserAgent)

++++++ Net-OBS-Client-0.1.1.tar.gz -> Net-OBS-Client-0.1.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/Changes 
new/Net-OBS-Client-0.1.2/Changes
--- old/Net-OBS-Client-0.1.1/Changes    2023-11-30 13:51:34.821017279 +0100
+++ new/Net-OBS-Client-0.1.2/Changes    2024-03-27 16:11:10.902957250 +0100
@@ -1,4 +1,9 @@
 Revision history for Net-OBS-Client
+0.1.2 2024-03-27
+
+  * added Net::OBS::LWP::UserAgent with 'mirror' method
+  * multiple configuration parameters for Net::OBS::SigAuth
+
 
 0.1.1 2023-11-30
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/MANIFEST 
new/Net-OBS-Client-0.1.2/MANIFEST
--- old/Net-OBS-Client-0.1.1/MANIFEST   2023-11-30 14:10:39.728067997 +0100
+++ new/Net-OBS-Client-0.1.2/MANIFEST   2024-03-28 10:56:55.385643856 +0100
@@ -7,6 +7,7 @@
 lib/Net/OBS/Client/Roles/BuildStatus.pm
 lib/Net/OBS/Client/Roles/Client.pm
 lib/Net/OBS/SigAuth.pm
+lib/Net/OBS/LWP/UserAgent.pm
 
 Makefile.PL
 MANIFEST                       This list of files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/META.json 
new/Net-OBS-Client-0.1.2/META.json
--- old/Net-OBS-Client-0.1.1/META.json  2023-11-30 14:10:39.691401532 +0100
+++ new/Net-OBS-Client-0.1.2/META.json  2024-03-28 10:56:55.322310870 +0100
@@ -36,6 +36,7 @@
          "requires" : {
             "Config::INI::Reader" : "0",
             "Config::Tiny" : "0",
+            "Const::Fast" : "0",
             "HTTP::Cookies" : "0",
             "HTTP::Request" : "0",
             "LWP::UserAgent" : "0",
@@ -49,6 +50,16 @@
       }
    },
    "release_status" : "stable",
-   "version" : "v0.1.1",
+   "resources" : {
+      "bugtracker" : {
+         "web" : "https://github.com/M0ses/Net-OBS-Client/issues";
+      },
+      "repository" : {
+         "type" : "git",
+         "url" : "https://github.com/M0ses/Net-OBS-Client.git";,
+         "web" : "https://github.com/M0ses/Net-OBS-Client";
+      }
+   },
+   "version" : "v0.1.2",
    "x_serialization_backend" : "JSON::PP version 4.16"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/META.yml 
new/Net-OBS-Client-0.1.2/META.yml
--- old/Net-OBS-Client-0.1.1/META.yml   2023-11-30 14:10:39.534735725 +0100
+++ new/Net-OBS-Client-0.1.2/META.yml   2024-03-28 10:56:55.095645447 +0100
@@ -22,6 +22,7 @@
 requires:
   Config::INI::Reader: '0'
   Config::Tiny: '0'
+  Const::Fast: '0'
   HTTP::Cookies: '0'
   HTTP::Request: '0'
   LWP::UserAgent: '0'
@@ -31,5 +32,8 @@
   URI::URL: '0'
   XML::Structured: '0'
   perl: '5.006'
-version: v0.1.1
+resources:
+  bugtracker: https://github.com/M0ses/Net-OBS-Client/issues
+  repository: https://github.com/M0ses/Net-OBS-Client.git
+version: v0.1.2
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/Makefile.PL 
new/Net-OBS-Client-0.1.2/Makefile.PL
--- old/Net-OBS-Client-0.1.1/Makefile.PL        2023-04-24 17:01:12.340774551 
+0200
+++ new/Net-OBS-Client-0.1.2/Makefile.PL        2024-03-28 09:50:33.200829213 
+0100
@@ -3,7 +3,7 @@
 use warnings;
 use ExtUtils::MakeMaker;
 
-WriteMakefile(
+%::d =  (
     NAME             => 'Net::OBS::Client',
     AUTHOR           => q{Frank Schreiner <[email protected]>},
     VERSION_FROM     => 'lib/Net/OBS/Client.pm',
@@ -30,7 +30,21 @@
         'HTTP::Cookies'       =>  0,
         'URI::URL'            =>  0,
         'Path::Class'         =>  0,
+        'Const::Fast'         =>  0,
+    },
+    META_MERGE    => {
+        'meta-spec' => { version => 2 },
+         resources => {
+             repository => {
+                 type => 'git',
+                 url  => 'https://github.com/M0ses/Net-OBS-Client.git',
+                 web  => 'https://github.com/M0ses/Net-OBS-Client',
+             },
+             bugtracker => {web => 
'https://github.com/M0ses/Net-OBS-Client/issues'},
+         },
     },
     dist  => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
     clean => { FILES => 'Net-OBS-Client-*' },
 );
+WriteMakefile(%::d) if $0 =~ m#^(?:.*/)?Makefile.PL$#;
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Net-OBS-Client-0.1.1/lib/Net/OBS/Client/Roles/Client.pm 
new/Net-OBS-Client-0.1.2/lib/Net/OBS/Client/Roles/Client.pm
--- old/Net-OBS-Client-0.1.1/lib/Net/OBS/Client/Roles/Client.pm 2023-11-24 
16:36:27.664755951 +0100
+++ new/Net-OBS-Client-0.1.2/lib/Net/OBS/Client/Roles/Client.pm 2024-03-26 
15:23:06.676232988 +0100
@@ -2,13 +2,13 @@
 
 use Moose::Role;
 
-use LWP::UserAgent;
 use XML::Structured;
 use Config::Tiny;
 use HTTP::Request;
 use HTTP::Cookies;
 use Carp qw/croak/;
 use File::Path qw/make_path/;
+use Net::OBS::LWP::UserAgent;
 
 use Net::OBS::SigAuth;
 
@@ -55,7 +55,7 @@
   isa     =>    'Object',
   lazy    =>    1,
   default => sub {
-    my $ua = LWP::UserAgent->new(
+    my $ua = Net::OBS::LWP::UserAgent->new(
       cookie_jar => $_[0]->cookie_jar
     );
     if ($ENV{NET_OBS_CLIENT_DEBUG}) {
@@ -68,7 +68,7 @@
     }
     $ua->timeout(10);
     $ua->env_proxy;
-
+    $ua->sigauth_credentials($_[0]->sigauth_credentials) if 
%{$_[0]->sigauth_credentials};
     return $ua
   },
 );
@@ -119,6 +119,13 @@
   },
 );
 
+has sigauth_credentials => (
+  is      =>    'rw',
+  isa     =>    'HashRef',
+  lazy    =>    1,
+  default =>    sub { {} },
+);
+
 has cookie_jar_file => (
   is      =>    'rw',
   isa     =>    'Str',
@@ -149,6 +156,7 @@
   $self->api_path($api_path) if $api_path;
 
   my $ua = $self->user_agent();
+  $ua->sigauth_credentials($self->sigauth_credentials) if 
$self->sigauth_credentials;
   my $url = $self->apiurl . $self->api_path;
 
   debug(" $method: $url");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/lib/Net/OBS/Client.pm 
new/Net-OBS-Client-0.1.2/lib/Net/OBS/Client.pm
--- old/Net-OBS-Client-0.1.1/lib/Net/OBS/Client.pm      2023-11-30 
13:46:41.435960547 +0100
+++ new/Net-OBS-Client-0.1.2/lib/Net/OBS/Client.pm      2024-03-27 
16:11:21.136234428 +0100
@@ -8,7 +8,7 @@
 
 with 'Net::OBS::Client::Roles::Client';
 
-our $VERSION = '0.1.1';
+our $VERSION = '0.1.2';
 
 sub project {
   my ($self, @args) = @_;
@@ -19,6 +19,7 @@
     pass       => $self->pass,
     repository => $self->repository,
     arch       => $self->arch,
+    sigauth_credentials => $self->sigauth_credentials,
     @args,
   );
 }
@@ -30,6 +31,7 @@
     use_oscrc  => $self->use_oscrc,
     user       => $self->user,
     pass       => $self->pass,
+    sigauth_credentials => $self->sigauth_credentials,
     @args,
   );
 }
@@ -41,6 +43,7 @@
     use_oscrc  => $self->use_oscrc,
     user       => $self->user,
     pass       => $self->pass,
+    sigauth_credentials => $self->sigauth_credentials,
     @args,
   );
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/lib/Net/OBS/LWP/UserAgent.pm 
new/Net-OBS-Client-0.1.2/lib/Net/OBS/LWP/UserAgent.pm
--- old/Net-OBS-Client-0.1.1/lib/Net/OBS/LWP/UserAgent.pm       1970-01-01 
01:00:00.000000000 +0100
+++ new/Net-OBS-Client-0.1.2/lib/Net/OBS/LWP/UserAgent.pm       2024-03-26 
17:25:16.922675325 +0100
@@ -0,0 +1,98 @@
+package Net::OBS::LWP::UserAgent;
+
+use strict;
+use warnings;
+use Const::Fast;
+
+use base 'LWP::UserAgent';
+
+const my $MTIME_POS => 9;
+const my $FILE_LENGTH_POS => 7;
+const my $FILE_MODE_RW_ALL => '0777';
+
+sub sigauth_credentials {
+  my ($self, $creds) = @_;
+  die "Credentials a not a HASH Ref!" if $creds && ref($creds) ne 'HASH';
+  $self->{sigauth_credentials} = $creds if $creds;
+  return $self->{sigauth_credentials};
+}
+
+sub mirror
+{
+    my($self, %opt) = @_;
+    my $url         = $opt{url};
+    my $file        = $opt{file};
+    my $etag        = $opt{etag};
+
+    my $request = $opt{request} || HTTP::Request->new('GET', $url);
+
+    $self->prepare_cache_related_headers($request, %opt);
+
+    my $tmpfile = "$file-$$";
+
+    my $response = $self->request($request, $tmpfile);
+    croak($response->header('X-Died')) if $response->header('X-Died');
+
+    # Only fetching a fresh copy of the would be considered success.
+    # If the file was not modified, "304" would returned, which
+    # is considered by HTTP::Status to be a "redirect", /not/ "success"
+    if ( $response->is_success ) {
+        my @stat        = stat $tmpfile or croak("Could not stat tmpfile 
'$tmpfile': $!");
+        my $file_length = $stat[$FILE_LENGTH_POS];
+        my ($content_length) = $response->header('Content-length');
+
+        if ( defined $content_length and $file_length < $content_length ) {
+            unlink $tmpfile || croak("Could not unlink $tmpfile: $!\n");
+            croak("Transfer truncated: only $file_length out of 
$content_length bytes received\n");
+        }
+        elsif ( defined $content_length and $file_length > $content_length ) {
+            unlink $tmpfile || croak("Could not unlink $tmpfile: $!\n");
+            croak("Content-length mismatch: expected $content_length bytes, 
got $file_length\n");
+        }
+        # The file was the expected length.
+        else {
+            # Replace the stale file with a fresh copy
+            if ( -e $file ) {
+                # Some DOSish systems fail to rename if the target exists
+                chmod $FILE_MODE_RW_ALL, $file
+                  || croak("Cannot change mode for '$file': $!\n");
+                unlink $file || croak("Could not unlink $file: $!\n");
+            }
+            rename $tmpfile, $file
+                or croak("Cannot rename '$tmpfile' to '$file': $!\n");
+
+            # make sure the file has the same last modification time
+            if ( my $lm = $response->last_modified ) {
+                utime $lm, $lm, $file || croak("Cannot set utime for '$file': 
$!\n");
+            }
+        }
+    }
+    # The local copy is fresh enough, so just delete the temp file
+    else {
+        unlink $tmpfile || croak("Could not unlink $tmpfile: $!\n");
+    }
+    return $response;
+}
+
+sub prepare_cache_related_headers {
+    my ($self, $request, %opt) = @_;
+    my $file        = $opt{file};
+    my $etag        = $opt{etag};
+
+    # If the file exists, add a cache-related header
+    if ( -e $file ) {
+        my ($mtime)   = ( stat $file )[$MTIME_POS];
+        if ($etag) {
+          $request->header('If-None-Match' => $etag);
+          $self->default_header('If-None-Match' => $etag);
+        } elsif ($mtime) {
+          my $http_date = HTTP::Date::time2str($mtime);
+          $request->header('If-Modified-Since' => $http_date);
+          $self->default_header('If-Modified-Since' => $http_date);
+        }
+    }
+
+    return;
+}
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Net-OBS-Client-0.1.1/lib/Net/OBS/SigAuth.pm 
new/Net-OBS-Client-0.1.2/lib/Net/OBS/SigAuth.pm
--- old/Net-OBS-Client-0.1.1/lib/Net/OBS/SigAuth.pm     2023-11-24 
14:42:19.182336624 +0100
+++ new/Net-OBS-Client-0.1.2/lib/Net/OBS/SigAuth.pm     2024-03-27 
16:03:16.435560863 +0100
@@ -105,37 +105,51 @@
 }
 
 sub get_key_data {
-  my ($uri) = @_;
-  my $keyid = $::ENV{SSH_PUB_KEY_ID};
-  my $keyfile = _get_tmp_keyfile_from_agent($keyid);
-  if (!defined($keyid)) {
-    # check if the host includes a user name
-    my $authority = $uri->authority;
-    if ($authority =~ s/^([^\@]*)\@//) {
-      $keyid = $1;
-      $keyid =~ s/:.*//;       # ignore password
-    }
+  my ($uri, $creds)    = @_;
+  my $keyid    = $::ENV{SSH_PUB_KEY_ID} || $creds->{keyid};
+  my $auth_type = $creds->{auth_type} || 'agent';
+  my $keyfile;
+  if ($auth_type eq 'agent' ) {
+    $keyfile = _get_tmp_keyfile_from_agent($keyid);
+    die 'No key (keyid: '.($keyid||'NONE').') found in ssh-agent and 
nofallback expicitly configured!' if !$keyfile and $creds->{nofallback};
+  }
+  my $username = $creds->{user} || $keyid;
+  my $authority = $uri->authority;
+  if ($authority =~ s/^([^\@]*)\@//) {
+    $username = $1;
+    $username =~ s/:.*//;      # ignore password
   }
+  if (!defined($keyfile) && $creds->{keyfile}) {
+      $keyfile = $creds->{keyfile};
+      die "Key file '$keyfile' doesn't exit and nofallback expicitly 
configured!" if !(-e $keyfile) && $creds->{nofallback};
+  };
   if (!defined($keyfile)) {
-    my $home = $ENV{'HOME'};
-    if ($home && -d "$home/.ssh") {
-      for my $idfile (qw{id_ed25519 id_rsa}) {
-       next unless -s "$home/.ssh/$idfile";
-       $keyfile = "$home/.ssh/$idfile";
-       last;
+    my @_dirs = ("$ENV{'HOME'}/.ssh");
+    unshift @_dirs, $creds->{keydir} if ($creds->{keydir});
+    for my $_dir (@_dirs) {
+      $_dir =~ s#/$##;
+      if (-d "$_dir") {
+       for my $idfile (qw{id_ed25519 id_rsa}) {
+         next unless -s "$_dir/$idfile";
+         $keyfile = "$_dir/$idfile";
+         last;
+       }
+      } else {
+       die "Key dir '$_dir' does not exists and nofallback expicitly 
configured!" if $creds->{nofallback};
       }
     }
   }
-  return ($keyid, $keyfile);
+  die "No keyfile found!" unless $keyfile;
+  return ($username, $keyid, $keyfile);
 }
 
 sub authenticate {
   my ($class, $ua, $proxy, $auth_param, $response, $request, $arg, $size) = @_;
   my $uri = $request->uri->canonical;
   return $response unless $uri && !$proxy;
-  my ($keyid, $keyfile) = get_key_data($uri);
+  my ($username, $keyid, $keyfile) = get_key_data($uri, 
$ua->sigauth_credentials);
   my $host_port = $uri->host_port;
-  my $auth = generate_authorization($auth_param, $keyid, $keyfile);
+  my $auth = generate_authorization($auth_param, $username, $keyfile);
   my $h = $ua->get_my_handler('request_prepare', 'm_host_port' => $host_port, 
sub {
     $_[0]{callback} = sub { $_[0]->header('Authorization' => $auth) };
   });

Reply via email to