149e111a2Schristos#! /bin/sh 249e111a2Schristos# 3*5b28f239Srillig# $NetBSD: libmalloc2netbsd,v 1.2 2024/09/08 09:36:47 rillig Exp $ 449e111a2Schristos# 549e111a2Schristos# Copyright (c) 2016 The NetBSD Foundation, Inc. 649e111a2Schristos# All rights reserved. 749e111a2Schristos# 849e111a2Schristos# Redistribution and use in source and binary forms, with or without 949e111a2Schristos# modification, are permitted provided that the following conditions 1049e111a2Schristos# are met: 1149e111a2Schristos# 1. Redistributions of source code must retain the above copyright 1249e111a2Schristos# notice, this list of conditions and the following disclaimer. 1349e111a2Schristos# 2. Redistributions in binary form must reproduce the above copyright 1449e111a2Schristos# notice, this list of conditions and the following disclaimer in the 1549e111a2Schristos# documentation and/or other materials provided with the distribution. 1649e111a2Schristos# 1749e111a2Schristos# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1849e111a2Schristos# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1949e111a2Schristos# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2049e111a2Schristos# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2149e111a2Schristos# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2249e111a2Schristos# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2349e111a2Schristos# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2449e111a2Schristos# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2549e111a2Schristos# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2649e111a2Schristos# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2749e111a2Schristos# POSSIBILITY OF SUCH DAMAGE. 2849e111a2Schristos# 29*5b28f239Srillig# libmalloc2netbsd: convert a glibc source tree into a 3049e111a2Schristos# netbsd libmalloc source tree, 3149e111a2Schristos# 3249e111a2Schristos# Rough instructions for importing new libmalloc release: 3349e111a2Schristos# 3449e111a2Schristos# $ cd /some/where/temporary 3549e111a2Schristos# $ tar xpfz /malloc/release/tar/file 3649e111a2Schristos# $ sh /usr/src/external/gpl2/libmalloc/libmalloc2netbsd malloc `pwd` 3749e111a2Schristos# $ cd `pwd`/src/external/gpl2/libmalloc/dist 3849e111a2Schristos# $ cvs import -m "Import libmalloc YYYY-MM-DD" src/external/gpl2/libmalloc/dist FSF malloc-YYYY-MM-DD 3949e111a2Schristos# merge sources according to instructions given 4049e111a2Schristos# e.g. cvs -d cvs.netbsd.org:/cvsroot checkout -jlibmalloc-1-19 -jlibmalloc-1-19-1 src/gnu/dist/libmalloc 4149e111a2Schristos 4249e111a2Schristosif [ $# -ne 2 ]; then echo "libmalloc2netbsd src dest"; exit 1; fi 4349e111a2Schristos 4449e111a2Schristosr=$1 4549e111a2Schristosd=$2/src/external/gpl2/libmalloc/dist 4649e111a2Schristos 4749e111a2Schristoscase "$d" in 4849e111a2Schristos /*) 4949e111a2Schristos ;; 5049e111a2Schristos *) 5149e111a2Schristos d=`/bin/pwd`/$d 5249e111a2Schristos ;; 5349e111a2Schristosesac 5449e111a2Schristos 5549e111a2Schristoscase "$r" in 5649e111a2Schristos /*) 5749e111a2Schristos ;; 5849e111a2Schristos *) 5949e111a2Schristos r=`/bin/pwd`/$r 6049e111a2Schristos ;; 6149e111a2Schristosesac 6249e111a2Schristos 6349e111a2Schristosecho preparing directory $d 6449e111a2Schristosrm -rf $d 6549e111a2Schristosmkdir -p $d 6649e111a2Schristos 6749e111a2Schristos### Copy the files and directories 6849e111a2Schristosecho copying $r to $d 6949e111a2Schristoscd $r 7049e111a2Schristospax -rw * $d 7149e111a2Schristoschmod -x $d/* 7249e111a2Schristos 7349e111a2Schristos# cd to import directory 7449e111a2Schristoscd $d 7549e111a2Schristos 7649e111a2Schristos# 7749e111a2Schristos 7849e111a2Schristos### Remove the $'s around RCS tags 7949e111a2Schristoscleantags $d 8049e111a2Schristos 8149e111a2Schristos### Add our NetBSD RCS Id 8249e111a2Schristosfind $d -type f -name '*.[chly]' -print | while read c; do 8349e111a2Schristos sed 1q < $c | grep -q '\$NetBSD' || ( 8449e111a2Schristosecho "/* \$NetBSD\$ */" >/tmp/libmalloc3n$$ 8549e111a2Schristosecho "" >>/tmp/libmalloc3n$$ 8649e111a2Schristoscat $c >> /tmp/libmalloc3n$$ 8749e111a2Schristosmv /tmp/libmalloc3n$$ $c && echo added NetBSD RCS tag to $c 8849e111a2Schristos ) 8949e111a2Schristosdone 9049e111a2Schristos 9149e111a2Schristosfind $d -type f -name '*.cpp' -print | while read c; do 9249e111a2Schristos sed 1q < $c | grep -q '\$NetBSD' || ( 9349e111a2Schristosecho "/* \$NetBSD\$ */" >/tmp/libmalloc3n$$ 9449e111a2Schristosecho "" >>/tmp/libmalloc3n$$ 9549e111a2Schristoscat $c >> /tmp/libmalloc3n$$ 9649e111a2Schristosmv /tmp/libmalloc3n$$ $c && echo added NetBSD RCS tag to $c 9749e111a2Schristos ) 9849e111a2Schristosdone 9949e111a2Schristos 10049e111a2Schristosfind $d -type f -name '*.[0-9]' -print | while read m; do 10149e111a2Schristos sed 1q < $m | grep -q '\$NetBSD' || ( 10249e111a2Schristosecho ".\\\" \$NetBSD\$" >/tmp/libmalloc2m$$ 10349e111a2Schristosecho ".\\\"" >>/tmp/libmalloc2m$$ 10449e111a2Schristoscat $m >> /tmp/libmalloc2m$$ 10549e111a2Schristosmv /tmp/libmalloc2m$$ $m && echo added NetBSD RCS tag to $m 10649e111a2Schristos ) 10749e111a2Schristosdone 10849e111a2Schristos 10949e111a2Schristosfind $d -type f -name '*.texi' -print | while read t; do 11049e111a2Schristos sed "2 s/^/@c \$NetBSD\$\\ 11149e111a2Schristos/" < $t > /tmp/libmalloc4t$$ 11249e111a2Schristos mv /tmp/libmalloc4t$$ $t && echo added NetBSD RCS tag to $t 11349e111a2Schristosdone 11449e111a2Schristos 11549e111a2Schristosecho done 11649e111a2Schristos 11749e111a2Schristos### Clean up any CVS directories that might be around. 11849e111a2Schristosecho "cleaning up CVS residue." 11949e111a2Schristos( 12049e111a2Schristos cd $d 12149e111a2Schristos find . -type d -name "CVS" -print | xargs rm -r 12249e111a2Schristos) 12349e111a2Schristosecho done 12449e111a2Schristos 12549e111a2Schristos### Fixing file and directory permissions. 12649e111a2Schristosecho "Fixing file/directory permissions." 12749e111a2Schristos( 12849e111a2Schristos cd $d 12949e111a2Schristos find . -type f -print | xargs chmod u+rw,go+r 13049e111a2Schristos find . -type d -print | xargs chmod u+rwx,go+rx 13149e111a2Schristos) 13249e111a2Schristosecho done 13349e111a2Schristos 13449e111a2Schristosexit 0 135