#!/usr/bin/perl # rpm helper scriptlet to remove a syslog entry (sysklogd and syslog-ng) # $Id$ use strict; die < EOF my ($package, $number) = @ARGV; # don't do anything for upgrade exit(0) if $number == 1; 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 (version->parse($release) < version->parse("2010.1")) { del_sysklogd_entry($package); } else { del_rsyslog_entry($package); } sub del_sysklogd_entry { my $file = "/etc/syslog.conf"; my $content; open(my $in, '<', $file) or die "Can't open $file for reading: $!"; while (my $line = <$in>) { if ($line =~ /^# BEGIN: Automatically added by $package installation$/) { while ($line = <$in>) { last if $line =~ /^# END$/; } } else { $content .= $line; } } open(my $out, '>', $file) 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/); }