Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Update/consolidate linux install #153

Merged
merged 4 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.0a20
current_version = 1.0.0a21
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+))(?P<release_version>\d+)
serialize =
{major}.{minor}.{patch}{release}{release_version}
Expand Down
2 changes: 1 addition & 1 deletion mssqlscripter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

__version__ = '1.0.0a20'
__version__ = '1.0.0a21'
17 changes: 6 additions & 11 deletions mssqltoolsservice/buildwheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@
from urllib.request import urlopen


DOWNLOAD_URL_BASE = 'https://mssqlscripter.blob.core.windows.net/sqltoolsservice-08-16-2017/'
DOWNLOAD_URL_BASE = 'https://mssqlscripter.blob.core.windows.net/sqltoolsservice-10-12-2017/'

# Supported platform key's must match those in mssqlscript's setup.py.
SUPPORTED_PLATFORMS = {
'CentOS_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-centos-x64-netcoreapp2.0.tar.gz',
'Debian_8': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-debian-x64-netcoreapp2.0.tar.gz',
'Fedora_23': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-fedora-x64-netcoreapp2.0.tar.gz',
'openSUSE_13_2': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-opensuse-x64-netcoreapp2.0.tar.gz',
'OSX_10_11_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-osx-x64-netcoreapp2.0.tar.gz',
'RHEL_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-rhel-x64-netcoreapp2.0.tar.gz',
'Ubuntu_14': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu14-x64-netcoreapp2.0.tar.gz',
'Ubuntu_16': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu16-x64-netcoreapp2.0.tar.gz',
'Windows_7_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x64-netcoreapp2.0.zip',
'Windows_7_86': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x86-netcoreapp2.0.zip'
'Linux_64': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-linux-x64-netcoreapp2.0.tar.gz',
'OSX_10_11_64': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-osx-x64-netcoreapp2.0.tar.gz',
'Windows_7_64': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-win-x64-netcoreapp2.0.zip',
'Windows_7_86': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-win-x86-netcoreapp2.0.zip'
}

CURRENT_DIRECTORY = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))
Expand Down Expand Up @@ -78,6 +72,7 @@ def build_sqltoolsservice_wheels(platforms):
os.environ[u'MSSQLTOOLSSERVICE_PLATFORM'] = platform

print(u'Calling setup bdist_wheel for platform:{}'.format(platform))
print(SUPPORTED_PLATFORMS[platform])
download_and_unzip(SUPPORTED_PLATFORMS[platform], directory=TARGET_DIRECTORY)
utility.exec_command(u'python setup.py check -r -s bdist_wheel', CURRENT_DIRECTORY)

Expand Down
2 changes: 1 addition & 1 deletion mssqltoolsservice/mssqltoolsservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
import platform

__version__ = '1.0.0a20'
__version__ = '1.0.0a21'


def get_executable_path():
Expand Down
2 changes: 1 addition & 1 deletion mssqltoolsservice/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# This version number is in place in two places and must be in sync with
# mssqlscripter's version in setup.py.
MSSQLTOOLSSERVICE_VERSION = '1.0.0a20'
MSSQLTOOLSSERVICE_VERSION = '1.0.0a21'

# If we have source, validate version numbers match to prevent
# uploading releases with mismatched versions.
Expand Down
115 changes: 4 additions & 111 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# This version number is in place in two places and must be in sync with
# mssqltoolsservice's version in setup.py.
MSSQLSCRIPTER_VERSION = '1.0.0a20'
MSSQLSCRIPTER_VERSION = '1.0.0a21'

# If we have the source, validate our setup version matches source version.
# This will prevent uploading releases with mismatched versions. This will
Expand Down Expand Up @@ -58,119 +58,12 @@

MSSQLTOOLSSERVICE_PACKAGE_NAME = 'mssqltoolsservice-{}=={}'
MSSQLTOOLSSERVICE_PACKAGE_SUFFIX = [
'CentOS_7',
'Debian_8',
'Fedora_23',
'openSUSE_13_2',
'OSX_10_11_64',
'RHEL_7',
'Ubuntu_14',
'Ubuntu_16',
'Windows_7_64',
'Windows_7_86'
'Windows_7_86',
'Linux_64'
]

LINUX_DISTRO_NO_VERSION = {
'centos': 'CentOS_7',
'ol': 'CentOS_7',
'fedora': 'Fedora_23',
'opensuse': 'OpenSUSE_13_2',
'rhel': 'RHEL_7',
'debian': 'Debian_8',
}

LINUX_DISTRO_WITH_VERSION = {
'ubuntu':
{
'14': 'Ubuntu_14',
'16': 'Ubuntu_16'
},
'elementary':
{
'0.3': 'Ubuntu_14',
'0.4': 'Ubuntu_16'
},
'elementaryOS':
{
'0.3': 'Ubuntu_14',
'0.4': 'Ubuntu_16'
},
'linuxmint':
{
'18': 'Ubuntu_16'
},
'galliumos':
{
'2.0': 'Ubuntu_16'
},
}


def _get_runtime_id_helper(name, version):
"""
Checks if linux distro name and version match to a supported package.
"""
if name in LINUX_DISTRO_NO_VERSION:
return LINUX_DISTRO_NO_VERSION[name]

if name in LINUX_DISTRO_WITH_VERSION:
for supported_version in LINUX_DISTRO_WITH_VERSION[name]:
if version.startswith(supported_version):
return LINUX_DISTRO_WITH_VERSION[name][supported_version]
return None


def _get_linux_distro_runtime_id(content):
"""
Parse content for linux distro run time id.
"""
name = None
version = None
id_like = None

# Try to find name, version and id_like best effort.
for line in content.splitlines():
key, value = line.rstrip().split('=')
value = value.strip('"')
if key == 'ID':
name = value
elif key == 'VERSION_ID':
version = value
elif key == 'ID_LIKE':
id_like = value.split(' ')
if name and version and id_like:
break
# First try the distribution name.
run_time_id = _get_runtime_id_helper(name, version)

# If we don't understand it, try the 'ID_LIKE' field.
if not run_time_id and id_like:
for name in id_like:
run_time_id = _get_runtime_id_helper(name, version)
if run_time_id:
break

return run_time_id


def _get_linux_distro_from_file():
"""
Find linux distro based on
https://www.freedesktop.org/software/systemd/man/os-release.html.
"""
os_release_info_file = None

if os.path.exists('/etc/os-release'):
os_release_info_file = '/etc/os-release'
elif os.path.exists('/usr/lib/os-release'):
os_release_info_file = '/usr/lib/os-release'
else:
raise EnvironmentError('Error detecting Linux distro version.')

with io.open(os_release_info_file, 'r', encoding='utf-8') as os_release_file:
content = os_release_file.read()
return _get_linux_distro_runtime_id(content)


def _get_runtime_id(
system=_platform.system(),
Expand All @@ -191,7 +84,7 @@ def _get_runtime_id(
run_time_id = 'OSX_10_11_64'
elif system == 'Linux':
if architecture == '64bit':
run_time_id = _get_linux_distro_from_file()
run_time_id = 'Linux_64'

return run_time_id

Expand Down