Hi,

here's a somewhat straightforward update to latest Rex, quite some
changes since the 1.6.0 version we have in ports (3 years old):

https://metacpan.org/changes/distribution/Rex

there's a new upstream maintainer since some months, patches from
https://github.com/RexOps/Rex/pull/1211 were merged, and all tests pass
(but two are skipped):

t/db.t ........................... skipped: Could not load DBI module
t/write_utf8_files.t ............. skipped: Could not load File::LibMagic 
module or find a compatible file command

Files=72, Tests=1538

add missing test depends ?

i dont use it, and i havent really found if new runtime deps were
needed (doesnt seem so from changelog), so i guess runtime testing is
required :)

Landry
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/p5-Rex/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile    12 Jul 2019 21:02:26 -0000      1.2
+++ Makefile    14 Apr 2020 08:59:01 -0000
@@ -2,8 +2,8 @@
 
 COMMENT=       perl-based deployment and configuration management
 
-CPAN_AUTHOR=   JFRIED
-DISTNAME=      Rex-1.6.0
+CPAN_AUTHOR=   FERKI
+DISTNAME=      Rex-1.9.0
 
 CATEGORIES=    sysutils
 
Index: distinfo
===================================================================
RCS file: /cvs/ports/sysutils/p5-Rex/distinfo,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 distinfo
--- distinfo    21 Feb 2019 04:54:50 -0000      1.1.1.1
+++ distinfo    14 Apr 2020 08:59:01 -0000
@@ -1,2 +1,2 @@
-SHA256 (Rex-1.6.0.tar.gz) = HDXFpIAYIFvFQNDMHRH8KkdXmxMZJilAQSuiuDckWdY=
-SIZE (Rex-1.6.0.tar.gz) = 331330
+SHA256 (Rex-1.9.0.tar.gz) = iJDTq26r4VzYFkBzi1n+aWvoq9KhvHG0POHviL36/TA=
+SIZE (Rex-1.9.0.tar.gz) = 331106
Index: patches/patch-lib_Rex_Commands_User_pm
===================================================================
RCS file: patches/patch-lib_Rex_Commands_User_pm
diff -N patches/patch-lib_Rex_Commands_User_pm
--- patches/patch-lib_Rex_Commands_User_pm      21 Feb 2019 04:54:50 -0000      
1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-$OpenBSD: patch-lib_Rex_Commands_User_pm,v 1.1.1.1 2019/02/21 04:54:50 afresh1 
Exp $
-
-Index: lib/Rex/Commands/User.pm
---- lib/Rex/Commands/User.pm.orig
-+++ lib/Rex/Commands/User.pm
-@@ -67,6 +67,7 @@ Manage user account.
-    comment        => 'User Account',
-    expire         => '2011-05-30',
-    groups         => [ 'root', '...' ],
-+   login_class    => 'staff',   # on OpenBSD
-    password       => 'blahblah',
-    crypt_password => '*', # on Linux, OpenBSD and NetBSD
-    system         => 1,
-@@ -273,7 +274,7 @@ sub delete_user {
- =head2 lock_password($user)
- 
- Lock the password of a user account. Currently this is only
--available on Linux (see passwd --lock).
-+available on Linux (see passwd --lock) and OpenBSD.
- 
- =cut
- 
-@@ -284,7 +285,7 @@ sub lock_password {
- =head2 unlock_password($user)
- 
- Unlock the password of a user account. Currently this is only
--available on Linux (see passwd --unlock).
-+available on Linux (see passwd --unlock) and OpenBSD.
- 
- =cut
- 
Index: patches/patch-lib_Rex_Pkg_Base_pm
===================================================================
RCS file: patches/patch-lib_Rex_Pkg_Base_pm
diff -N patches/patch-lib_Rex_Pkg_Base_pm
--- patches/patch-lib_Rex_Pkg_Base_pm   21 Feb 2019 04:54:50 -0000      1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
-$OpenBSD: patch-lib_Rex_Pkg_Base_pm,v 1.1.1.1 2019/02/21 04:54:50 afresh1 Exp $
-
-Index: lib/Rex/Pkg/Base.pm
---- lib/Rex/Pkg/Base.pm.orig
-+++ lib/Rex/Pkg/Base.pm
-@@ -63,6 +63,7 @@ sub update {
-   my ( $self, $pkg, $option ) = @_;
- 
-   my $version = $option->{'version'} || '';
-+  my $env     = $option->{'env'}     || ();
- 
-   Rex::Logger::debug( "Installing $pkg" . ( $version ? "-$version" : "" ) );
-   my $cmd = sprintf $self->{commands}->{install}, $pkg;
-@@ -72,7 +73,7 @@ sub update {
-       $option->{version};
-   }
- 
--  my $f = i_run $cmd, fail_ok => 1;
-+  my $f = i_run $cmd, fail_ok => 1, env => $env;
- 
-   unless ( $? == 0 ) {
-     Rex::Logger::info( "Error installing $pkg.", "warn" );
Index: patches/patch-lib_Rex_Pkg_OpenBSD_pm
===================================================================
RCS file: patches/patch-lib_Rex_Pkg_OpenBSD_pm
diff -N patches/patch-lib_Rex_Pkg_OpenBSD_pm
--- patches/patch-lib_Rex_Pkg_OpenBSD_pm        21 Feb 2019 04:54:50 -0000      
1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-$OpenBSD: patch-lib_Rex_Pkg_OpenBSD_pm,v 1.1.1.1 2019/02/21 04:54:50 afresh1 
Exp $
-
-Index: lib/Rex/Pkg/OpenBSD.pm
---- lib/Rex/Pkg/OpenBSD.pm.orig
-+++ lib/Rex/Pkg/OpenBSD.pm
-@@ -11,18 +11,58 @@ use warnings;
- 
- our $VERSION = '1.6.0'; # VERSION
- 
--use Rex::Pkg::NetBSD;
-+use Rex::Helper::Run;
-+use Rex::Commands::File;
-+use Rex::Pkg::Base;
-+use base qw(Rex::Pkg::Base);
- 
--use base qw(Rex::Pkg::NetBSD);
--
- sub new {
-   my $that  = shift;
-   my $proto = ref($that) || $that;
--  my $self  = $that->SUPER::new(@_);
-+  my $self  = $proto->SUPER::new(@_);
- 
-   bless( $self, $proto );
- 
-+  $self->{commands} = {
-+    install         => '/usr/sbin/pkg_add %s',
-+    install_version => '/usr/sbin/pkg_add %s-%s',
-+    remove          => '/usr/sbin/pkg_delete %s',
-+  };
-+
-   return $self;
-+}
-+
-+sub remove {
-+  my ( $self, $pkg ) = @_;
-+
-+  my ($pkg_found) = grep { $_->{"name"} eq "$pkg" } $self->get_installed();
-+  my $pkg_version = $pkg_found->{"version"};
-+
-+  return $self->SUPER::remove("$pkg-$pkg_version");
-+}
-+
-+sub get_installed {
-+  my ($self) = @_;
-+
-+  my @lines = i_run "/usr/sbin/pkg_info";
-+
-+  my @pkg;
-+
-+  for my $line (@lines) {
-+    my ( $pkg_name_v, $descr ) = split( /\s/, $line, 2 );
-+
-+    my ( $pkg_name, $pkg_version ) = ( $pkg_name_v =~ m/^(.*)-(.*?)$/ );
-+
-+    push(
-+      @pkg,
-+      {
-+        name    => $pkg_name,
-+        version => $pkg_version,
-+      }
-+    );
-+  }
-+
-+  return @pkg;
- }
- 
- 1;
Index: patches/patch-lib_Rex_User_OpenBSD_pm
===================================================================
RCS file: patches/patch-lib_Rex_User_OpenBSD_pm
diff -N patches/patch-lib_Rex_User_OpenBSD_pm
--- patches/patch-lib_Rex_User_OpenBSD_pm       21 Feb 2019 04:54:50 -0000      
1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,186 +0,0 @@
-$OpenBSD: patch-lib_Rex_User_OpenBSD_pm,v 1.1.1.1 2019/02/21 04:54:50 afresh1 
Exp $
-
-Index: lib/Rex/User/OpenBSD.pm
---- lib/Rex/User/OpenBSD.pm.orig
-+++ lib/Rex/User/OpenBSD.pm
-@@ -14,14 +14,16 @@ our $VERSION = '1.6.0'; # VERSION
- use Rex::Logger;
- use Rex::Commands::MD5;
- use Rex::Helper::Run;
-+use Rex::Helper::Encode;
- use Rex::Commands::Fs;
--use Rex::User::NetBSD;
- use Rex::Interface::File;
- use Rex::Interface::Fs;
- use Rex::Interface::Exec;
-+use Rex::User::Linux;
- use Rex::Helper::Path;
-+use JSON::MaybeXS;
- 
--use base qw(Rex::User::NetBSD);
-+use base qw(Rex::User::Linux);
- 
- sub new {
-   my $that  = shift;
-@@ -40,7 +42,8 @@ sub create_user {
- 
-   my $old_pw_md5 = md5("/etc/passwd");
- 
--  my $uid = $self->get_uid($user);
-+  my $uid       = $self->get_uid($user);
-+  my %user_info = $self->get_user($user);
-   my $should_create_home;
- 
-   if ( $data->{'create_home'} || $data->{'create-home'} ) {
-@@ -70,7 +73,11 @@ sub create_user {
-   }
- 
-   if ( exists $data->{uid} ) {
--    $cmd .= " -u " . $data->{uid};
-+
-+    # On OpenBSD, "usermod -u n login" fails when the user login
-+    # has already n as userid. So skip it from the command arg
-+    # when the uid is already correct.
-+    $cmd .= " -u " . $data->{uid} unless $data->{uid} == $user_info{uid};
-   }
- 
-   if ( exists $data->{home} ) {
-@@ -93,6 +100,10 @@ sub create_user {
-     $cmd .= " -e '" . $data->{expire} . "'";
-   }
- 
-+  if ( exists $data->{login_class} ) {
-+    $cmd .= " -L '" . $data->{login_class} . "'";
-+  }
-+
-   if ( exists $data->{groups} ) {
-     my @groups    = @{ $data->{groups} };
-     my $pri_group = shift @groups;
-@@ -170,6 +181,127 @@ sub create_user {
-       ret     => $self->get_uid($user),
-       },
-       ;
-+  }
-+
-+}
-+
-+sub get_user {
-+  my ( $self, $user ) = @_;
-+
-+  Rex::Logger::debug("Getting information for $user");
-+  my $rnd_file = get_tmp_file;
-+  my $fh       = Rex::Interface::File->create;
-+  my $script   = q|
-+    unlink $0;
-+    print to_json([ getpwnam($ARGV[0]) ]);
-+  |;
-+  $fh->open( ">", $rnd_file );
-+  $fh->write($script);
-+  $fh->write( func_to_json() );
-+  $fh->close;
-+
-+  my $data_str = i_run "perl $rnd_file $user", fail_ok => 1;
-+  if ( $? != 0 ) {
-+    die("Error getting user information for $user");
-+  }
-+
-+  my $data = decode_json($data_str);
-+
-+  return (
-+    name     => $data->[0],
-+    password => $data->[1],
-+    uid      => $data->[2],
-+    gid      => $data->[3],
-+    pwchange => $data->[4],
-+    class    => $data->[5],
-+    comment  => $data->[6],
-+    home     => $data->[7],
-+    shell    => $data->[8],
-+    expire   => $data->[9],
-+  );
-+}
-+
-+sub lock_password {
-+  my ( $self, $user ) = @_;
-+
-+  # Is the password already locked?
-+  my $result = i_run "getent passwd $user", fail_ok => 1;
-+
-+  if ( $result !~ /^$user.*$/ ) {
-+    die "Unexpected result from getent: $result";
-+  }
-+  elsif ( $result =~ /^$user.*-$/ ) {
-+
-+    # Already locked
-+    return { changed => 0 };
-+  }
-+  else {
-+    my $ret = i_run "usermod -Z $user", fail_ok => 1;
-+    if ( $? != 0 ) {
-+      die("Error locking account $user: $ret");
-+    }
-+    return {
-+      changed => 1,
-+      ret     => $ret,
-+    };
-+  }
-+}
-+
-+sub unlock_password {
-+  my ( $self, $user ) = @_;
-+
-+  # Is the password already unlocked?
-+  my $result = i_run "getent passwd $user", fail_ok => 1;
-+
-+  if ( $result !~ /^$user.*$/ ) {
-+    die "Unexpected result from getent: $result";
-+  }
-+  elsif ( $result !~ /^$user.*-$/ ) {
-+
-+    # Already unlocked
-+    return { changed => 0 };
-+  }
-+  else {
-+    my $ret = i_run "usermod -U $user", sub { @_ }, fail_ok => 1;
-+    if ( $? != 0 ) {
-+      die("Error unlocking account $user: $ret");
-+    }
-+    return {
-+      changed => 1,
-+      ret     => $ret,
-+    };
-+  }
-+}
-+
-+sub rm_user {
-+  my ( $self, $user, $data ) = @_;
-+
-+  Rex::Logger::debug("Removing user $user");
-+
-+  my %user_info = $self->get_user($user);
-+
-+  my $cmd = "userdel";
-+
-+  if ( exists $data->{delete_home} ) {
-+    $cmd .= " -r";
-+  }
-+
-+  my $output = i_run $cmd . " " . $user, fail_ok => 1;
-+  if ( $? == 67 ) {
-+    Rex::Logger::info( "Cannot delete user $user (no such user)", "warn" );
-+  }
-+  elsif ( $? != 0 ) {
-+    die("Error deleting user $user ($output)");
-+  }
-+
-+  if ( exists $data->{delete_home} && is_dir( $user_info{home} ) ) {
-+    Rex::Logger::debug(
-+      "userdel doesn't delete home directory. removing it now by hand...");
-+    rmdir $user_info{home};
-+  }
-+
-+  if ( $? != 0 ) {
-+    die( "Error removing " . $user_info{home} );
-   }
- 
- }
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/sysutils/p5-Rex/pkg/PLIST,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 PLIST
--- pkg/PLIST   21 Feb 2019 04:54:50 -0000      1.1.1.1
+++ pkg/PLIST   14 Apr 2020 08:59:01 -0000
@@ -247,6 +247,7 @@
 ${P5SITE}/Rex/Pkg/SunOS/OpenCSW.pm
 ${P5SITE}/Rex/Pkg/SunOS/pkg.pm
 ${P5SITE}/Rex/Pkg/Ubuntu.pm
+${P5SITE}/Rex/Pkg/VoidLinux.pm
 ${P5SITE}/Rex/PkgConf/
 ${P5SITE}/Rex/PkgConf.pm
 ${P5SITE}/Rex/PkgConf/Base.pm
@@ -301,6 +302,7 @@
 ${P5SITE}/Rex/Service/SunOS.pm
 ${P5SITE}/Rex/Service/SunOS/svcadm.pm
 ${P5SITE}/Rex/Service/Ubuntu.pm
+${P5SITE}/Rex/Service/VoidLinux.pm
 ${P5SITE}/Rex/Shared/
 ${P5SITE}/Rex/Shared/Var/
 ${P5SITE}/Rex/Shared/Var.pm

Reply via email to