OSSP CVS Repository

ossp - ossp-pkg/cvsfusion/cvsfusion.pl 1.2
Not logged in
[Honeypot]  [Browse]  [Directory]  [Home]  [Login
[Reports]  [Search]  [Ticket]  [Timeline
  [Raw

ossp-pkg/cvsfusion/cvsfusion.pl 1.2
#!/usr/opkg/bin/perl
##
##  OSSP cvsfusion - CVS Repository Fusion
##  Copyright (c) 2004 Ralf S. Engelschall <rse@engelschall.com>
##  Copyright (c) 2004 The OSSP Project <http://www.ossp.org/>
##  Copyright (c) 2004 Cable & Wireless <http://www.cw.com/>
##
##  This file is part of OSSP cvsfusion, a CVS repository fusion
##  utility which can be found at http://www.ossp.org/pkg/tool/cvsfusion/.
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##
##  cvsfusion.pl: main program
##

require 5;
use strict;
use warnings;
use lib ".";
use Getopt::Long;
use IO::File;
use RCS;

#   program information
my $prog = {
    'name' => "cvsfusion",
    'vers' => "0.0.1",
    'date' => "20-Apr-2004"
};

#   program parameters (defaults)
my $opt = {
    'version'        => 0,
    'verbose'        => 0,
    'help'           => 0,
    'tmpdir'         => ($ENV{TMPDIR} || "/tmp") . "/" . $prog->{'name'},
    'cvsroot-source' => '',
    'cvsroot-target' => '',
    'cvs-branch'     => '',
    'cvs-module'     => [],
    'prog-rcs'       => "rcs",
    'prog-diff'      => "diff"
};

#   exception handling support
$SIG{__DIE__} = sub {
    my ($err) = @_;
    $err =~ s|\s+at\s+.*||s if (not $opt->{'verbose'});
    print STDERR $prog->{'name'} . ":ERROR: $err ". ($! ? "($!)" : "") . "\n";
    exit(1);
};

#   command line parsing
Getopt::Long::Configure("bundling");
my $result = GetOptions(
    'V|version'           => \$opt->{'version'},
    'v|verbose'           => \$opt->{'verbose'},
    'h|help'              => \$opt->{'help'},
    't|tmpdir=s'          => \$opt->{'tmpdir'},
    'f|cvsroot-source=s'  => \$opt->{'cvsroot-source'},
    'l|cvsroot-target=s'  => \$opt->{'cvsroot-target'},
    'b|cvs-branch=s'      => \$opt->{'cvs-branch'},
    'm|cvs-module=s@'     =>  $opt->{'cvs-module'},
    'R|prog-rcs=s'        => \$opt->{'prog-rcs'},
    'D|prog-diff=s'       => \$opt->{'prog-diff'},
) || die "option parsing failed";
if ($opt->{-help}) {
    print "Usage: ".$prog->{'name'}." [options]\n" .
          "Available options:\n" .
          " -V,--version             print program version\n" .
          " -v,--verbose             enable verbose run-time mode\n" .
          " -h,--help                print out this usage page\n" .
          " -t,--tmpdir=DIR          filesystem path to temporary directory\n" .
          " -f,--cvsroot-source=DIR  filesystem path to source CVS repository\n" .
          " -l,--cvsroot-target=DIR  filesystem path to target CVS repository\n" .
          " -b,--cvs-branch=TAG:REV  selects the CVS branch tag and revision to use\n" .
          " -m,--cvs-module=SUBDIR   selects the CVS repository module(s)\n" .
          " -R,--prog-rcs=FILE       filesystem path to rcs(1) program\n" .
          " -D,--prog-diff=FILE      filesystem path to diff(1) program\n";
    exit(0);
}
if ($opt->{-version}) {
    print "OSSP ".$prog->{'name'}." ".$prog->{'vers'}." (".$prog->{'date'}.")\n";
    exit(0);
}

#   verbose message printing
sub msg_verbose {
    my ($msg) = @_;
    print STDERR "$msg\n" if ($opt->{'verbose'});
}

#   warning message printing
sub msg_warning {
    my ($msg) = @_;
    print STDERR $prog->{'name'}.":WARNING: $msg\n";
}

#   error message printing
sub msg_error { 
    my ($msg) = @_;
    print STDERR $prog->{'name'}.":ERROR: $msg\n";
}

##  TEST

my $rcs = new RCS;
$rcs->tool("rcs",  "/usr/bin/rcs");
$rcs->tool("co",   "/usr/bin/co");
$rcs->tool("diff", "/usr/opkg/bin/diff");
$rcs->load("bash.spec,v");
$rcs->save("bash.spec,v.new");
undef $rcs;

__END__

=pod

=head1 NAME

B<cvsfusion> - CVS Repository Fusion

=head1 SYNOPSIS

B<cvsfusion>
[B<--verbose>]
[B<--tmpdir=>I<dir>]
[B<--cvsroot-source=>I<dir>]
[B<--cvsroot-target=>I<dir>]
[B<--cvs-branch=>I<tag>B<:>I<rev>]
[B<--cvs-module=>I<subdir>]
[B<--prog-rcs=>I<file>]
[B<--prog-diff=>I<file>]

B<cvsfusion>
[--version]
[--help]

=head1 DESCRIPTION

=cut


CVSTrac 2.0.1