forked from opensciencegrid/osg-certificates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-manifest
executable file
·114 lines (93 loc) · 3.26 KB
/
make-manifest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env perl
use Getopt::Long;
my @keys = qw(itb);
my %args;
@args{@keys} = ("") x @keys;
GetOptions(\%args,"itb+","help+");
if ( $args{help} ) {
usage();
exit 0;
}
my $cert_dir = ".";
my $manifest_file = "ca-certs-version";
my $tarball_path = "osg-certificates-$ENV{OUR_CERTS_VERSION}.tar.gz";
my $tarball_name = $tarball_path;
my $tarball_version;
my $tarball_release;
my $tarball_releasetype;
my $exit;
my $manifest;
#[01/12/18]replacing repo.grid.iu.edu -> repo.opensciencegrid.org
my $repository = "repo.opensciencegrid.org/pacman/cadist";
if ( index($ENV{OUR_CERTS_VERSION},"ITB") > 0 || $args{itb} ) {
$repository = "software-itb.grid.iu.edu/pacman/cadist";
}
if ($tarball_name =~ /(\d+)\.(\d+)([A-z]*)\.tar/) {
$tarball_version = $1;
$tarball_release = $2;
$tarball_releasetype = $3;
$tarball_release = $tarball_release . $tarball_releasetype;
} else {
die "Can't parse $tarball_name to extract version and release information.\n";
}
if (! -e $tarball_path) {
die "Can't access $tarball_path\n";
}
print "Making manifest of $tarball_path...\n";
#[10/30/18] commenting out to remove MD5 sum
#[11/06/18] uncommenting the following code to again include MD5 sum
#[10/21/19] commenting out to remove MD5 sum [SOFTWARE-3005]
##
## Calculate the MD5 of our tarbal
##
#my $md5sum_out = `md5sum $tarball_path 2> /dev/null`;
#my $md5sum = (split(/ /, $md5sum_out))[0];
##
## Calculate the SHA256 of our tarbal
##
my $sha256sum_out = `sha256sum $tarball_path 2> /dev/null`;
my $sha256sum = (split(/ /, $sha256sum_out))[0];
##
## Calculate the timestamp
##
my $timestamp;
my ($sec,$min,$hour,$mday,$month,$year) = gmtime(time);
$month++;
$year += 1900;
$timestamp = sprintf("%d%02d%02dT%02d%02d%02d",
$year, $month, $mday, $hour, $min, $sec);
##
## Figure out a text version of the description string that can eventually be
## put into vdt-version (via the updater script)
##
$versiondesc = "$ENV{OUR_CERTS_VERSION} (includes IGTF $ENV{IGTF_CERTS_VERSION} CAs)";
##
## Create the manifest
##
$manifest .= "dataversion=1 # The version of data in this file\n";
$manifest .= "timestamp=$timestamp # Time of creation of this file\n";
$manifest .= "certsversion=$tarball_version.$tarball_release # Version of the certificates\n";
$manifest .= "versiondesc=$versiondesc\n";
$manifest .= "tarball=http://$repository/$tarball_version.$tarball_release/$tarball_name\n";
#[10/30/18] commenting out to remove MD5
#[11/06/18] uncommenting the following code to again include MD5 sum
#[10/21/19] commenting out to remove MD5 sum [SOFTWARE-3005]
#$manifest .= "tarball_md5sum=$md5sum\n";
$manifest .= "tarball_sha256sum=$sha256sum\n";
##
## Write the manifest
##
open(MANIFEST, ">$cert_dir/$manifest_file");
print MANIFEST $manifest;
close(MANIFEST);
print " Manifest: $cert_dir/$manifest_file\n";
exit 0;
#####################################################################
sub usage() {
print "$0: [--itb] [--help]
Generates the manifest file for pacman, ca-certs-version
--help shows this text
--itb forces the distribution point of the tarball to be for the ITB
even if the OSG version does not contain ITB. This is needed
for a production release version that is first tested on ITB\n";
}