Merge pull request #2949 from Tyriar/2679_deb_package
Add gulp tasks to build deb packages
This commit is contained in:
commit
aec4996f73
7 changed files with 114 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ out-editor/
|
|||
out-editor-min/
|
||||
out-editor-ossfree/
|
||||
out-editor-ossfree-min/
|
||||
out-linux/
|
||||
out-vscode/
|
||||
out-vscode-min/
|
||||
build/node_modules
|
|
@ -32,6 +32,7 @@ var indentationFilter = [
|
|||
'**',
|
||||
'!ThirdPartyNotices.txt',
|
||||
'!**/*.md',
|
||||
'!**/*.template',
|
||||
'!**/*.yml',
|
||||
'!**/lib/**',
|
||||
'!**/*.d.ts',
|
||||
|
@ -58,8 +59,10 @@ var indentationFilter = [
|
|||
|
||||
var copyrightFilter = [
|
||||
'**',
|
||||
'!**/*.desktop',
|
||||
'!**/*.json',
|
||||
'!**/*.html',
|
||||
'!**/*.template',
|
||||
'!**/test/**',
|
||||
'!**/*.md',
|
||||
'!**/*.bat',
|
||||
|
|
|
@ -13,10 +13,12 @@ var azure = require('gulp-azure-storage');
|
|||
var electron = require('gulp-atom-electron');
|
||||
var symdest = require('gulp-symdest');
|
||||
var rename = require('gulp-rename');
|
||||
var replace = require('gulp-replace');
|
||||
var filter = require('gulp-filter');
|
||||
var json = require('gulp-json-editor');
|
||||
var insert = require('gulp-insert');
|
||||
var remote = require('gulp-remote-src');
|
||||
var shell = require("gulp-shell");
|
||||
var File = require('vinyl');
|
||||
var rimraf = require('rimraf');
|
||||
var _ = require('underscore');
|
||||
|
@ -215,7 +217,7 @@ function packageTask(platform, arch, opts) {
|
|||
.pipe(util.cleanNodeModule('native-keymap', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], true))
|
||||
.pipe(util.cleanNodeModule('weak', ['binding.gyp', 'build/**', 'src/**'], true));
|
||||
|
||||
var resources = gulp.src('resources/*', { base: '.' });
|
||||
var resources = gulp.src(['resources/*','resources/common/**'], { base: '.' });
|
||||
|
||||
if (platform === 'win32') {
|
||||
resources = es.merge(resources, gulp.src('resources/win32/code_file.ico', { base: '.' }));
|
||||
|
@ -257,11 +259,88 @@ function packageTask(platform, arch, opts) {
|
|||
};
|
||||
}
|
||||
|
||||
function getFolderSize(root) {
|
||||
var size = 0;
|
||||
var paths = [root];
|
||||
while (paths.length > 0) {
|
||||
var current = path.normalize(paths.pop());
|
||||
var stat = fs.statSync(current);
|
||||
size += stat.size;
|
||||
if (stat.isDirectory()) {
|
||||
var newPaths = fs.readdirSync(current);
|
||||
newPaths.forEach(function(newPath) {
|
||||
paths.push(path.join(current, newPath));
|
||||
});
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
function getDebPackageArch(arch) {
|
||||
if (arch === 'x64')
|
||||
return 'amd64'
|
||||
if (arch === 'ia32')
|
||||
return 'i386';
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function prepareDebPackage(arch) {
|
||||
var binaryDir = '../VSCode-linux-' + arch;
|
||||
var debArch = getDebPackageArch(arch);
|
||||
var destination = './out-linux/vscode-' + debArch;
|
||||
var packageRevision = '1';
|
||||
|
||||
return function () {
|
||||
var shortcut = gulp.src('resources/common/bin/code.sh', { base: '.' })
|
||||
.pipe(rename(function (p) {
|
||||
p.extname = ''
|
||||
p.dirname = 'usr/bin';
|
||||
}));
|
||||
|
||||
var desktop = gulp.src('resources/linux/debian/code.desktop', { base: '.' })
|
||||
.pipe(rename(function (p) { p.dirname = 'usr/share/applications'; }));
|
||||
|
||||
var icon = gulp.src('resources/linux/code.png', { base: '.' })
|
||||
.pipe(rename(function (p) { p.dirname = 'usr/share/pixmaps'; }));
|
||||
|
||||
var installedSize = Math.ceil(getFolderSize(root + '/' + binaryDir) / 1024);
|
||||
|
||||
var control = gulp.src('resources/linux/debian/control.template', { base: '.' })
|
||||
.pipe(replace('@@VERSION@@', packageJson.version + '-' + packageRevision))
|
||||
.pipe(replace('@@ARCHITECTURE@@', debArch))
|
||||
.pipe(replace('@@INSTALLEDSIZE@@', installedSize))
|
||||
.pipe(rename(function (p) {
|
||||
p.extname = '';
|
||||
p.dirname = 'DEBIAN';
|
||||
}));
|
||||
|
||||
var all = es.merge(
|
||||
control,
|
||||
desktop,
|
||||
icon,
|
||||
shortcut);
|
||||
|
||||
all.pipe(symdest(destination));
|
||||
|
||||
var binaryResult = gulp.src(binaryDir + '/**/*', { base: binaryDir })
|
||||
.pipe(gulp.dest(destination + '/usr/share/code'));
|
||||
|
||||
return es.merge(all, binaryResult);
|
||||
};
|
||||
}
|
||||
|
||||
function buildDebPackage(arch) {
|
||||
var debArch = getDebPackageArch(arch);
|
||||
return shell.task(['fakeroot dpkg-deb -b ' + path.join(root, 'out-linux', 'vscode-' + debArch)]);
|
||||
}
|
||||
|
||||
gulp.task('clean-vscode-win32', util.rimraf(path.join(path.dirname(root), 'VSCode-win32')));
|
||||
gulp.task('clean-vscode-darwin', util.rimraf(path.join(path.dirname(root), 'VSCode-darwin')));
|
||||
gulp.task('clean-vscode-linux-ia32', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-ia32')));
|
||||
gulp.task('clean-vscode-linux-x64', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-x64')));
|
||||
gulp.task('clean-vscode-linux-arm', util.rimraf(path.join(path.dirname(root), 'VSCode-linux-arm')));
|
||||
gulp.task('clean-vscode-linux-ia32-deb', util.rimraf('out-linux/vscode-i386*'));
|
||||
gulp.task('clean-vscode-linux-x64-deb', util.rimraf('out-linux/vscode-amd64*'));
|
||||
|
||||
gulp.task('vscode-win32', ['optimize-vscode', 'clean-vscode-win32'], packageTask('win32'));
|
||||
gulp.task('vscode-darwin', ['optimize-vscode', 'clean-vscode-darwin'], packageTask('darwin'));
|
||||
|
@ -275,6 +354,12 @@ gulp.task('vscode-linux-ia32-min', ['minify-vscode', 'clean-vscode-linux-ia32'],
|
|||
gulp.task('vscode-linux-x64-min', ['minify-vscode', 'clean-vscode-linux-x64'], packageTask('linux', 'x64', { minified: true }));
|
||||
gulp.task('vscode-linux-arm-min', ['minify-vscode', 'clean-vscode-linux-arm'], packageTask('linux', 'arm', { minified: true }));
|
||||
|
||||
gulp.task('vscode-linux-ia32-prepare-deb', ['clean-vscode-linux-ia32-deb', 'vscode-linux-ia32'], prepareDebPackage('ia32'));
|
||||
gulp.task('vscode-linux-x64-prepare-deb', ['clean-vscode-linux-x64-deb'/*, 'vscode-linux-x64'*/], prepareDebPackage('x64'));
|
||||
gulp.task('vscode-linux-ia32-build-deb', ['vscode-linux-ia32-prepare-deb'], buildDebPackage('ia32'));
|
||||
gulp.task('vscode-linux-x64-build-deb', ['vscode-linux-x64-prepare-deb'], buildDebPackage('x64'));
|
||||
gulp.task('vscode-linux-packages', ['vscode-linux-ia32-build-deb', 'vscode-linux-x64-build-deb']);
|
||||
|
||||
// Sourcemaps
|
||||
|
||||
gulp.task('vscode-sourcemaps', ['minify-vscode'], function () {
|
||||
|
@ -285,4 +370,4 @@ gulp.task('vscode-sourcemaps', ['minify-vscode'], function () {
|
|||
container: 'sourcemaps',
|
||||
prefix: commit + '/'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
"gulp-mocha": "^2.1.3",
|
||||
"gulp-remote-src": "^0.4.0",
|
||||
"gulp-rename": "^1.2.0",
|
||||
"gulp-replace": "^0.5.4",
|
||||
"gulp-shell": "^0.5.2",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"gulp-symdest": "^1.0.0",
|
||||
"gulp-tsb": "^1.10.1",
|
||||
|
|
|
@ -25,7 +25,7 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
VSCODE_LAUNCHER="$VSCODE_DIR/launcher.js"
|
||||
VSCODE_LAUNCHER="$VSCODE_DIR/resources/app/resources/common/bin/launcher.js"
|
||||
|
||||
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 VSCODE_PATH="$VSCODE_DIR/$ELECTRON_FILE" \
|
||||
"$VSCODE_DIR/$ELECTRON_FILE" $VSCODE_LAUNCHER "$@"
|
||||
|
|
10
resources/linux/debian/code.desktop
Normal file
10
resources/linux/debian/code.desktop
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Desktop Entry]
|
||||
Name=Visual Studio Code
|
||||
Comment=Code Editing. Redefined.
|
||||
GenericName=Text Editor
|
||||
Exec=/usr/bin/code %U
|
||||
Icon=code
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
Categories=Utility;TextEditor;Development;IDE;
|
||||
MimeType=text/plain;
|
10
resources/linux/debian/control.template
Normal file
10
resources/linux/debian/control.template
Normal file
|
@ -0,0 +1,10 @@
|
|||
Package: visual-studio-code
|
||||
Version: @@VERSION@@
|
||||
Section: devel
|
||||
Priority: optional
|
||||
Architecture: @@ARCHITECTURE@@
|
||||
Maintainer: Microsoft Corporation <vscode-linux@microsoft.com>
|
||||
Homepage: https://github.com/Microsoft/vscode
|
||||
Installed-Size: @@INSTALLEDSIZE@@
|
||||
Description: Code Editing. Redefined.
|
||||
Build and debug modern web and cloud applications.
|
Loading…
Reference in a new issue