diff --git a/azurelinuxagent/distro/ubuntu/loader.py b/azurelinuxagent/distro/ubuntu/loader.py index 5e2d283..289e1ba 100644 --- a/azurelinuxagent/distro/ubuntu/loader.py +++ b/azurelinuxagent/distro/ubuntu/loader.py @@ -17,29 +17,19 @@ # Requires Python 2.4+ and Openssl 1.0+ # -from azurelinuxagent.metadata import DISTRO_NAME, DISTRO_VERSION +from azurelinuxagent.metadata import DISTRO_NAME, DISTRO_VERSION, DISTRO_FULL_NAME def get_osutil(): from azurelinuxagent.distro.ubuntu.osutil import Ubuntu1204OSUtil, \ UbuntuOSUtil, \ Ubuntu14xOSUtil, \ UbuntuSnappyOSUtil - import os - import azurelinuxagent.utils.fileutil as fileutil - - # TODO: https://bugs.launchpad.net/snappy/+bug/1481086 - def is_snappy(): - if os.path.exists("/etc/motd"): - motd = fileutil.read_file("/etc/motd") - if "snappy" in motd: - return True - return False if DISTRO_VERSION == "12.04": return Ubuntu1204OSUtil() elif DISTRO_VERSION == "14.04" or DISTRO_VERSION == "14.10": return Ubuntu14xOSUtil() - elif is_snappy(): + elif DISTRO_FULL_NAME == "Snappy Ubuntu Core": return UbuntuSnappyOSUtil() else: return UbuntuOSUtil() diff --git a/azurelinuxagent/metadata.py b/azurelinuxagent/metadata.py index 83d4676..7a9c113 100644 --- a/azurelinuxagent/metadata.py +++ b/azurelinuxagent/metadata.py @@ -21,6 +21,7 @@ import os import re import platform import sys +import azurelinuxagent.utils.fileutil as fileutil from azurelinuxagent.future import text def get_distro(): @@ -70,24 +71,12 @@ PY_VERSION_MICRO = sys.version_info[2] Add this walk arround for detecting Snappy Ubuntu Core temporarily, until ubuntu fixed this bug: https://bugs.launchpad.net/snappy/+bug/1481086 """ -def which(program): - # Return path of program for execution if found in path - def is_exe(fpath): - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - _fpath, _ = os.path.split(program) - if _fpath: - if is_exe(program): - return program - else: - for path in os.environ.get("PATH", "").split(os.pathsep): - path = path.strip('"') - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file - return None - def is_snappy(): - return which("snappy") + if os.path.exists("/etc/motd"): + motd = fileutil.read_file("/etc/motd") + if "snappy" in motd: + return True + return False if is_snappy(): DISTRO_FULL_NAME = "Snappy Ubuntu Core" diff --git a/config/snappy/lib/readme.md b/config/snappy/lib/readme.md deleted file mode 100644 index 3e9361f..0000000 --- a/config/snappy/lib/readme.md +++ /dev/null @@ -1 +0,0 @@ -Place the azurelinuxagent folder here diff --git a/config/snappy/bin/waagent b/snappy/bin/waagent old mode 100755 new mode 100644 similarity index 100% rename from config/snappy/bin/waagent rename to snappy/bin/waagent diff --git a/config/snappy/bin/waagent.start b/snappy/bin/waagent.start old mode 100755 new mode 100644 similarity index 100% rename from config/snappy/bin/waagent.start rename to snappy/bin/waagent.start diff --git a/snappy/lib/readme.md b/snappy/lib/readme.md new file mode 100644 index 0000000..c91a79c --- /dev/null +++ b/snappy/lib/readme.md @@ -0,0 +1 @@ +Copy the azurelinuxagent folder here diff --git a/config/snappy/meta/package.yaml b/snappy/meta/package.yaml similarity index 100% rename from config/snappy/meta/package.yaml rename to snappy/meta/package.yaml diff --git a/config/snappy/meta/readme.md b/snappy/meta/readme.md similarity index 100% rename from config/snappy/meta/readme.md rename to snappy/meta/readme.md diff --git a/config/snappy/meta/walinuxagent.apparmor b/snappy/meta/walinuxagent.apparmor similarity index 100% rename from config/snappy/meta/walinuxagent.apparmor rename to snappy/meta/walinuxagent.apparmor diff --git a/config/snappy/meta/walinuxagent.seccomp b/snappy/meta/walinuxagent.seccomp similarity index 100% rename from config/snappy/meta/walinuxagent.seccomp rename to snappy/meta/walinuxagent.seccomp diff --git a/snappy/readme.md b/snappy/readme.md new file mode 100644 index 0000000..841bc35 --- /dev/null +++ b/snappy/readme.md @@ -0,0 +1,13 @@ +### Building the walinuxagent snap package + +1. You will need the snappy developer tools on your Ubuntu Developer Desktop: + $ sudo add-apt-repository ppa:snappy-dev/tools + $ sudo apt-get update + $ sudo apt-get upgrade + $ sudo apt-get install snappy-tools + +2. Copy the azurelinuxagent folder to snappy/lib + $ cp -rf ../azurelinuxagent snappy/lib + +3. Build the snap package under the snappy folder + $ snappy build \ No newline at end of file diff --git a/config/snappy/waagent.conf b/snappy/waagent.conf similarity index 100% rename from config/snappy/waagent.conf rename to snappy/waagent.conf