2015-10-21 19:46:24 +00:00
#!/usr/bin/env bash
#
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
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 " ) "
[ [ $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
done
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
2015-11-11 01:30:01 +00:00
source " $DIR /../_common.sh "
2015-10-21 19:46:24 +00:00
if [ " $UNAME " != "Linux" ] ; then
2015-11-03 22:13:25 +00:00
error "Debian Package build only supported on Linux"
2015-10-21 19:46:24 +00:00
exit 1
fi
2015-11-11 01:30:01 +00:00
REPO_ROOT = $( readlink -f $DIR /../..)
2015-10-21 19:46:24 +00:00
2015-10-22 06:41:38 +00:00
OUTPUT_DIR = " $REPO_ROOT /artifacts "
PACKAGE_LAYOUT_DIR = " $OUTPUT_DIR /deb_intermediate "
PACKAGE_OUTPUT_DIR = " $OUTPUT_DIR /packages/debian "
REPO_BINARIES_DIR = " $REPO_ROOT /artifacts/ubuntu.14.04-x64/stage2 "
2015-10-21 19:46:24 +00:00
execute( ) {
create_empty_debian_layout
copy_files_to_debian_layout
create_debian_package
2015-10-22 17:13:05 +00:00
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
2015-10-21 19:46:24 +00:00
rm -rf $PACKAGE_LAYOUT_DIR
mkdir -p $PACKAGE_LAYOUT_DIR
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
cp " $REPO_ROOT /debian_config.json " " $PACKAGE_LAYOUT_DIR "
}
create_debian_package( ) {
2015-11-11 01:30:01 +00:00
header "Packing .deb"
2015-10-29 17:33:39 +00:00
2015-10-21 19:46:24 +00:00
mkdir -p $PACKAGE_OUTPUT_DIR
2015-10-29 17:33:39 +00:00
2015-11-03 22:13:25 +00:00
$REPO_ROOT /package_tool/package_tool $PACKAGE_LAYOUT_DIR $PACKAGE_OUTPUT_DIR $DOTNET_BUILD_VERSION
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-10-22 17:13:05 +00:00
git clone https://github.com/sstephenson/bats.git /tmp/bats
pushd /tmp/bats
./install.sh /usr/local
popd
bats $PACKAGE_OUTPUT_DIR /test_package.bats
}
2015-10-21 19:46:24 +00:00
execute
2015-10-27 21:19:04 +00:00
DEBIAN_FILE = $( find $PACKAGE_OUTPUT_DIR -iname "*.deb" )
2015-11-11 01:30:01 +00:00
$DIR /../publish/publish.sh $DEBIAN_FILE