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