@@ -14,36 +14,12 @@ import {
14
14
import spawn from 'cross-spawn' ;
15
15
import unCompress from 'all-unpacker' ;
16
16
import fetching from 'node-wget-fetch' ;
17
- import system_installer from 'system-installer' ;
18
- import macos_release from 'macos-release' ;
19
17
20
18
const __filename = fileURLToPath (
21
19
import . meta. url ) ;
22
20
const __dirname = dirname ( __filename ) ;
23
21
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/' ,
47
23
cwd = process . cwd ( ) ,
48
24
binaryDestination = join ( __dirname , 'binaries' , process . platform ) ;
49
25
@@ -81,17 +57,12 @@ const windowsOtherPlatform = {
81
57
82
58
const linuxPlatform = {
83
59
source : join ( cwd , 'linux-cmake-p7zip.7z' ) ,
84
- // source: join(cwd, 'p7zip_16.02_x86_linux_bin.tar.bz2'),
85
60
destination : join ( cwd , 'linux' ) ,
86
61
url : 'https://github.com/techno-express/p7zip/releases/download/17.02/' ,
87
- // url: ' https://pilotfiber.dl.sourceforge.net/project/p7zip/p7zip/16.02/',
88
62
filename : 'linux-cmake-p7zip.7z' ,
89
- // filename: 'p7zip_16.02_x86_linux_bin.tar.bz2',
90
63
extraName : 'lzma1701.7z' ,
91
64
extractFolder : '' ,
92
- // extractFolder: 'p7zip_16.02',
93
65
appLocation : '' ,
94
- // appLocation: 'bin',
95
66
binaryFiles : [ '7z_' , '7z.so' , '7za' , '7zCon.sfx' , '7zr' , 'Codecs' ] ,
96
67
binaryDestinationDir : join ( __dirname , 'binaries' , 'linux' ) ,
97
68
sfxModules : null ,
@@ -100,19 +71,14 @@ const linuxPlatform = {
100
71
extraSourceFile : join ( cwd , 'linux' , 'lzma1701.7z' ) ,
101
72
} ;
102
73
103
- // const macVersion = (macOsVersion == '10.15') ? 'p7zip-16.02-macos10.15.pkg' : 'p7zip-16.02-macos10.11.pkg';
104
74
const appleMacPlatform = {
105
75
source : join ( cwd , 'macos-cmake-p7zip.7z' ) ,
106
- // source: join(cwd, macVersion),
107
76
destination : join ( cwd , 'darwin' ) ,
108
77
url : 'https://github.com/techno-express/p7zip/releases/download/17.02/' ,
109
- // url: 'https://raw.githubusercontent.com/rudix-mac/packages/master/',
110
78
filename : 'macos-cmake-p7zip.7z' ,
111
- // filename: macVersion,
112
79
extraName : 'lzma1701.7z' ,
113
80
extractFolder : '' ,
114
81
appLocation : '' ,
115
- // appLocation: 'usr/local/lib/p7zip',
116
82
binaryFiles : [ '7z_' , '7z.so' , '7za' , '7zCon.sfx' , '7zr' , 'Codecs' ] ,
117
83
binaryDestinationDir : join ( __dirname , 'binaries' , 'darwin' ) ,
118
84
sfxModules : null ,
@@ -142,49 +108,6 @@ function platformUnpacker(platformData = windowsPlatform) {
142
108
dest : platformData . source
143
109
} ) . then ( ( ) => {
144
110
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 */
188
111
if ( fetching . isString ( platformData . platform ) ) {
189
112
unpack ( platformData . source , platformData . destination )
190
113
. then ( ( ) => {
@@ -223,40 +146,6 @@ function extraUnpack(cmd = '', source = '', destination = '', toCopy = []) {
223
146
return spawnSync ( cmd , extraArgs ) ;
224
147
}
225
148
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
-
260
149
function spawnSync ( spCmd = '' , spArgs = [ ] ) {
261
150
let doUnpack = spawn . sync ( spCmd , spArgs , {
262
151
stdio : 'pipe'
@@ -397,7 +286,7 @@ platforms.forEach((dataFor) => {
397
286
} ) ;
398
287
399
288
if ( dataFor . platform != 'win32' )
400
- makeExecutable ( [ file ] , dataFor . binaryDestinationDir ) ;
289
+ makeExecutable ( [ file . replace ( / 7 z _ / g , '7z' ) ] , dataFor . binaryDestinationDir ) ;
401
290
}
402
291
} catch ( err ) {
403
292
throw ( err ) ;
0 commit comments