2015-10-21 19:46:24 +00:00
#!/usr/bin/env bash
2015-11-16 19:21:57 +00: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-22 22:12:49 +00:00
# Debian Packaging Script
2015-10-21 19:46:24 +00:00
# Currently Intended to build on ubuntu14.04
2015-12-02 19:52:19 +00:00
set -e
2015-10-21 19:46:24 +00: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 19:47:21 +00: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-21 19:46:24 +00:00
done
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
2015-12-29 10:34:10 +00:00
source " $DIR /../common/_common.sh "
2015-10-21 19:46:24 +00:00
2016-01-07 00:46:25 +00:00
if [ " $OSNAME " != "ubuntu" ] ; then
error "Debian Package build only supported on Ubuntu"
2015-10-21 19:46:24 +00:00
exit 1
fi
2016-01-07 00:46:25 +00:00
PACKAGING_ROOT = " $REPOROOT /packaging/debian "
2015-10-21 19:46:24 +00:00
2015-12-02 19:52:19 +00:00
OUTPUT_DIR = " $REPOROOT /artifacts "
2015-10-22 06:41:38 +00:00
PACKAGE_LAYOUT_DIR = " $OUTPUT_DIR /deb_intermediate "
PACKAGE_OUTPUT_DIR = " $OUTPUT_DIR /packages/debian "
2015-12-02 19:52:19 +00:00
TEST_STAGE_DIR = " $PACKAGE_OUTPUT_DIR /test "
REPO_BINARIES_DIR = " $REPOROOT /artifacts/ubuntu.14.04-x64/stage2 "
2015-12-30 00:42:24 +00:00
MANPAGE_DIR = " $REPOROOT /Documentation/manpages "
2015-10-21 19:46:24 +00:00
2016-01-07 00:46:25 +00:00
NIGHTLY_PACKAGE_NAME = "dotnet-nightly"
RELEASE_PACKAGE_NAME = "dotnet"
2015-12-02 19:52:19 +00:00
execute_build( ) {
2016-01-07 00:46:25 +00:00
determine_package_name
2015-10-21 19:46:24 +00:00
create_empty_debian_layout
copy_files_to_debian_layout
create_debian_package
}
2016-01-07 00:46:25 +00:00
determine_package_name( ) {
if [ [ " $RELEASE_SUFFIX " = = "dev" ] ] ; then
DOTNET_DEB_PACKAGE_NAME = $NIGHTLY_PACKAGE_NAME
elif [ [ "beta rc1 rc2 rtm" = ~ ( ^| ) " $RELEASE_SUFFIX " ( $| ) ] ] ; then
DOTNET_DEB_PACKAGE_NAME = $RELEASE_PACKAGE_NAME
elif [ [ " $RELEASE_SUFFIX " = = "" ] ] ; then
DOTNET_DEB_PACKAGE_NAME = $RELEASE_PACKAGE_NAME
else
DOTNET_DEB_PACKAGE_NAME = $NIGHTLY_PACKAGE_NAME
fi
}
2015-12-02 19:52:19 +00:00
execute_test( ) {
test_debian_package
}
2015-10-21 19:46:24 +00:00
create_empty_debian_layout( ) {
2015-11-11 01:30:01 +00:00
header "Creating empty debian package layout"
2015-10-29 17:33:39 +00:00
2016-01-07 00:46:25 +00:00
rm -rf " $PACKAGE_LAYOUT_DIR "
mkdir -p " $PACKAGE_LAYOUT_DIR "
2015-10-21 19:46:24 +00:00
mkdir " $PACKAGE_LAYOUT_DIR /\$ "
mkdir " $PACKAGE_LAYOUT_DIR /package_root "
mkdir " $PACKAGE_LAYOUT_DIR /samples "
mkdir " $PACKAGE_LAYOUT_DIR /docs "
}
copy_files_to_debian_layout( ) {
2015-11-11 01:30:01 +00:00
header "Copying files to debian layout"
2015-10-29 17:33:39 +00:00
2015-10-21 19:46:24 +00:00
# Copy Built Binaries
cp -a " $REPO_BINARIES_DIR /. " " $PACKAGE_LAYOUT_DIR /package_root "
# Copy config file
2016-01-07 00:46:25 +00:00
cp " $PACKAGING_ROOT / $DOTNET_DEB_PACKAGE_NAME -debian_config.json " " $PACKAGE_LAYOUT_DIR /debian_config.json "
2015-12-30 00:42:24 +00:00
# Copy Manpages
cp -a " $MANPAGE_DIR /. " " $PACKAGE_LAYOUT_DIR /docs "
2015-10-21 19:46:24 +00:00
}
create_debian_package( ) {
2015-11-11 01:30:01 +00:00
header "Packing .deb"
2015-10-29 17:33:39 +00:00
2016-01-07 00:46:25 +00:00
mkdir -p " $PACKAGE_OUTPUT_DIR "
2016-01-12 23:27:02 +00:00
" $PACKAGING_ROOT /package_tool/package_tool " -i " $PACKAGE_LAYOUT_DIR " -o " $PACKAGE_OUTPUT_DIR " -v $DOTNET_CLI_VERSION -n $DOTNET_DEB_PACKAGE_NAME
2015-10-21 19:46:24 +00:00
}
2015-10-22 17:13:05 +00:00
test_debian_package( ) {
2015-11-11 01:30:01 +00:00
header "Testing debian package"
2015-10-29 17:33:39 +00:00
2015-12-05 01:24:30 +00:00
rm -rf $TEST_STAGE_DIR
2015-12-02 19:52:19 +00:00
git clone https://github.com/sstephenson/bats.git $TEST_STAGE_DIR
$TEST_STAGE_DIR /bin/bats $PACKAGE_OUTPUT_DIR /test_package.bats
2015-10-22 17:13:05 +00:00
2015-12-02 19:52:19 +00:00
# E2E Testing of package surface area
2015-12-03 00:26:05 +00:00
# Disabled: https://github.com/dotnet/cli/issues/381
2016-01-07 00:46:25 +00:00
# run_e2e_test
2015-10-22 17:13:05 +00:00
}
2015-12-02 19:52:19 +00:00
run_e2e_test( ) {
set +e
sudo dpkg -i $DEBIAN_FILE
$REPOROOT /scripts/test/e2e-test.sh
result = $?
sudo dpkg -r dotnet
set -e
return result
}
execute_build
2015-10-27 21:19:04 +00:00
DEBIAN_FILE = $( find $PACKAGE_OUTPUT_DIR -iname "*.deb" )
2015-12-02 19:52:19 +00:00
execute_test
# Publish
$REPOROOT /scripts/publish/publish.sh $DEBIAN_FILE