#!/bin/sh
################################################################################
### Copyright (C) 2011-2015 VMware, Inc.  All rights reserved.
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of version 2 of the GNU General Public License as
### published by the Free Software Foundation.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
################################################################################

#
# instvmsg.sh - VMSG catalog install script.
#
# This script installs a set of VMSG catalogs into their correct location. It
# avoids having to copy and paste this logic into several makefiles, especially
# since non-GNU make does not support $(call ...).
#
# Arguments:
# prog   ($1): program name (name of target catalog file)
# src    ($2): directory where catalogs are stored in the source tree.
# dest   ($3): $(datadir)
# $@         : language codes
#

prog=$1
src=$2
dest=$3

if test -z $dest; then
   echo "Missing parameters." 1>&2
   exit 1
fi

for i in $src/*.vmsg; do
   ldest=`basename $i`
   ldest=${dest}/open-vm-tools/messages/`echo $ldest | cut -d . -f 1 -`
   if ! test -d $ldest; then
      mkdir -p $ldest
   fi
   cp -f $i ${ldest}/${prog}.vmsg || exit 1
done

