--- /dev/null
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Config::Simple;
+use Getopt::Long;
+
+my ($help, $config_file, $component, $srcpath);
+
+GetOptions(
+ 'help' => \$help, # show help message and exit
+ 'config=s' => \$config_file, # INI file for path mappings
+ 'component=s' => \$component, # The component to grab the source paths for
+ 'srcpath=s' => \$srcpath # The source path to grap the destination path for
+);
+
+if ($help) {
+ print <<"HELP";
+
+OPTIONS:
+ --help
+ Show help message and exit.
+ --config
+ Location of INI file for path mappings.
+ --component
+ The component of the INI file for which you want the paths
+ --srcpath
+ The source path to return the destination path for
+
+HELP
+ exit;
+}
+
+# load config
+die "No config file specified\n" unless ($config_file);
+die "Config file does not exist\n" unless (-r $config_file and -s $config_file);
+my $cfg = new Config::Simple($config_file);
+
+if (!$component) {
+ my @components = ();
+ #pull out components from INI file
+ open my $fh, '<', $config_file;
+ while (<$fh>) {
+ chomp;
+ if ($_ =~ /^\[[^]]+\]$/) {
+ $_ =~ s/[\[\]]//g;
+ push(@components, $_);
+ }
+ }
+ print "@components\n";
+} elsif (!$srcpath) {
+ foreach my $key (keys $cfg->get_block($component)) {
+ print $key . "\n";
+ }
+} else {
+ print $cfg->get_block($component)->{$srcpath};
+}
+
#!/usr/bin/perl
+use strict;
+use warnings;
# On Ubuntu, you'll want the following packages:
# - libconfig-simple-perl
# - libgit-repository-perl
use Getopt::Long;
use Data::Dumper;
-my ($help, $config_file, $all, $print_hashes, $repo_path, $check_files);
+my ($help, $config_file, $repo_path, $all, $check_files, $hash_file, $since, $git_output, $deployed_output);
my $branch = 'HEAD';
my $remote = 'origin';
my @components;
}
# specify all possible components (--all option);
-# it would be better to pull all block labels from the config file,
-# but that's not possible with Config::Simple
-@components = qw/perl tt2 web xul misc/ if ($all);
-
-# load config
-die "No config file specified\n" unless ($config_file);
-die "Config file does not exist\n" unless (-r $config_file and -s $config_file);
-my $cfg = new Config::Simple($config_file);
+@components = split(' ', `./access_pathmap.pl --config $config_file`) if ($all);
if ($git_output) {
open (GITOUTPUT, '>>', $git_output) or die "Could not open $git_output: $!\n";
}
foreach my $component (@components) {
- my $paths = $cfg->get_block($component);
+ my @paths = split('\n', `./access_pathmap.pl --config $config_file --component $component`);
# if no hash file was supplied, grab git hashes from repo
if (!$hash_file) {
}
# get hashes from git
- foreach my $srcpath (keys %$paths) {
+ foreach my $srcpath (@paths) {
# use git-ls-tree to traverse the file tree starting at $srcpath
# e.g. `git ls-tree -r HEAD Open-ILS/src/perlmods/lib`
my @tree = $repo->run( 'ls-tree' => '-r', $branch, $srcpath );
# check deployed files
if ($check_files || $deployed_output) {
- foreach my $srcpath (keys %$paths) {
- my $destpath = $paths->{$srcpath};
- my @files;
+ foreach my $srcpath (@paths) {
+ my $destpath = `./access_pathmap.pl --config $config_file --component $component --srcpath $srcpath`;
# for each file in the destination path, push the file's absolute path to @files;
# output will include symlinked files, but will not include directories
+ # clear @files for each time through loop
+ my @files = ();
find( { wanted => sub { push @files, $_ if -f }, follow => 1, no_chdir => 1 }, $destpath );
foreach my $file (@files) {
-
if ($since) {
# convert $since to seconds since epoch
my $since_ts = UnixDate($since, '%s');
print "modified\t$file\n";
}
}
- print DEPLOYEDOUTPUT $hash, "\t", $filename, "\n" if ($deployed_output);
+ print DEPLOYEDOUTPUT $hash, "\t", $file, "\n" if ($deployed_output);
}
}