From 686bfbe28df198ba989eff9dbdeea6f422f253e1 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Wed, 27 Apr 2016 17:08:35 +0200 Subject: [PATCH 1/9] Changes to build a bundle RPM with GPII Linux and GPII universal --- Gruntfile.js | 50 ++++++++++++++++++++ build/resources/gpii-linux-autostart.desktop | 5 ++ build/resources/gpii-linux-start | 5 ++ build/resources/gpii-linux.service | 14 ++++++ 4 files changed, 74 insertions(+) create mode 100644 build/resources/gpii-linux-autostart.desktop create mode 100755 build/resources/gpii-linux-start create mode 100644 build/resources/gpii-linux.service diff --git a/Gruntfile.js b/Gruntfile.js index 210bc36..bb4deaa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,6 +22,16 @@ module.exports = function (grunt) { var usbListenerDir = "./usbDriveListener"; var gypCompileCmd = "node-gyp configure build"; var gypCleanCmd = "node-gyp clean"; + var pkgdata = require('./package.json'); + + var currentArch = (function() { + if (process.arch == 'ia32') + return 'i386'; + else if (process.arch == 'x64') + return "x86_64"; + else + return "noarch"; + })(); function nodeGypShell(cmd, cwd) { return { @@ -43,6 +53,9 @@ module.exports = function (grunt) { jsonlint: { src: ["gpii/**/*.json"] }, + appFileName: "gpii-linux", + buildDir: "build", + pkgdata: pkgdata, shell: { options: { stdout: true, @@ -85,6 +98,38 @@ module.exports = function (grunt) { runUnitTests: { command: "vagrant ssh -c 'cd /home/vagrant/sync/tests/; DISPLAY=:0 ./UnitTests.sh'" } + }, + easy_rpm: { + options: { + release: 1, + summary: pkgdata.description, + rpmDestination: "bin", + tempDir: "bin/tmp", + keepTemp: true, + license: pkgdata.licenses[0].type, + url: pkgdata.homepage, + buildArch: currentArch, + requires: [ + "nodejs >= 0.10.42", + "python-httplib2" + ] + }, + release: { + files: [ + {src: "gpii.js", dest: "/opt/gpii-linux"}, + {src: "index.js", dest: "/opt/gpii-linux"}, + {src: "package.json", dest: "/opt/gpii-linux"}, + {src: "gpii/**/*", dest: "/opt/gpii-linux"}, + {src: "../node_modules/**/*", dest: "/opt/gpii-linux/node_modules"}, + {src: "gpii-linux-autostart.desktop", dest: "/etc/xdg/autostart", cwd: 'build/resources'}, + {src: "gpii-linux-start", dest: "/usr/bin", cwd: 'build/resources'}, + {src: "gpii-usb-user-listener", dest: "/usr/bin", mode: "755", cwd: 'usbDriveListener'}, + {src: "gpii-usb-user-listener.desktop", dest: "/usr/share/applications", cwd: 'usbDriveListener'} + ], + excludeFiles: [ + "../node_modules/**/examples/switch-bench.js" //avoid strange dependency + ] + }, } }); @@ -132,4 +177,9 @@ module.exports = function (grunt) { grunt.task.run("shell:runUnitTests"); grunt.task.run("shell:runAcceptanceTests"); }); + grunt.registerTask("buildrpm", "Build GPII Linux and RPM package", function () { + grunt.task.run("build"); + grunt.task.run("easy_rpm"); + }); + grunt.loadNpmTasks("grunt-easy-rpm"); }; diff --git a/build/resources/gpii-linux-autostart.desktop b/build/resources/gpii-linux-autostart.desktop new file mode 100644 index 0000000..154897f --- /dev/null +++ b/build/resources/gpii-linux-autostart.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=GPII Linux +Exec=/usr/bin/gpii-linux-start +OnlyShowIn=GNOME; diff --git a/build/resources/gpii-linux-start b/build/resources/gpii-linux-start new file mode 100755 index 0000000..3df929a --- /dev/null +++ b/build/resources/gpii-linux-start @@ -0,0 +1,5 @@ +#!/bin/sh +systemctl --user import-environment +env > /tmp/env.gpii +cd /opt/gpii-linux +node gpii.js diff --git a/build/resources/gpii-linux.service b/build/resources/gpii-linux.service new file mode 100644 index 0000000..f9a08d8 --- /dev/null +++ b/build/resources/gpii-linux.service @@ -0,0 +1,14 @@ +# Use with Systemd > 219 +[Unit] +Description=omponents of the GPII personalization infrastructure for use on Linux +Documentation=http://gpii.net + +[Service] +Type=simple +ExecStart=/usr/bin/gpii-linux-start +WorkingDirectory=/opt/gpii-linux +Restart=on-failure + +[Install] +WantedBy=default.target + From e0d80c06db9879ef75d6dc88db67dc7061395e92 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Thu, 28 Apr 2016 12:20:55 +0200 Subject: [PATCH 2/9] Add log file for usblistener --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index bb4deaa..f6abed2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -123,6 +123,7 @@ module.exports = function (grunt) { {src: "../node_modules/**/*", dest: "/opt/gpii-linux/node_modules"}, {src: "gpii-linux-autostart.desktop", dest: "/etc/xdg/autostart", cwd: 'build/resources'}, {src: "gpii-linux-start", dest: "/usr/bin", cwd: 'build/resources'}, + {src: "/var/lib/gpii/log.txt", dest: "/", mode: 666}, {src: "gpii-usb-user-listener", dest: "/usr/bin", mode: "755", cwd: 'usbDriveListener'}, {src: "gpii-usb-user-listener.desktop", dest: "/usr/share/applications", cwd: 'usbDriveListener'} ], From 1242a0e1b7c5c8e1a82e72c52fcdf70eda743071 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Thu, 28 Apr 2016 13:11:35 +0200 Subject: [PATCH 3/9] Added Grunt tasks to build the package using Docker --- Gruntfile.js | 4 ++++ README.md | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index f6abed2..1c4c77d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -92,6 +92,9 @@ module.exports = function (grunt) { "sudo rm -f -r /var/lib/gpii" ].join("&&") }, + prepareRpmEnv: { + command: "dnf install -y nodejs-grunt-cli npm alsa-lib-devel json-glib-devel PackageKit-glib-devel libXrandr-devel libgnome-keyring-devel sudo @development-tools rpmdevtools" + }, runAcceptanceTests: { command: "vagrant ssh -c 'DISPLAY=:0 node /home/vagrant/sync/tests/AcceptanceTests.js'" }, @@ -179,6 +182,7 @@ module.exports = function (grunt) { grunt.task.run("shell:runAcceptanceTests"); }); grunt.registerTask("buildrpm", "Build GPII Linux and RPM package", function () { + grunt.task.run("shell:prepareRpmEnv"); grunt.task.run("build"); grunt.task.run("easy_rpm"); }); diff --git a/README.md b/README.md index 2add2ee..35d9aa2 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,20 @@ this may prompt you for sudo access. grunt install grunt uninstall +## Building a RPM package + +We use Docker to build the RPM package in a clean environment, this also avoids +to polute your environment. + +To build a RPM package run the following command at the root of the git repository: + + docker run --rm -it \ + -v $(pwd):/sync fedora \ + /bin/bash -c "dnf install -y nodejs-grunt-cli; cp -r /sync /packages; cd /packages; grunt buildrpm; cp -r /packages/bin /sync" + +you will get the rpm package and the source files of the package in the ``bin`` +directory. + # Setting Up a Virtual Machine This repository contains content that will allow you to automatically provision a development VM. A [Vagrantfile](http://docs.vagrantup.com/v2/vagrantfile/) is provided that downloads a [Fedora Vagrant box](https://github.com/idi-ops/packer-fedora), starts a VM, and deploys the GPII Framework on it. From cb853f70967eee95a0298879cf7ede46692bd94b Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Thu, 28 Apr 2016 17:22:40 +0200 Subject: [PATCH 4/9] Simplified the command to build the package using Grunt --- Gruntfile.js | 6 ++++++ README.md | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1c4c77d..594c61d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -95,6 +95,9 @@ module.exports = function (grunt) { prepareRpmEnv: { command: "dnf install -y nodejs-grunt-cli npm alsa-lib-devel json-glib-devel PackageKit-glib-devel libXrandr-devel libgnome-keyring-devel sudo @development-tools rpmdevtools" }, + buildRpmDocker: { + command: "docker run --rm -i -v $(pwd):/sync fedora /bin/bash -c 'dnf install -y nodejs-grunt-cli; cp -r /sync /packages; cd /packages; grunt buildrpm; cp -r /packages/bin /sync'" + }, runAcceptanceTests: { command: "vagrant ssh -c 'DISPLAY=:0 node /home/vagrant/sync/tests/AcceptanceTests.js'" }, @@ -181,6 +184,9 @@ module.exports = function (grunt) { grunt.task.run("shell:runUnitTests"); grunt.task.run("shell:runAcceptanceTests"); }); + grunt.registerTask("buildRpmDocker", "Build Linux RPM package using a Docker container", function () { + grunt.task.run("shell:buildRpmDocker"); + }); grunt.registerTask("buildrpm", "Build GPII Linux and RPM package", function () { grunt.task.run("shell:prepareRpmEnv"); grunt.task.run("build"); diff --git a/README.md b/README.md index 35d9aa2..941a69d 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,7 @@ to polute your environment. To build a RPM package run the following command at the root of the git repository: - docker run --rm -it \ - -v $(pwd):/sync fedora \ - /bin/bash -c "dnf install -y nodejs-grunt-cli; cp -r /sync /packages; cd /packages; grunt buildrpm; cp -r /packages/bin /sync" + grunt buildRpmDocker you will get the rpm package and the source files of the package in the ``bin`` directory. From 178ad59d5e923ea8b765254a7856127244175cd4 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Thu, 28 Apr 2016 17:51:08 +0200 Subject: [PATCH 5/9] Removed debug file --- build/resources/gpii-linux-start | 1 - 1 file changed, 1 deletion(-) diff --git a/build/resources/gpii-linux-start b/build/resources/gpii-linux-start index 3df929a..3058793 100755 --- a/build/resources/gpii-linux-start +++ b/build/resources/gpii-linux-start @@ -1,5 +1,4 @@ #!/bin/sh systemctl --user import-environment -env > /tmp/env.gpii cd /opt/gpii-linux node gpii.js From 9f8aba1a9c2d983600b9214922729ebbfc819482 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Thu, 28 Apr 2016 17:51:58 +0200 Subject: [PATCH 6/9] Fixed typo --- build/resources/gpii-linux.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/resources/gpii-linux.service b/build/resources/gpii-linux.service index f9a08d8..46f3f34 100644 --- a/build/resources/gpii-linux.service +++ b/build/resources/gpii-linux.service @@ -1,6 +1,6 @@ # Use with Systemd > 219 [Unit] -Description=omponents of the GPII personalization infrastructure for use on Linux +Description=Components of the GPII personalization infrastructure for use on Linux Documentation=http://gpii.net [Service] From e5ada9be45623fe9f3383cdd2a774bcaaabd697c Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Fri, 29 Apr 2016 12:25:08 +0200 Subject: [PATCH 7/9] Changed the name of Grunt tasks --- Gruntfile.js | 6 +++--- README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 594c61d..4af56a7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -96,7 +96,7 @@ module.exports = function (grunt) { command: "dnf install -y nodejs-grunt-cli npm alsa-lib-devel json-glib-devel PackageKit-glib-devel libXrandr-devel libgnome-keyring-devel sudo @development-tools rpmdevtools" }, buildRpmDocker: { - command: "docker run --rm -i -v $(pwd):/sync fedora /bin/bash -c 'dnf install -y nodejs-grunt-cli; cp -r /sync /packages; cd /packages; grunt buildrpm; cp -r /packages/bin /sync'" + command: "docker run --rm -i -v $(pwd):/sync fedora /bin/bash -c 'dnf install -y nodejs-grunt-cli; cp -r /sync /packages; cd /packages; grunt build-rpm; cp -r /packages/bin /sync'" }, runAcceptanceTests: { command: "vagrant ssh -c 'DISPLAY=:0 node /home/vagrant/sync/tests/AcceptanceTests.js'" @@ -184,10 +184,10 @@ module.exports = function (grunt) { grunt.task.run("shell:runUnitTests"); grunt.task.run("shell:runAcceptanceTests"); }); - grunt.registerTask("buildRpmDocker", "Build Linux RPM package using a Docker container", function () { + grunt.registerTask("build-rpm-docker", "Build Linux RPM package using a Docker container", function () { grunt.task.run("shell:buildRpmDocker"); }); - grunt.registerTask("buildrpm", "Build GPII Linux and RPM package", function () { + grunt.registerTask("build-rpm", "Build GPII Linux and RPM package", function () { grunt.task.run("shell:prepareRpmEnv"); grunt.task.run("build"); grunt.task.run("easy_rpm"); diff --git a/README.md b/README.md index 941a69d..d1357f5 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ to polute your environment. To build a RPM package run the following command at the root of the git repository: - grunt buildRpmDocker + grunt build-rpm-docker you will get the rpm package and the source files of the package in the ``bin`` directory. From e292b63a67baa4218d8b78b7d5250b99ce1caff3 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Wed, 15 Jun 2016 15:23:13 +0200 Subject: [PATCH 8/9] Merged Gruntfile.js --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4af56a7..d3ca0f6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,7 +23,6 @@ module.exports = function (grunt) { var gypCompileCmd = "node-gyp configure build"; var gypCleanCmd = "node-gyp clean"; var pkgdata = require('./package.json'); - var currentArch = (function() { if (process.arch == 'ia32') return 'i386'; @@ -193,4 +192,5 @@ module.exports = function (grunt) { grunt.task.run("easy_rpm"); }); grunt.loadNpmTasks("grunt-easy-rpm"); + grunt.loadTasks('tasks'); }; From 7868efc92a229b9eb84bc26fe7dd55a1e0f98e76 Mon Sep 17 00:00:00 2001 From: Alfredo Matas Date: Mon, 26 Sep 2016 14:21:02 +0200 Subject: [PATCH 9/9] Fix license variable reference --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index d3ca0f6..ff23d61 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -111,7 +111,7 @@ module.exports = function (grunt) { rpmDestination: "bin", tempDir: "bin/tmp", keepTemp: true, - license: pkgdata.licenses[0].type, + license: pkgdata.license, url: pkgdata.homepage, buildArch: currentArch, requires: [