#!@PERL@ # GNU Stow - manage the installation of multiple software packages # Copyright (C) 1993, 1994, 1995, 1996 by Bob Glickstein # Copyright (C) 2000,2001 Guillaume Morin # Copyright (C) 2005 Adam Spiers # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # $Id$ # $Source$ # $Date$ # $Author$ ##################################################################### # Thu Dec 29 2005 Adam Spiers # Hacked into a Perl module ##################################################################### my $Version = '1.4.0'; require 5.005; use strict; use warnings; use File::Spec; use FindBin qw($RealBin $RealScript); use Getopt::Long; use POSIX; use lib "$RealBin/../lib/perl5"; use Sh 'glob_to_re'; use Stow; my $ignore_file = File::Spec->join($ENV{HOME}, ".cvsignore"); my $ignore_re = get_ignore_re_from_file($ignore_file); my %opts = ( conflicts => 0, delete => 0, not_really => 0, verbose => 0, stow => undef, target => undef, restow => 0, ); GetOptions( \%opts, 'conflicts|c', 'not_really|n', 'stow|dir|d=s', 'target|t=s', 'verbose|v:+', 'delete|D', 'version|V', 'help|h', ) or usage(); version() if $opts{version}; usage() if $opts{help}; usage("No packages named") unless @ARGV; Stow::SetOptions(%opts); Stow::Init(); my @Collections = @ARGV; Stow::CheckCollections(@Collections); if ($opts{delete} || $opts{restow}) { Stow::Unstow('', &RelativePath($opts{target}, $opts{stow}), \@Collections); } if (!$opts{delete} || $opts{restow}) { foreach my $Collection (@ARGV) { warn "Stowing package $Collection...\n" if $opts{verbose}; Stow::StowContents($Collection, &RelativePath($opts{target}, $opts{stow})); } } sub usage { my($msg) = shift; if ($msg) { print "$RealScript: $msg\n"; } print "$RealScript (GNU Stow) version $Version\n\n"; print "Usage: $RealScript [OPTION ...] PACKAGE ...\n"; print <