@@ -2,7 +2,7 @@ const { Binary } = require('binary-install-raw')
2
2
const os = require ( 'os' )
3
3
const chalk = require ( 'chalk' )
4
4
const fetch = require ( 'node-fetch' )
5
- const { filesystem, patching, print } = require ( 'gluegun' )
5
+ const { filesystem, patching, print, system } = require ( 'gluegun' )
6
6
const { fixParameters } = require ( '../command-helpers/gluegun' )
7
7
const path = require ( 'path' )
8
8
const semver = require ( 'semver' )
@@ -103,7 +103,7 @@ async function runBinary(datasource, opts) {
103
103
let latestVersion = opts . get ( "latestVersion" )
104
104
let recompileOpt = opts . get ( "recompile" )
105
105
106
- const platform = getPlatform ( logsOpt )
106
+ const platform = await getPlatform ( logsOpt )
107
107
108
108
const url = `https://github.com/LimeChain/matchstick/releases/download/${ versionOpt || latestVersion } /${ platform } `
109
109
@@ -121,16 +121,18 @@ async function runBinary(datasource, opts) {
121
121
args . length > 0 ? binary . run ( ...args ) : binary . run ( )
122
122
}
123
123
124
- function getPlatform ( logsOpt ) {
124
+ async function getPlatform ( logsOpt ) {
125
125
const type = os . type ( )
126
126
const arch = os . arch ( )
127
127
const release = os . release ( )
128
128
const cpuCore = os . cpus ( ) [ 0 ]
129
- const majorVersion = semver . major ( release )
130
129
const isM1 = cpuCore . model . includes ( "Apple M1" )
130
+ const majorVersion = semver . major ( release )
131
+ let linuxVersion = ""
132
+ if ( type === 'Linux' ) linuxVersion = await getLinuxVersion ( )
131
133
132
134
if ( logsOpt ) {
133
- print . info ( `OS type: ${ type } \nOS arch: ${ arch } \nOS release: ${ release } \nOS major version: ${ majorVersion } \nCPU model: ${ cpuCore . model } ` )
135
+ print . info ( `OS type: ${ type } \nOS arch: ${ arch } \nOS release: ${ release } \nOS major version: ${ type === 'Linux' ? linuxVersion : majorVersion } \nCPU model: ${ cpuCore . model } ` )
134
136
}
135
137
136
138
if ( arch === 'x64' || ( arch === 'arm64' && isM1 ) ) {
@@ -144,10 +146,13 @@ function getPlatform(logsOpt) {
144
146
}
145
147
return 'binary-macos-11'
146
148
} else if ( type === 'Linux' ) {
147
- if ( majorVersion === 18 ) {
149
+ if ( linuxVersion === '18.04' ) {
148
150
return 'binary-linux-18'
151
+ } else if ( linuxVersion == '20.04' ) {
152
+ return 'binary-linux-20'
153
+ } else {
154
+ throw new Error ( `Unsupported Linux Version: ${ linuxVersion } ` )
149
155
}
150
- return 'binary-linux-20'
151
156
} else if ( type === 'Windows_NT' ) {
152
157
return 'binary-windows'
153
158
}
@@ -156,6 +161,11 @@ function getPlatform(logsOpt) {
156
161
throw new Error ( `Unsupported platform: ${ type } ${ arch } ${ majorVersion } ` )
157
162
}
158
163
164
+ async function getLinuxVersion ( ) {
165
+ let version = await system . run ( "grep '^VERSION_ID' /etc/os-release" , { trim : true } )
166
+ return version . replace ( / [ V E R S I O N _ I D = ] | [ ' " ] + / g, '' ) . trim ( )
167
+ }
168
+
159
169
async function runDocker ( datasource , opts ) {
160
170
let coverageOpt = opts . get ( "coverage" )
161
171
let forceOpt = opts . get ( "force" )
0 commit comments