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AC7B,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;YACnE,OAAO,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAA;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,cAAc,gBAAgB,CAAC,CAAA;IACpE,CAAC;CACF;AA3DD,gCA2DC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS, Logger } from \"./types\"\nimport { findFile } from \"./providers/Provider\"\nimport { LinuxUpdater } from \"./LinuxUpdater\"\n\nexport class RpmUpdater extends LinuxUpdater {\n  constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n    super(options, app)\n  }\n\n  /*** @private */\n  protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n    const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n    const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"rpm\", [\"AppImage\", \"deb\", \"pacman\"])!\n    return this.executeDownload({\n      fileExtension: \"rpm\",\n      fileInfo,\n      downloadUpdateOptions,\n      task: async (updateFile, downloadOptions) => {\n        if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n          downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n        }\n        await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n      },\n    })\n  }\n\n  protected doInstall(options: InstallOptions): boolean {\n    const installerPath = this.installerPath\n    if (installerPath == null) {\n      this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n      return false\n    }\n\n    const priorityList = [\"zypper\", \"dnf\", \"yum\", \"rpm\"]\n    const packageManager = this.detectPackageManager(priorityList)\n    try {\n      RpmUpdater.installWithCommandRunner(packageManager as any, installerPath, this.runCommandWithSudoIfNeeded.bind(this), this._logger)\n    } catch (error: any) {\n      this.dispatchError(error)\n      return false\n    }\n    if (options.isForceRunAfter) {\n      this.app.relaunch()\n    }\n    return true\n  }\n\n  static installWithCommandRunner(packageManager: \"zypper\" | \"dnf\" | \"yum\" | \"rpm\", installerPath: string, commandRunner: (commandWithArgs: string[]) => void, logger: Logger) {\n    if (packageManager === \"zypper\") {\n      return commandRunner([\"zypper\", \"--non-interactive\", \"--no-refresh\", \"install\", \"--allow-unsigned-rpm\", \"-f\", installerPath])\n    }\n    if (packageManager === \"dnf\") {\n      return commandRunner([\"dnf\", \"install\", \"--nogpgcheck\", \"-y\", installerPath])\n    }\n    if (packageManager === \"yum\") {\n      return commandRunner([\"yum\", \"install\", \"--nogpgcheck\", \"-y\", installerPath])\n    }\n    if (packageManager === \"rpm\") {\n      logger.warn(\"Installing with rpm only (no dependency resolution).\")\n      return commandRunner([\"rpm\", \"-Uvh\", \"--replacepkgs\", \"--replacefiles\", \"--nodeps\", installerPath])\n    }\n    throw new Error(`Package manager ${packageManager} not supported`)\n  }\n}\n"]}