Normal
  7   	ˆl–Ým_JJi?u8 ¸È®2Ê˜´o‘äÇò 8à$}°¿$�È/çÈƒh¹ÇÆÅ      	0000000d
  6   ˆl–ß=¿JÅ5*�zà¸ËÊbÑ¿�þDÔaY²�À¼Ë1¾'�üÿÉƒ}—ÙÈÇÆ $±    #!/usr/bin/perl
## ----------------------------------------------------------------------
## Debian GNU/Linux update-catalog version 0.2
## ----------------------------------------------------------------------
## Copyright (c) 2001-2004 Ardo van Rangelrooij
## Copyright (c) 2012 Helmut Grohne
## Copyright (c) 2012 Jakub Wilk
##
## This is free software; see the GNU General Public Licence version 2
## or later for copying conditions.  There is NO warranty.
## ----------------------------------------------------------------------

## ----------------------------------------------------------------------
use strict;

## ----------------------------------------------------------------------
$0 =~ m|[^/]+$|;

## ----------------------------------------------------------------------
use vars qw( $name );
$name = $&;

## ----------------------------------------------------------------------
use vars qw( $add );
use vars qw( $backup );
use vars qw( $catalog );
use vars qw( @data );
use vars qw( $debug );
use vars qw( $entry );
use vars qw( $quiet );
use vars qw( $remove );
use vars qw( $super );
use vars qw( $updatesuper );
use vars qw( $template );
use vars qw( $type );

## ----------------------------------------------------------------------
while ( $ARGV[0] =~ m/^--/ )
{
    $_ = shift( @ARGV );
    last if $_ eq '--';
    if ( $_ eq '--add' )
    {
        $add = 1;
    }
    elsif ( $_ eq '--remove' )
    {
        $remove = 1;
    }
    elsif ( $_ eq '--quiet' )
    {
        $quiet = 1;
    }
    elsif ( $_ eq '--super' )
    {
        $super = 1;
    }
    elsif ( $_ eq '--test' )
    {
        $debug = 1;
    }
    elsif ( $_ eq '--update-super' )
    {
        $updatesuper = 1;
    }
    elsif ( $_ eq '--help' )
    {
        &help;
	exit -1;
    }
    elsif ( $_ eq '--version' )
    {
        &help;
	exit -1;
    }
    else
    {
        print STDERR "$name: unknown option \`$_'\n";
	&help;
	exit 1;
    }
}

## ----------------------------------------------------------------------
if ( $add + $remove + $updatesuper != 1)
{
    print "Huh? You have to use precisely one out of --add --remove or --update-super.\n";
    exit 1;
}

## ----------------------------------------------------------------------
if ( $add || $remove )
{
    if ( ! @ARGV )
    {
        print STDERR "\n";
        &help;
        exit 1;
    }

    if ( $super )
    {
	$catalog = '/etc/sgml/catalog';
    }
    else
    {
	$catalog = shift( @ARGV );
    }

    if ( ! @ARGV )
    {
        print STDERR "\n";
        &help;
        exit 1;
    }

    $entry = shift( @ARGV );
}

## ----------------------------------------------------------------------
if ( @ARGV )
{
    print STDERR "$name: too many arguments\n";
    &help;
    exit 1;
}

## ----------------------------------------------------------------------
print STDERR "$name: test mode - catalog file will not be updated\n"
    if $debug && ! $quiet;

## ----------------------------------------------------------------------
if ( $super )
{
    print "update-catalog: Suppressing action on super catalog. Invoking trigger instead.\n";
    system("dpkg-trigger /etc/sgml");
    if ( $? != 0 )
    {
        print "Invocation of dpkg-trigger failed with status $?.\n";
        print "Forcing update of the super catalog...\n";
        &update_super;
    }
}
elsif ( $add )
{
    print "Adding entry $entry to catalog $catalog...\n"
        unless $quiet;
    
    &read_catalog_without_entry;
    &add_entry;
    &write_catalog;
}
elsif ( $remove )
{
    print "Removing entry $entry from catalog $catalog...\n"
        unless $quiet;
    
    &read_catalog_without_entry;
    &write_catalog;
}
elsif ( $updatesuper )
{
    print "Updating the super catalog...\n"
        unless $quiet;
    &update_super;
}

## ----------------------------------------------------------------------
exit 0;

## -----------------------------------------------------------------