summaryrefslogtreecommitdiffstats
path: root/deployment/funcs_jars_pack_sign.sh
blob: 979f57ceaf9e7778db53ecc3a76b54d99bec201b (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#! /bin/bash

#
# wsdir_jars_repack  <wsdir>
# wsdir_jars_pack200 <wsdir>
# wsdir_jars_sign    <wsdir> <pkcs12-keystore> <storepass> [signarg]
#

#
# see Java Bug 5078608
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5078608
#
PACK200_OPTIONS="--segment-limit=-1"

function wsdir_jars_repack() {

local wsdir=$1
shift 

if [ -z "$wsdir" ] ; then
    echo usage $0 webstartdir
    exit 1
fi

if [ ! -e $wsdir/jar ] ; then
    echo $wsdir/jar does not exist
    exit 1
fi

local THISDIR=`pwd`

cd $wsdir/jar

if [ -z "$JOGAMP_DEPLOYMENT_NO_REPACK" ] ; then
  mkdir orig
  cp -a *jar orig/

  for i in *.jar ; do
    echo pack200 --repack $PACK200_OPTIONS $i
    pack200 --repack $PACK200_OPTIONS $i
  done
fi

if [ -e atomic ] ; then
    cd atomic
    if [ -z "$JOGAMP_DEPLOYMENT_NO_REPACK" ] ; then
      mkdir orig
      cp -a *jar orig/

      for i in *.jar ; do
        echo pack200 --repack $PACK200_OPTIONS $i
        pack200 --repack $PACK200_OPTIONS $i
      done
    fi

fi

cd $THISDIR

}

function wsdir_jars_pack200() {

local wsdir=$1
shift 

if [ -z "$wsdir" ] ; then
    echo usage $0 webstartdir
    exit 1
fi

if [ ! -e $wsdir/jar ] ; then
    echo $wsdir/jar does not exist
    exit 1
fi

local THISDIR=`pwd`

cd $wsdir/jar

if [ -z "$JOGAMP_DEPLOYMENT_NO_REPACK" ] ; then
  mkdir -p DLLS
  mv *natives*.jar DLLS/

  for i in *.jar ; do
    echo gzip -9 $i to $i.gz
    gzip -9 -cv $i > $i.gz
    echo pack200 -E9 $PACK200_OPTIONS $i.pack.gz $i
    pack200 -E9 $PACK200_OPTIONS $i.pack.gz $i
  done

  mv DLLS/* .
  rm -rf DLLS
fi

if [ -e atomic ] ; then
    cd atomic
    if [ -z "$JOGAMP_DEPLOYMENT_NO_REPACK" ] ; then
      mkdir -p DLLS
      mv *natives*.jar DLLS/

      for i in *.jar ; do
        echo gzip -9 $i to $i.gz
        gzip -9 -cv $i > $i.gz
        echo pack200 -E9 $PACK200_OPTIONS $i.pack.gz $i
        pack200 -E9 $PACK200_OPTIONS $i.pack.gz $i
      done

      mv DLLS/* .
      rm -rf DLLS
    fi
fi

cd $THISDIR

}


function wsdir_jars_sign() {

local wsdir=$1
shift 

local keystore=$1
shift 

local storepass=$1
shift 

local signarg="$*"

if [ -z "$wsdir" -o -z "$keystore" -o -z "$storepass" ] ; then
    echo "usage $0 webstartdir pkcs12-keystore storepass [signarg]"
    exit 1
fi

if [ ! -e $wsdir/jar ] ; then
    echo $wsdir/jar does not exist
    exit 1
fi

if [ ! -e $keystore ] ; then
    echo $keystore does not exist
    exit 1
fi

local THISDIR=`pwd`

cd $wsdir/jar

rm -rf no-signing
mkdir -p no-signing
mv junit.jar no-signing/

for i in *.jar ; do
    echo jarsigner -storetype pkcs12 -keystore $keystore $i \"$signarg\"
    jarsigner -storetype pkcs12 -keystore $keystore -storepass $storepass $i "$signarg"
done

mv no-signing/*jar .
rm -rf no-signing

if [ -e atomic ] ; then
    cd atomic
    for i in *.jar ; do
        echo jarsigner -storetype pkcs12 -keystore $keystore $i \"$signarg\"
        jarsigner -storetype pkcs12 -keystore $keystore -storepass $storepass $i "$signarg"
    done
fi

cd $THISDIR

}