#!/bin/sh
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the mac_os make-diskimage script.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#  John Wolfe <wolfe@lobo.us>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

# Create a CAB installation of a folder
#
# Usage: make-cab-package <vs_install_dir>
#                         <moz_src_dir>
#                         <moz_pkg_dir>
#                         <moz_pkg_cab_inf>
#                         <moz_app_name>
#                         <package_name>


VS_INSTALL_DIR=$1
MOZ_SRC_DIR=$2
MOZ_PKG_DIR=$3
MOZ_PKG_CAB_INF=$4
MOZ_APP_NAME=$5
PACKAGE_NAME=$6

echo `dirname $0`/make-cab-package --vs_install_dir "$VS_INSTALL_DIR" --moz_src_dir "$MOZ_SRC_DIR" --moz_pkg_dir "$MOZ_PKG_DIR" --moz_pkg_cab_inf "$MOZ_PKG_CAB_INF" --moz_app_name "$MOZ_APP_NAME" --package "$PACKAGE_NAME"

echo mkdir -p wince
mkdir -p wince

echo cp "$MOZ_PKG_CAB_INF" wince
cp "$MOZ_PKG_CAB_INF" wince

echo cp $MOZ_PKG_DIR/xulrunner/mozce_shunt.dll                                     $MOZ_PKG_DIR/xulrunner/mozce_shunt_2.dll
cp $MOZ_PKG_DIR/xulrunner/mozce_shunt.dll                                     $MOZ_PKG_DIR/xulrunner/mozce_shunt_2.dll

echo cp $MOZ_PKG_DIR/xulrunner/chrome/classic.jar                                  $MOZ_PKG_DIR/xulrunner/chrome/classic_2.jar
cp $MOZ_PKG_DIR/xulrunner/chrome/classic.jar                                  $MOZ_PKG_DIR/xulrunner/chrome/classic_2.jar

echo cp $MOZ_PKG_DIR/xulrunner/chrome/classic.manifest                             $MOZ_PKG_DIR/xulrunner/chrome/classic_2.manifest
cp $MOZ_PKG_DIR/xulrunner/chrome/classic.manifest                             $MOZ_PKG_DIR/xulrunner/chrome/classic_2.manifest

echo cp $MOZ_PKG_DIR/xulrunner/chrome/en-US.jar                                    $MOZ_PKG_DIR/xulrunner/chrome/en-US_2.jar
cp $MOZ_PKG_DIR/xulrunner/chrome/en-US.jar                                    $MOZ_PKG_DIR/xulrunner/chrome/en-US_2.jar

echo cp $MOZ_PKG_DIR/xulrunner/chrome/en-US.manifest                               $MOZ_PKG_DIR/xulrunner/chrome/en-US_2.manifest
cp $MOZ_PKG_DIR/xulrunner/chrome/en-US.manifest                               $MOZ_PKG_DIR/xulrunner/chrome/en-US_2.manifest

echo cp $MOZ_PKG_DIR/xulrunner/defaults/profile/US/localstore.rdf                  $MOZ_PKG_DIR/xulrunner/defaults/profile/US/localstore_2.rdf
cp $MOZ_PKG_DIR/xulrunner/defaults/profile/US/localstore.rdf                  $MOZ_PKG_DIR/xulrunner/defaults/profile/US/localstore_2.rdf

echo cp $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userChrome-example.css   $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userChrome-example_2.css
cp $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userChrome-example.css   $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userChrome-example_2.css

echo cp $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userContent-example.css  $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userContent-example_2.css
cp $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userContent-example.css  $MOZ_PKG_DIR/xulrunner/defaults/profile/US/chrome/userContent-example_2.css

echo "$VS_INSTALL_DIR/SmartDevices/SDK/SDKTools/cabwiz.exe" wince/$MOZ_APP_NAME.inf -compress
python -c "import os; os.system('\"$VS_INSTALL_DIR/SmartDevices/SDK/SDKTools/cabwiz.exe\" wince/$MOZ_APP_NAME.inf /compress')"

echo mv wince/$MOZ_APP_NAME.CAB $PACKAGE_NAME
mv wince/$MOZ_APP_NAME.CAB $PACKAGE_NAME

exit $?
