替换开发环境命令;修改系统识别脚本

This commit is contained in:
dinglili 2024-07-04 14:12:34 +08:00 committed by wangpenglong
parent 0b598b9674
commit 7b70d4ea1b
2 changed files with 91 additions and 57 deletions

View File

@ -472,13 +472,13 @@ class deployWindow {
const parentdivshow = document.getElementById('osInfoShow') as HTMLDivElement; const parentdivshow = document.getElementById('osInfoShow') as HTMLDivElement;
parentdiv.innerHTML = ""; parentdiv.innerHTML = "";
parentdivshow.innerHTML = ""; parentdivshow.innerHTML = "";
let osinfo; let osrelease;
if (!result.osinfo) { if (!result.osrelease) {
osinfo = `<h3>操作系统信息</h3><p>操作系统检测脚本运行失败,未成功检测到操作系统类型</p>` osrelease = `<h3>操作系统信息</h3><p>操作系统检测脚本运行失败,未成功检测到操作系统类型</p>`
} else { } else {
osinfo = `<h3>操作系统信息</h3><p>已检测到当前操作系统信息为:<span>${result.osinfo}</span></p>`; osrelease = `<h3>操作系统信息</h3><p>已检测到当前操作系统信息为:<span>${result.osrelease}</span></p>`;
} }
parentdiv.innerHTML = osinfo; parentdiv.innerHTML = osrelease;
let dataSys = ""; let dataSys = "";
let osdiv; let osdiv;
osdiv = `<p>判断依据:</p><div><p>cat ${result.osFile}</p>`; osdiv = `<p>判断依据:</p><div><p>cat ${result.osFile}</p>`;
@ -608,8 +608,8 @@ class deployWindow {
console.log("kylinide.installWizard.init.configVersify result is void"); console.log("kylinide.installWizard.init.configVersify result is void");
return; return;
} }
console.log("kylinide.installWizard.init configVersify result:" + JSON.stringify(configData)); // console.log("kylinide.installWizard.init configVersify result:" + JSON.stringify(configData));
console.log(configData.type + " " + configData.selectPageShow + " " + configData.message); // console.log(configData.type + " " + configData.selectPageShow + " " + configData.message);
if (configData.selectPageShow) { if (configData.selectPageShow) {
const onlineUpdateConfig = document.getElementById("onlineUpdateConfig") as HTMLInputElement; const onlineUpdateConfig = document.getElementById("onlineUpdateConfig") as HTMLInputElement;
const onlineLocalConfig = document.getElementById("onlineLocalConfig") as HTMLInputElement; const onlineLocalConfig = document.getElementById("onlineLocalConfig") as HTMLInputElement;
@ -628,6 +628,7 @@ class deployWindow {
parentdiv.innerHTML = configData.message; parentdiv.innerHTML = configData.message;
} else if (configData.selectPageShow == 4) { } else if (configData.selectPageShow == 4) {
onlineUpdateConfig.checked = true; onlineUpdateConfig.checked = true;
parentdiv.innerHTML = configData.message;
} }
} }
if (this.nextBtn && this.prevBtn) { if (this.nextBtn && this.prevBtn) {
@ -1232,13 +1233,10 @@ class EventInvokeCheck {
} }
export function startup(configuration: DeployWindowConfiguration): void { export function startup(configuration: DeployWindowConfiguration): void {
console.log("-----------------dll---------head----startupdeploy");
// const platformClass = configuration.data.platform === 'win32' ? 'windows' : configuration.data.platform === 'linux' ? 'linux' : 'mac'; // const platformClass = configuration.data.platform === 'win32' ? 'windows' : configuration.data.platform === 'linux' ? 'linux' : 'mac';
// mainWindow.document.body.classList.add(platformClass); // used by our fonts // mainWindow.document.body.classList.add(platformClass); // used by our fonts
// createCodiconStyleSheet(); // createCodiconStyleSheet();
// applyZoom(configuration.data.zoomLevel); // applyZoom(configuration.data.zoomLevel);
console.log("-----------------dll-------------startupdeploy");
new deployWindow(configuration.windowId); new deployWindow(configuration.windowId);
} }

View File

@ -66,17 +66,15 @@ export class DeployMainService implements IDeployMainService {
private DeployWindow: BrowserWindow | null = null; private DeployWindow: BrowserWindow | null = null;
// private sysinfo: installInfo;
// private installconfigpath: string;
private localConfigObject: { res: number; depConfigInfo: any; g_index_Object: any; osinfo: string; localConfigMatch: number; };
// private baseUrl: string = "";
private selectObject = { private selectObject = {
dirPath: "", dirPath: "",
updateFlag: false, updateFlag: false,
depInfoJsonPath: "", //选中的依赖配置文件路径, depInfoJsonPath: "", //选中的依赖配置文件路径,
extAddressPath: "",//选中的插件配置文件路径 extAddressPath: "",//选中的插件配置文件路径
} };
updateConfigObject: { res: number; g_index_Object: any; osinfo: string; ConfigMatch: number; base_url: any; depConfigInfo: any; }; private localConfigObject: { res: number; depConfigInfo: any; g_index_Object: any; osinfo: string; localConfigMatch: number; osrelease: string; supportList: string[] };
updateConfigObject: { res: number; g_index_Object: any; osinfo: string; ConfigMatch: number; base_url: any; depConfigInfo: any; osrelease: string; supportList: string[] };
localConfigDir: any; localConfigDir: any;
localConfigPathname: any; localConfigPathname: any;
installConfig: any; installConfig: any;
@ -122,32 +120,51 @@ export class DeployMainService implements IDeployMainService {
private userEnv: IProcessEnvironment, private userEnv: IProcessEnvironment,
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService, @IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@ILoggerMainService private readonly loggerMainService: ILoggerMainService, @ILoggerMainService private readonly loggerMainService: ILoggerMainService,
// @ILogService private readonly logService: ILogService,
// @IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService,
// @IDiagnosticsMainService private readonly diagnosticsMainService: IDiagnosticsMainService,
// @IDialogMainService private readonly dialogMainService: IDialogMainService,
// @INativeHostMainService private readonly nativeHostMainService: INativeHostMainService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService, @IProtocolMainService private readonly protocolMainService: IProtocolMainService,
@IProductService private readonly productService: IProductService, @IProductService private readonly productService: IProductService,
// @IStateService private readonly stateService: IStateService,
// @IWindowsMainService private readonly windowsMainService: IWindowsMainService,
// @IOpenerService private readonly _openerService: IOpenerService,
// @IThemeMainService private readonly themeMainService: IThemeMainService,
// @IThemeService private readonly themeService: IThemeService,
// @INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
) { ) {
// this.sysinfo = { IDEVersion: this.productService.IDEVersion || "", localConfigFile: "", addNewPage: 0, localosinfo: "", urlosinfo: "", urlConfigFile: "" } this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0, osrelease: "", supportList: [] };
this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: "", osinfo: "", localConfigMatch: 0 }; this.updateConfigObject = { res: 0, g_index_Object: {}, osinfo: "", ConfigMatch: 0, base_url: "", depConfigInfo: "", osrelease: "", supportList: [] };
this.updateConfigObject = { res: 0, g_index_Object: {}, osinfo: "", ConfigMatch: 0, base_url: "", depConfigInfo: "" }; this.updateConfigDir = installUtils.installConfigDirPre() + "/" + installUtils.getDateDir();
this.reset();
this.logger = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/instguide.log"));
this.removeListeners();
this.registerListeners();
}
reset() {
this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0 };
this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0, osrelease: "", supportList: [] };
this.updateConfigObject = { res: 0, g_index_Object: {}, osinfo: "", ConfigMatch: 0, base_url: "", depConfigInfo: "", osrelease: "", supportList: [] };
this.localConfigDir = installUtils.localConfigPath(); this.localConfigDir = installUtils.localConfigPath();
this.installConfig = installUtils.installConfigDirPre();//.kylin-ide/installconfig this.installConfig = installUtils.installConfigDirPre();//.kylin-ide/installconfig
this.updateConfigDir = installUtils.installConfigDirPre() + "/" + installUtils.getDateDir(); this.updateConfigDir = installUtils.installConfigDirPre() + "/" + installUtils.getDateDir();
this.logFile0 = this.installConfig + '/log/install.1.log'; this.logFile0 = this.installConfig + '/log/install.1.log';
this.resultFile = this.installConfig + '/resultFile'; this.resultFile = this.installConfig + '/resultFile';
this.extLogFile0 = this.installConfig + '/log/extInstall.1.log'; this.extLogFile0 = this.installConfig + '/log/extInstall.1.log';
this.logger = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/installguide.log"));
this.removeListeners(); this.baseUrl = "";
this.registerListeners(); this.extDownloadPath = "";
this.extMap = {};
this.depList = [];
this.extList = [];
this.lastLogPosition = 0;
//文件监听;
this.installFsWatcher = null;
this.extlogFsWatcher = null;
this.pkglogFsWatcher = null;
//执行安装脚本的进程号;
this.installProcessId = null;
this.cancelFlag = false;
this.offset = 0;
this.resultIndex = 0;
this.flagPkexec = 0;
this.lastExtLogPosition = 0;
this.startInstallDepWatch = 0;
this.controller = new AbortController();
} }
//#region Register Listeners //#region Register Listeners
@ -200,7 +217,13 @@ export class DeployMainService implements IDeployMainService {
let installCommand = ""; let installCommand = "";
try { try {
const installItem = this.extDownloadPath + msg.downloadDone; const installItem = this.extDownloadPath + msg.downloadDone;
installCommand = "kylin-ide --install-extension " + installItem; if (this.environmentMainService.isBuilt) {
installCommand = "kylin-code" + " " + "--install-extension" + " " + installItem;
}
else {
let comandpath = path.join(FileAccess.asFileUri('').fsPath, '..', "scripts/code-cli.sh")
installCommand = comandpath + " " + "--install-extension" + " " + installItem;
}
this.logger.debug("安装 ext installCommand", installCommand); this.logger.debug("安装 ext installCommand", installCommand);
if (this.installQueue.length === 0) { if (this.installQueue.length === 0) {
this.installQueue.push({ installCommand, msg }); this.installQueue.push({ installCommand, msg });
@ -438,7 +461,7 @@ export class DeployMainService implements IDeployMainService {
if (this.localConfigObject.res != 0 && this.updateConfigObject.res != 0) { if (this.localConfigObject.res != 0 && this.updateConfigObject.res != 0) {
if (this.DeployWindow) { if (this.DeployWindow) {
if (this.localConfigObject.osinfo == "undefined" && this.updateConfigObject.osinfo == "undefined") { if (this.localConfigObject.osinfo == "undefined" && this.updateConfigObject.osinfo == "undefined") {
this.logger.error("安装引导器仅支持openKylin操作系统,脚本根据/etc/os-release信息判断操作系统类型"); this.logger.error("安装引导器仅支持openKylin操作系统,具体为", this.localConfigObject.supportList);
await dialog.showMessageBox(this.DeployWindow, await dialog.showMessageBox(this.DeployWindow,
{ {
type: "error", type: "error",
@ -502,15 +525,15 @@ export class DeployMainService implements IDeployMainService {
if (installUtils.compareVersions(this.updateConfigObject.g_index_Object.ver, this.localConfigObject.g_index_Object.ver) > 0) { if (installUtils.compareVersions(this.updateConfigObject.g_index_Object.ver, this.localConfigObject.g_index_Object.ver) > 0) {
//显示询问用户是否更新配置文件 //显示询问用户是否更新配置文件
//比较具体的配置文件是否一致,若是一致则还是选择本地配置,若是不同则 //比较具体的配置文件是否一致,若是一致则还是选择本地配置,若是不同则
let updateosinfo = this.updateConfigObject.osinfo; selectPageShow = 4;
let localosinfo = this.localConfigObject.osinfo; message = "配置文件有更新";
if (this.updateConfigObject.g_index_Object["config-file"][updateosinfo][0]['sign-md5'] !== this.localConfigObject.g_index_Object["config-file"][localosinfo][0]['sign-md5']) // if (this.updateConfigObject.g_index_Object["config-file"][updateosinfo][0]['sign-md5'] !== this.localConfigObject.g_index_Object["config-file"][localosinfo][0]['sign-md5'])
selectPageShow = 4; // selectPageShow = 4;
else { // else {
this.logger.info("联网数据与本地配置文件数据版本一致"); // this.logger.info("联网数据与本地配置文件数据版本一致");
selectPageShow = 3; // selectPageShow = 3;
message = "联网数据与本地配置文件数据版本一致"; // message = "联网数据与本地配置文件数据版本一致";
} // }
} else { } else {
selectPageShow = 3; selectPageShow = 3;
this.logger.info("联网数据与本地配置文件数据版本一致"); this.logger.info("联网数据与本地配置文件数据版本一致");
@ -524,6 +547,7 @@ export class DeployMainService implements IDeployMainService {
this.selectObject.extAddressPath = this.localConfigDir + "/" + this.localConfigObject.g_index_Object['ext-file']['file_name']; this.selectObject.extAddressPath = this.localConfigDir + "/" + this.localConfigObject.g_index_Object['ext-file']['file_name'];
Data = { Data = {
osinfo: this.localConfigObject.osinfo, osinfo: this.localConfigObject.osinfo,
osrelease: this.localConfigObject.osrelease,
selectPageShow: selectPageShow, selectPageShow: selectPageShow,
type: "configVersify" type: "configVersify"
} }
@ -548,9 +572,9 @@ export class DeployMainService implements IDeployMainService {
}; };
handleInitConfigSelect = async (event: IpcMainInvokeEvent, msg: any) => { handleInitConfigSelect = async (event: IpcMainInvokeEvent, msg: any) => {
let osinfo = ""; let osrelease = "";
if (msg.select === "local") { if (msg.select === "local") {
osinfo = this.localConfigObject.osinfo; osrelease = this.localConfigObject.osrelease;
this.selectObject.dirPath = this.localConfigDir; this.selectObject.dirPath = this.localConfigDir;
this.selectObject.updateFlag = false; this.selectObject.updateFlag = false;
this.selectObject.depInfoJsonPath = this.localConfigDir + "/" + this.localConfigObject.depConfigInfo['file_name']; this.selectObject.depInfoJsonPath = this.localConfigDir + "/" + this.localConfigObject.depConfigInfo['file_name'];
@ -558,7 +582,7 @@ export class DeployMainService implements IDeployMainService {
} else if (msg.select === "update") { } else if (msg.select === "update") {
this.selectObject.dirPath = this.updateConfigDir; this.selectObject.dirPath = this.updateConfigDir;
this.selectObject.updateFlag = true; this.selectObject.updateFlag = true;
osinfo = this.updateConfigObject.osinfo; osrelease = this.updateConfigObject.osrelease;
this.selectObject.depInfoJsonPath = this.updateConfigDir + "/" + this.updateConfigObject.depConfigInfo['file_name']; this.selectObject.depInfoJsonPath = this.updateConfigDir + "/" + this.updateConfigObject.depConfigInfo['file_name'];
this.selectObject.extAddressPath = this.updateConfigDir + "/" + this.updateConfigObject.g_index_Object['ext-file']['file_name']; //error this.selectObject.extAddressPath = this.updateConfigDir + "/" + this.updateConfigObject.g_index_Object['ext-file']['file_name']; //error
@ -566,12 +590,12 @@ export class DeployMainService implements IDeployMainService {
const { osFile, data } = this.readOSInfo(); const { osFile, data } = this.readOSInfo();
const osObject = { const osObject = {
type: "osinfo", type: "osinfo",
osinfo: osinfo, osrelease: osrelease,
osFile: osFile, osFile: osFile,
osData: data osData: data
} }
this.logger.info(`选择的配置文件名称:${this.selectObject.depInfoJsonPath}`); this.logger.info(`选择的配置文件名称:${this.selectObject.depInfoJsonPath}`);
this.logger.info(`识别操作系统信息:${osinfo}`); this.logger.info(`识别操作系统信息:${osrelease}`);
if (this.DeployWindow) { if (this.DeployWindow) {
// this.DeployWindow.webContents.send('kylinide.installWizard.init', osObject); // this.DeployWindow.webContents.send('kylinide.installWizard.init', osObject);
@ -1613,10 +1637,14 @@ export class DeployMainService implements IDeployMainService {
if (!this.versify(`${match_ext_filePath}`, match_ext_file_sign)) { if (!this.versify(`${match_ext_filePath}`, match_ext_file_sign)) {
flag++; flag++;
} }
//执行脚本,获取操作系统标识信息
const functionName = 'getoscontent';
let [osinfo, osrelease, supportList] = await this.loadAndInvokeFunction(match_script_filePath, functionName);
//执行脚本,获取操作系统信息 //执行脚本,获取操作系统信息
const functionName = 'getosinfo'; // const = await this.loadAndInvokeFunction(match_script_filePath, "showosinfo");
const osinfo = await this.loadAndInvokeFunction(match_script_filePath, functionName); //执行脚本,获取操作系统信息
this.logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osinfo);
this.logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osrelease);
let localConfigMatch = 0; let localConfigMatch = 0;
// 检测文件是否有osinfo想匹配的 // 检测文件是否有osinfo想匹配的
if (g_index_localDataObject["config-file"].hasOwnProperty(`${osinfo}`)) { if (g_index_localDataObject["config-file"].hasOwnProperty(`${osinfo}`)) {
@ -1660,6 +1688,8 @@ export class DeployMainService implements IDeployMainService {
res: res, res: res,
g_index_Object: g_index_localDataObject, g_index_Object: g_index_localDataObject,
osinfo: osinfo, osinfo: osinfo,
osrelease: osrelease,
supportList: supportList,
localConfigMatch: localConfigMatch, localConfigMatch: localConfigMatch,
depConfigInfo: osinfo !== "undefined" ? g_index_localDataObject['config-file'][osinfo][0] : {} depConfigInfo: osinfo !== "undefined" ? g_index_localDataObject['config-file'][osinfo][0] : {}
} }
@ -1671,7 +1701,9 @@ export class DeployMainService implements IDeployMainService {
g_index_Object: "", g_index_Object: "",
osinfo: "", osinfo: "",
localConfigMatch: -1, localConfigMatch: -1,
depConfigInfo: {} depConfigInfo: {},
osrelease: "",
supportList: []
} }
return configData; return configData;
} }
@ -1722,9 +1754,9 @@ export class DeployMainService implements IDeployMainService {
flag++; flag++;
} }
//执行脚本,获取操作系统信息 //执行脚本,获取操作系统信息
const functionName = 'getosinfo'; const functionName = 'getoscontent';
let osinfo = await this.loadAndInvokeFunction(match_script_filePath, functionName); let [osinfo, osrelease, supportList] = await this.loadAndInvokeFunction(match_script_filePath, functionName);
this.logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osinfo); this.logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osrelease);
let ConfigMatch = 0; let ConfigMatch = 0;
// 检测文件是否有osinfo想匹配的 // 检测文件是否有osinfo想匹配的
@ -1782,6 +1814,8 @@ export class DeployMainService implements IDeployMainService {
res: res, res: res,
g_index_Object: g_index_Object, g_index_Object: g_index_Object,
osinfo: osinfo, osinfo: osinfo,
osrelease: osrelease,
supportList: supportList,
ConfigMatch: ConfigMatch, ConfigMatch: ConfigMatch,
base_url: g_index_Object['base-url'], base_url: g_index_Object['base-url'],
depConfigInfo: osinfo !== "undefined" ? g_index_Object['config-file'][osinfo][0] : {} depConfigInfo: osinfo !== "undefined" ? g_index_Object['config-file'][osinfo][0] : {}
@ -1795,7 +1829,9 @@ export class DeployMainService implements IDeployMainService {
osinfo: "", osinfo: "",
ConfigMatch: -1, ConfigMatch: -1,
base_url: "", base_url: "",
depConfigInfo: {} depConfigInfo: {},
osrelease: "",
supportList: []
} }
return configData; return configData;
} }