aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Rousse <guillomovitch@mandriva.org>2010-01-25 21:26:01 +0000
committerGuillaume Rousse <guillomovitch@mandriva.org>2010-01-25 21:26:01 +0000
commit480d2b551cc5fceef31ee366a06b3c15d660bbea (patch)
tree1c0aac6586c6a00283204fb8dcdd9d72b9c3d036
parent62dd233fb558c3f651c4b73ba69c30e00f23eb2c (diff)
downloadrpm-helper-480d2b551cc5fceef31ee366a06b3c15d660bbea.tar
rpm-helper-480d2b551cc5fceef31ee366a06b3c15d660bbea.tar.gz
rpm-helper-480d2b551cc5fceef31ee366a06b3c15d660bbea.tar.bz2
rpm-helper-480d2b551cc5fceef31ee366a06b3c15d660bbea.tar.xz
rpm-helper-480d2b551cc5fceef31ee366a06b3c15d660bbea.zip
adapt del-syslog to new add-syslog behaviour
-rwxr-xr-xdel-syslog39
1 files changed, 30 insertions, 9 deletions
diff --git a/del-syslog b/del-syslog
index 185b6ae..08176ca 100755
--- a/del-syslog
+++ b/del-syslog
@@ -11,19 +11,22 @@ my ($package, $number) = @ARGV;
# don't do anything for upgrade
exit(0) if $number == 1;
-if (-f '/etc/syslog.conf') {
- del_syslog_entry($package, '/etc/syslog.conf');
- system(qw/service syslog condrestart/);
-}
+open(my $fh, '<', '/etc/mandriva-release')
+ or die "can't open /etc/mandriva-release: $!";
+my $line = <$fh>;
+$line =~ /^Mandriva Linux release (\d\d\d\d\.\d)/;
+my $release = $1;
+close($fh);
-if (-f '/etc/syslog-ng.conf') {
- del_syslog_entry($package, '/etc/syslog-ng.conf');
- system(qw/service syslog-ng condrestart/);
+if (version->parse($release) < version->parse("2010.1")) {
+ del_sysklogd_entry($package);
+} else {
+ del_rsyslog_entry($package);
}
-sub del_syslog_entry {
- my ($package, $file) = @_;
+sub del_sysklogd_entry {
+ my $file = "/etc/syslog.conf";
my $content;
open(my $in, '<', $file)
or die "Can't open $file for reading: $!";
@@ -41,4 +44,22 @@ sub del_syslog_entry {
or die "Can't open $file for writing: $!";
print $out $content;
close($out);
+
+ system(qw/service syslog condrestart/);
+}
+
+sub del_rsyslog_entry {
+
+ my $file = "/etc/rsyslog.d/$package.conf";
+
+ # check the file is the one created by package installation
+ open(my $in, '<', $file)
+ or die "Can't open $file for reading: $!";
+ my $line = <$in>;
+ close($in);
+ return if $line ne "# Automatically added by $package installation\n";
+
+ unlink $file
+ or die "Can't delete $file: $!";
+ system(qw/service rsyslog condrestart/);
}