Skip to content

Commit 68fea37

Browse files
author
Elliot Boschwitz
authored
Removed dev dependencies for deb and rpm (#463)
* fix for debian and rpm * removed dev-latest
1 parent 69dfe99 commit 68fea37

File tree

3 files changed

+53
-28
lines changed

3 files changed

+53
-28
lines changed

build_scripts/debian/build.sh

+24-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ fi
1111
local_repo=$1
1212

1313
sudo apt-get update
14+
# required to run the 'make install'
15+
sudo apt-get install -y zlib1g-dev
1416

1517
# the ',,' makes environment variable lower case in Bash 4+
1618
if [ "${MSSQL_CLI_OFFICIAL_BUILD,,}" != "true" ]
@@ -39,34 +41,47 @@ rm -rf $source_dir/../debian_output
3941
[ -d $local_repo/privates ] && cp $local_repo/privates/*.whl $tmp_pkg_dir
4042

4143
# Build Python from source and include
42-
python_dir=$(mktemp -d)
4344
python_archive=$(mktemp)
4445
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive
46+
47+
# A copy of Python is created for build dependencies only
48+
python_dir=$(mktemp -d)
49+
python_dir_build=$(mktemp -d)
4550
tar -xvzf $python_archive -C $python_dir
51+
tar -xvzf $python_archive -C $python_dir_build
4652
echo "Python dir is $python_dir"
53+
echo "Python build dir is $python_dir_build"
4754

4855
# clean any previous make files
4956
make clean || echo "Nothing to clean"
5057

5158
$python_dir/*/configure --srcdir $python_dir/* --prefix $source_dir/python_env
5259
make
53-
# required to run the 'make install'
54-
sudo apt-get install -y zlib1g-dev
5560
make install
5661

57-
# Set env var to ensure build.py uses the python we built from source.
58-
export CUSTOM_PYTHON=$source_dir/python_env/bin/python3
59-
export CUSTOM_PIP=$source_dir/python_env/bin/pip3
62+
$python_dir_build/*/configure --srcdir $python_dir_build/* --prefix $source_dir/python_build
63+
make
64+
make install
6065

61-
# Download dependencies needed to run build stage
66+
# upgrade pip
6267
$source_dir/python_env/bin/python3 -m pip install --upgrade pip
63-
$source_dir/python_env/bin/python3 -m pip install -r $source_dir/requirements-dev.txt
68+
$source_dir/python_build/bin/python3 -m pip install --upgrade pip
69+
70+
# Download dependencies needed to run build stage
71+
$source_dir/python_build/bin/python3 -m pip install -r $source_dir/requirements-dev.txt
72+
73+
# Set env var to ensure build.py uses the python we built from source.
74+
export CUSTOM_PYTHON=$source_dir/python_build/bin/python3
75+
export CUSTOM_PIP=$source_dir/python_build/bin/pip3
6476

6577
# Build mssql-cli wheel from source.
6678
cd $source_dir
67-
$source_dir/python_env/bin/python3 $source_dir/build.py build
79+
$source_dir/python_build/bin/python3 $source_dir/build.py build
6880
cd -
6981

82+
# Remove python build version after build completes
83+
rm -rf $source_dir/python_build
84+
7085
# Install mssql-cli wheel.
7186
dist_dir=$source_dir/dist
7287

@@ -86,6 +101,4 @@ cp -r $cli_debian_dir_tmp/* $source_dir/debian
86101
cd $source_dir
87102
dpkg-buildpackage -us -uc
88103
cp $deb_file $source_dir/../debian_output
89-
# Create a second copy for latest dev version to be used by homepage.
90-
cp $deb_file $source_dir/../debian_output/mssql-cli-dev-latest.deb
91104
echo "The archive has also been outputted to $source_dir/../debian_output"

build_scripts/rpm/build.sh

-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@ rpmbuild -v -bb --clean ${REPO_PATH}/build_scripts/rpm/mssql-cli.spec
2626
# Copy build artifact to output dir.
2727
mkdir ${REPO_PATH}/../rpm_output
2828
cp ~/rpmbuild/RPMS/x86_64/*.rpm ${REPO_PATH}/../rpm_output
29-
# Create a second copy for latest dev version to be used by homepage.
30-
cp ~/rpmbuild/RPMS/x86_64/*.rpm ${REPO_PATH}/../rpm_output/mssql-cli-dev-latest.rpm
3129
echo "The archive has also been outputted to ${REPO_PATH}/../rpm_output"

build_scripts/rpm/mssql-cli.spec

+29-15
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
%define dist .el7
99
%endif
1010

11-
%define name mssql-cli
12-
%define release 1%{?dist}
13-
%define time_stamp %(date +%y%m%d%H%M)
14-
%define base_version 1.0.0
15-
%define python_dir %{_builddir}/python_env
16-
%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
17-
%define cli_lib_dir %{_libdir}/mssql-cli
18-
%define repo_path %{getenv:REPO_PATH}
19-
%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD}
11+
%define name mssql-cli
12+
%define release 1%{?dist}
13+
%define time_stamp %(date +%y%m%d%H%M)
14+
%define base_version 1.0.0
15+
%define python_dir %{_builddir}/python_env
16+
%define python_build_src /root/python_build_src
17+
%define python_build /root/python_build
18+
%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
19+
%define cli_lib_dir %{_libdir}/mssql-cli
20+
%define repo_path %{getenv:REPO_PATH}
21+
%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD}
2022

2123
# the ',,' makes environment variable lower case in Bash 4+
2224
%if "%{official_build}" != "true"
@@ -48,10 +50,14 @@ Requires: libunwind, libicu, less
4850
%prep
4951
# Clean previous build directory.
5052
rm -rf %{_builddir}/*
53+
rm -rf %{python_build_src}
54+
5155
# Download, Extract Python3
56+
mkdir %{python_build_src}
5257
python_archive=$(mktemp)
5358
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive
5459
tar -xvzf $python_archive -C %{_builddir}
60+
tar -xvzf $python_archive -C %{python_build_src}
5561

5662
%build
5763
# clean any previous make files
@@ -62,15 +68,23 @@ make clean || echo "Nothing to clean"
6268
make
6369
make install
6470

65-
# Install Python dependencies for build
71+
# A copy of Python is created for build dependencies only
72+
%{python_build_src}/*/configure --srcdir %{python_build_src}/* --prefix %{python_build}
73+
make
74+
make install
75+
76+
# Update pip
6677
%{python_dir}/bin/pip3 install --upgrade pip
67-
%{python_dir}/bin/pip3 install -r %{repo_path}/requirements-dev.txt
78+
%{python_build}/bin/pip3 install --upgrade pip
6879

69-
# Build mssql-cli wheel from source.
70-
export CUSTOM_PYTHON=%{python_dir}/bin/python3
71-
export CUSTOM_PIP=%{python_dir}/bin/pip3
80+
# Install Python dependencies and build from source
81+
export CUSTOM_PYTHON=%{python_build}/bin/python3
82+
export CUSTOM_PIP=%{python_build}/bin/pip3
83+
%{python_build}/bin/pip3 install -r %{repo_path}/requirements-dev.txt
84+
%{python_build}/bin/python3 %{repo_path}/build.py build
7285

73-
%{python_dir}/bin/python3 %{repo_path}/build.py build
86+
# Remove python build version after build completes
87+
rm -rf %{python_build}
7488

7589
%install
7690
# Install mssql-cli

0 commit comments

Comments
 (0)