Hi,
Here is an update to version 1.7 for sysutils/p5-Rex.
All the patches have to be dropped since I managed to integrate them
upstream.
Thanks for tests / comments / import.
Best
--
Olivier Cherrier
mailto:[email protected]
Index: sysutils/p5-Rex/Makefile
===================================================================
RCS file: /data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- sysutils/p5-Rex/Makefile 12 Jul 2019 21:02:26 -0000 1.2
+++ sysutils/p5-Rex/Makefile 16 Nov 2019 15:59:11 -0000
@@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.2 2019/07/12 21:02:26 sthen Exp $
-COMMENT= perl-based deployment and configuration management
+COMMENT= the friendly automation framework
-CPAN_AUTHOR= JFRIED
-DISTNAME= Rex-1.6.0
+CPAN_AUTHOR= FERKI
+DISTNAME= Rex-1.7.0
CATEGORIES= sysutils
Index: sysutils/p5-Rex/distinfo
===================================================================
RCS file: /data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/distinfo,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 distinfo
--- sysutils/p5-Rex/distinfo 21 Feb 2019 04:54:50 -0000 1.1.1.1
+++ sysutils/p5-Rex/distinfo 16 Nov 2019 15:59:11 -0000
@@ -1,2 +1,2 @@
-SHA256 (Rex-1.6.0.tar.gz) = HDXFpIAYIFvFQNDMHRH8KkdXmxMZJilAQSuiuDckWdY=
-SIZE (Rex-1.6.0.tar.gz) = 331330
+SHA256 (Rex-1.7.0.tar.gz) = vKD9KNkVd5iP9ScELtDk5hvsJsHJAGLjw8O/PoV7GDQ=
+SIZE (Rex-1.7.0.tar.gz) = 315479
Index: sysutils/p5-Rex/patches/patch-lib_Rex_Commands_User_pm
===================================================================
RCS file:
/data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/patches/patch-lib_Rex_Commands_User_pm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 patch-lib_Rex_Commands_User_pm
--- sysutils/p5-Rex/patches/patch-lib_Rex_Commands_User_pm 21 Feb 2019
04:54:50 -0000 1.1.1.1
+++ sysutils/p5-Rex/patches/patch-lib_Rex_Commands_User_pm 16 Nov 2019
15:59:11 -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: sysutils/p5-Rex/patches/patch-lib_Rex_Interface_Shell_pm
===================================================================
RCS file:
/data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/patches/patch-lib_Rex_Interface_Shell_pm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 patch-lib_Rex_Interface_Shell_pm
--- sysutils/p5-Rex/patches/patch-lib_Rex_Interface_Shell_pm 21 Feb 2019
04:54:50 -0000 1.1.1.1
+++ sysutils/p5-Rex/patches/patch-lib_Rex_Interface_Shell_pm 16 Nov 2019
15:59:11 -0000
@@ -1,15 +0,0 @@
-$OpenBSD: patch-lib_Rex_Interface_Shell_pm,v 1.1.1.1 2019/02/21 04:54:50
afresh1 Exp $
-
-Index: lib/Rex/Interface/Shell.pm
---- lib/Rex/Interface/Shell.pm.orig
-+++ lib/Rex/Interface/Shell.pm
-@@ -17,7 +17,8 @@ my %SHELL_PROVIDER = (
- ash => "Rex::Interface::Shell::Ash",
- bash => "Rex::Interface::Shell::Bash",
- csh => "Rex::Interface::Shell::Csh",
-- idrac => "Rex::Interface::Shell::Idrac",
-+ # idrac triggers a weird "version: not found" command.
-+ # idrac => "Rex::Interface::Shell::Idrac",
- ksh => "Rex::Interface::Shell::Ksh",
- sh => "Rex::Interface::Shell::Sh",
- tcsh => "Rex::Interface::Shell::Tcsh",
Index: sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_Base_pm
===================================================================
RCS file:
/data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_Base_pm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 patch-lib_Rex_Pkg_Base_pm
--- sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_Base_pm 21 Feb 2019 04:54:50
-0000 1.1.1.1
+++ sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_Base_pm 16 Nov 2019 15:59:11
-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: sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_OpenBSD_pm
===================================================================
RCS file:
/data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_OpenBSD_pm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 patch-lib_Rex_Pkg_OpenBSD_pm
--- sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_OpenBSD_pm 21 Feb 2019
04:54:50 -0000 1.1.1.1
+++ sysutils/p5-Rex/patches/patch-lib_Rex_Pkg_OpenBSD_pm 16 Nov 2019
15:59:11 -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: sysutils/p5-Rex/patches/patch-lib_Rex_User_OpenBSD_pm
===================================================================
RCS file:
/data/clients/OpenBSD_cvsync/ports/sysutils/p5-Rex/patches/patch-lib_Rex_User_OpenBSD_pm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 patch-lib_Rex_User_OpenBSD_pm
--- sysutils/p5-Rex/patches/patch-lib_Rex_User_OpenBSD_pm 21 Feb 2019
04:54:50 -0000 1.1.1.1
+++ sysutils/p5-Rex/patches/patch-lib_Rex_User_OpenBSD_pm 16 Nov 2019
15:59:11 -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} );
- }
-
- }