Skip to content

#GPII-1740: Implement automatic build of Linux Package #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
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
61 changes: 61 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 {
Expand All @@ -46,6 +56,9 @@ module.exports = function (grunt) {
jsonlint: {
src: ["gpii/**/*.json", "tests/**/*.json"]
},
appFileName: "gpii-linux",
buildDir: "build",
pkgdata: pkgdata,
shell: {
options: {
stdout: true,
Expand Down Expand Up @@ -82,12 +95,51 @@ 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the IDI ansible-nodejs role should be used so that these dependencies don't have to be tracked in multiple places. This repo uses that role to install these packages like so:

https://github.com/GPII/linux/blob/master/provisioning/vars.yml#L17-L37

},
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 build-rpm; cp -r /packages/bin /sync'"
},
runAcceptanceTests: {
command: "vagrant ssh -c 'DISPLAY=:0 node /home/vagrant/sync/tests/AcceptanceTests.js'"
},
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: "/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'}
],
excludeFiles: [
"../node_modules/**/examples/switch-bench.js" //avoid strange dependency
]
},
}
});

Expand Down Expand Up @@ -128,4 +180,13 @@ module.exports = function (grunt) {
grunt.task.run("shell:runUnitTests");
grunt.task.run("shell:runAcceptanceTests");
});
grunt.registerTask("build-rpm-docker", "Build Linux RPM package using a Docker container", function () {
grunt.task.run("shell:buildRpmDocker");
});
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");
});
grunt.loadNpmTasks("grunt-easy-rpm");
};
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a Dockerfile that was meant to be included as part of this PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't necessary because it uses the Fedora container to build the RPM package. I believe we don't need to build a container in this case.

to polute your environment.

To build a RPM package run the following command at the root of the git repository:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work for someone using OS X or Windows? Should they use a Linux VM for this task? Those details should be explained here.


grunt build-rpm-docker

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.
Expand Down
5 changes: 5 additions & 0 deletions build/resources/gpii-linux-autostart.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Desktop Entry]
Type=Application
Name=GPII Linux
Exec=/usr/bin/gpii-linux-start
OnlyShowIn=GNOME;
4 changes: 4 additions & 0 deletions build/resources/gpii-linux-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
systemctl --user import-environment
cd /opt/gpii-linux
node gpii.js
14 changes: 14 additions & 0 deletions build/resources/gpii-linux.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use with Systemd > 219
[Unit]
Description=Components of the GPII personalization infrastructure for use on Linux
Documentation=http://gpii.net

[Service]
Type=simple
ExecStart=/usr/bin/gpii-linux-start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refer to the comment above regarding the use of the IDI ansible-nodejs role which provides a systemd unit template.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Systemd unit uses the Systemd User feature to launch GPII with user pemissions at log in time. The environment variables like dbus socket or policykit resources are set by pam.d at login time and retrieved by the command systemctl --user import-environment when the service is launched. The ansible-nodejs wasn't made for the previous purpose. For example, the user and group statements don't make sense here because, Systemd will set the user's UID and GID to the child processes.

Anyway this unit can only be use in >=Fedora 23 because Fedora 22 has a minor version of Systemd that doesn't have that feature.

WorkingDirectory=/opt/gpii-linux
Restart=on-failure

[Install]
WantedBy=default.target

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"grunt-shell": "0.6.4",
"grunt-contrib-jshint": "~0.9.0",
"grunt-jsonlint": "1.0.4",
"grunt-gpii": "git://github.com/GPII/grunt-gpii.git#ec8412064e107febb120f0b7437d403453b40d2d"
"grunt-gpii": "git://github.com/GPII/grunt-gpii.git#ec8412064e107febb120f0b7437d403453b40d2d",
"grunt-easy-rpm": "1.5.5"
},
"licenses": [
{
Expand Down