Skip to content

Commit

Permalink
Merge pull request #245 from dberzano/debian-ubuntu
Browse files Browse the repository at this point in the history
Detect Debian 7 and 8, and Ubuntu 16.04
  • Loading branch information
dberzano committed May 3, 2016
2 parents 7c847c2 + 783e19b commit 96a4509
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
3 changes: 2 additions & 1 deletion aliBuild
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ ARCHITECTURE_TABLE = [
" RHEL7 / CC7 compatible: slc7_x86-64\n"
" Ubuntu 14.04 compatible: ubuntu1404_x86-64\n"
" Ubuntu 15.04 compatible: ubuntu1504_x86-64\n"
" Ubuntu 15.10 compatible: ubuntu1510_x86-64\n\n"
" Ubuntu 15.10 compatible: ubuntu1510_x86-64\n"
" Ubuntu 16.04 compatible: ubuntu1604_x86-64\n\n"
"On Linux, POWER8 / PPC64 (little endian):\n"
" RHEL7 / CC7 compatible: slc7_ppc64\n\n"
"On Mac, x86-64:\n"
Expand Down
16 changes: 15 additions & 1 deletion alibuild_helpers/utilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
import subprocess

def format(s, **kwds):
return s % kwds

Expand All @@ -22,10 +24,22 @@ def doDetectArch(hasOsRelease, osReleaseLines, platformTuple, platformSystem, pl
if distribution.lower() == "ubuntu":
version = version.split(".")
version = version[0] + version[1]
if distribution in ["redhat", "centos"]:
elif distribution.lower() == "debian":
# http://askubuntu.com/questions/445487/which-ubuntu-version-is-equivalent-to-debian-squeeze
debian_ubuntu = { "7": "1204",
"8": "1404" }
if version in debian_ubuntu:
distribution = "ubuntu"
version = debian_ubuntu[version]
elif distribution in ["redhat", "centos"]:
distribution = distribution.replace("centos","slc").replace("redhat","slc").lower()

processor = platformProcessor
if not processor:
# Sometimes platform.processor returns an empty string
p = subprocess.Popen(["uname", "-m"], stdout=subprocess.PIPE)
processor = p.stdout.read().strip()

return format("%(d)s%(v)s_%(c)s",
d=distribution.lower(),
v=version.split(".")[0],
Expand Down
39 changes: 39 additions & 0 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,56 @@
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
"""

UBUNTU_1604_OS_RELEASE = """
NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial
"""

DEBIAN_7_OS_RELEASE = """
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
"""

DEBIAN_8_OS_RELEASE = """
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
"""

architecturePayloads = [
['osx_x86-64', False, [], ('','',''), 'Darwin', 'x86-64'],
['slc5_x86-64', False, [], ('redhat', '5.XX', 'Boron'), 'Linux', 'x86-64'],
['slc6_x86-64', False, [], ('centos', '6.X', 'Carbon'), 'Linux', 'x86-64'],
['slc7_x86-64', False, [], ('centos', '7.X', 'Ptor'), 'Linux', 'x86-64'],
['ubuntu1604_x86-64', True, UBUNTU_1604_OS_RELEASE.split("\n"), ('Ubuntu', '16.04', 'xenial'), 'Linux', 'x86-64'],
['ubuntu1510_x86-64', False, [], ('Ubuntu', '15.10', 'wily'), 'Linux', 'x86-64'],
['ubuntu1510_x86-64', True, UBUNTU_1510_OS_RELEASE.split("\n"), ('Ubuntu', '15.10', 'wily'), 'Linux', 'x86-64'],
['ubuntu1510_x86-64', True, UBUNTU_1510_OS_RELEASE.split("\n"), ('', '', ''), 'Linux', 'x86-64'], # ANACONDA case
['ubuntu1404_x86-64', True, UBUNTU_1404_OS_RELEASE.split("\n"), ('Ubuntu', '14.04', 'trusty'), 'Linux', 'x86-64'],
['ubuntu1404_x86-64', True, UBUNTU_1404_OS_RELEASE.split("\n"), ('', '', ''), 'Linux', 'x86-64'],
['ubuntu1404_x86-64', True, LINUX_MINT_OS_RELEASE.split("\n"), ('LinuxMint', '17.3', 'rosa'), 'Linux', 'x86-64'], # LinuxMint
['ubuntu1204_x86-64', True, DEBIAN_7_OS_RELEASE.split("\n"), ('Debian', '7', 'wheezy'), 'Linux', 'x86-64'],
['ubuntu1404_x86-64', True, DEBIAN_8_OS_RELEASE.split("\n"), ('Debian', '8', 'jessie'), 'Linux', 'x86-64']
]

class TestArchitectures(unittest.TestCase):
Expand Down

0 comments on commit 96a4509

Please sign in to comment.