Merge remote-tracking branch 'upstream/main' into nagilson-intermittent-error-fix
This commit is contained in:
Коммит
58f879b0f8
|
@ -130,11 +130,6 @@
|
|||
"version": "18.04",
|
||||
"preInstallCommands":
|
||||
[
|
||||
{
|
||||
"runUnderSudo": true,
|
||||
"commandRoot": "apt-get",
|
||||
"commandParts": ["update"]
|
||||
},
|
||||
{
|
||||
"runUnderSudo": true,
|
||||
"commandRoot": "apt-get",
|
||||
|
@ -149,6 +144,11 @@
|
|||
"runUnderSudo": true,
|
||||
"commandRoot": "dpkg",
|
||||
"commandParts": ["-i", "packages-microsoft-prod.deb"]
|
||||
},
|
||||
{
|
||||
"runUnderSudo": true,
|
||||
"commandRoot": "apt-get",
|
||||
"commandParts": ["update"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -15,13 +15,7 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
|
|||
{
|
||||
public async installDotnet(fullySpecifiedVersion : string, installType : LinuxInstallType): Promise<string>
|
||||
{
|
||||
const supportStatus = await this.getDotnetVersionSupportStatus(fullySpecifiedVersion, installType);
|
||||
if(supportStatus === DotnetDistroSupportStatus.Microsoft)
|
||||
{
|
||||
const myVersionDetails = this.myVersionDetails();
|
||||
const preInstallCommands = myVersionDetails[this.preinstallCommandKey] as CommandExecutorCommand[];
|
||||
await this.commandRunner.executeMultipleCommands(preInstallCommands);
|
||||
}
|
||||
await this.injectPMCFeed(fullySpecifiedVersion, installType);
|
||||
|
||||
let commands = this.myDistroCommands(this.installCommandKey);
|
||||
const sdkPackage = await this.myDotnetVersionPackageName(fullySpecifiedVersion, installType);
|
||||
|
@ -39,6 +33,10 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
|
|||
public async getInstalledGlobalDotnetPathIfExists(installType : LinuxInstallType) : Promise<string | null>
|
||||
{
|
||||
const commandResult = await this.commandRunner.executeMultipleCommands(this.myDistroCommands(this.currentInstallPathCommandKey));
|
||||
if(commandResult[0])
|
||||
{
|
||||
commandResult[0] = commandResult[0].trim();
|
||||
}
|
||||
return commandResult[0];
|
||||
}
|
||||
|
||||
|
@ -129,7 +127,7 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
|
|||
|
||||
// we need to run this command in the root directory otherwise local dotnets on the path may interfere
|
||||
const rootDir = path.parse(__dirname).root;
|
||||
let commandResult = (await this.commandRunner.executeMultipleCommands(command, rootDir))[0];
|
||||
let commandResult = (await this.commandRunner.executeMultipleCommands(command, { cwd: path.resolve(rootDir), shell: true }))[0];
|
||||
|
||||
commandResult = commandResult.replace('\n', '');
|
||||
if(!this.versionResolver.isValidLongFormVersionFormat(commandResult))
|
||||
|
@ -170,37 +168,6 @@ export class GenericDistroSDKProvider extends IDistroDotnetSDKProvider
|
|||
return Promise.resolve(DotnetDistroSupportStatus.Unknown);
|
||||
}
|
||||
|
||||
protected myVersionDetails() : any
|
||||
{
|
||||
|
||||
const distroVersions = this.distroJson[this.distroVersion.distro][this.distroVersionsKey];
|
||||
const versionData = distroVersions.filter((x: { [x: string]: string; }) => x[this.versionKey] === this.distroVersion.version)[0];
|
||||
if(!versionData)
|
||||
{
|
||||
const closestVersion = this.findMostSimilarVersion(this.distroVersion.version, distroVersions.map((x: { [x: string]: string; }) => parseFloat(x[this.versionKey])));
|
||||
return distroVersions.filter((x: { [x: string]: string; }) => parseFloat(x[this.versionKey]) === closestVersion)[0];
|
||||
}
|
||||
return versionData;
|
||||
}
|
||||
|
||||
private findMostSimilarVersion(myVersion : string, knownVersions : number[]) : number
|
||||
{
|
||||
const sameMajorVersions = knownVersions.filter(x => Math.floor(x) === Math.floor(parseFloat(myVersion)));
|
||||
if(sameMajorVersions && sameMajorVersions.length)
|
||||
{
|
||||
return Math.max(...sameMajorVersions);
|
||||
}
|
||||
|
||||
const lowerMajorVersions = knownVersions.filter(x => x < Math.floor(parseFloat(myVersion)));
|
||||
if(lowerMajorVersions && lowerMajorVersions.length)
|
||||
{
|
||||
return Math.max(...lowerMajorVersions);
|
||||
}
|
||||
|
||||
// Just return the lowest known version, as it will be the closest to our version, as they are all larger than our version.
|
||||
return Math.min(...knownVersions);
|
||||
}
|
||||
|
||||
public async getRecommendedDotnetVersion(installType : LinuxInstallType) : Promise<string>
|
||||
{
|
||||
let maxVersion = '0';
|
||||
|
|
|
@ -172,7 +172,7 @@ export abstract class IDistroDotnetSDKProvider {
|
|||
return supportedType;
|
||||
}
|
||||
|
||||
protected async myVersionPackages(installType : LinuxInstallType) : Promise<LinuxPackageCollection[]>
|
||||
protected async myVersionPackages(installType : LinuxInstallType, haveTriedFeedInjectionAlready = false) : Promise<LinuxPackageCollection[]>
|
||||
{
|
||||
const availableVersions : LinuxPackageCollection[] = [];
|
||||
|
||||
|
@ -203,9 +203,60 @@ export abstract class IDistroDotnetSDKProvider {
|
|||
}
|
||||
}
|
||||
|
||||
if(availableVersions.length === 0 && !haveTriedFeedInjectionAlready)
|
||||
{
|
||||
// PMC is only injected and should only be injected for MSFT feed distros.
|
||||
// Our check runs by checking the feature band first, so that needs to be supported for it to fallback to the preinstall command check.
|
||||
const fakeVersionToCheckMicrosoftSupportStatus = '6.0.1xx';
|
||||
|
||||
await this.injectPMCFeed(fakeVersionToCheckMicrosoftSupportStatus, installType);
|
||||
return this.myVersionPackages(installType, true);
|
||||
}
|
||||
return availableVersions;
|
||||
}
|
||||
|
||||
protected async injectPMCFeed(fullySpecifiedVersion : string, installType : LinuxInstallType)
|
||||
{
|
||||
const supportStatus = await this.getDotnetVersionSupportStatus(fullySpecifiedVersion, installType);
|
||||
if(supportStatus === DotnetDistroSupportStatus.Microsoft)
|
||||
{
|
||||
const myVersionDetails = this.myVersionDetails();
|
||||
const preInstallCommands = myVersionDetails[this.preinstallCommandKey] as CommandExecutorCommand[];
|
||||
await this.commandRunner.executeMultipleCommands(preInstallCommands);
|
||||
}
|
||||
}
|
||||
|
||||
protected myVersionDetails() : any
|
||||
{
|
||||
|
||||
const distroVersions = this.distroJson[this.distroVersion.distro][this.distroVersionsKey];
|
||||
const versionData = distroVersions.filter((x: { [x: string]: string; }) => x[this.versionKey] === this.distroVersion.version)[0];
|
||||
if(!versionData)
|
||||
{
|
||||
const closestVersion = this.findMostSimilarVersion(this.distroVersion.version, distroVersions.map((x: { [x: string]: string; }) => parseFloat(x[this.versionKey])));
|
||||
return distroVersions.filter((x: { [x: string]: string; }) => parseFloat(x[this.versionKey]) === closestVersion)[0];
|
||||
}
|
||||
return versionData;
|
||||
}
|
||||
|
||||
protected findMostSimilarVersion(myVersion : string, knownVersions : number[]) : number
|
||||
{
|
||||
const sameMajorVersions = knownVersions.filter(x => Math.floor(x) === Math.floor(parseFloat(myVersion)));
|
||||
if(sameMajorVersions && sameMajorVersions.length)
|
||||
{
|
||||
return Math.max(...sameMajorVersions);
|
||||
}
|
||||
|
||||
const lowerMajorVersions = knownVersions.filter(x => x < Math.floor(parseFloat(myVersion)));
|
||||
if(lowerMajorVersions && lowerMajorVersions.length)
|
||||
{
|
||||
return Math.max(...lowerMajorVersions);
|
||||
}
|
||||
|
||||
// Just return the lowest known version, as it will be the closest to our version, as they are all larger than our version.
|
||||
return Math.min(...knownVersions);
|
||||
}
|
||||
|
||||
protected myDistroStrings(stringKey : string) : string
|
||||
{
|
||||
return this.distroJson[this.distroVersion.distro][stringKey];
|
||||
|
|
Загрузка…
Ссылка в новой задаче