Skip to content
Snippets Groups Projects
Commit 95781814 authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- build absolute paths if needed

- spelling fixes
parent 52d5df4e
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ use 5.20.0; ...@@ -24,7 +24,7 @@ use 5.20.0;
use strict; use strict;
use warnings; use warnings;
use Archive::Zip::SimpleZip qw($SimpleZipError); use Archive::Zip::SimpleZip qw($SimpleZipError);
use Cwd; use Cwd qw(abs_path);
use DateTime::Format::ISO8601; use DateTime::Format::ISO8601;
use Digest::MD5 qw(md5); use Digest::MD5 qw(md5);
use File::Basename; use File::Basename;
...@@ -79,16 +79,15 @@ if ($help) { pod2usage(1); } ...@@ -79,16 +79,15 @@ if ($help) { pod2usage(1); }
if ($man) { pod2usage(-exitval => 0, -verbose => 2); } if ($man) { pod2usage(-exitval => 0, -verbose => 2); }
if (!defined $directory) { confess("you need to specify an IE directory, which needs to be archived"); } if (!defined $directory) { confess("you need to specify an IE directory, which needs to be archived"); }
if (!defined $ppn && !defined $noppn) { confess("you need to specify a PPN, which exists in SWB catalogue"); } if (!defined $ppn && !defined $noppn) { confess("you need to specify a PPN, which exists in SWB catalogue"); }
if (defined $ppn && defined $noppn) { confess("you could only use --ppn=foo or --noppn=bar"); } if (defined $ppn && defined $noppn) { confess("you can only use '--ppn=foo' or '--noppn=bar'"); }
if (!defined $output) { confess(" you need to specify an output path, where the SIP will be stored"); } if (!defined $output) { confess("you need to specify an output path, where the SIP will be stored"); }
if ($output !~ m#^/#) { confess("you need to specify an output path using absoluet paths, $!"); }
if (!defined $url) { $url = "http://swb.bsz-bw.de/sru/DB=2.1/username=/password=/";} if (!defined $url) { $url = "http://swb.bsz-bw.de/sru/DB=2.1/username=/password=/";}
if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; } if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; }
if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); } if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); }
if ($directory !~ m#^/#) { confess("you need to specify an IE directory using absoluet paths, $!"); } if ($directory !~ m#^/#) { $directory = abs_path($directory); }
if ($external_id !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); } if ($external_id !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); }
if ($external_workflow !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); } if ($external_workflow !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); }
if (!$external_value_descr) { confess("you need to specify a external value description (reason for archiving)"); } if (!$external_value_descr) { confess("you need to specify an external value description (reason for archiving)"); }
#=============================================================================== #===============================================================================
...@@ -186,14 +185,15 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) ...@@ -186,14 +185,15 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn)
say "Rebuilding XSL directory '$xsl_dir'"; say "Rebuilding XSL directory '$xsl_dir'";
mkpath($xsl_dir) || confess ("could not mkdir '$xsl_dir', $!");; mkpath($xsl_dir) || confess ("could not mkdir '$xsl_dir', $!");;
} }
$xsl_dir = abs_path($xsl_dir);
#### where to find XSLT #### where to find XSLT
# my $marc_dc_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slim2RDFDC.xsl'; # my $marc_dc_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slim2RDFDC.xsl';
my $marc_mods_url = 'http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3-6.xsl'; my $marc_mods_url = 'http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3-6.xsl';
my $marc_mods_path = $xsl_dir . basename($marc_mods_url); my $marc_mods_path = "$xsl_dir/" . basename($marc_mods_url);
my $marc_mods_patched_path = $xsl_dir . basename($marc_mods_url, ".xsl") . ".patched.xsl"; my $marc_mods_patched_path = "$xsl_dir/" . basename($marc_mods_url, ".xsl") . ".patched.xsl";
my $marc_utils_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slimUtils.xsl'; my $marc_utils_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slimUtils.xsl';
my $marc_utils_path = $xsl_dir . basename($marc_utils_url); my $marc_utils_path = "$xsl_dir/" . basename($marc_utils_url);
my $ua = LWP::UserAgent->new; my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 "); $ua->agent("MyApp/0.1 ");
...@@ -285,6 +285,7 @@ sub main { ...@@ -285,6 +285,7 @@ sub main {
if (! -d $output) { if (! -d $output) {
mkpath("$output") || confess("could not create SIP directory for '$output', $!"); mkpath("$output") || confess("could not create SIP directory for '$output', $!");
} }
$output = abs_path($output);
my $sip_root_dir = "PPN-${ppn}_${file_date}"; my $sip_root_dir = "PPN-${ppn}_${file_date}";
my $content = "$output/$sip_root_dir/data"; my $content = "$output/$sip_root_dir/data";
if (!defined $as_zip) { if (!defined $as_zip) {
...@@ -361,7 +362,7 @@ AMD ...@@ -361,7 +362,7 @@ AMD
$filecopyhash{$source}{'relative'}="data/$file"; $filecopyhash{$source}{'relative'}="data/$file";
$filecopyhash{$source}{'target'}="$content/$file"; $filecopyhash{$source}{'target'}="$content/$file";
my $fh; my $fh;
open($fh, "<", $source) or confess ("Can't open '$source' (current='",getcwd,"', $!\n"); open($fh, "<", $source) or confess ("Can't open '$source', $!");
binmode($fh); binmode($fh);
my $ctx = Digest::MD5->new; my $ctx = Digest::MD5->new;
$ctx->addfile(*$fh); $ctx->addfile(*$fh);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment