Skip to content

Commit 482d975

Browse files
committed
Added Slackware Linux support
- Detect Slackware Linux via lsb_release or via /etc/slackware-version file - Use slackpkg for download, install, updare and remove packages - Use /etc/rc.d/rc.* files for start & stop Slackware Linux services
1 parent df033ce commit 482d975

File tree

4 files changed

+148
-1
lines changed

4 files changed

+148
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Revision history for Rex
1414
[MINOR]
1515

1616
[NEW FEATURES]
17+
- Added Slackware Linux support <[email protected]>
1718

1819
[REVISION]
1920

lib/Rex/Commands/Gather.pm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use vars qw(@EXPORT);
4646

4747
@EXPORT = qw(operating_system_is network_interfaces memory
4848
get_operating_system operating_system operating_system_version operating_system_release
49-
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
49+
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
5050
get_system_information dump_system_information kernelname);
5151

5252
=head2 get_operating_system
@@ -540,6 +540,20 @@ sub is_gentoo {
540540

541541
}
542542

543+
=head2 is_slackware
544+
545+
Returns true if the target system is a Gentoo System.
546+
547+
=cut
548+
549+
sub is_slackware {
550+
my $os = get_operating_system();
551+
if ( $os =~ m/Slackware/i ) {
552+
return 1;
553+
}
554+
555+
}
556+
543557
=head2 is_arch
544558
545559
task "foo", "server1", sub {

lib/Rex/Pkg/Slackware.pm

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Slackware
2+
#
3+
# (c) Giuseppe Di Terlizzi <[email protected]>
4+
#
5+
# vim: set ts=2 sw=2 tw=0:
6+
# vim: set expandtab:
7+
8+
package Rex::Pkg::Slackware;
9+
10+
use 5.010001;
11+
use strict;
12+
use warnings;
13+
14+
our $VERSION = '9999.99.99_99'; # VERSION
15+
16+
use Rex::Commands::Run;
17+
use Rex::Helper::Run;
18+
use Rex::Commands::File;
19+
use Rex::Pkg::Base;
20+
use base qw(Rex::Pkg::Base);
21+
22+
sub new {
23+
my $that = shift;
24+
my $proto = ref($that) || $that;
25+
my $self = $proto->SUPER::new(@_);
26+
27+
bless( $self, $proto );
28+
29+
$self->{commands} = {
30+
install => 'slackpkg -batch=on -default_answer=y install %s',
31+
install_version => 'slackpkg -batch=on -default_answer=y install %s',
32+
update_system => 'slackpkg -batch=on -default_answer=y upgrade-all',
33+
dist_update_system => 'slackpkg -batch=on -default_answer=y upgrade-all',
34+
remove => 'slackpkg -batch=on -default_answer=y remove %s',
35+
update_package_db => 'slackpkg -batch=on -default_answer=y update',
36+
};
37+
38+
return $self;
39+
}
40+
41+
sub bulk_install {
42+
my ( $self, $packages_aref, $option ) = @_;
43+
44+
delete $option->{version}; # makes no sense to specify the same version for several packages
45+
46+
$self->update( "@{$packages_aref}", $option );
47+
48+
return 1;
49+
}
50+
51+
sub get_installed {
52+
my ($self) = @_;
53+
54+
my @ret;
55+
56+
for my $line ( i_run("ls -d /var/log/packages/* | cut -d '/' -f5-") ) {
57+
58+
my $name;
59+
my $version;
60+
my $build;
61+
my $tag;
62+
my $arch;
63+
64+
# Stantard Slackware Linux package naming:
65+
#
66+
# name-1.0-arch-1 (Official: name + version + arch + build)
67+
# name-1.0-arch-1tag (Third-Party: name + version + arch + build + tag)
68+
69+
my @parts = split /-/, $line;
70+
71+
$build = pop @parts;
72+
$arch = pop @parts;
73+
$version = pop @parts;
74+
$name = join '-', @parts;
75+
76+
( $build, $tag ) = ( $build =~ /^(\d+)(.*)/ );
77+
78+
push(
79+
@ret,
80+
{
81+
name => $name,
82+
version => $version,
83+
arch => $arch,
84+
build => $build,
85+
tag => $tag
86+
}
87+
);
88+
}
89+
90+
return @ret;
91+
}
92+
93+
1;

lib/Rex/Service/Slackware.pm

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# (c) Giuseppe Di Terlizzi <[email protected]>
3+
#
4+
# vim: set ts=2 sw=2 tw=0:
5+
# vim: set expandtab:
6+
7+
package Rex::Service::Slackware;
8+
9+
use 5.010001;
10+
use strict;
11+
use warnings;
12+
13+
our $VERSION = '9999.99.99_99'; # VERSION
14+
15+
use base qw(Rex::Service::Base);
16+
17+
sub new {
18+
my $that = shift;
19+
my $proto = ref($that) || $that;
20+
my $self = $proto->SUPER::new(@_);
21+
22+
bless( $self, $proto );
23+
24+
$self->{commands} = {
25+
start => '/etc/rc.d/rc.%s start',
26+
restart => '/etc/rc.d/rc.%s restart',
27+
stop => '/etc/rc.d/rc.%s stop',
28+
reload => '/etc/rc.d/rc.%s reload',
29+
status => '/etc/rc.d/rc.%s status',
30+
ensure_stop => 'chmod -x /etc/rc.d/rc.%s',
31+
ensure_start => 'chmod +x /etc/rc.d/rc.%s',
32+
action => '/etc/rc.d/rc.%s %s',
33+
service_exists => 'test -e /etc/rc.d/rc.%s',
34+
};
35+
36+
return $self;
37+
}
38+
39+
1;

0 commit comments

Comments
 (0)