d73262ec7722027a02054aedf7742a7082085269
[jalview.git] / utils / jarunsigner.pl
1 #!/usr/bin/perl
2 #*******************************************************************************
3 # Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
4 # Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 #
6 # This file is part of Jalview.
7 #
8 # Jalview is free software: you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License 
10 # as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 #
12 # Jalview is distributed in the hope that it will be useful, but 
13 # WITHOUT ANY WARRANTY; without even the implied warranty 
14 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15 # PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
18 #*******************************************************************************
19 use strict;
20
21 # perverse script to get rid of unwanted jar signatures
22 use Cwd qw(abs_path);
23 use File::Temp qw(tempdir);
24
25 my $tempdir = tempdir( CLEANUP => 1);
26
27 my $jarfile;
28
29 my @jarfiles;
30
31 while (scalar @ARGV) {
32     my $jarfile = shift @ARGV;
33     ((-f $jarfile) and $jarfile=~/.+\.jar/) 
34         and push @jarfiles, abs_path($jarfile);
35 }
36 my $pwdir = `pwd`;
37 chdir($tempdir);
38
39 while (scalar @jarfiles) {
40     $jarfile = shift @jarfiles;
41     system("rm -Rf *");
42     system("jar xf $jarfile");
43     system("mv $jarfile $jarfile.bak");
44     system("find META-INF \\( -name \"*.SF\" \\) -exec rm -f \\{\\} \\;");
45     system("find META-INF \\( -name \"*.RSA\" \\) -exec rm -f \\{\\} \\;");
46     system("find META-INF \\( -name \"*.DSA\" \\) -exec rm -f \\{\\} \\;");
47     system("jar cf $jarfile *");
48 }
49
50 chdir($pwdir);