Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Slackware Linux support #1485

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Revision history for Rex
[MINOR]

[NEW FEATURES]
- Added Slackware Linux support <[email protected]>

[REVISION]

Expand Down
16 changes: 15 additions & 1 deletion lib/Rex/Commands/Gather.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use vars qw(@EXPORT);

@EXPORT = qw(operating_system_is network_interfaces memory
get_operating_system operating_system operating_system_version operating_system_release
is_freebsd is_netbsd is_openbsd is_redhat is_linux is_bsd is_solaris is_suse is_debian is_mageia is_windows is_alt is_openwrt is_gentoo is_fedora is_arch is_void
is_freebsd is_netbsd is_openbsd is_redhat is_linux is_bsd is_solaris is_suse is_debian is_mageia is_windows is_alt is_openwrt is_gentoo is_slackware is_fedora is_arch is_void
get_system_information dump_system_information kernelname);

=head2 get_operating_system
Expand Down Expand Up @@ -537,6 +537,20 @@ sub is_gentoo {

}

=head2 is_slackware

Returns true if the target system is a Gentoo System.

=cut

sub is_slackware {
my $os = get_operating_system();
if ( $os =~ m/Slackware/i ) {
return 1;
}

}

=head2 is_arch

task "foo", "server1", sub {
Expand Down
18 changes: 18 additions & 0 deletions lib/Rex/Hardware/Host.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ sub get_operating_system {
elsif ( $ret eq "ManjaroLinux" ) {
$ret = "Manjaro";
}
elsif ( $ret =~ m/Slackware/i ) {
$ret = "Slackware";
}
return $ret;
}
}
Expand Down Expand Up @@ -187,6 +190,10 @@ sub get_operating_system {
return "Manjaro";
}

if ( is_file("/etc/slackware-version") ) {
return "Slackware";
}

my $os_string = i_run("uname -s");
return $os_string; # return the plain os

Expand Down Expand Up @@ -339,6 +346,17 @@ sub get_operating_system_version {
return $version;
}
}
elsif ( $op eq 'Slackware' ) {
my $fh = file_read("/etc/slackware-version");
my $content = $fh->read_all;
$fh->close;

chomp $content;

$content =~ m/(\d+(\.[\d+]+)*)/;

return $1;
}

return [ i_run("uname -r") ]->[0];

Expand Down
93 changes: 93 additions & 0 deletions lib/Rex/Pkg/Slackware.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Slackware
#
# (c) Giuseppe Di Terlizzi <[email protected]>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:

package Rex::Pkg::Slackware;

use 5.010001;
use strict;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Rex::Commands::Run;
use Rex::Helper::Run;
use Rex::Commands::File;
use Rex::Pkg::Base;
use base qw(Rex::Pkg::Base);

sub new {
my $that = shift;
my $proto = ref($that) || $that;
my $self = $proto->SUPER::new(@_);

bless( $self, $proto );

$self->{commands} = {
install => 'slackpkg -batch=on -default_answer=y install %s',
install_version => 'slackpkg -batch=on -default_answer=y install %s',
update_system => 'slackpkg -batch=on -default_answer=y upgrade-all',
dist_update_system => 'slackpkg -batch=on -default_answer=y upgrade-all',
remove => 'slackpkg -batch=on -default_answer=y remove %s',
update_package_db => 'slackpkg -batch=on -default_answer=y update',
};

return $self;
}

sub bulk_install {
my ( $self, $packages_aref, $option ) = @_;

delete $option->{version}; # makes no sense to specify the same version for several packages

$self->update( "@{$packages_aref}", $option );

return 1;
}

sub get_installed {
my ($self) = @_;

my @ret;

for my $line ( i_run("ls -d /var/log/packages/* | cut -d '/' -f5-") ) {

my $name;
my $version;
my $build;
my $tag;
my $arch;

# Stantard Slackware Linux package naming:
#
# name-1.0-arch-1 (Official: name + version + arch + build)
# name-1.0-arch-1tag (Third-Party: name + version + arch + build + tag)

my @parts = split /-/, $line;

$build = pop @parts;
$arch = pop @parts;
$version = pop @parts;
$name = join '-', @parts;

( $build, $tag ) = ( $build =~ /^(\d+)(.*)/ );

push(
@ret,
{
name => $name,
version => $version,
arch => $arch,
build => $build,
tag => $tag
}
);
}

return @ret;
}

1;
39 changes: 39 additions & 0 deletions lib/Rex/Service/Slackware.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# (c) Giuseppe Di Terlizzi <[email protected]>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:

package Rex::Service::Slackware;

use 5.010001;
use strict;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use base qw(Rex::Service::Base);

sub new {
my $that = shift;
my $proto = ref($that) || $that;
my $self = $proto->SUPER::new(@_);

bless( $self, $proto );

$self->{commands} = {
start => '/etc/rc.d/rc.%s start',
restart => '/etc/rc.d/rc.%s restart',
stop => '/etc/rc.d/rc.%s stop',
reload => '/etc/rc.d/rc.%s reload',
status => '/etc/rc.d/rc.%s status',
ensure_stop => 'chmod -x /etc/rc.d/rc.%s',
ensure_start => 'chmod +x /etc/rc.d/rc.%s',
action => '/etc/rc.d/rc.%s %s',
service_exists => 'test -e /etc/rc.d/rc.%s',
};

return $self;
}

1;
Loading