20131N/A#!/bin/bash
20131N/A# usage:
20131N/A# update-sqlite-map-file new-version new-sqlite-lib old-sqlite-lib old-map-file
20131N/A
20131N/AUsage()
20131N/A{
20131N/A echo "Usage: $0 new-version new-sqlite-lib old-sqlite-lib old-map-file [new-map-file]"
20131N/A echo "If new-map-file is missing, default is new-map-file"
20131N/A}
20131N/A
20131N/Aif [ $# -ne 4 -a $# -ne 5 ]
20131N/Athen
20131N/A Usage
20131N/A exit 1
20131N/Afi
20131N/A
20131N/ANEW_VERSION=$1
20131N/ANEW_SQLITE_LIB=$2
20131N/ANEW_GLOBAL_SYMBOL_FILE="/tmp/new-sqlite-lib-global-symobl.$$"
20131N/A
20131N/AOLD_SQLITE_LIB=$3
20131N/AOLD_MAP_FILE=$4
20131N/AOLD_GLOBAL_SYMBOL_FILE="/tmp/old-sqlite-lib-global-symobl.$$"
20131N/AOLD_VERSION=""
20131N/A
20131N/Aif [ $# -eq 5 ]
20131N/Athen
20131N/A NEW_MAP_FILE=$5
20131N/Aelse
20131N/A NEW_MAP_FILE="new-map-file"
20131N/Afi
20131N/A
20131N/A# get parent interface
20131N/APARENT_INTERFACE=`grep "^sqlite_" $OLD_MAP_FILE | sed -n -s '1p' | cut -d ' ' -f 1`
20131N/A
20131N/Anm $NEW_SQLITE_LIB | grep GLOB | grep FUNC | grep -v 'UNDEF' | cut -d '|' -f 8 | uniq |sort > $NEW_GLOBAL_SYMBOL_FILE
20131N/A
20131N/Anm $OLD_SQLITE_LIB | grep GLOB | grep FUNC | grep -v 'UNDEF' | cut -d '|' -f 8 | uniq |sort > $OLD_GLOBAL_SYMBOL_FILE
20131N/A
20131N/Anew_global_symbols=`diff -u $OLD_GLOBAL_SYMBOL_FILE $NEW_GLOBAL_SYMBOL_FILE | grep '^+[a-zA-Z][a-zA-Z]*' | sed -e 's,^+,,'`
20131N/A
20131N/A# output License HEAD
20131N/Acat >$NEW_MAP_FILE <<END_OF_LICENSE
20131N/A#
20131N/A# CDDL HEADER START
20131N/A#
20131N/A# The contents of this file are subject to the terms of the
20131N/A# Common Development and Distribution License (the "License").
20131N/A# You may not use this file except in compliance with the License.
20131N/A#
20131N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
20131N/A# or http://www.opensolaris.org/os/licensing.
20131N/A# See the License for the specific language governing permissions
20131N/A# and limitations under the License.
20131N/A#
20131N/A# When distributing Covered Code, include this CDDL HEADER in each
20131N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20131N/A# If applicable, add the following below this CDDL HEADER, with the
20131N/A# fields enclosed by brackets "[]" replaced with your own identifying
20131N/A# information: Portions Copyright [yyyy] [name of copyright owner]
20131N/A#
20131N/A# CDDL HEADER END
20131N/A#
20131N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
20131N/A# Use is subject to license terms.
20131N/A#
20131N/A# ident "@(#)mapfile-libsqlite3 1.4 09/06/05 SMI"
20131N/A#
20131N/A# Defines the public interface to SQLite3
20131N/A#
20131N/AEND_OF_LICENSE
20131N/A
20131N/A# output new interface
20131N/Acat >>$NEW_MAP_FILE <<INTERFACE_END
20131N/Asqlite_$NEW_VERSION {
20131N/A global:
20131N/AINTERFACE_END
20131N/A
20131N/A# output new global symbols
20131N/Afor global_symbol in `echo $new_global_symbols`
20131N/Ado
20131N/A echo " $global_symbol;"
20131N/Adone >> $NEW_MAP_FILE
20131N/A
20131N/Aecho "} $PARENT_INTERFACE;\n" >> $NEW_MAP_FILE
20131N/A
20131N/A# output the old interfaces
20131N/A# ^sqlite_ : catch the first section
20131N/A# $ : match the last line in the file
20131N/A# p : print the line in the range
20131N/Acat $OLD_MAP_FILE | sed -n -s '/^sqlite_/,$p' >> $NEW_MAP_FILE
20131N/A
20131N/Arm -f $NEW_GLOBAL_SYMBOL_FILE $OLD_GLOBAL_SYMBOL_FILE_
20131N/Aexit 0