Skip to content

Commit 3ddbbe9

Browse files
committed
Implement .rpm package gulp task
.rpm packages can now be build with: gulp vscode-linux-<arch>-build-rpm The resulting package will be output to ~/rpmbuild/RPMS/<arch>/ and can be installed on a Red Hat-based distro with: yum localinstall <path> Note that Debian systems can build the package after installing the 'rpm' package: apt-get install rpm This was tested building 64-bit on Ubuntu 15.10 and installing on CentOS 7. Fixes microsoft#3595
1 parent 571ba1f commit 3ddbbe9

3 files changed

Lines changed: 84 additions & 5 deletions

File tree

build/gulpfile.vscode.js

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,16 @@ function prepareDebPackage(arch) {
255255
var packageRevision = getEpochTime();
256256

257257
return function () {
258-
var shortcut = gulp.src('resources/linux/bin/code.sh')
258+
var shortcut = gulp.src('resources/linux/bin/code.sh', { base: '.' })
259259
.pipe(replace('@@NAME@@', product.applicationName))
260260
.pipe(rename('usr/bin/' + product.applicationName));
261261

262-
var desktop = gulp.src('resources/linux/debian/code.desktop')
262+
var desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
263263
.pipe(replace('@@NAME_LONG@@', product.nameLong))
264264
.pipe(replace('@@NAME@@', product.applicationName))
265265
.pipe(rename('usr/share/applications/' + product.applicationName + '.desktop'));
266266

267-
var icon = gulp.src('resources/linux/code.png')
267+
var icon = gulp.src('resources/linux/code.png', { base: '.' })
268268
.pipe(rename('usr/share/pixmaps/' + product.applicationName + '.png'));
269269

270270
var code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
@@ -306,8 +306,7 @@ function prepareDebPackage(arch) {
306306
all = es.merge(all, postinst);
307307
}
308308

309-
return all
310-
.pipe(symdest(destination));
309+
return all.pipe(symdest(destination));
311310
};
312311
}
313312

@@ -320,13 +319,59 @@ function buildDebPackage(arch) {
320319
], { cwd: '.build/linux/' + debArch});
321320
}
322321

322+
function getRpmBuildPath() {
323+
return path.join(process.env['HOME'], 'rpmbuild');
324+
}
325+
326+
function prepareRpmPackage(arch) {
327+
var binaryDir = '../VSCode-linux-' + arch;
328+
var destination = process.env['HOME'] + '/rpmbuild';
329+
var packageRevision = getEpochTime();
330+
331+
return function () {
332+
var shortcut = gulp.src('resources/linux/bin/code.sh', { base: '.' })
333+
.pipe(replace('@@NAME@@', product.applicationName))
334+
.pipe(rename('BUILD/usr/bin/' + product.applicationName));
335+
336+
var desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
337+
.pipe(replace('@@NAME_LONG@@', product.nameLong))
338+
.pipe(replace('@@NAME@@', product.applicationName))
339+
.pipe(rename('BUILD/usr/share/applications/' + product.applicationName + '.desktop'));
340+
341+
var icon = gulp.src('resources/linux/code.png', { base: '.' })
342+
.pipe(rename('BUILD/usr/share/pixmaps/' + product.applicationName + '.png'));
343+
344+
var code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
345+
.pipe(rename(function (p) { p.dirname = 'BUILD/usr/share/' + product.applicationName + '/' + p.dirname; }));
346+
347+
var spec = gulp.src('resources/linux/rpm/code.spec.template', { base: '.' })
348+
.pipe(replace('@@NAME@@', product.applicationName))
349+
.pipe(replace('@@VERSION@@', packageJson.version))
350+
.pipe(replace('@@RELEASE@@', packageRevision))
351+
.pipe(rename('SPECS/' + product.applicationName + '.spec'));
352+
353+
var all = es.merge(code, desktop, icon, shortcut, spec);
354+
355+
return all.pipe(symdest(destination));
356+
}
357+
}
358+
359+
function buildRpmPackage() {
360+
return shell.task([
361+
'fakeroot rpmbuild -ba ' + getRpmBuildPath() + '/SPECS/' + product.applicationName + '.spec',
362+
]);
363+
}
364+
323365
gulp.task('clean-vscode-win32', util.rimraf(path.join(path.dirname(root), 'VSCode-win32')));
324366
gulp.task('clean-vscode-darwin', util.rimraf(path.join(path.dirname(root), 'VSCode-darwin')));
325367
gulp.task('clean-vscode-linux-ia32', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-ia32')));
326368
gulp.task('clean-vscode-linux-x64', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-x64')));
327369
gulp.task('clean-vscode-linux-arm', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-arm')));
328370
gulp.task('clean-vscode-linux-ia32-deb', util.rimraf('.build/linux/i386'));
329371
gulp.task('clean-vscode-linux-x64-deb', util.rimraf('.build/linux/amd64'));
372+
gulp.task('clean-vscode-linux-ia32-rpm', util.rimraf('.build/linux/rpm/i386'));
373+
gulp.task('clean-vscode-linux-x64-rpm', util.rimraf('.build/linux/rpm/x86_64'));
374+
gulp.task('clean-rpmbuild', util.rimraf(getRpmBuildPath()));
330375

331376
gulp.task('vscode-win32', ['optimize-vscode', 'clean-vscode-win32'], packageTask('win32'));
332377
gulp.task('vscode-darwin', ['optimize-vscode', 'clean-vscode-darwin'], packageTask('darwin'));
@@ -345,6 +390,11 @@ gulp.task('vscode-linux-x64-prepare-deb', ['clean-vscode-linux-x64-deb', 'vscode
345390
gulp.task('vscode-linux-ia32-build-deb', ['vscode-linux-ia32-prepare-deb'], buildDebPackage('ia32'));
346391
gulp.task('vscode-linux-x64-build-deb', ['vscode-linux-x64-prepare-deb'], buildDebPackage('x64'));
347392

393+
gulp.task('vscode-linux-ia32-prepare-rpm', ['clean-rpmbuild', 'clean-vscode-linux-ia32-rpm', 'vscode-linux-ia32-min'], prepareRpmPackage('ia32'));
394+
gulp.task('vscode-linux-x64-prepare-rpm', ['clean-rpmbuild', 'clean-vscode-linux-x64-rpm', 'vscode-linux-x64-min'], prepareRpmPackage('x64'));
395+
gulp.task('vscode-linux-ia32-build-rpm', ['vscode-linux-ia32-prepare-rpm'], buildRpmPackage());
396+
gulp.task('vscode-linux-x64-build-rpm', ['vscode-linux-x64-prepare-rpm'], buildRpmPackage());
397+
348398
// Sourcemaps
349399

350400
gulp.task('upload-vscode-sourcemaps', ['minify-vscode'], function () {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Name: @@NAME@@
2+
Version: @@VERSION@@
3+
Release: @@RELEASE@@
4+
Summary: Code editing. Redefined.
5+
License: MIT
6+
URL: https://code.visualstudio.com/
7+
Requires: git
8+
AutoReq: 0
9+
10+
%description
11+
Visual Studio Code is a new choice of tool that combines the simplicity of a code editor with what developers need for the core edit-build-debug cycle.
12+
13+
%install
14+
mkdir -p %{buildroot}/usr/bin
15+
cp -r usr/bin/@@NAME@@ %{buildroot}/usr/bin
16+
mkdir -p %{buildroot}/usr/share/@@NAME@@
17+
cp -r usr/share/@@NAME@@/* %{buildroot}/usr/share/@@NAME@@
18+
mkdir -p %{buildroot}/usr/share/applications
19+
cp -r usr/share/applications/@@NAME@@.desktop %{buildroot}/usr/share/applications
20+
mkdir -p %{buildroot}/usr/share/pixmaps
21+
cp -r usr/share/pixmaps/@@NAME@@.png %{buildroot}/usr/share/pixmaps
22+
23+
%files
24+
%defattr(-,root,root)
25+
26+
/usr/bin/@@NAME@@
27+
/usr/share/@@NAME@@/
28+
/usr/share/applications/@@NAME@@.desktop
29+
/usr/share/pixmaps/@@NAME@@.png

0 commit comments

Comments
 (0)