@@ -124,13 +124,15 @@ async function runBinary(datasource, opts) {
124
124
async function getPlatform ( logsOpt ) {
125
125
const type = os . type ( )
126
126
const arch = os . arch ( )
127
- const release = os . release ( )
128
127
const cpuCore = os . cpus ( ) [ 0 ]
129
128
const isM1 = cpuCore . model . includes ( "Apple M1" )
130
- const majorVersion = ( type === 'Linux' ) ? await getLinuxVersion ( ) : semver . major ( release )
129
+ const linuxInfo = type === 'Linux' ? await getLinuxInfo ( ) : [ ]
130
+ const linuxDestro = linuxInfo [ 0 ] || type
131
+ const release = linuxInfo [ 1 ] || os . release ( )
132
+ const majorVersion = parseInt ( linuxInfo [ 1 ] ) || semver . major ( release )
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: ${ linuxDestro || type } \nOS arch: ${ arch } \nOS release: ${ release } \nOS major version: ${ majorVersion } \nCPU model: ${ cpuCore . model } ` )
134
136
}
135
137
136
138
if ( arch === 'x64' || ( arch === 'arm64' && isM1 ) ) {
@@ -146,10 +148,8 @@ async function getPlatform(logsOpt) {
146
148
} else if ( type === 'Linux' ) {
147
149
if ( majorVersion === 18 ) {
148
150
return 'binary-linux-18'
149
- } else if ( majorVersion == 20 ) {
150
- return 'binary-linux-20'
151
151
} else {
152
- throw new Error ( `Unsupported Linux Version: ${ majorVersion } ` )
152
+ return 'binary-linux-20'
153
153
}
154
154
} else if ( type === 'Windows_NT' ) {
155
155
return 'binary-windows'
@@ -159,10 +159,14 @@ async function getPlatform(logsOpt) {
159
159
throw new Error ( `Unsupported platform: ${ type } ${ arch } ${ majorVersion } ` )
160
160
}
161
161
162
- async function getLinuxVersion ( ) {
163
- let version = await system . run ( "grep '^VERSION_ID' /etc/os-release" , { trim : true } )
164
- version = version . replace ( / [ V E R S I O N _ I D = ] | [ ' " ] + / g, '' )
165
- return parseInt ( version )
162
+ async function getLinuxInfo ( ) {
163
+ try {
164
+ let info = await system . run ( "cat /etc/*-release | egrep -e '(^VERSION|^NAME)='" , { trim : true } )
165
+ return info . replace ( / [ V E R S I O N = ] | [ N A M E = ] | [ ' " ] + / g, '' ) . split ( '\n' )
166
+ } catch ( error ) {
167
+ print . error ( `Error fetching the Linux version:\n ${ error } ` )
168
+ process . exit ( 1 )
169
+ }
166
170
}
167
171
168
172
async function runDocker ( datasource , opts ) {
0 commit comments