Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
01c72a5f
Commit
01c72a5f
authored
21 years ago
by
Andreas Kusalananda Kähäri
Browse files
Options
Downloads
Patches
Plain Diff
aux.pm incorporated into build.pl and apply.pl to ease distribution
parent
dc48b05d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
misc-scripts/binary_delta/apply.pl
+91
-1
91 additions, 1 deletion
misc-scripts/binary_delta/apply.pl
misc-scripts/binary_delta/aux.pm
+0
-172
0 additions, 172 deletions
misc-scripts/binary_delta/aux.pm
misc-scripts/binary_delta/build.pl
+88
-1
88 additions, 1 deletion
misc-scripts/binary_delta/build.pl
with
179 additions
and
174 deletions
misc-scripts/binary_delta/apply.pl
+
91
−
1
View file @
01c72a5f
...
...
@@ -22,7 +22,97 @@ use File::Copy;
use
Getopt::
Std
;
use
aux
qw(:default :apply)
;
use
Digest::
MD5
;
use
Compress::
Zlib
;
# Compute the MD5 checksum of a file. Returns the checksum as a
# hex string.
sub
make_checksum
{
my
$file_path
=
shift
;
my
$digest
=
new
Digest::
MD5
;
open
FILE
,
$file_path
or
die
$!
;
binmode
FILE
;
$digest
->
addfile
(
*FILE
);
my
$hex
=
$digest
->
hexdigest
;
close
FILE
;
return
$hex
;
}
# Converts a byte count to a form more easly read by humans.
# Returns a string consisting of an float (two decimal places),
# a space, and a suffix.
sub
make_human_readable
{
my
$bytes
=
shift
;
my
@prefix
=
qw(b Kb Mb Gb Tb Pb)
;
my
$step
=
0
;
while
(
$bytes
>
10000
)
{
$bytes
/=
1024
;
++
$step
;
}
return
sprintf
("
%.2f %s
",
$bytes
,
$prefix
[
$step
]);
}
# Display usage information for the apply.pl program.
sub
usage_apply
{
my
$opts
=
shift
;
print
STDERR
<<EOT;
Usage: $0 [options] [--] database old_v new_v
database The database to work on, e.g. "homo_sapiens_core".
old_v The older version, e.g. "11_31".
new_v The newer version, e.g. "12_31".
The options may be any of these:
-c cmd Path to xdelta executable.
Default: "$opts->{'c'}".
-s path Path to the directory where the delta directory is stored.
Default: "$opts->{'s'}"
-d path Path to the directory holding the old version of the
database, and where the new version of the database
should be created. The new database directory will be
given a unique name.
Default: "$opts->{'d'}"
EOT
}
# Decompress a file.
sub
do_decompress
{
my
$zfile_path
=
shift
;
my
$file_path
=
shift
;
open
(
OUT
,
'
>
'
.
$file_path
)
or
die
$!
;
binmode
OUT
;
my
$gz
=
gzopen
(
$zfile_path
,
"
r
");
if
(
!
defined
(
$gz
))
{
close
OUT
;
die
$gzerrno
;
}
my
$buffer
;
while
((
my
$bytesread
=
$gz
->
gzread
(
$buffer
))
!=
0
)
{
print
OUT
substr
(
$buffer
,
0
,
$bytesread
);
}
$gz
->
gzclose
();
close
OUT
;
}
my
%opts
;
my
$xdelta_cmd
=
$opts
{'
c
'}
=
'
xdelta
';
...
...
This diff is collapsed.
Click to expand it.
misc-scripts/binary_delta/aux.pm
deleted
100644 → 0
+
0
−
172
View file @
dc48b05d
package
aux
;
# $Id$
#
# aux.pm
#
# Auxiliary subroutines for the apply.pl and build.pl programs.
#
# Author: Andreas Kahari, <andreas.kahari@ebi.ac.uk>
#
require
Exporter
;
@ISA
=
qw(Exporter)
;
@EXPORT_OK
=
qw( make_human_readable make_checksum
usage_apply do_decompress
usage_build do_compress )
;
%EXPORT_TAGS
=
(
default
=>
[
qw( make_human_readable make_checksum )
],
apply
=>
[
qw( usage_apply do_decompress )
],
build
=>
[
qw( usage_build do_compress )
]
);
use
Digest::
MD5
;
use
Compress::
Zlib
;
#================= :default
# Compute the MD5 checksum of a file. Returns the checksum as a
# hex string.
sub
make_checksum
{
my
$file_path
=
shift
;
my
$digest
=
new
Digest::
MD5
;
open
FILE
,
$file_path
or
die
$!
;
binmode
FILE
;
$digest
->
addfile
(
*FILE
);
my
$hex
=
$digest
->
hexdigest
;
close
FILE
;
return
$hex
;
}
# Converts a byte count to a form more easly read by humans.
# Returns a string consisting of an float (two decimal places),
# a space, and a suffix.
sub
make_human_readable
{
my
$bytes
=
shift
;
my
@prefix
=
qw(b Kb Mb Gb Tb Pb)
;
my
$step
=
0
;
while
(
$bytes
>
10000
)
{
$bytes
/=
1024
;
++
$step
;
}
return
sprintf
("
%.2f %s
",
$bytes
,
$prefix
[
$step
]);
}
#================= :apply
# Display usage information for the apply.pl program.
sub
usage_apply
{
my
$opts
=
shift
;
print
STDERR
<<EOT;
Usage: $0 [options] [--] database old_v new_v
database The database to work on, e.g. "homo_sapiens_core".
old_v The older version, e.g. "11_31".
new_v The newer version, e.g. "12_31".
The options may be any of these:
-c cmd Path to xdelta executable.
Default: "$opts->{'c'}".
-s path Path to the directory where the delta directory is stored.
Default: "$opts->{'s'}"
-d path Path to the directory holding the old version of the
database, and where the new version of the database
should be created. The new database directory will be
given a unique name.
Default: "$opts->{'d'}"
EOT
}
# Decompress a file.
sub
do_decompress
{
my
$zfile_path
=
shift
;
my
$file_path
=
shift
;
open
(
OUT
,
'
>
'
.
$file_path
)
or
die
$!
;
binmode
OUT
;
my
$gz
=
gzopen
(
$zfile_path
,
"
r
");
if
(
!
defined
(
$gz
))
{
close
OUT
;
die
$gzerrno
;
}
my
$buffer
;
while
((
my
$bytesread
=
$gz
->
gzread
(
$buffer
))
!=
0
)
{
print
OUT
substr
(
$buffer
,
0
,
$bytesread
);
}
$gz
->
gzclose
();
close
OUT
;
}
#================= :build
# Display usage information for the build.pl program.
sub
usage_build
{
my
$opts
=
shift
;
print
STDERR
<<EOT;
Usage: $0 [options] [--] database old_v new_v
database The database to work on, e.g. "homo_sapiens_core".
old_v The older version, e.g. "11_31".
new_v The newer version, e.g. "12_31".
The options may be any of these:
-c cmd Path to xdelta executable.
Default: "$opts->{'c'}".
-s path Path to the directory where the databases are stored.
Default: "$opts->{'s'}"
-d path Path to the directory within which the delta
directory should be created.
Default: "$opts->{'d'}"
EOT
}
# Compress a file.
sub
do_compress
{
my
$file_path
=
shift
;
my
$zfile_path
=
shift
;
open
(
IN
,
$file_path
)
or
die
$!
;
binmode
IN
;
my
$gz
=
gzopen
(
$zfile_path
,
"
w
");
if
(
!
defined
(
$gz
))
{
close
IN
;
die
$gzerrno
;
}
while
(
defined
(
my
$input
=
<
IN
>
))
{
$gz
->
gzwrite
(
$input
)
or
die
$gzerrno
;
}
$gz
->
gzclose
();
close
IN
;
}
1
;
This diff is collapsed.
Click to expand it.
misc-scripts/binary_delta/build.pl
+
88
−
1
View file @
01c72a5f
...
...
@@ -21,7 +21,94 @@ use File::Copy;
use
Getopt::
Std
;
use
aux
qw(:default :build)
;
use
Digest::
MD5
;
use
Compress::
Zlib
;
# Compute the MD5 checksum of a file. Returns the checksum as a
# hex string.
sub
make_checksum
{
my
$file_path
=
shift
;
my
$digest
=
new
Digest::
MD5
;
open
FILE
,
$file_path
or
die
$!
;
binmode
FILE
;
$digest
->
addfile
(
*FILE
);
my
$hex
=
$digest
->
hexdigest
;
close
FILE
;
return
$hex
;
}
# Converts a byte count to a form more easly read by humans.
# Returns a string consisting of an float (two decimal places),
# a space, and a suffix.
sub
make_human_readable
{
my
$bytes
=
shift
;
my
@prefix
=
qw(b Kb Mb Gb Tb Pb)
;
my
$step
=
0
;
while
(
$bytes
>
10000
)
{
$bytes
/=
1024
;
++
$step
;
}
return
sprintf
("
%.2f %s
",
$bytes
,
$prefix
[
$step
]);
}
# Display usage information for the build.pl program.
sub
usage_build
{
my
$opts
=
shift
;
print
STDERR
<<EOT;
Usage: $0 [options] [--] database old_v new_v
database The database to work on, e.g. "homo_sapiens_core".
old_v The older version, e.g. "11_31".
new_v The newer version, e.g. "12_31".
The options may be any of these:
-c cmd Path to xdelta executable.
Default: "$opts->{'c'}".
-s path Path to the directory where the databases are stored.
Default: "$opts->{'s'}"
-d path Path to the directory within which the delta
directory should be created.
Default: "$opts->{'d'}"
EOT
}
# Compress a file.
sub
do_compress
{
my
$file_path
=
shift
;
my
$zfile_path
=
shift
;
open
(
IN
,
$file_path
)
or
die
$!
;
binmode
IN
;
my
$gz
=
gzopen
(
$zfile_path
,
"
w
");
if
(
!
defined
(
$gz
))
{
close
IN
;
die
$gzerrno
;
}
while
(
defined
(
my
$input
=
<
IN
>
))
{
$gz
->
gzwrite
(
$input
)
or
die
$gzerrno
;
}
$gz
->
gzclose
();
close
IN
;
}
my
%opts
;
my
$xdelta_cmd
=
$opts
{'
c
'}
=
'
xdelta
';
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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