]> git.pld-linux.org Git - packages/openjdk9.git/blob - make-cacerts.sh
preparing new package
[packages/openjdk9.git] / make-cacerts.sh
1 #!/bin/sh -e
2 #
3 # make-cacerts.sh
4 #
5 # based on:
6 #
7 # update-ca-certificates
8 #
9 # Copyright (c) 2003 Fumitoshi UKAI <ukai@debian.or.jp>
10 # Copyright (c) 2009 Philipp Kern <pkern@debian.org>
11
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301,
25 # USA.
26 #
27
28 verbose=0
29 DESTDIR=
30 while [ $# -gt 0 ];
31 do
32   case $1 in
33   --verbose|-v)
34         verbose=1;;
35   --destdir)
36         DESTDIR=$2; shift;;
37   --help|-h|*)
38         echo "$0: [--verbose]"
39         exit;;
40   esac
41   shift
42 done
43
44 CERTSCONF=$DESTDIR/etc/ca-certificates.conf
45 CERTSCONFD=$DESTDIR/etc/ca-certificates.d
46 CERTSDIR=$DESTDIR/usr/share/ca-certificates
47 LOCALCERTSDIR=$DESTDIR/etc/certs
48 CERTBUNDLE=$DESTDIR/etc/certs/ca-certificates.crt
49 ETCCERTSDIR=$DESTDIR/etc/openssl/certs
50
51 KEYSTORE=$PWD/cacerts
52 KEYTOOL=$PWD/openjdk.build/bin/keytool
53
54 # Adds a certificate to the list of trusted ones.
55 # Adds the certificate to the cacerts file
56 add() {
57   CERT="$1"
58   NAME="$2"
59   ALIAS="$(echo "$NAME" | sed -e 's/.\(crt|pem\)$//' -e 's/ /_/g' \
60                                                 -e 's/[()]/=/g' -e 's/,/_/g')"
61
62   if [ "$verbose" = 1 ] ; then
63     echo "  adding '$CERT' as '$ALIAS'"
64   fi
65   if ! $KEYTOOL -noprompt -import -alias "$ALIAS" \
66                 -keystore $KEYSTORE -storepass 'changeit' \
67                 -file "$CERT" ; then
68         echo "W: $NAME certification could not be added"
69   fi 
70 }
71
72 cd $ETCCERTSDIR
73
74 for conf in $CERTSCONF $CERTSCONFD/*.conf; do
75   # skip inexistent files (matched by glob)
76   [ -f $conf ] || continue
77
78   sed -e '/^$/d' -e '/^#/d' -e '/^!/d' $conf | while read crt
79   do
80     if test -f "$CERTSDIR/$crt"
81     then
82       add "$CERTSDIR/$crt" "$crt"
83     elif test -f "$LOCALCERTSDIR/$crt"
84     then
85       add "$LOCALCERTSDIR/$crt" "$crt"
86     else
87       echo "W: $CERTSDIR/$crt or $LOCALCERTSDIR/$crt not found, but listed in $conf." >&2
88       continue
89     fi
90   done
91 done
92
93 echo "done."
94
95 # vim:set et sw=2:
96
This page took 0.064813 seconds and 4 git commands to generate.