/usr/sbin/install-sgmlcatalog is in sgml-base 1.26+nmu1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | #!/usr/bin/perl
## ----------------------------------------------------------------------
## install-sgmlcatalog : Debian SGML catalog management tool
## ----------------------------------------------------------------------
## Copyright (c) 1997 Christian Schwarz
## Copyright (c) 2001-2004 Ardo van Rangelrooij
##
## This is free software; see the GNU General Public Licence version 2
## or later for copying conditions. There is NO warranty.
## ----------------------------------------------------------------------
## ----------------------------------------------------------------------
use strict;
use warnings;
## ----------------------------------------------------------------------
use Getopt::Long qw( &GetOptions );
## ----------------------------------------------------------------------
$0 =~ m|[^/]+$|;
## ----------------------------------------------------------------------
my $name = $&;
## ----------------------------------------------------------------------
use vars qw( $package );
use vars qw( $quiet );
## ----------------------------------------------------------------------
Getopt::Long::Configure( 'no_ignore_case' );
if ( ! GetOptions(
'quiet' => \$quiet,
'remove=s' => \$package,
)
)
{
&usage();
exit 1;
}
## ----------------------------------------------------------------------
if ( ! defined( $package ) )
{
&usage();
exit -1;
}
## ----------------------------------------------------------------------
&remove( $package );
## ----------------------------------------------------------------------
exit 0;
## ----------------------------------------------------------------------
sub remove
{
## ------------------------------------------------------------------
my $package = $_[0];
## ----------------------------------------------------------------------
my $catalog = '/etc/sgml/transitional.cat';
my $backup = '/etc/sgml/transitional.cat.old';
## ------------------------------------------------------------------
return if ( ! -f $catalog );
## ----------------------------------------------------------------------
my $top_marker = '-- START SGML CATALOG ENTRY FOR PACKAGE';
my $bottom_marker = '-- END SGML CATALOG ENTRY FOR PACKAGE';
my $eol_marker = '--';
## ------------------------------------------------------------------
my @data;
## -------------------------------------------------------------------
open( CATALOG, '<', $catalog )
or &error( "cannot open SGML catalog $catalog for reading: $!" );
## -------------------------------------------------------------------
while ( <CATALOG> )
{
chop;
if ( /$top_marker $package $eol_marker/o )
{
if ( $data[ $#data ] =~ /^\s*/o )
{
pop( @data );
}
while ( !/$bottom_marker $package $eol_marker/o )
{
if ( not ($_ = <CATALOG>) )
{
&error( "cannot find bottom marker for package $package:\n $bottom_marker $package $eol_marker\nplease remove the entry for $package manually" );
}
}
}
else
{
push( @data, $_ );
}
}
## ------------------------------------------------------------------
close( CATALOG )
or &error( "cannot close SGML catalog $catalog: $!" );
## ------------------------------------------------------------------
if ( -f $catalog )
{
if ( -f $backup )
{
unlink( $backup )
or &error( "cannot remove backup of catalog $backup: $!" );
}
rename( $catalog, $backup )
or &error( "cannot rename $catalog to $backup: $!" );
}
## ------------------------------------------------------------------
open( CATALOG, '>', $catalog )
or &error( "cannot open SGML catalog $catalog for writing: $!" );
## ------------------------------------------------------------------
for ( @data )
{
print CATALOG "$_\n";
}
## ------------------------------------------------------------------
close( CATALOG )
or &error( "cannot close SGML catalog $catalog: $!" );
} ## remove
## ----------------------------------------------------------------------
sub usage
{
## ------------------------------------------------------------------
print STDERR <<END;
Usage:
$name --remove package
END
} ## usage
## ----------------------------------------------------------------------
sub error
{
## ------------------------------------------------------------------
die "$name: error: $_[0]\n";
} ## error
## ----------------------------------------------------------------------
|