From 840630c72d19d86d57883eb586a01302904cf34e Mon Sep 17 00:00:00 2001 From: Elliot Boschwitz Date: Thu, 23 Apr 2020 19:18:20 -0700 Subject: [PATCH 1/4] fix for debian --- build_scripts/debian/build.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/build_scripts/debian/build.sh b/build_scripts/debian/build.sh index 4730d44b..121b62e0 100755 --- a/build_scripts/debian/build.sh +++ b/build_scripts/debian/build.sh @@ -11,6 +11,8 @@ fi local_repo=$1 sudo apt-get update +# required to run the 'make install' +sudo apt-get install -y zlib1g-dev # the ',,' makes environment variable lower case in Bash 4+ if [ "${MSSQL_CLI_OFFICIAL_BUILD,,}" != "true" ] @@ -39,34 +41,47 @@ rm -rf $source_dir/../debian_output [ -d $local_repo/privates ] && cp $local_repo/privates/*.whl $tmp_pkg_dir # Build Python from source and include -python_dir=$(mktemp -d) python_archive=$(mktemp) wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive + +# A copy of Python is created for build dependencies only +python_dir=$(mktemp -d) +python_dir_build=$(mktemp -d) tar -xvzf $python_archive -C $python_dir +tar -xvzf $python_archive -C $python_dir_build echo "Python dir is $python_dir" +echo "Python build dir is $python_dir_build" # clean any previous make files make clean || echo "Nothing to clean" $python_dir/*/configure --srcdir $python_dir/* --prefix $source_dir/python_env make -# required to run the 'make install' -sudo apt-get install -y zlib1g-dev make install -# Set env var to ensure build.py uses the python we built from source. -export CUSTOM_PYTHON=$source_dir/python_env/bin/python3 -export CUSTOM_PIP=$source_dir/python_env/bin/pip3 +$python_dir_build/*/configure --srcdir $python_dir_build/* --prefix $source_dir/python_build +make +make install -# Download dependencies needed to run build stage +# upgrade pip $source_dir/python_env/bin/python3 -m pip install --upgrade pip -$source_dir/python_env/bin/python3 -m pip install -r $source_dir/requirements-dev.txt +$source_dir/python_build/bin/python3 -m pip install --upgrade pip + +# Download dependencies needed to run build stage +$source_dir/python_build/bin/python3 -m pip install -r $source_dir/requirements-dev.txt + +# Set env var to ensure build.py uses the python we built from source. +export CUSTOM_PYTHON=$source_dir/python_build/bin/python3 +export CUSTOM_PIP=$source_dir/python_build/bin/pip3 # Build mssql-cli wheel from source. cd $source_dir -$source_dir/python_env/bin/python3 $source_dir/build.py build +$source_dir/python_build/bin/python3 $source_dir/build.py build cd - +# Remove python build version after build completes +rm -rf $source_dir/python_build + # Install mssql-cli wheel. dist_dir=$source_dir/dist From 94c8b010a99981ffb90548dbf9e93254fb91bfcb Mon Sep 17 00:00:00 2001 From: Elliot Boschwitz Date: Thu, 23 Apr 2020 22:21:03 -0700 Subject: [PATCH 2/4] fix for rpm --- build_scripts/rpm/mssql-cli.spec | 44 +++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/build_scripts/rpm/mssql-cli.spec b/build_scripts/rpm/mssql-cli.spec index 628e3262..25e0affe 100644 --- a/build_scripts/rpm/mssql-cli.spec +++ b/build_scripts/rpm/mssql-cli.spec @@ -8,15 +8,17 @@ %define dist .el7 %endif -%define name mssql-cli -%define release 1%{?dist} -%define time_stamp %(date +%y%m%d%H%M) -%define base_version 1.0.0 -%define python_dir %{_builddir}/python_env -%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -%define cli_lib_dir %{_libdir}/mssql-cli -%define repo_path %{getenv:REPO_PATH} -%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD} +%define name mssql-cli +%define release 1%{?dist} +%define time_stamp %(date +%y%m%d%H%M) +%define base_version 1.0.0 +%define python_dir %{_builddir}/python_env +%define python_build_archive /root/python_build_archive +%define python_build /root/python_build +%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz +%define cli_lib_dir %{_libdir}/mssql-cli +%define repo_path %{getenv:REPO_PATH} +%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD} # the ',,' makes environment variable lower case in Bash 4+ %if "%{official_build}" != "true" @@ -48,10 +50,14 @@ Requires: libunwind, libicu, less %prep # Clean previous build directory. rm -rf %{_builddir}/* +rm -rf %{python_build_archive} + # Download, Extract Python3 +mkdir %{python_build_archive} python_archive=$(mktemp) wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive tar -xvzf $python_archive -C %{_builddir} +tar -xvzf $python_archive -C %{python_build_archive} %build # clean any previous make files @@ -62,15 +68,23 @@ make clean || echo "Nothing to clean" make make install -# Install Python dependencies for build +# A copy of Python is created for build dependencies only +%{python_build_archive}/*/configure --srcdir %{python_build_archive}/* --prefix %{python_build} +make +make install + +# Update pip %{python_dir}/bin/pip3 install --upgrade pip -%{python_dir}/bin/pip3 install -r %{repo_path}/requirements-dev.txt +%{python_build}/bin/pip3 install --upgrade pip -# Build mssql-cli wheel from source. -export CUSTOM_PYTHON=%{python_dir}/bin/python3 -export CUSTOM_PIP=%{python_dir}/bin/pip3 +# Install Python dependencies and build from source +export CUSTOM_PYTHON=%{python_build}/bin/python3 +export CUSTOM_PIP=%{python_build}/bin/pip3 +%{python_build}/bin/pip3 install -r %{repo_path}/requirements-dev.txt +%{python_build}/bin/python3 %{repo_path}/build.py build -%{python_dir}/bin/python3 %{repo_path}/build.py build +# Remove python build version after build completes +rm -rf %{python_build} %install # Install mssql-cli From 12f27f6545a6233f2a87e08edec693adb8dda64e Mon Sep 17 00:00:00 2001 From: Elliot Boschwitz Date: Fri, 24 Apr 2020 16:23:22 -0700 Subject: [PATCH 3/4] renamed python src folder --- build_scripts/rpm/mssql-cli.spec | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build_scripts/rpm/mssql-cli.spec b/build_scripts/rpm/mssql-cli.spec index 25e0affe..1595c551 100644 --- a/build_scripts/rpm/mssql-cli.spec +++ b/build_scripts/rpm/mssql-cli.spec @@ -8,17 +8,17 @@ %define dist .el7 %endif -%define name mssql-cli -%define release 1%{?dist} -%define time_stamp %(date +%y%m%d%H%M) -%define base_version 1.0.0 -%define python_dir %{_builddir}/python_env -%define python_build_archive /root/python_build_archive -%define python_build /root/python_build -%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -%define cli_lib_dir %{_libdir}/mssql-cli -%define repo_path %{getenv:REPO_PATH} -%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD} +%define name mssql-cli +%define release 1%{?dist} +%define time_stamp %(date +%y%m%d%H%M) +%define base_version 1.0.0 +%define python_dir %{_builddir}/python_env +%define python_build_src /root/python_build_src +%define python_build /root/python_build +%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz +%define cli_lib_dir %{_libdir}/mssql-cli +%define repo_path %{getenv:REPO_PATH} +%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD} # the ',,' makes environment variable lower case in Bash 4+ %if "%{official_build}" != "true" @@ -50,14 +50,14 @@ Requires: libunwind, libicu, less %prep # Clean previous build directory. rm -rf %{_builddir}/* -rm -rf %{python_build_archive} +rm -rf %{python_build_src} # Download, Extract Python3 -mkdir %{python_build_archive} +mkdir %{python_build_src} python_archive=$(mktemp) wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive tar -xvzf $python_archive -C %{_builddir} -tar -xvzf $python_archive -C %{python_build_archive} +tar -xvzf $python_archive -C %{python_build_src} %build # clean any previous make files @@ -69,7 +69,7 @@ make make install # A copy of Python is created for build dependencies only -%{python_build_archive}/*/configure --srcdir %{python_build_archive}/* --prefix %{python_build} +%{python_build_src}/*/configure --srcdir %{python_build_src}/* --prefix %{python_build} make make install From 36cba29cdc4eb3b87c20d25dcfbeadd638884bfc Mon Sep 17 00:00:00 2001 From: Elliot Boschwitz Date: Fri, 24 Apr 2020 16:23:39 -0700 Subject: [PATCH 4/4] removed dev-latest --- build_scripts/debian/build.sh | 2 -- build_scripts/rpm/build.sh | 2 -- 2 files changed, 4 deletions(-) diff --git a/build_scripts/debian/build.sh b/build_scripts/debian/build.sh index 121b62e0..88a196f2 100755 --- a/build_scripts/debian/build.sh +++ b/build_scripts/debian/build.sh @@ -101,6 +101,4 @@ cp -r $cli_debian_dir_tmp/* $source_dir/debian cd $source_dir dpkg-buildpackage -us -uc cp $deb_file $source_dir/../debian_output -# Create a second copy for latest dev version to be used by homepage. -cp $deb_file $source_dir/../debian_output/mssql-cli-dev-latest.deb echo "The archive has also been outputted to $source_dir/../debian_output" diff --git a/build_scripts/rpm/build.sh b/build_scripts/rpm/build.sh index d09d10bb..5be3db4d 100755 --- a/build_scripts/rpm/build.sh +++ b/build_scripts/rpm/build.sh @@ -26,6 +26,4 @@ rpmbuild -v -bb --clean ${REPO_PATH}/build_scripts/rpm/mssql-cli.spec # Copy build artifact to output dir. mkdir ${REPO_PATH}/../rpm_output cp ~/rpmbuild/RPMS/x86_64/*.rpm ${REPO_PATH}/../rpm_output -# Create a second copy for latest dev version to be used by homepage. -cp ~/rpmbuild/RPMS/x86_64/*.rpm ${REPO_PATH}/../rpm_output/mssql-cli-dev-latest.rpm echo "The archive has also been outputted to ${REPO_PATH}/../rpm_output"