Use 7zip to manipulate windows zip archives

This commit is contained in:
Yuya Ochiai 2016-10-07 23:49:39 +09:00
parent 3c63d98960
commit e5c5ca9d9a
2 changed files with 35 additions and 5 deletions

View file

@ -24,13 +24,15 @@
"watch": "gulp watch", "watch": "gulp watch",
"serve": "gulp watch", "serve": "gulp watch",
"test": "gulp build && mocha --reporter mocha-circleci-reporter --recursive test/specs && gulp prettify:verify", "test": "gulp build && mocha --reporter mocha-circleci-reporter --recursive test/specs && gulp prettify:verify",
"package:all": "build -wml --x64 --ia32", "package:all": "build -wml --x64 --ia32 && npm run manipulate-windows-zip",
"package:windows": "build --win --x64 --ia32", "package:windows": "build --win --x64 --ia32 && npm run manipulate-windows-zip",
"package:mac": "build --mac --x64 --ia32", "package:mac": "build --mac --x64 --ia32",
"package:linux": "build --linux --x64 --ia32", "package:linux": "build --linux --x64 --ia32",
"manipulate-windows-zip": "node scripts/manipulate_windows_zip.js",
"prettify": "gulp prettify" "prettify": "gulp prettify"
}, },
"devDependencies": { "devDependencies": {
"7zip-bin": "^2.0.1",
"babel-core": "^6.7.5", "babel-core": "^6.7.5",
"babel-loader": "^6.2.4", "babel-loader": "^6.2.4",
"babel-preset-react": "^6.5.0", "babel-preset-react": "^6.5.0",
@ -61,7 +63,10 @@
"appId": "com.mattermost.desktop", "appId": "com.mattermost.desktop",
"linux": { "linux": {
"category": "InstantMessaging", "category": "InstantMessaging",
"target": ["deb", "tar.gz"], "target": [
"deb",
"tar.gz"
],
"synopsis": "Mattermost", "synopsis": "Mattermost",
"extraFiles": [{ "extraFiles": [{
"from": "resources", "from": "resources",
@ -73,11 +78,16 @@
}, },
"mac": { "mac": {
"category": "public.app-category.productivity", "category": "public.app-category.productivity",
"target": ["tar.gz"] "target": [
"tar.gz"
]
}, },
"win": { "win": {
"description": "Mattermost", "description": "Mattermost",
"target": ["squirrel", "zip"], "target": [
"squirrel",
"zip"
],
"iconUrl": "https://raw.githubusercontent.com/mattermost/desktop/master/resources/icon.ico" "iconUrl": "https://raw.githubusercontent.com/mattermost/desktop/master/resources/icon.ico"
} }
}, },

View file

@ -0,0 +1,20 @@
'use strict';
const spawnSync = require('child_process').spawnSync;
const path7za = require('7zip-bin').path7za;
const appVersion = require('../package.json').version;
function renameInZip(zipPath, oldName, newName) {
const result = spawnSync(path7za, ['rn', zipPath, oldName, newName]);
return result.status === 0;
}
console.log('Manipulating 64-bit zip...');
if (!renameInZip(`release/Mattermost-${appVersion}-win.zip`, 'win-unpacked', `Mattermost-${appVersion}-win64`)) {
throw new Error('7za returned non-zero exit code for 64-bit zip');
}
console.log('Manipulating 32-bit zip...');
if (!renameInZip(`release/Mattermost-${appVersion}-ia32-win.zip`, 'win-ia32-unpacked', `Mattermost-${appVersion}-win32`)) {
throw new Error('7za returned non-zero exit code for 32-bit zip');
}