Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SLUB_SIP_Builder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
SLUB_SIP_Builder
Commits
95781814
Commit
95781814
authored
5 years ago
by
Jens Steidl
Browse files
Options
Downloads
Patches
Plain Diff
- build absolute paths if needed
- spelling fixes
parent
52d5df4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/slubsipbuilder.pl
+11
-10
11 additions, 10 deletions
bin/slubsipbuilder.pl
with
11 additions
and
10 deletions
bin/slubsipbuilder.pl
+
11
−
10
View file @
95781814
...
@@ -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 a
n
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment