2013-06-24 13:41:48 +02:00
#!/bin/bash
2023-08-23 23:17:36 +02:00
# Copyright (c) Cloud Software Group, Inc.
2017-12-07 15:39:32 +01:00
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2013-06-24 13:41:48 +02:00
# SUCH DAMAGE.
2020-01-13 13:37:35 +01:00
# Script parameters:
# 1 Global build number
2016-12-14 11:05:35 +01:00
2020-01-13 13:37:35 +01:00
set -exu
2013-06-24 13:41:48 +02:00
UNZIP = "unzip -q -o"
mkdir_clean( )
{
rm -rf $1 && mkdir -p $1
}
2017-01-18 14:33:36 +01:00
REPO = " $( cd -P " $( dirname " ${ BASH_SOURCE [0] } " ) /.. " && pwd ) "
2019-12-26 18:23:32 +01:00
SCRATCH_DIR = ${ REPO } /_scratch
OUTPUT_DIR = ${ REPO } /_output
2020-01-13 13:37:35 +01:00
#build
2023-08-24 00:40:40 +02:00
MSBUILD = "/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/MSBuild.exe"
SWITCHES = "/m /verbosity:minimal /p:Configuration=Release /p:TargetFrameworkVersion=v4.8 /p:VisualStudioVersion=17.0"
2020-01-13 13:37:35 +01:00
2021-02-01 15:49:42 +01:00
if [ ! -f " ${ MSBUILD } " ] ; then
echo "DEBUG: Did not find VS Community edition. Trying Professional"
2023-08-24 00:40:40 +02:00
MSBUILD = "/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/MSBuild.exe"
2021-02-01 15:49:42 +01:00
fi
2022-03-16 15:25:08 +01:00
if [ ! -f " ${ MSBUILD } " ] ; then
echo "DEBUG: Did not find VS Professional edition. Trying Enterprise"
2023-08-24 00:40:40 +02:00
MSBUILD = "/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe"
2022-03-16 15:25:08 +01:00
fi
2019-12-26 18:23:32 +01:00
mkdir_clean ${ SCRATCH_DIR }
mkdir_clean ${ OUTPUT_DIR }
2016-12-14 11:05:35 +01:00
2016-01-12 07:59:05 +01:00
source ${ REPO } /Branding/branding.sh
2020-02-22 16:19:13 +01:00
source ${ REPO } /scripts/re-branding.sh $1
2013-06-24 13:41:48 +02:00
2020-01-13 13:37:35 +01:00
#packages sources
2020-02-25 13:41:19 +01:00
mkdir_clean ${ SCRATCH_DIR } /SOURCES
2020-02-04 10:12:25 +01:00
cd ${ REPO }
gitCommit = ` git rev-parse HEAD`
2020-02-25 13:41:19 +01:00
git archive --format= zip -o "_scratch/SOURCES/xenadmin-sources.zip" ${ gitCommit }
cp ${ REPO } /packages/dotnet-packages-sources.zip ${ SCRATCH_DIR } /SOURCES
2021-02-17 15:51:13 +01:00
cd ${ SCRATCH_DIR } /SOURCES && zip ${ OUTPUT_DIR } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } -source.zip dotnet-packages-sources.zip xenadmin-sources.zip
2013-06-24 13:41:48 +02:00
2019-12-26 18:23:32 +01:00
${ UNZIP } -d ${ SCRATCH_DIR } ${ REPO } /packages/XenCenterOVF.zip
2019-12-17 15:23:26 +01:00
cd ${ REPO } && " ${ MSBUILD } " ${ SWITCHES } XenAdmin.sln
2013-06-24 13:41:48 +02:00
2020-01-13 13:37:35 +01:00
#sign files only if all parameters are set and non-empty
2020-06-16 01:24:52 +02:00
SIGN_BAT = " ${ REPO } /scripts/sign.bat "
2020-01-13 13:37:35 +01:00
2020-06-16 01:24:52 +02:00
if [ -f " ${ SIGN_BAT } " ] ; then
2022-11-08 12:18:35 +01:00
for file in ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .exe CommandLib.dll MSTSCLib.dll CoreUtilsLib.dll XenModel.dll XenOvf.dll
2020-01-13 13:37:35 +01:00
do
2021-04-12 14:12:33 +02:00
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } ${ file } " ${ BRANDING_BRAND_CONSOLE } "
2020-01-13 13:37:35 +01:00
done
2021-04-12 14:12:33 +02:00
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .exe " ${ BRANDING_BRAND_CONSOLE } "
cd ${ REPO } /xe/bin/Release && ${ SIGN_BAT } xe.exe " ${ BRANDING_BRAND_CONSOLE } "
2020-01-13 13:37:35 +01:00
2020-06-07 03:34:06 +02:00
for file in Microsoft.ReportViewer.Common.dll Microsoft.ReportViewer.ProcessingObjectModel.dll Microsoft.ReportViewer.WinForms.dll Microsoft.ReportViewer.Common.resources.dll Microsoft.ReportViewer.WinForms.resources.dll
2020-01-13 13:37:35 +01:00
do
2021-04-12 14:12:33 +02:00
cd ${ REPO } /XenAdmin/ReportViewer && ${ SIGN_BAT } ${ file } " ${ BRANDING_BRAND_CONSOLE } "
2020-01-13 13:37:35 +01:00
done
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } CookComputing.XmlRpcV2.dll "XML-RPC.NET"
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } Newtonsoft.Json.CH.dll "JSON.NET"
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } log4net.dll "Log4Net"
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } ICSharpCode.SharpZipLib.dll "SharpZipLib"
cd ${ REPO } /XenAdmin/bin/Release && ${ SIGN_BAT } DiscUtils.dll "DiscUtils"
2020-06-16 01:24:52 +02:00
else
echo "Sign script does not exist; skip signing binaries"
2020-01-13 13:37:35 +01:00
fi
#prepare wix
WIX_BIN = ${ SCRATCH_DIR } /wixbin
WIX_SRC = ${ SCRATCH_DIR } /wixsrc
WIX = ${ SCRATCH_DIR } /WixInstaller
CANDLE = ${ WIX_BIN } /candle.exe
LIT = ${ WIX_BIN } /lit.exe
LIGHT = ${ WIX_BIN } /light.exe
mkdir_clean ${ WIX_BIN } && ${ UNZIP } ${ REPO } /packages/wix311-binaries.zip -d ${ WIX_BIN }
mkdir_clean ${ WIX_SRC } && ${ UNZIP } ${ REPO } /packages/wix311-debug.zip -d ${ WIX_SRC }
cp -r ${ REPO } /WixInstaller ${ SCRATCH_DIR } /
cp -r ${ WIX_SRC } /src/ext/UIExtension/wixlib ${ WIX } /
cd ${ WIX } /wixlib && cp CustomizeDlg.wxs CustomizeStdDlg.wxs
cd ${ WIX } /wixlib && patch -p1 --binary < ${ WIX } /wix_src.patch
touch ${ WIX } /PrintEula.dll
#compile_wix
chmod -R u+rx ${ WIX_BIN }
cd ${ WIX } && mkdir -p obj lib
RepoRoot = $( cygpath -w ${ REPO } ) ${ CANDLE } -out obj/ @candleList.txt
${ LIT } -out lib/WixUI_InstallDir.wixlib @litList.txt
locale_id( ) {
case " $1 " in
"ja-jp" ) echo 1041 ; ;
"zh-cn" ) echo 2052 ; ;
"zh-tw" ) echo 1028 ; ;
*) echo 1033 ; ; #en-us
esac
}
if [ "XenCenter" != " ${ BRANDING_BRAND_CONSOLE } " ] ; then
2021-01-12 13:23:29 +01:00
cd ${ WIX } && mv XenCenter.wxs ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .wxs
2020-01-13 13:37:35 +01:00
fi
#for each locale create an msi containing all resources
2023-02-20 10:49:15 +01:00
for locale in en-us
2020-01-13 13:37:35 +01:00
do
if [ " ${ locale } " = "en-us" ] ; then
2021-01-12 13:23:29 +01:00
name = ${ BRANDING_BRAND_CONSOLE_NO_SPACE }
2020-01-13 13:37:35 +01:00
else
2021-01-12 13:23:29 +01:00
name = ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .${ locale }
2020-01-13 13:37:35 +01:00
fi
cd ${ WIX }
mkdir -p obj${ name } out${ name }
WixLangId = $( locale_id ${ locale } | tr -d [ :space:] ) RepoRoot = $( cygpath -w ${ REPO } ) \
2023-03-30 01:16:00 +02:00
${ CANDLE } -ext WiXNetFxExtension -ext WixUtilExtension -out obj${ name } / ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .wxs
2020-01-13 13:37:35 +01:00
2022-06-06 11:43:09 +02:00
${ LIGHT } -sval -ext WiXNetFxExtension -ext WixUtilExtension -out out${ name } /${ name } .msi \
2020-01-13 13:37:35 +01:00
-loc wixlib/wixui_${ locale } .wxl -loc ${ locale } .wxl \
2023-03-30 01:16:00 +02:00
obj${ name } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } .wixobj lib/WixUI_InstallDir.wixlib
2020-01-13 13:37:35 +01:00
cp ${ WIX } /out${ name } /${ name } .msi ${ WIX }
done
#copy and sign the combined installer
2020-06-16 01:24:52 +02:00
if [ -f " ${ SIGN_BAT } " ] ; then
2021-04-12 14:12:33 +02:00
cd ${ WIX } && chmod a+rw ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .msi && ${ SIGN_BAT } ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .msi " ${ BRANDING_BRAND_CONSOLE } "
2020-06-16 01:24:52 +02:00
else
echo "Sign script does not exist; skip signing installer"
2020-01-13 13:37:35 +01:00
fi
2013-06-24 13:41:48 +02:00
2021-01-12 13:23:29 +01:00
cp ${ WIX } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } .msi ${ OUTPUT_DIR }
2020-01-23 00:52:14 +01:00
2013-06-24 13:41:48 +02:00
#build the tests
2015-07-22 10:36:15 +02:00
echo "INFO: Build the tests..."
2019-12-24 14:28:58 +01:00
cd ${ REPO } /XenAdminTests && " ${ MSBUILD } " ${ SWITCHES }
2013-06-24 13:41:48 +02:00
cp ${ REPO } /XenAdmin/ReportViewer/* ${ REPO } /XenAdminTests/bin/Release/
2021-02-01 15:49:42 +01:00
cd ${ REPO } /XenAdminTests/bin/ && zip -r ${ OUTPUT_DIR } /XenAdminTests.zip Release
2021-02-17 15:51:13 +01:00
cd ${ REPO } /XenAdmin/TestResources && zip -r ${ OUTPUT_DIR } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } TestResources.zip *
2016-01-22 06:50:12 +01:00
2018-02-09 16:00:07 +01:00
#include cfu validator binary in output directory
2022-11-08 12:18:35 +01:00
cd ${ REPO } /CFUValidator/bin/Release && zip ${ OUTPUT_DIR } /CFUValidator.zip ./{ *.dll,CFUValidator.exe,${ BRANDING_BRAND_CONSOLE_NO_SPACE } .exe}
2018-02-09 16:00:07 +01:00
2019-09-02 14:54:45 +02:00
#now package the pdbs
2019-12-26 18:23:32 +01:00
cp ${ REPO } /packages/*.pdb ${ OUTPUT_DIR }
2019-09-02 14:54:45 +02:00
2022-11-08 12:18:35 +01:00
cp ${ REPO } /XenAdmin/bin/Release/{ CommandLib.pdb,${ BRANDING_BRAND_CONSOLE_NO_SPACE } .pdb,CoreUtilsLib.pdb,${ BRANDING_BRAND_CONSOLE_NO_SPACE } .pdb,XenModel.pdb,XenOvf.pdb} \
2013-06-24 13:41:48 +02:00
${ REPO } /xe/bin/Release/xe.pdb \
${ OUTPUT_DIR }
2021-02-17 15:51:13 +01:00
cd ${ OUTPUT_DIR } && zip -r -m ${ BRANDING_BRAND_CONSOLE_NO_SPACE } .Symbols.zip *.pdb
2013-06-24 13:41:48 +02:00
2022-05-10 12:56:12 +02:00
msi_checksum_with_file_name = ` sha256sum ./${ BRANDING_BRAND_CONSOLE_NO_SPACE } .msi`
2022-03-22 12:06:41 +01:00
echo $msi_checksum_with_file_name > ${ OUTPUT_DIR } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } .msi.checksum
msi_checksum = ( $msi_checksum_with_file_name )
2021-05-27 17:13:32 +02:00
sha256sum ${ OUTPUT_DIR } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } -source.zip > ${ OUTPUT_DIR } /${ BRANDING_BRAND_CONSOLE_NO_SPACE } -source.zip.checksum
2021-02-22 14:40:42 +01:00
2023-02-14 16:18:09 +01:00
echo "INFO: Generating XCUpdates.xml"
2022-03-22 12:06:41 +01:00
2022-05-10 12:56:12 +02:00
# UPDATE_URL points at the updates XML, we need to point to the MSI
2023-08-21 14:35:49 +02:00
msi_url = " ${ XC_UPDATES_URL /XCUpdates.xml/ $BRANDING_BRAND_CONSOLE_NO_SPACE .msi } "
2022-05-10 12:56:12 +02:00
2022-03-22 12:06:41 +01:00
output_xml = " <?xml version=\"1.0\" ?>
<patchdata>
2023-02-14 16:18:09 +01:00
<versions>
2022-03-22 12:06:41 +01:00
<version
latest = \" true\"
latestcr = \" true\"
name = \" ${ BRANDING_BRAND_CONSOLE } ${ BRANDING_XC_PRODUCT_VERSION } .${ 1 } \"
timestamp = \" ` date -u +"%Y-%m-%dT%H:%M:%SZ" ` \"
2022-05-10 12:56:12 +02:00
url = \" ${ msi_url } \"
2022-03-22 12:06:41 +01:00
checksum = \" ${ msi_checksum } \"
value = \" ${ BRANDING_XC_PRODUCT_VERSION } .${ 1 } \"
2023-08-23 23:17:36 +02:00
/>
2023-02-14 16:18:09 +01:00
</versions>
2022-03-22 12:06:41 +01:00
</patchdata>"
2023-02-14 16:18:09 +01:00
echo $output_xml > ${ OUTPUT_DIR } /XCUpdates.xml
2022-03-22 12:06:41 +01:00
2023-02-14 16:18:09 +01:00
echo "INFO: Generating stage-test-XCUpdates.xml. URL is a placeholder value"
2022-03-22 12:06:41 +01:00
2023-02-14 16:18:09 +01:00
echo " ${ output_xml / " url=\" ${ msi_url } \" " / "url=\"@DEV_MSI_URL_PLACEHOLDER@\"" } " > ${ OUTPUT_DIR } /stage-test-XCUpdates.xml
2022-03-22 12:06:41 +01:00
2020-06-16 01:24:52 +02:00
set +u