diff --git a/bin/slubsipbuilder.pl b/bin/slubsipbuilder.pl index f387c1271bd68cc21c2c1367adcf85208cf4f851..f4887a4ae92f5faee51d2f910b82a8d4d34c14c7 100755 --- a/bin/slubsipbuilder.pl +++ b/bin/slubsipbuilder.pl @@ -24,7 +24,7 @@ use 5.20.0; use strict; use warnings; use Archive::Zip::SimpleZip qw($SimpleZipError); -use Cwd; +use Cwd qw(abs_path); use DateTime::Format::ISO8601; use Digest::MD5 qw(md5); use File::Basename; @@ -79,16 +79,15 @@ if ($help) { pod2usage(1); } 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 $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 $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 $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 $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 (! -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_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) say "Rebuilding XSL directory '$xsl_dir'"; mkpath($xsl_dir) || confess ("could not mkdir '$xsl_dir', $!");; } + $xsl_dir = abs_path($xsl_dir); #### where to find XSLT # 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_path = $xsl_dir . basename($marc_mods_url); - my $marc_mods_patched_path = $xsl_dir . basename($marc_mods_url, ".xsl") . ".patched.xsl"; + 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_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; $ua->agent("MyApp/0.1 "); @@ -285,6 +285,7 @@ sub main { if (! -d $output) { mkpath("$output") || confess("could not create SIP directory for '$output', $!"); } + $output = abs_path($output); my $sip_root_dir = "PPN-${ppn}_${file_date}"; my $content = "$output/$sip_root_dir/data"; if (!defined $as_zip) { @@ -361,7 +362,7 @@ AMD $filecopyhash{$source}{'relative'}="data/$file"; $filecopyhash{$source}{'target'}="$content/$file"; 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); my $ctx = Digest::MD5->new; $ctx->addfile(*$fh);