2015-10-23 11:10:47 -07:00
#!/bin/bash
2015-11-16 11:21:57 -08:00
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
2015-10-23 11:10:47 -07:00
SOURCE = " ${ BASH_SOURCE [0] } "
while [ -h " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
SOURCE = " $( readlink " $SOURCE " ) "
2015-12-28 11:47:21 -08:00
[ [ " $SOURCE " != /* ] ] && SOURCE = " $DIR / $SOURCE " # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
2015-10-23 11:10:47 -07:00
done
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
2016-03-07 12:20:50 -08:00
help( ) {
echo " Usage: $0 [--version <pkg version>] [--input <input directory>] [--output <output pkg>] [--help] "
echo ""
echo "Options:"
echo " --version <pkg version> Specify a version for the package."
echo " --input <input directory> Package the entire contents of the directory tree."
echo " --output <output pkg> The path to which the package will be written."
exit 1
}
while [ [ $# > 0 ] ] ; do
lowerI = " $( echo $1 | awk '{print tolower($0)}' ) "
case $lowerI in
-v| --version)
DOTNET_CLI_VERSION = $2
shift
; ;
-o| --output)
OUTPUT_PKG = $2
shift
; ;
-i| --input)
INPUT_DIR = $2
shift
; ;
--help)
help
; ;
*)
break
; ;
esac
shift
done
2015-10-23 11:10:47 -07:00
2016-01-12 15:27:02 -08:00
if [ -z " $DOTNET_CLI_VERSION " ] ; then
2016-03-07 12:20:50 -08:00
echo "Provide a version number. Missing option '--version'" && help
fi
if [ -z " $OUTPUT_PKG " ] ; then
echo "Provide an output pkg. Missing option '--output'" && help
2015-10-23 11:10:47 -07:00
fi
2016-03-07 12:20:50 -08:00
if [ -z " $INPUT_DIR " ] ; then
echo "Provide an inout directory. Missing option '--input'" && help
fi
2015-10-23 11:10:47 -07:00
2016-03-07 12:20:50 -08:00
if [ ! -d " $INPUT_DIR " ] ; then
echo " Missing input directory - $INPUT_DIR " 1>& 2
2015-10-23 11:10:47 -07:00
exit 1
fi
2016-03-07 12:20:50 -08:00
PACKAGE_DIR = $( dirname " ${ OUTPUT_PKG } " )
2015-10-23 11:10:47 -07:00
[ -d " $PACKAGE_DIR " ] || mkdir -p $PACKAGE_DIR
2016-03-07 12:20:50 -08:00
PACKAGE_ID = $( basename " ${ OUTPUT_PKG } " )
#chmod -R 755 $INPUT_DIR
pkgbuild --root $INPUT_DIR \
2016-01-12 15:27:02 -08:00
--version $DOTNET_CLI_VERSION \
2015-10-23 11:10:47 -07:00
--scripts $DIR /scripts \
--identifier com.microsoft.dotnet.cli.pkg.dotnet-osx-x64 \
2015-12-15 14:08:00 -08:00
--install-location /usr/local/share/dotnet \
2016-02-29 06:57:47 -08:00
$DIR /$PACKAGE_ID
2015-10-23 11:10:47 -07:00
2016-01-12 15:27:02 -08:00
cat $DIR /Distribution-Template | sed " /{VERSION}/s// $DOTNET_CLI_VERSION /g " > $DIR /Dist
2015-10-23 11:10:47 -07:00
2016-03-07 12:20:50 -08:00
productbuild --version $DOTNET_CLI_VERSION --identifier com.microsoft.dotnet.cli --package-path $DIR --resources $DIR /resources --distribution $DIR /Dist $OUTPUT_PKG
2015-10-23 11:10:47 -07:00
#Clean temp files
2016-02-29 06:57:47 -08:00
rm $DIR /$PACKAGE_ID
2015-11-06 12:48:34 -08:00
rm $DIR /Dist