diff --git a/.gitignore b/.gitignore index da762a5..a2fdf86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ *.pro.user *.autosave +# QtCtreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCtreator CMake +CMakeLists.txt.user* +.crossbuilder diff --git a/snap/gui/icon.svg b/snap/gui/icon.svg new file mode 100644 index 0000000..17065d0 --- /dev/null +++ b/snap/gui/icon.svg @@ -0,0 +1,602 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/snap/plugins/x-autotools.py b/snap/plugins/x-autotools.py new file mode 100644 index 0000000..8e09680 --- /dev/null +++ b/snap/plugins/x-autotools.py @@ -0,0 +1,135 @@ +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- +# +# Copyright (C) 2015, 2016 Canonical Ltd +# Copyright (C) 2016 Harald Sitter +# Copyright (C) 2017 Simon Stürz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""The autotools plugin is used for autotools based parts. + +Autotools based projects are the ones that have the usual +`./configure && make && make install` instruction set. + +The plugin tries to build using ./configure first, if it is not there +it will run ./autogen and if autogen is not there it will run autoreconf. + +This plugin uses the common plugin keywords as well as those for "sources". +For more information check the 'plugins' topic for the former and the +'sources' topic for the latter. + +In addition, this plugin uses the following plugin-specific keywords: + + - configflags: + (list of strings) + configure flags to pass to the build such as those shown by running + './configure --help' + - install-via: + (enum, 'destdir' or 'prefix') + Whether to install via DESTDIR or by using --prefix (default is + 'prefix') +""" + +import os +import stat + +import snapcraft + + +class XAutotoolsPlugin(snapcraft.BasePlugin): + + @classmethod + def schema(cls): + schema = super().schema() + schema['properties']['configflags'] = { + 'type': 'array', + 'minitems': 1, + 'uniqueItems': False, + 'items': { + 'type': 'string', + }, + 'default': [], + } + + schema['properties']['install-via'] = { + 'enum': ['destdir', 'prefix'], + 'default': 'prefix', + } + + return schema + + @classmethod + def get_build_properties(cls): + # Inform Snapcraft of the properties associated with building. If these + # change in the YAML Snapcraft will consider the build step dirty. + return super().get_build_properties() + ["configflags", "install-via"] + + def __init__(self, name, options, project): + super().__init__(name, options, project) + self.build_packages.extend([ + 'autoconf', + 'automake', + 'autopoint', + 'libtool', + 'make', + ]) + + if options.install_via == 'destdir': + self.install_via_destdir = True + elif options.install_via == 'prefix': + self.install_via_destdir = False + else: + raise RuntimeError('Unsupported installation method: "{}"'.format( + options.install_via)) + + def build(self): + super().build() + if not os.path.exists(os.path.join(self.builddir, "configure")): + generated = False + scripts = ["autogen.sh", "bootstrap"] + for script in scripts: + path = os.path.join(self.builddir, script) + if not os.path.exists(path) or os.path.isdir(path): + continue + # Make sure it's executable + if not os.access(path, os.X_OK): + os.chmod(path, + stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | + stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | + stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH) + self.run(['env', 'NOCONFIGURE=1', './{}'.format(script)]) + generated = True + break + if not generated: + self.run(['autoreconf', '-i']) + + configure_command = ['./configure'] + make_install_command = ['make', 'install'] + + if self.install_via_destdir: + # Use an empty prefix since we'll install via DESTDIR + #configure_command.append('--prefix=') + make_install_command.append('DESTDIR=' + self.installdir) + + self.run(configure_command + ['-prefix', self.installdir] + self.options.configflags) + self.run(['make', '-j{}'.format(self.parallel_build_count)]) + self.run(make_install_command) + + def snap_fileset(self): + fileset = super().snap_fileset() + # Remove .la files which don't work when they are moved around + fileset.append("-**/*.la") + return fileset + + + diff --git a/snap/plugins/x-qmake.py b/snap/plugins/x-qmake.py new file mode 100644 index 0000000..6147758 --- /dev/null +++ b/snap/plugins/x-qmake.py @@ -0,0 +1,129 @@ +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- +# +# Copyright (C) 2016 Canonical Ltd +# Copyright (C) 2017 Simon Stürz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""The qmake plugin is useful for building qmake-based parts. + +These are projects that are built using .pro files. + +This plugin uses the common plugin keywords as well as those for "sources". +For more information check the 'plugins' topic for the former and the +'sources' topic for the latter. + +Additionally, this plugin uses the following plugin-specific keywords: + + - options: + (list of strings) + additional options to pass to the qmake invocation. + - project-files: + (list of strings) + list of .pro files to pass to the qmake invocation. +""" + +import os + +import snapcraft +from snapcraft import common + + +class XQmakePlugin(snapcraft.BasePlugin): + + @classmethod + def schema(cls): + schema = super().schema() + schema['properties']['options'] = { + 'type': 'array', + 'minitems': 1, + 'uniqueItems': True, + 'items': { + 'type': 'string', + }, + 'default': [], + } + schema['properties']['project-files'] = { + 'type': 'array', + 'minitems': 1, + 'uniqueItems': True, + 'items': { + 'type': 'string', + }, + 'default': [], + } + + return schema + + @classmethod + def get_build_properties(cls): + # Inform Snapcraft of the properties associated with building. If these + # change in the YAML Snapcraft will consider the build step dirty. + return ['options', 'project-files'] + + def __init__(self, name, options, project): + super().__init__(name, options, project) + + self.build_packages.append('make') + + def build(self): + super().build() + + env = self._build_environment() + + sources = [] + if self.options.project_files: + sourcedir = self.sourcedir + source_subdir = getattr(self.options, 'source_subdir', None) + if source_subdir: + sourcedir = os.path.join(sourcedir, source_subdir) + sources = [os.path.join(sourcedir, project_file) + for project_file in self.options.project_files] + + #self.run(['qmake'] + self._extra_config() + self.options.options + sources, env=env) + self.run([ self.project.parts_dir + '/qt-5-11-1/install/bin/qmake'] + self._extra_config() + self.options.options + sources, env=env) + + self.run(['make', '-j{}'.format( self.parallel_build_count)], env=env) + + self.run(['make', 'install', 'INSTALL_ROOT=' + self.installdir], env=env) + + def _extra_config(self): + extra_config = [] + + for root in [self.installdir, self.project.stage_dir]: + paths = common.get_library_paths(root, self.project.arch_triplet) + for path in paths: + extra_config.append("LIBS+=\"-L{}\"".format(path)) + extra_config.append("LIBS+=\"-L{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/lib')) + extra_config.append("QMAKE_LIBS+=\"-L{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/lib')) + extra_config.append("QMAKE_LIBDIR+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/lib')) + + paths = common.get_include_paths(root, self.project.arch_triplet) + for path in paths: + extra_config.append("INCLUDEPATH+=\"{}\"".format(path)) + extra_config.append("INCLUDEPATH+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/include')) + + extra_config.append("QML_IMPORT_PATH+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/qml')) + extra_config.append("QML2_IMPORT_PATH+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/qml')) + + return extra_config + + def _build_environment(self): + env = os.environ.copy() + env['QTDIR' ] = self.project.parts_dir + '/qt-5-11-1/install/' + env['QML_IMPORT_PATH' ] = self.project.parts_dir + '/qt-5-11-1/install/qml' + env['QML2_IMPORT_PATH' ] = self.project.parts_dir + '/qt-5-11-1/install/qml' + env['LD_LIBRARY_PATH' ] = self.project.parts_dir + '/qt-5-11-1/install/lib:' + self.project.parts_dir + '/qt-5-11-1/install/usr/lib/:' + env['PATH' ] = self.project.parts_dir + '/qt-5-11-1/install/bin:' + os.environ["PATH"] + return env + diff --git a/snap/qt5-launch b/snap/qt5-launch new file mode 100755 index 0000000..d6cce6b --- /dev/null +++ b/snap/qt5-launch @@ -0,0 +1,81 @@ +#!/bin/sh + +case "$SNAP_ARCH" in + "amd64") + ARCH='x86_64-linux-gnu';; + "i386") + ARCH='i386-linux-gnu';; + "armhf") + ARCH='arm-linux-gnueabihf' ;; + *) + echo "Unsupported architecture $SNAP_ARCH for this app build" + exit 1;; +esac + +# Add executable paths +export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH" + +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/$ARCH:$SNAP/usr/lib/$ARCH" +export LD_LIBRARY_PATH="$SNAP/lib:$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH + +# XKB config +export XKB_CONFIG_ROOT=$SNAP/usr/share/X11/xkb + +# Qt Platform to Mir +export QTCHOOSER_NO_GLOBAL_DIR=1 +export QT_SELECT=snappy-qt5 + +# Qt Libs +export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/qt5/libs:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/pulseaudio:$LD_LIBRARY_PATH + +# Qt Modules +export QT_PLUGIN_PATH=$SNAP/plugins + +# Mesa Libs +export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH + +# XDG Config +export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$XDG_CONFIG_DIRS +export XDG_CONFIG_DIRS=$SNAP/usr/xdg:$XDG_CONFIG_DIRS + +# Note: this doesn't seem to work, QML's LocalStorage either ignores +# or fails to use $SNAP_USER_DATA if defined here +export XDG_DATA_DIRS=$SNAP_USER_DATA:$XDG_DATA_DIRS +export XDG_DATA_DIRS=$SNAP/usr/share:$XDG_DATA_DIRS + +# Not good, needed for fontconfig +export XDG_DATA_HOME=$SNAP/usr/share + +# Font Config +export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d +export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf + +# Tell libGL where to find the drivers +export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri + +# Necessary for the SDK to find the translations directory +export APP_DIR=$SNAP + +# Removes Qt warning: Could not find a location +# of the system Compose files +export QTCOMPOSE=$SNAP/usr/share/X11/locale + +# Use GTK styling for running under Unity 7 +# TODO: find out what needs to be done for Unity 8 +export QT_STYLE_OVERRIDE=gtk +export DESKTOP_SESSION=ubuntu +export XDG_SESSION_DESKTOP=ubuntu +export XDG_CURRENT_DESKTOP=Unity +export GTK2_MODULES=overlay-scrollbar +export GTK_MODULES=gail:atk-bridge:unity-gtk-module +export QT_QPA_PLATFORMTHEME=appmenu-qt5 +export GTK_PATH=$SNAP/usr/lib/$ARCH/gtk-2.0 +export GIO_MODULE_DIR=$SNAP/usr/lib/$ARCH/gio/modules + +cd $SNAP +exec "$@" + diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..cb9672b --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,200 @@ +name: nymea-networkmanager +version: 0.1.0 +summary: Daemon for setup wireless connection using Bluetooth LE. +description: | + The nymea-networkmanager daemon provides a bluetooth low energy server and + allowes to configure the wireless network using the network-manager DBus connection. + +grade: stable +confinement: classic + +apps: + nymea-networkmanager: + command: env PATH=$PATH:$SNAP/bin nymea-networkmanager -a "BT WLAN setup" -m offline + daemon: simple + restart-condition: always + plugs: + - dbus + - bluez + - bluetooth-control + - network-manager + +parts: + nymea-networkmanager: + plugin: qmake + source: https://github.com/guh/nymea-networkmanager.git + source-type: git + build-attributes: [keep-execstack] + source-branch: master + project-files: [ nymea-networkmanager.pro ] + after: [ qt-5-11-1 ] + build-packages: + - qt5-default + - qt5-qmake + - qtbase5-dev + - qtconnectivity5-dev + stage-packages: + - libqt5gui5 + - libqt5core5a + - libqt5bluetooth5 + - libqt5network5 + - libqt5dbus5 + + # Custom launcher to support also armhf + qt5-launch: + plugin: dump + build-attributes: [keep-execstack] + source: . + organize: + qt5-launch: bin/ + + + # Qt 5.11.1 + qt-5-11-1: + plugin: autotools + source: http://download.qt.io/archive/qt/5.11/5.11.1/single/qt-everywhere-src-5.11.1.tar.xz + source-type: tar + build-attributes: [keep-execstack] + build-packages: + - g++ + - freetds-dev + - gdb + - libatspi2.0-dev + - libdbus-1-dev + - libsystemd-dev + - libfontconfig1-dev + - libfreetype6-dev + - libgbm-dev + - libgles2-mesa-dev + - libglib2.0-dev + - libgstreamer-plugins-base1.0-dev + - libgstreamer1.0-dev + - libharfbuzz-dev + - libicu-dev + - libinput-dev + - libmtdev-dev + - libmysqlclient-dev + - libpcre3-dev + - libpq-dev + - libproxy-dev + - libsqlite3-dev + - libssl-dev + - libudev-dev + - libbluetooth-dev + - libx11-dev + - libx11-xcb-dev + - libxcb-icccm4-dev + - libxcb-image0-dev + - libxcb-keysyms1-dev + - libxcb-randr0-dev + - libxcb-render-util0-dev + - libxcb-render0-dev + - libxcb-shape0-dev + - libxcb-shm0-dev + - libxcb-sync-dev + - libxcb-xfixes0-dev + - libxcb-xinerama0-dev + - libxcb-xkb-dev + - libxcb1-dev + - libxext-dev + - libxi-dev + - libxkbcommon-dev + - libxkbcommon-x11-dev + - libxrender-dev + - pkg-kde-tools + - publicsuffix + - unixodbc-dev + - zlib1g-dev + configflags: + - -release + - -confirm-license + - -opensource + - -platform + - linux-g++ + - -openssl + - -syslog + - -journald + - -no-rpath + - -verbose + - -silent + - -opengl + - es2 + - -no-widgets + - -xcb + - -no-gtk + - -fontconfig + - -no-eglfs + - -no-cups + - -no-accessibility + - -no-use-gold-linker + - -nomake + - examples + - -nomake + - tests + - -skip + - qt3d + - -skip + - qtactiveqt + - -skip + - qtandroidextras + - -skip + - qtcanvas3d + - -skip + - qtcharts + - -skip + - qtdatavis3d + - -skip + - qtdoc + - -skip + - qtgamepad + - -skip + - qtlocation + - -skip + - qtmacextras + - -skip + - qtpurchasing + - -skip + - qtscxml + - -skip + - qtsensors + - -skip + - qtvirtualkeyboard + - -skip + - qtwayland + - -skip + - qtwebchannel + - -skip + - qtwebengine + - -skip + - qtwebview + - -skip + - qtwinextras + - -skip + - qtx11extras + - -skip + - qtxmlpatterns + stage-packages: + - icu-devtools + - libc6 + - libdbus-1-3 + - libdrm2 + - libfreetype6 + - libgbm1 + - libgcc1 + - libglib2.0-0 + - libharfbuzz0b + - libice6 + - libinput10 + - libmtdev1 + - libpcre16-3 + - libproxy1v5 + - libsm6 + - libsqlite3-0 + - libstdc++6 + - libudev1 + - libxext-dev + - libxi6 + - libxkbcommon0 + - perl + - zlib1g + - libdouble-conversion-dev