Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-misc/ca-certificates/files: ca-certificates-20110502-root.patch
Date: Wed, 07 Sep 2011 01:47:59
Message-Id: 20110907014748.4E22020051@flycatcher.gentoo.org
1 vapier 11/09/07 01:47:48
2
3 Added: ca-certificates-20110502-root.patch
4 Log:
5 Generate relative symlinks to certs when using --root so c_rehash works properly.
6
7 (Portage version: 2.2.0_alpha51/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 app-misc/ca-certificates/files/ca-certificates-20110502-root.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-misc/ca-certificates/files/ca-certificates-20110502-root.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-misc/ca-certificates/files/ca-certificates-20110502-root.patch?rev=1.1&content-type=text/plain
14
15 Index: ca-certificates-20110502-root.patch
16 ===================================================================
17 --- a/usr/sbin/update-ca-certificates
18 +++ b/usr/sbin/update-ca-certificates
19 @@ -23,6 +23,8 @@
20
21 verbose=0
22 fresh=0
23 +ROOT=""
24 +RELPATH=""
25 while [ $# -gt 0 ];
26 do
27 case $1 in
28 @@ -30,6 +31,11 @@
29 verbose=1;;
30 --fresh|-f)
31 fresh=1;;
32 + --root|-r)
33 + ROOT=$(readlink -f "$2")
34 + # needed as c_rehash wants to read the files directly
35 + RELPATH="../../.."
36 + shift;;
37 --help|-h|*)
38 - echo "$0: [--verbose] [--fresh]"
39 + echo "$0: [--verbose] [--fresh] [--root <dir>]"
40 exit;;
41 @@ -37,11 +41,11 @@
42 shift
43 done
44
45 -CERTSCONF=/etc/ca-certificates.conf
46 -CERTSDIR=/usr/share/ca-certificates
47 -LOCALCERTSDIR=/usr/local/share/ca-certificates
48 +CERTSCONF="$ROOT/etc/ca-certificates.conf"
49 +CERTSDIR="$ROOT/usr/share/ca-certificates"
50 +LOCALCERTSDIR="$ROOT/usr/local/share/ca-certificates"
51 CERTBUNDLE=ca-certificates.crt
52 -ETCCERTSDIR=/etc/ssl/certs
53 +ETCCERTSDIR="$ROOT/etc/ssl/certs"
54
55 cleanup() {
56 rm -f "$TEMPBUNDLE"
57 @@ -66,7 +70,7 @@
58 -e 's/,/_/g').pem"
59 if ! test -e "$PEM" || [ "$(readlink "$PEM")" != "$CERT" ]
60 then
61 - ln -sf "$CERT" "$PEM"
62 + ln -sf "${RELPATH}${CERT#$ROOT}" "$PEM"
63 echo +$PEM >> "$ADDED"
64 fi
65 cat "$CERT" >> "$TEMPBUNDLE"
66 @@ -78,22 +82,22 @@
67 if test -L "$PEM"
68 then
69 rm -f "$PEM"
70 - echo -$PEM >> "$REMOVED"
71 + echo "-$PEM" >> "$REMOVED"
72 fi
73 }
74
75 -cd $ETCCERTSDIR
76 +cd "$ETCCERTSDIR"
77 if [ "$fresh" = 1 ]; then
78 echo -n "Clearing symlinks in $ETCCERTSDIR..."
79 find . -type l -print | while read symlink
80 do
81 - case $(readlink $symlink) in
82 - $CERTSDIR*) rm -f $symlink;;
83 + case $(readlink "$symlink") in
84 + "$CERTSDIR"*) rm -f "$symlink";;
85 esac
86 done
87 find . -type l -print | while read symlink
88 do
89 - test -f $symlink || rm -f $symlink
90 + test -f "$symlink" || rm -f "$symlink"
91 done
92 echo "done."
93 fi
94 @@ -102,12 +106,12 @@
95
96 # Handle certificates that should be removed. This is an explicit act
97 # by prefixing lines in the configuration files with exclamation marks (!).
98 -sed -n -e '/^$/d' -e 's/^!//p' $CERTSCONF | while read crt
99 +sed -n -e '/^$/d' -e 's/^!//p' "$CERTSCONF" | while read crt
100 do
101 remove "$CERTSDIR/$crt"
102 done
103
104 -sed -e '/^$/d' -e '/^#/d' -e '/^!/d' $CERTSCONF | while read crt
105 +sed -e '/^$/d' -e '/^#/d' -e '/^!/d' "$CERTSCONF" | while read crt
106 do
107 if ! test -f "$CERTSDIR/$crt"
108 then
109 @@ -146,14 +150,14 @@
110
111 echo "$ADDED_CNT added, $REMOVED_CNT removed; done."
112
113 -HOOKSDIR=/etc/ca-certificates/update.d
114 +HOOKSDIR="$ROOT/etc/ca-certificates/update.d"
115 echo -n "Running hooks in $HOOKSDIR...."
116 VERBOSE_ARG=
117 [ "$verbose" = 0 ] || VERBOSE_ARG=--verbose
118 -eval run-parts $VERBOSE_ARG --test -- $HOOKSDIR | while read hook
119 +eval run-parts $VERBOSE_ARG --test -- \""$HOOKSDIR"\" | while read hook
120 do
121 ( cat $ADDED
122 - cat $REMOVED ) | $hook || echo E: $hook exited with code $?.
123 + cat $REMOVED ) | "$hook" || echo E: "$hook" exited with code $?.
124 done
125 echo "done."