summarylogtreecommitdiffstats
path: root/use-system-7za-and-disable-updater.patch
blob: cd267c267f0196c68ae208bf2e3c820319cd268e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
diff --git i/public/electron.js w/public/electron.js
index 63683319..4b9879fc 100644
--- i/public/electron.js
+++ w/public/electron.js
@@ -12,7 +12,6 @@ const {
 } = require('electron');
 const path = require('path');
 const { spawn, exec } = require('child_process');
-const { autoUpdater } = require('electron-updater');
 const log = require('electron-log');
 const fss = require('fs');
 const os = require('os');
@@ -240,41 +239,6 @@ try {
 
 log.log(process.env.REACT_APP_RELEASE_TYPE, app.getVersion());
 
-const get7zPath = async () => {
-  let baseDir = path.dirname(app.getPath('exe'));
-  if (isDev) {
-    baseDir = path.resolve(baseDir, '../../');
-    if (process.platform === 'win32') {
-      baseDir = path.join(baseDir, '7zip-bin/win/x64');
-    } else if (process.platform === 'linux') {
-      baseDir = path.join(baseDir, '7zip-bin/linux', process.arch);
-    } else if (process.platform === 'darwin') {
-      baseDir = path.resolve(baseDir, '../../../', '7zip-bin/mac/x64');
-    }
-  }
-  if (process.platform === 'linux') {
-    return path.join(baseDir, '7za');
-  }
-  if (process.platform === 'darwin') {
-    return path.resolve(baseDir, isDev ? '' : '../', '7za');
-  }
-  return path.join(baseDir, '7za.exe');
-};
-
-async function patchSevenZip() {
-  try {
-    if (process.platform === 'linux' || process.platform === 'darwin') {
-      const sevenZipPath = await get7zPath();
-      await promisify(exec)(`chmod +x "${sevenZipPath}"`);
-      await promisify(exec)(`chmod 755 "${sevenZipPath}"`);
-    }
-  } catch (e) {
-    log.error(e);
-  }
-}
-
-patchSevenZip();
-
 function createWindow() {
   mainWindow = new BrowserWindow({
     width: 1100,
@@ -932,79 +896,3 @@ ipcMain.handle('calculateMurmur2FromPath', async (e, filePath) => {
   const res = await napi.computePathMurmur(filePath);
   return res.toString();
 });
-
-// AutoUpdater
-
-if (process.env.REACT_APP_RELEASE_TYPE === 'setup') {
-  autoUpdater.autoDownload = false;
-  autoUpdater.allowDowngrade =
-    !allowUnstableReleases && app.getVersion().includes('beta');
-  autoUpdater.allowPrerelease = allowUnstableReleases;
-  autoUpdater.setFeedURL({
-    owner: 'gorilla-devs',
-    repo: 'GDLauncher',
-    provider: 'github'
-  });
-
-  autoUpdater.on('update-available', () => {
-    autoUpdater.downloadUpdate();
-  });
-
-  autoUpdater.on('update-downloaded', () => {
-    mainWindow.webContents.send('updateAvailable');
-  });
-
-  ipcMain.handle('checkForUpdates', () => {
-    autoUpdater.checkForUpdates();
-  });
-}
-
-ipcMain.handle('installUpdateAndQuitOrRestart', async (e, quitAfterInstall) => {
-  const tempFolder = path.join(
-    path.dirname(app.getPath('exe')),
-    'data',
-    'temp'
-  );
-  if (process.env.REACT_APP_RELEASE_TYPE === 'setup') {
-    autoUpdater.quitAndInstall(true, !quitAfterInstall);
-  } else {
-    const updaterVbs = 'updater.vbs';
-    const updaterBat = 'updateLauncher.bat';
-    await fs.writeFile(
-      path.join(tempFolder, updaterBat),
-      `ping 127.0.0.1 -n 1 > nul & robocopy "${path.join(
-        tempFolder,
-        'update'
-      )}" "." /MOV /E${
-        quitAfterInstall ? '' : ` & start "" "${app.getPath('exe')}"`
-      }
-        DEL "${path.join(tempFolder, updaterVbs)}"
-        DEL "%~f0"
-        `
-    );
-
-    await fs.writeFile(
-      path.join(tempFolder, updaterVbs),
-      `Set WshShell = CreateObject("WScript.Shell")
-          WshShell.Run chr(34) & "${path.join(
-            tempFolder,
-            updaterBat
-          )}" & Chr(34), 0
-          Set WshShell = Nothing
-          `
-    );
-
-    const updateSpawn = spawn(path.join(tempFolder, updaterVbs), {
-      cwd: path.dirname(app.getPath('exe')),
-      detached: true,
-      shell: true,
-      stdio: [
-        'ignore' /* stdin */,
-        'ignore' /* stdout */,
-        'ignore' /* stderr */
-      ]
-    });
-    updateSpawn.unref();
-    mainWindow.close();
-  }
-});
diff --git i/scripts/createDeploy.js w/scripts/createDeploy.js
index 604236f9..733a90cf 100644
--- i/scripts/createDeploy.js
+++ w/scripts/createDeploy.js
@@ -99,32 +99,6 @@ const createDeployFiles = async () => {
   );
 };
 
-const extraFiles = [];
-let sevenZipPath = null;
-if (process.platform === 'win32') {
-  sevenZipPath = 'node_modules/7zip-bin/win/x64/7za.exe';
-  extraFiles.push({
-    from: 'vcredist/',
-    to: './',
-    filter: '**/*'
-  });
-} else if (process.platform === 'linux') {
-  if (process.arch === 'arm64') {
-    sevenZipPath = 'node_modules/7zip-bin/linux/arm64/7za';
-  } else if (process.arch === 'arm') {
-    sevenZipPath = 'node_modules/7zip-bin/linux/arm/7za';
-  } else {
-    sevenZipPath = 'node_modules/7zip-bin/linux/x64/7za';
-  }
-} else if (process.platform === 'darwin') {
-  sevenZipPath = 'node_modules/7zip-bin/mac/x64/7za';
-}
-
-extraFiles.push({
-  from: sevenZipPath,
-  to: './'
-});
-
 const commonConfig = {
   publish: 'never',
   config: {
@@ -138,7 +112,6 @@ const commonConfig = {
       'package.json',
       'public/icon.png'
     ],
-    extraFiles,
     asar: {
       smartUnpack: false
     },
diff --git i/src/app/desktop/utils/index.js w/src/app/desktop/utils/index.js
index dcd0e3a9..e054e5b2 100644
--- i/src/app/desktop/utils/index.js
+++ w/src/app/desktop/utils/index.js
@@ -5,7 +5,6 @@ import { extractFull } from 'node-7z';
 import jimp from 'jimp/es';
 import makeDir from 'make-dir';
 import { promisify } from 'util';
-import { ipcRenderer } from 'electron';
 import path from 'path';
 import crypto from 'crypto';
 import { exec, spawn } from 'child_process';
@@ -387,42 +386,16 @@ export const isLatestJavaDownloaded = async (
   return { isValid, log: log?.stderr };
 };
 
-export const get7zPath = async () => {
-  // Get userData from ipc because we can't always get this from redux
-  let baseDir = await ipcRenderer.invoke('getExecutablePath');
-  const isDev = process.env.NODE_ENV === 'development';
-  if (isDev) {
-    baseDir = path.resolve(baseDir, '../../');
-    if (process.platform === 'win32') {
-      baseDir = path.join(baseDir, '7zip-bin/win/x64');
-    } else if (process.platform === 'linux') {
-      baseDir = path.join(baseDir, '7zip-bin/linux/x64');
-    } else if (process.platform === 'darwin') {
-      baseDir = path.resolve(baseDir, '../../../', '7zip-bin/mac/x64');
-    }
-  }
-  if (process.platform === 'linux') {
-    return path.join(baseDir, '7za');
-  }
-  if (process.platform === 'darwin') {
-    return path.resolve(baseDir, isDev ? '' : '../', '7za');
-  }
-  return path.join(baseDir, '7za.exe');
-};
-
-get7zPath();
-
 export const extractAll = async (
   source,
   destination,
   args = {},
   funcs = {}
 ) => {
-  const sevenZipPath = await get7zPath();
   const extraction = extractFull(source, destination, {
     ...args,
     yes: true,
-    $bin: sevenZipPath,
+    $bin: '/usr/bin/7za',
     $spawnOptions: { shell: true }
   });
   let extractedParentDir = null;
diff --git i/src/common/modals/InstanceExport/CurseForge/ThirdStep.js w/src/common/modals/InstanceExport/CurseForge/ThirdStep.js
index 705ca681..c7ae1537 100644
--- i/src/common/modals/InstanceExport/CurseForge/ThirdStep.js
+++ w/src/common/modals/InstanceExport/CurseForge/ThirdStep.js
@@ -11,7 +11,6 @@ import makeDir from 'make-dir';
 import { Transition } from 'react-transition-group';
 import styled from 'styled-components';
 import pMap from 'p-map';
-import { get7zPath } from '../../../../app/desktop/utils';
 import { FABRIC, VANILLA, FORGE } from '../../../utils/constants';
 import { getAddon } from '../../../api';
 
@@ -22,12 +21,11 @@ import { getAddon } from '../../../api';
  * @param {Array} filesArray Array of files to include. Relative to current working directory unless full path is passed for each file.
  */
 const createZip = async (archiveName, zipDestPath, filesArray) => {
-  const sevenZipPath = await get7zPath();
   const zipCreation = add7z(
     path.join(zipDestPath, `${archiveName}.zip`),
     filesArray,
     {
-      $bin: sevenZipPath,
+      $bin: '/usr/bin/7za',
       $raw: ['-tzip'],
       $spawnOptions: { cwd: zipDestPath, shell: true }
     }
diff --git i/src/common/reducers/actions.js w/src/common/reducers/actions.js
index b7ec4ebc..13356aed 100644
--- i/src/common/reducers/actions.js
+++ w/src/common/reducers/actions.js
@@ -95,7 +95,6 @@ import {
   extractNatives,
   filterFabricFilesByVersion,
   filterForgeFilesByVersion,
-  get7zPath,
   getFileHash,
   getFilesRecursive,
   getJVMArguments112,
@@ -1233,7 +1232,7 @@ export function downloadForge(instanceName) {
       `${loader?.mcVersion}.json`
     );
 
-    const sevenZipPath = await get7zPath();
+    const sevenZipPath = '/usr/bin/7za';
     const pre152 = lte(coerce(loader?.mcVersion), coerce('1.5.2'));
     const pre132 = lte(coerce(loader?.mcVersion), coerce('1.3.2'));
     const baseUrl = 'https://maven.minecraftforge.net/net/minecraftforge/forge';