heimdal2netbsd revision 1.1 1 1.1 elric #! /bin/sh
2 1.1 elric #
3 1.1 elric # $NetBSD: heimdal2netbsd,v 1.1 2011/04/13 19:04:40 elric Exp $
4 1.1 elric #
5 1.1 elric # Copyright (c) 2011 The NetBSD Foundation, Inc.
6 1.1 elric # All rights reserved.
7 1.1 elric #
8 1.1 elric # Redistribution and use in source and binary forms, with or without
9 1.1 elric # modification, are permitted provided that the following conditions
10 1.1 elric # are met:
11 1.1 elric # 1. Redistributions of source code must retain the above copyright
12 1.1 elric # notice, this list of conditions and the following disclaimer.
13 1.1 elric # 2. Redistributions in binary form must reproduce the above copyright
14 1.1 elric # notice, this list of conditions and the following disclaimer in the
15 1.1 elric # documentation and/or other materials provided with the distribution.
16 1.1 elric #
17 1.1 elric # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.1 elric # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.1 elric # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.1 elric # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.1 elric # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.1 elric # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.1 elric # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.1 elric # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.1 elric # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.1 elric # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.1 elric # POSSIBILITY OF SUCH DAMAGE.
28 1.1 elric #
29 1.1 elric # heimdal2netbsd: convert a heimdal source tree into a
30 1.1 elric # netbsd amd source tree, under src/crypto/external/bsd/heimdal/dist
31 1.1 elric # based on bind2netbsd by Bernd Ernesti and changes by Simon Burge
32 1.1 elric #
33 1.1 elric # Rough instructions for importing new heimdal release from their git
34 1.1 elric # repository:
35 1.1 elric #
36 1.1 elric # $ export SRCDIR=/usr/src
37 1.1 elric # $ export HEIMDAL_SRCDIR=src/crypto/external/bsd/heimdal
38 1.1 elric # $ cd /some/where/temporary
39 1.1 elric # $ git clone git://svn.h5l.org/heimdal.git
40 1.1 elric # $ sh $SRCDIR/$HEIMDAL_SRCDIR/heimdal2netbsd heimdal `pwd`
41 1.1 elric # $ cd $HEIMDAL_SRCDIR/dist
42 1.1 elric # $ cvs -d ... import $HEIMDAL_SRCDIR/dist HEIMDAL head-20110317
43 1.1 elric # $ cd /some/where/temporary/heimdal
44 1.1 elric # $ autoreconf -f -i
45 1.1 elric # $ ./configure
46 1.1 elric # $ make
47 1.1 elric # >>> merge newly generated config.h
48 1.1 elric # >>> with $HEIMDAL_SRCDIR/include/config.h
49 1.1 elric # >>> and check out diffs in generated headers
50 1.1 elric # >>> and C files.
51 1.1 elric # $ cd ..
52 1.1 elric # $ rm -r src heimdal
53 1.1 elric # $ cd $SRCDIR/$HEIMDAL_SRCDIR
54 1.1 elric # $ cvs commit -m "Updated generated files for Heimdal head-20110317"
55 1.1 elric #
56 1.1 elric # - check makefiles to see if any extra sources have been added.
57 1.1 elric # - update distrib/sets if necessary.
58 1.1 elric
59 1.1 elric if [ $# -ne 2 ]; then echo "heimdal2netbsd src dest"; exit 1; fi
60 1.1 elric
61 1.1 elric r=$1
62 1.1 elric d=$2/src/crypto/external/bsd/heimdal/dist
63 1.1 elric
64 1.1 elric case "$d" in
65 1.1 elric /*)
66 1.1 elric ;;
67 1.1 elric *)
68 1.1 elric d=`/bin/pwd`/$d
69 1.1 elric ;;
70 1.1 elric esac
71 1.1 elric
72 1.1 elric case "$r" in
73 1.1 elric /*)
74 1.1 elric ;;
75 1.1 elric *)
76 1.1 elric r=`/bin/pwd`/$r
77 1.1 elric ;;
78 1.1 elric esac
79 1.1 elric
80 1.1 elric echo preparing directory $d
81 1.1 elric rm -rf $d
82 1.1 elric mkdir -p $d
83 1.1 elric
84 1.1 elric ### Copy the files and directories
85 1.1 elric echo copying $r to $d
86 1.1 elric cd $r
87 1.1 elric pax -rw * $d
88 1.1 elric
89 1.1 elric ### Remove unneeded files
90 1.1 elric #echo removing unneeded directories and files
91 1.1 elric #find $d/po -name '*[0-9] XXX:
92 1.1 elric find $d -name '*.cat[0-9]' | xargs rm -f && echo removed catman pages
93 1.1 elric find $d -name '*.info' | xargs rm -f && echo removed info pages
94 1.1 elric rm -rf $d/appl && echo removed appl
95 1.1 elric rm -rf $d/lib/libedit && echo removed lib/libedit
96 1.1 elric rm -rf $d/lib/sqlite && echo removed lib/sqlite
97 1.1 elric rm -rf $d/doc/standardisation && echo removed doc/standardisation
98 1.1 elric
99 1.1 elric # Fix man pages
100 1.1 elric find $d -type f -name '*.[1358]' -print | while read f; do
101 1.1 elric sed \
102 1.1 elric -e 's,\.Os HEIMDAL,.Os,' \
103 1.1 elric -e 's,\.Pa krb5.h,.Pa krb5/krb5.h,' \
104 1.1 elric -e 's,\.In krb5.h,.In krb5/krb5.h,' \
105 1.1 elric -e 's,\.Pa gssapi.h,.Pa gssapi/gssapi.h,' \
106 1.1 elric -e 's,\.In gssapi.h,.In gssapi/gssapi.h,' \
107 1.1 elric -e 's,#include <krb5.h>,#include <krb5/krb5.h>,' \
108 1.1 elric < $f > /tmp/heimdal1f$$ && mv /tmp/heimdal1f$$ $f && \
109 1.1 elric echo fixing man page $f
110 1.1 elric done
111 1.1 elric
112 1.1 elric # Fix include usage
113 1.1 elric
114 1.1 elric KRB5_INCRE="asn1-common|asn1_err"
115 1.1 elric KRB5_INCRE="$KRB5_INCRE|base64"
116 1.1 elric KRB5_INCRE="$KRB5_INCRE|cms_asn1"
117 1.1 elric KRB5_INCRE="$KRB5_INCRE|com_err"
118 1.1 elric KRB5_INCRE="$KRB5_INCRE|com_right"
119 1.1 elric KRB5_INCRE="$KRB5_INCRE|crmf_asn1"
120 1.1 elric KRB5_INCRE="$KRB5_INCRE|der|der-protos"
121 1.1 elric KRB5_INCRE="$KRB5_INCRE|digest_asn1"
122 1.1 elric KRB5_INCRE="$KRB5_INCRE|getarg"
123 1.1 elric KRB5_INCRE="$KRB5_INCRE|hdb|hdb_err|hdb-protos|hdb_asn1"
124 1.1 elric KRB5_INCRE="$KRB5_INCRE|heim_asn1|heim_err"
125 1.1 elric KRB5_INCRE="$KRB5_INCRE|heimbase"
126 1.1 elric KRB5_INCRE="$KRB5_INCRE|heimntlm|heimntlm-protos"
127 1.1 elric KRB5_INCRE="$KRB5_INCRE|hex"
128 1.1 elric KRB5_INCRE="$KRB5_INCRE|hx509|hx509-protos|hx509_err"
129 1.1 elric KRB5_INCRE="$KRB5_INCRE|k524_err"
130 1.1 elric KRB5_INCRE="$KRB5_INCRE|kafs"
131 1.1 elric KRB5_INCRE="$KRB5_INCRE|kcm|kcm-protos"
132 1.1 elric KRB5_INCRE="$KRB5_INCRE|kdc|kdc-protos"
133 1.1 elric KRB5_INCRE="$KRB5_INCRE|krb5|krb5-private|krb5-protos|krb5-types"
134 1.1 elric KRB5_INCRE="$KRB5_INCRE|krb5_asn1|krb5_err|krb5_ccapi"
135 1.1 elric KRB5_INCRE="$KRB5_INCRE|krb5-v4compat"
136 1.1 elric KRB5_INCRE="$KRB5_INCRE|krb_err"
137 1.1 elric KRB5_INCRE="$KRB5_INCRE|kx509_asn1"
138 1.1 elric KRB5_INCRE="$KRB5_INCRE|ntlm_err"
139 1.1 elric KRB5_INCRE="$KRB5_INCRE|ocsp_asn1"
140 1.1 elric KRB5_INCRE="$KRB5_INCRE|parse_bytes|parse_time|parse_units"
141 1.1 elric KRB5_INCRE="$KRB5_INCRE|pkcs8_asn1|pkcs9_asn1|pkcs10_asn1|pkcs12_asn1"
142 1.1 elric KRB5_INCRE="$KRB5_INCRE|pkinit_asn1"
143 1.1 elric KRB5_INCRE="$KRB5_INCRE|resolve"
144 1.1 elric KRB5_INCRE="$KRB5_INCRE|rfc2459_asn1"
145 1.1 elric KRB5_INCRE="$KRB5_INCRE|roken|roken-common"
146 1.1 elric KRB5_INCRE="$KRB5_INCRE|rtbl"
147 1.1 elric KRB5_INCRE="$KRB5_INCRE|sl|ss"
148 1.1 elric KRB5_INCRE="$KRB5_INCRE|wind|wind_err"
149 1.1 elric KRB5_INCRE="$KRB5_INCRE|xdbm"
150 1.1 elric
151 1.1 elric GSS_INCRE="gssapi|gssapi_krb5|gssapi_spnego|gssapi_ntlm|gssapi_oid"
152 1.1 elric
153 1.1 elric KADM5_INCRE="admin|kadm5-protos|kadm5-pwcheck|kadm5_err"
154 1.1 elric
155 1.1 elric find $d -type f -name '*.[ch]' -a ! -name compile_et.? -print | while read f; do
156 1.1 elric sed -E \
157 1.1 elric -e "s,#include <($GSS_INCRE)\\.h>,#include <gssapi/\\1.h>," \
158 1.1 elric -e "s,#include \"($KRB5_INCRE)\\.h\",#include <krb5/\\1.h>," \
159 1.1 elric -e "s,#include <($KRB5_INCRE)\\.h>,#include <krb5/\\1.h>," \
160 1.1 elric -e "s,#include <($KADM5_INCRE)\\.h>,#include <kadm5/\\1.h>," \
161 1.1 elric < $f > /tmp/heimdal1f$$ && mv /tmp/heimdal1f$$ $f && \
162 1.1 elric echo fixing include paths in $f
163 1.1 elric done
164 1.1 elric
165 1.1 elric #
166 1.1 elric # In these files, we want only to fix the paths in the generated files, not
167 1.1 elric # in the file itself. To do this, we search for "#include meaning that
168 1.1 elric # it can't be on the left column.
169 1.1 elric
170 1.1 elric for f in $d/lib/sl/slc-gram.y $d/lib/com_err/compile_et.c; do
171 1.1 elric sed -E -e "s,(.#include <)($KRB5_INCRE)\\.h>,\\1krb5/\\2.h>," \
172 1.1 elric < $f > /tmp/heimdal1f$$ && mv /tmp/heimdal1f$$ $f && \
173 1.1 elric echo fixing include paths in $f
174 1.1 elric done
175 1.1 elric
176 1.1 elric # Freeze imported NetBSD RCSID's.
177 1.1 elric find $d -type f -print | xargs egrep -l '\$NetBSD:' | while read f; do
178 1.1 elric sed \
179 1.1 elric -e 's/\$\(NetBSD.*\) \$/\1/' \
180 1.1 elric < $f > /tmp/heimdal1f$$ && mv /tmp/heimdal1f$$ $f && \
181 1.1 elric echo froze NetBSD RCSID for $f
182 1.1 elric done
183 1.1 elric
184 1.1 elric # Convert unexpanded RCSID's to the NetBSD way.
185 1.1 elric find $d -type f -print | xargs egrep -l 'RCSID\("\$Id\$"\)' | while read f; do
186 1.1 elric sed -e 's/RCSID("\$\Id\$")/__RCSID("\$NetBSD\$")/' \
187 1.1 elric < $f > /tmp/heimdal1f$$ && mv /tmp/heimdal1f$$ $f && \
188 1.1 elric echo converted RCSID to NetBSD for $f
189 1.1 elric done
190 1.1 elric
191 1.1 elric ### Remove the $'s around RCS tags
192 1.1 elric find $d -type f -print | xargs egrep -l \
193 1.1 elric '\$(Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State)' |
194 1.1 elric while read f; do
195 1.1 elric sed \
196 1.1 elric -e 's/\$\(Author.*\) \$/\1/' \
197 1.1 elric -e 's/\$\(Date.*\) \$/\1/' \
198 1.1 elric -e 's/\$\(Header.*\) \$/\1/' \
199 1.1 elric -e 's/\$\(Id.*\) \$/\1/' \
200 1.1 elric -e 's/\$\(Locker.*\) \$/\1/' \
201 1.1 elric -e 's/\$\(Log.*\) \$/\1/' \
202 1.1 elric -e 's/\$\(Name.*\) \$/\1/' \
203 1.1 elric -e 's/\$\(RCSfile.*\) \$/\1/' \
204 1.1 elric -e 's/\$\(Revision.*\) \$/\1/' \
205 1.1 elric -e 's/\$\(Source.*\) \$/\1/' \
206 1.1 elric -e 's/\$\(State.*\) \$/\1/' \
207 1.1 elric < $f > /tmp/heimdal1f$$ && mv /tmp/heimdal1f$$ $f && \
208 1.1 elric echo removed \$RCS tag from $f
209 1.1 elric done
210 1.1 elric
211 1.1 elric ### Add our NetBSD RCS Id
212 1.1 elric find $d -type f -name '*.[chly]' -print | while read c; do
213 1.1 elric sed 1q < $c | grep -q '\$NetBSD' || (
214 1.1 elric echo "/* \$NetBSD\$ */" >/tmp/amd3n$$
215 1.1 elric echo "" >>/tmp/amd3n$$
216 1.1 elric cat $c >> /tmp/amd3n$$
217 1.1 elric mv /tmp/amd3n$$ $c && echo added NetBSD RCS tag to $c
218 1.1 elric )
219 1.1 elric done
220 1.1 elric
221 1.1 elric find $d -type f -name '*.[0-9]' -print | while read m; do
222 1.1 elric sed 1q < $m | grep -q '\$NetBSD' || (
223 1.1 elric echo ".\\\" \$NetBSD\$" >/tmp/amd2m$$
224 1.1 elric echo ".\\\"" >>/tmp/amd2m$$
225 1.1 elric cat $m >> /tmp/amd2m$$
226 1.1 elric mv /tmp/amd2m$$ $m && echo added NetBSD RCS tag to $m
227 1.1 elric )
228 1.1 elric done
229 1.1 elric
230 1.1 elric find $d -type f -name '*.texi' -print | while read t; do
231 1.1 elric sed "2 s/^/@c \$NetBSD\$\\
232 1.1 elric /" < $t > /tmp/amd4t$$
233 1.1 elric mv /tmp/amd4t$$ $t && echo added NetBSD RCS tag to $t
234 1.1 elric done
235 1.1 elric
236 1.1 elric echo done
237 1.1 elric
238 1.1 elric ### Clean up any CVS directories that might be around.
239 1.1 elric echo "cleaning up CVS residue."
240 1.1 elric (
241 1.1 elric cd $d
242 1.1 elric find . -type d -name "CVS" -print | xargs rm -r
243 1.1 elric )
244 1.1 elric echo done
245 1.1 elric
246 1.1 elric echo "cleaning up git residue."
247 1.1 elric rm -rf $d/.git
248 1.1 elric
249 1.1 elric ### Fixing file and directory permissions.
250 1.1 elric echo "Fixing file/directory permissions."
251 1.1 elric (
252 1.1 elric cd $d
253 1.1 elric find . -type f -print | xargs chmod u+rw,go+r
254 1.1 elric find . -type d -print | xargs chmod u+rwx,go+rx
255 1.1 elric )
256 1.1 elric echo done
257 1.1 elric
258 1.1 elric exit 0
259