Skip to content

Commit f3c4e25

Browse files
committed
bug fix, remove unneeded code and dependencies
1 parent cd39aae commit f3c4e25

File tree

3 files changed

+3
-120
lines changed

3 files changed

+3
-120
lines changed

installer.mjs

Lines changed: 2 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,12 @@ import {
1414
import spawn from 'cross-spawn';
1515
import unCompress from 'all-unpacker';
1616
import fetching from 'node-wget-fetch';
17-
import system_installer from 'system-installer';
18-
import macos_release from 'macos-release';
1917

2018
const __filename = fileURLToPath(
2119
import.meta.url);
2220
const __dirname = dirname(__filename);
2321

24-
const versionCompare = (left, right) => {
25-
if (typeof left + typeof right != 'stringstring')
26-
return false;
27-
28-
let a = left.split('.');
29-
let b = right.split('.');
30-
let i = 0;
31-
let len = Math.max(a.length, b.length);
32-
33-
for (; i < len; i++) {
34-
if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) {
35-
return 1;
36-
} else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) {
37-
return -1;
38-
}
39-
}
40-
41-
return 0;
42-
}
43-
44-
const appleOs = (process.platform == "darwin") ? macos_release.version : '99.99.99',
45-
macOsVersion = (versionCompare(appleOs, '10.11.12') == 1) ? '10.15' : '10.11',
46-
_7zAppUrl = 'https://7-zip.org/a/',
22+
const _7zAppUrl = 'https://7-zip.org/a/',
4723
cwd = process.cwd(),
4824
binaryDestination = join(__dirname, 'binaries', process.platform);
4925

@@ -81,17 +57,12 @@ const windowsOtherPlatform = {
8157

8258
const linuxPlatform = {
8359
source: join(cwd, 'linux-cmake-p7zip.7z'),
84-
// source: join(cwd, 'p7zip_16.02_x86_linux_bin.tar.bz2'),
8560
destination: join(cwd, 'linux'),
8661
url: 'https://github.com/techno-express/p7zip/releases/download/17.02/',
87-
// url: ' https://pilotfiber.dl.sourceforge.net/project/p7zip/p7zip/16.02/',
8862
filename: 'linux-cmake-p7zip.7z',
89-
// filename: 'p7zip_16.02_x86_linux_bin.tar.bz2',
9063
extraName: 'lzma1701.7z',
9164
extractFolder: '',
92-
// extractFolder: 'p7zip_16.02',
9365
appLocation: '',
94-
// appLocation: 'bin',
9566
binaryFiles: ['7z_', '7z.so', '7za', '7zCon.sfx', '7zr', 'Codecs'],
9667
binaryDestinationDir: join(__dirname, 'binaries', 'linux'),
9768
sfxModules: null,
@@ -100,19 +71,14 @@ const linuxPlatform = {
10071
extraSourceFile: join(cwd, 'linux', 'lzma1701.7z'),
10172
};
10273

103-
// const macVersion = (macOsVersion == '10.15') ? 'p7zip-16.02-macos10.15.pkg' : 'p7zip-16.02-macos10.11.pkg';
10474
const appleMacPlatform = {
10575
source: join(cwd, 'macos-cmake-p7zip.7z'),
106-
// source: join(cwd, macVersion),
10776
destination: join(cwd, 'darwin'),
10877
url: 'https://github.com/techno-express/p7zip/releases/download/17.02/',
109-
// url: 'https://raw.githubusercontent.com/rudix-mac/packages/master/',
11078
filename: 'macos-cmake-p7zip.7z',
111-
// filename: macVersion,
11279
extraName: 'lzma1701.7z',
11380
extractFolder: '',
11481
appLocation: '',
115-
// appLocation: 'usr/local/lib/p7zip',
11682
binaryFiles: ['7z_', '7z.so', '7za', '7zCon.sfx', '7zr', 'Codecs'],
11783
binaryDestinationDir: join(__dirname, 'binaries', 'darwin'),
11884
sfxModules: null,
@@ -142,49 +108,6 @@ function platformUnpacker(platformData = windowsPlatform) {
142108
dest: platformData.source
143109
}).then(() => {
144110
console.log('Extracting: ' + platformData.filename);
145-
/*if (platformData.platform == 'darwin') {
146-
let destination = platformData.destination;
147-
if (process.platform == 'win32') {
148-
macUnpack(platformData)
149-
.then(() => {
150-
return resolve('darwin');
151-
}).catch((err) => retry(err));
152-
} else {
153-
unpack(platformData.source, destination)
154-
.then((data) => {
155-
console.log('Decompressing: p7zipinstall.pkg/Payload');
156-
unpack(join(destination, 'p7zipinstall.pkg', 'Payload'), destination).then(() => {
157-
console.log('Decompressing: Payload');
158-
unpack(join(destination, 'Payload'), destination, platformData.appLocation + sep + '*').then(() => {
159-
return resolve('darwin');
160-
})
161-
.catch((err) => retry(err));
162-
})
163-
.catch((err) => retry(err));
164-
})
165-
.catch((err) => retry(err));
166-
}
167-
} else if (platformData.platform == 'win32') {
168-
unpack(platformData.source, platformData.destination)
169-
.then(() => {
170-
return resolve('win32');
171-
})
172-
.catch((err) => retry(err));
173-
} else if (platformData.platform == 'linux') {
174-
unpack(platformData.source, platformData.destination)
175-
.then(() => {
176-
const system = system_installer.packager();
177-
const toInstall = (system.packager == 'yum' || system.packager == 'dnf') ?
178-
'glibc.i686' : 'libc6-i386';
179-
if (process.platform == 'linux')
180-
system_installer.installer(toInstall).then(() => {
181-
return resolve('linux');
182-
});
183-
else
184-
return resolve('linux');
185-
})
186-
.catch((err) => retry(err));
187-
} else */
188111
if (fetching.isString(platformData.platform)) {
189112
unpack(platformData.source, platformData.destination)
190113
.then(() => {
@@ -223,40 +146,6 @@ function extraUnpack(cmd = '', source = '', destination = '', toCopy = []) {
223146
return spawnSync(cmd, extraArgs);
224147
}
225148

226-
function macUnpack(dataFor = appleMacPlatform, dataForOther = windowsOtherPlatform) {
227-
return new Promise((resolve, reject) => {
228-
retrieve({
229-
url: dataForOther.url + '7z1805-extra.7z',
230-
dest: '.' + sep + '7z-extra.7z'
231-
})
232-
.then(() => {
233-
let destination = join(cwd, 'other');
234-
235-
function extractDone() {
236-
fs.emptyDir(destination).then(() => {
237-
fs.unlink(join(__dirname, '7z-extra.7z')).then(() => {
238-
fs.removeSync(destination);
239-
return resolve('darwin');
240-
});
241-
});
242-
};
243-
244-
unpack(join(__dirname, '7z-extra.7z'), destination)
245-
.then(() => {
246-
extraUnpack(join(__dirname, 'other', '7za.exe'), dataFor.source, dataFor.destination);
247-
console.log('Decompressing: ' + 'p7zip-16.02-macos10.15');
248-
unpack(join(dataFor.destination, 'p7zip-16.02-macos10.15'), dataFor.destination)
249-
.then(() => {
250-
return extractDone();
251-
})
252-
.catch(() => {
253-
return extractDone();
254-
});
255-
}).catch((err) => reject);
256-
}).catch((err) => reject);
257-
});
258-
}
259-
260149
function spawnSync(spCmd = '', spArgs = []) {
261150
let doUnpack = spawn.sync(spCmd, spArgs, {
262151
stdio: 'pipe'
@@ -397,7 +286,7 @@ platforms.forEach((dataFor) => {
397286
});
398287

399288
if (dataFor.platform != 'win32')
400-
makeExecutable([file], dataFor.binaryDestinationDir);
289+
makeExecutable([file.replace(/7z_/g, '7z')], dataFor.binaryDestinationDir);
401290
}
402291
} catch (err) {
403292
throw (err);

package-lock.json

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@
7575
"all-unpacker": "^0.1.13",
7676
"cross-spawn": "^7.0.3",
7777
"fs-extra": "^9.0.1",
78-
"macos-release": "^2.4.1",
7978
"node-wget-fetch": "^1.0.5",
80-
"system-installer": "^1.1.5",
8179
"when": "^3.7.8",
8280
"minimist": "1.2.5"
8381
},

0 commit comments

Comments
 (0)