Skip to content

Commit 44f18be

Browse files
committedFeb 18, 2017
Add the ability to generate rpm and deb packages
This uses fpm and the commands are `gulp deploy:linux-$arch:$type`. For example, `gulp deploy:linux-x64:rpm` will create an RPM for 64-bit Fedora.
1 parent 9ade528 commit 44f18be

File tree

6 files changed

+89
-0
lines changed

6 files changed

+89
-0
lines changed
 

‎README.md

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ $ npm run deploy
117117
$ npm run deploy:darwin-x64
118118
```
119119

120+
If you have [fpm](https://github.com/jordansissel/fpm) installed (`gem install fpm`), you can also build RPM and Deb packages:
121+
122+
```bash
123+
$ npm run deploy:linux-x64:rpm
124+
$ npm run deploy:linux-x64:deb
125+
```
126+
120127
*note:* if you are building *Windows* binaries in *Linux* or *Mac OS X*, Wine (1.6 or higher) must be installed. It also requires a 32-bit Wine installation when building Windows 32-bit binary.
121128

122129
### Structure

‎gulpfile.coffee

+53
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,56 @@ deploy = (platform, arch) ->
332332
else
333333
zipIt zippath, fileprefix, -> deferred.resolve()
334334
deferred.promise
335+
336+
["ia32", "x64"].forEach (arch) ->
337+
['deb', 'rpm'].forEach (target) ->
338+
gulp.task 'deploy:linux-' + arch + ':' + target, (done) ->
339+
if arch is 'ia32'
340+
archName = 'i386'
341+
else if target is 'deb'
342+
archName = 'amd64'
343+
else
344+
archName = 'x86_64'
345+
346+
packageName = json.name + '-VERSION-linux-ARCH.' + target
347+
iconArgs = [16, 32, 48, 128, 256, 512].map (size) ->
348+
if size < 100
349+
src = "0#{size}"
350+
else
351+
src = size
352+
"./src/icons/icon_#{src}.png=/usr/share/icons/hicolor/#{size}x#{size}/apps/#{json.name}.png"
353+
fpmArgs = [
354+
'-s', 'dir'
355+
'-t', target
356+
'--architecture', archName
357+
'--rpm-os', 'linux'
358+
'--name', json.name
359+
'--force' # Overwrite existing files
360+
'--license', json.license
361+
'--description', json.description
362+
'--url', json.homepage
363+
'--maintainer', json.author
364+
'--vendor', json.authorName
365+
'--version', json.version
366+
'--package', "./dist/#{packageName}"
367+
'--after-install', './resources/linux/after-install.sh'
368+
'--after-remove', './resources/linux/after-remove.sh'
369+
"./dist/#{json.name}-linux-#{arch}/.=/opt/#{json.name}"
370+
"./resources/linux/app.desktop=/usr/share/applications/#{json.name}.desktop"
371+
].concat iconArgs
372+
373+
child = spawn 'fpm', fpmArgs
374+
# log all errors
375+
child.on 'error', (err) ->
376+
console.log 'Error: ' + err
377+
process.exit(1)
378+
# show err
379+
child.on 'exit', (code) ->
380+
if code == 0
381+
console.log "Created #{target} (#{packageName})"
382+
done()
383+
else
384+
console.log "Possible problem with #{target} #{packageName} " +
385+
"-- (exit with #{code})"
386+
done()
387+
process.exit(1)

‎package.json

+4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
"deploy:win32": "gulp deploy:win32",
1515
"deploy:darwin": "gulp deploy:darwin",
1616
"deploy:linux-x64": "gulp deploy:linux-x64",
17+
"deploy:linux-x64:deb": "gulp deploy:linux-x64:deb",
18+
"deploy:linux-x64:rpm": "gulp deploy:linux-x64:rpm",
1719
"deploy:linux-ia32": "gulp deploy:linux-ia32",
20+
"deploy:linux-ia32:deb": "gulp deploy:linux-ia32:deb",
21+
"deploy:linux-ia32:rpm": "gulp deploy:linux-ia32:rpm",
1822
"deploy:win32-x64": "gulp deploy:win32-x64",
1923
"deploy:win32-ia32": "gulp deploy:win32-ia32",
2024
"deploy:darwin-x64": "gulp deploy:darwin-x64"

‎resources/linux/after-install.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# Link to the binary
4+
ln -sf /opt/yakyak/yakyak /usr/bin/yakyak
5+
6+
# Update icon cache
7+
/bin/touch --no-create /usr/share/icons/hicolor &>/dev/null
8+
/usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor &>/dev/null || :

‎resources/linux/after-remove.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Delete the link to the binary
4+
rm -f /usr/bin/yakyak

‎resources/linux/app.desktop

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Desktop Entry]
2+
Name=YakYak
3+
Comment=Chat client for Google Hangouts
4+
GenericName=YakYak
5+
Exec=/opt/yakyak/yakyak %U
6+
Icon=yakyak
7+
Terminal=false
8+
Type=Application
9+
StartupNotify=true
10+
#StartupWMClass=YakYak
11+
Keywords=hangouts;messenger
12+
Categories=Network;InstantMessaging
13+
X-GNOME-UsesNotifications=true

0 commit comments

Comments
 (0)
Please sign in to comment.