Skip to content
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

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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 @@ -22,6 +22,15 @@ 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 @@ -43,6 +52,9 @@ module.exports = function (grunt) {
jsonlint: {
src: ["gpii/**/*.json"]
},
appFileName: "gpii-linux",
buildDir: "build",
pkgdata: pkgdata,
shell: {
options: {
stdout: true,
Expand Down Expand Up @@ -79,12 +91,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"
},
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.license,
url: pkgdata.homepage,
buildArch: currentArch,
requires: [
"nodejs >= 0.10.42",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this >= 6.9.2 just to ensure people are using a modern environment?

"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 @@ -132,4 +183,14 @@ 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");
grunt.loadTasks('tasks');
};
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
to polute your environment.

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

grunt build-rpm-docker
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to run npm install grunt-easy-rpm before this command would work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting the following error:

cp: cannot access '/sync': Permission denied
grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started
cp: cannot stat '/packages/bin': No such file or directory
Warning: Command failed: 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'
Unable to find image 'fedora:latest' locally
Trying to pull repository docker.io/library/fedora ... 
sha256:fbeff4f6ec6ce2393c77aff9b34e19e8a9e355fd46664613f14a36394adf8e71: Pulling from docker.io/library/fedora
5b0bacb7828e: Pulling fs layer
5b0bacb7828e: Download complete
5b0bacb7828e: Pull complete
Digest: sha256:fbeff4f6ec6ce2393c77aff9b34e19e8a9e355fd46664613f14a36394adf8e71
Status: Downloaded newer image for docker.io/fedora:latest
warning: /var/cache/dnf/fedora-310f9d37d74ceec1/packages/nodejs-grunt-cli-1.2.0-1.fc25.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fdb19c98: NOKEY
Importing GPG key 0xFDB19C98:
 Userid     : "Fedora 25 Primary (25) <[email protected]>"
 Fingerprint: C437 DCCD 558A 66A3 7D6F 4372 4089 D8F2 FDB1 9C98
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-25-x86_64
cp: cannot access '/sync': Permission denied
cp: cannot stat '/packages/bin': No such file or directory
 Use --force to continue.

Aborted due to warnings.

Full output: https://gist.github.com/gtirloni/6edd489d441f476869cb2638fdabd250

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the directories /sync and /packages don't exist inside the official fedora image.

I'm wondering if basing this work on our RPM builder image would be better (https://github.com/idi-ops/docker-centos-rpm-builder), but I guess that would be built against CentOS and we're targeting Fedora desktop packages here, right? Maybe this affords building a docker-fedora-rpm-builder image too.


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
WorkingDirectory=/opt/gpii-linux
Restart=on-failure

[Install]
WantedBy=default.target