2011-11-09 17:38:16 -05:00
|
|
|
#!@PERL@
|
|
|
|
|
|
|
|
# GNU Stow - manage the installation of multiple software packages
|
2011-11-09 17:39:32 -05:00
|
|
|
# Copyright (C) 1993, 1994, 1995, 1996 by Bob Glickstein
|
|
|
|
# Copyright (C) 2000,2001 Guillaume Morin
|
2005-12-29 14:17:59 -05:00
|
|
|
# Copyright (C) 2005 Adam Spiers
|
2011-11-09 17:39:32 -05:00
|
|
|
#
|
2011-11-09 17:38:16 -05:00
|
|
|
# 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.
|
2011-11-09 17:39:32 -05:00
|
|
|
#
|
2011-11-09 17:56:17 -05:00
|
|
|
# $Id$
|
|
|
|
# $Source$
|
|
|
|
# $Date$
|
|
|
|
# $Author$
|
2011-11-09 17:39:32 -05:00
|
|
|
|
2005-12-29 14:17:59 -05:00
|
|
|
#####################################################################
|
|
|
|
# Thu Dec 29 2005 Adam Spiers <stow@adamspiers.org>
|
|
|
|
# Hacked into a Perl module
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
my $Version = '1.4.0';
|
|
|
|
require 5.005;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2005-12-15 06:37:31 -05:00
|
|
|
use File::Spec;
|
2005-12-29 14:17:59 -05:00
|
|
|
use FindBin qw($RealBin $RealScript);
|
2005-12-15 06:37:31 -05:00
|
|
|
use Getopt::Long;
|
2005-12-29 14:17:59 -05:00
|
|
|
use POSIX;
|
2005-12-15 06:37:31 -05:00
|
|
|
|
|
|
|
use lib "$RealBin/../lib/perl5";
|
|
|
|
use Sh 'glob_to_re';
|
2005-12-29 14:17:59 -05:00
|
|
|
use Stow;
|
|
|
|
|
2005-12-15 06:37:31 -05:00
|
|
|
my $ignore_file = File::Spec->join($ENV{HOME}, ".cvsignore");
|
2006-01-01 20:48:25 -05:00
|
|
|
my $ignore_re = Stow::get_ignore_re_from_file($ignore_file);
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2005-12-29 14:17:59 -05:00
|
|
|
my %opts = (
|
|
|
|
conflicts => 0,
|
|
|
|
delete => 0,
|
2006-01-01 20:48:25 -05:00
|
|
|
prune => 0,
|
2005-12-29 14:17:59 -05:00
|
|
|
not_really => 0,
|
|
|
|
verbose => 0,
|
|
|
|
stow => undef,
|
|
|
|
target => undef,
|
|
|
|
restow => 0,
|
|
|
|
);
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2006-01-01 20:48:25 -05:00
|
|
|
Getopt::Long::Configure('noignorecase', 'bundling');
|
2005-12-29 14:17:59 -05:00
|
|
|
GetOptions(
|
|
|
|
\%opts,
|
2006-01-01 20:48:25 -05:00
|
|
|
'delete|D', 'prune|p', 'restow|R',
|
|
|
|
'conflicts|c', 'not_really|n',
|
|
|
|
'stow|dir|d=s', 'target|t=s',
|
|
|
|
'verbose|v:+', 'version|V', 'help|h',
|
2005-12-29 14:17:59 -05:00
|
|
|
)
|
|
|
|
or usage();
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2005-12-29 14:17:59 -05:00
|
|
|
version() if $opts{version};
|
|
|
|
usage() if $opts{help};
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2006-01-01 20:48:25 -05:00
|
|
|
usage("Pruning only makes sense when deleting or restowing")
|
|
|
|
if $opts{prune} and ! ($opts{delete} || $opts{restow});
|
2005-12-29 14:17:59 -05:00
|
|
|
usage("No packages named") unless @ARGV;
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2005-12-29 14:17:59 -05:00
|
|
|
Stow::SetOptions(%opts);
|
|
|
|
Stow::Init();
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2005-12-29 14:17:59 -05:00
|
|
|
my @Collections = @ARGV;
|
|
|
|
Stow::CheckCollections(@Collections);
|
2011-11-09 17:38:16 -05:00
|
|
|
|
2005-12-29 14:17:59 -05:00
|
|
|
if ($opts{delete} || $opts{restow}) {
|
2006-01-01 20:48:25 -05:00
|
|
|
# These are the packages we are unstowing.
|
|
|
|
my %to_unstow = map { $_ => 1 } @Collections;
|
|
|
|
|
|
|
|
Stow::Unstow(
|
|
|
|
'',
|
|
|
|
Stow::RelativePath($opts{target}, $opts{stow}),
|
|
|
|
\%to_unstow,
|
|
|
|
);
|
2011-11-09 17:38:16 -05:00
|
|
|
}
|
|
|
|
|
2006-01-01 20:48:25 -05:00
|
|
|
if (! $opts{delete} || $opts{restow}) {
|
2005-12-29 14:17:59 -05:00
|
|
|
foreach my $Collection (@ARGV) {
|
|
|
|
warn "Stowing package $Collection...\n" if $opts{verbose};
|
2006-01-01 20:48:25 -05:00
|
|
|
Stow::StowContents(
|
|
|
|
$Collection,
|
|
|
|
Stow::RelativePath($opts{target}, $opts{stow}),
|
|
|
|
);
|
2011-11-09 17:38:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub usage {
|
2005-12-29 14:17:59 -05:00
|
|
|
my($msg) = shift;
|
2011-11-09 17:38:16 -05:00
|
|
|
|
|
|
|
if ($msg) {
|
2005-12-29 14:17:59 -05:00
|
|
|
print "$RealScript: $msg\n";
|
2011-11-09 17:38:16 -05:00
|
|
|
}
|
2005-12-29 14:17:59 -05:00
|
|
|
print "$RealScript (GNU Stow) version $Version\n\n";
|
|
|
|
print "Usage: $RealScript [OPTION ...] PACKAGE ...\n";
|
2011-11-09 17:38:16 -05:00
|
|
|
print <<EOT;
|
|
|
|
-n, --no Do not actually make changes
|
|
|
|
-c, --conflicts Scan for conflicts, implies -n
|
|
|
|
-d DIR, --dir=DIR Set stow dir to DIR (default is current dir)
|
|
|
|
-t DIR, --target=DIR Set target to DIR (default is parent of stow dir)
|
|
|
|
-v, --verbose[=N] Increase verboseness (levels are 0,1,2,3;
|
|
|
|
-v or --verbose adds 1; --verbose=N sets level)
|
|
|
|
-D, --delete Unstow instead of stow
|
|
|
|
-R, --restow Restow (like stow -D followed by stow)
|
2006-01-01 20:48:25 -05:00
|
|
|
-p, --prune When deleting, skip target subdirectories not in
|
|
|
|
the package dir (faster but may leave symlinks)
|
2011-11-09 17:38:16 -05:00
|
|
|
-V, --version Show Stow version number
|
|
|
|
-h, --help Show this help
|
|
|
|
EOT
|
|
|
|
exit($msg ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub version {
|
2005-12-29 14:17:59 -05:00
|
|
|
print "$RealScript (GNU Stow) version $Version\n";
|
2011-11-09 17:38:16 -05:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|