From a2c66f1047fca3dd12ba422c87168069749b88dc Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 4 Jul 2019 17:42:48 -0500 Subject: [PATCH] \#28: Fix Linux upgrade --- CHANGELOG.md | 1 + public/electron.js | 8 ++------ public/update_linux.sh | 8 -------- src/App.js | 10 +++++++--- src/redux/actions/release_version_actions.js | 14 ++++++++++++-- src/redux/reducers/release_version_reducer.js | 7 +++++-- 6 files changed, 27 insertions(+), 21 deletions(-) delete mode 100644 public/update_linux.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 993f9a2..49c998b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog # ## 1.0.4 ## +* \#28: Fix Linux upgrade * Additional Linux distribution support: * OpenSUSE Leap 15 * OpenSUSE Leap 15.1 diff --git a/public/electron.js b/public/electron.js index 8cde87a..b4012e4 100644 --- a/public/electron.js +++ b/public/electron.js @@ -16,7 +16,6 @@ require.extensions['.sh'] = function (module, filename) { module.exports = fs.readFileSync(filename, 'utf8'); }; const detectScript = require('./detect_linux.sh'); -const installScript = require('./update_linux.sh'); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. @@ -747,11 +746,8 @@ ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => { args = ['-a', 'Finder', data.Source]; } else if (platform === 'linux') { try { - const execPath = path.join(os.tmpdir(), 'install_linux.sh'); - fs.writeFileSync(execPath, installScript); - fs.chmodSync(execPath, '750'); - command = execPath; - args = [data.Source]; + command = data.Source; + fs.chmodSync(command, '750'); } catch (e) { errorHandler(e); } diff --git a/public/update_linux.sh b/public/update_linux.sh deleted file mode 100644 index dcd771d..0000000 --- a/public/update_linux.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -sleep 5 -chmod +x "$1" -"$1"& - -sleep 1 -rm -f "$0" \ No newline at end of file diff --git a/src/App.js b/src/App.js index a4c5dd4..7b7139a 100644 --- a/src/App.js +++ b/src/App.js @@ -113,9 +113,12 @@ class App extends IPCContainer { }; handleDownloadUpgrade = () => { - const url = this.props.UpgradeData.urls[0]; - const name = this.props.Platform === 'win32' ? 'upgrade.exe' : this.props.Platform === 'darwin' ? 'upgrade.dmg' : extractFileNameFromURL(url); - this.props.downloadItem(name, Constants.INSTALL_TYPES.Upgrade, url, this.onDownloadFileComplete); + const name = (this.props.Platform === 'win32') ? + 'upgrade.exe' : + (this.props.Platform === 'darwin') ? + 'upgrade.dmg' : + 'repertory-ui_' + this.props.UpgradeVersion + '_linux_x86_64.AppImage'; + this.props.downloadItem(name, Constants.INSTALL_TYPES.Upgrade, this.props.UpgradeData.urls[0], this.onDownloadFileComplete); }; installDependency = result => { @@ -338,6 +341,7 @@ const mapStateToProps = state => { UpgradeAvailable: state.relver.UpgradeAvailable, UpgradeData: state.relver.UpgradeData, UpgradeDismissed: state.relver.UpgradeDismissed, + UpgradeVersion: state.relver.UpgradeVersion, Version: state.common.Version, VersionLookup: state.relver.VersionLookup, }; diff --git a/src/redux/actions/release_version_actions.js b/src/redux/actions/release_version_actions.js index 3856cec..0a131de 100644 --- a/src/redux/actions/release_version_actions.js +++ b/src/redux/actions/release_version_actions.js @@ -26,7 +26,7 @@ export const detectUIUpgrade = () => { data.Versions[appPlatform] && (data.Versions[appPlatform].length > 0) && (data.Versions[appPlatform][0] !== version)) { - dispatch(setUIUpgradeData(data.Locations[appPlatform][data.Versions[appPlatform][0]])); + dispatch(setUIUpgradeData(data.Locations[appPlatform][data.Versions[appPlatform][0]], data.Versions[appPlatform][0])); } else { dispatch(clearUIUpgrade()); } @@ -115,4 +115,14 @@ export const setReleaseData = (locationsLookup, versionLookup)=> { }; export const setReleaseUpgradeAvailable = createAction('relver/setReleaseUpgradeAvailable'); -export const setUIUpgradeData = createAction('relver/setUIUpgradeData'); \ No newline at end of file + +export const SET_UI_UPGRADE_DATA = 'relver/setUIUpgradeData'; +export const setUIUpgradeData = (upgradeData, version) => { + return { + type: SET_UI_UPGRADE_DATA, + payload: { + upgrade_data: upgradeData, + version: version, + } + } +}; \ No newline at end of file diff --git a/src/redux/reducers/release_version_reducer.js b/src/redux/reducers/release_version_reducer.js index 1a681be..4e6b4b5 100644 --- a/src/redux/reducers/release_version_reducer.js +++ b/src/redux/reducers/release_version_reducer.js @@ -20,6 +20,7 @@ export const releaseVersionReducer = createReducer({ ReleaseUpgradeAvailable: false, UpgradeAvailable: false, UpgradeData: null, + UpgradeVersion: null, UpgradeDismissed: false, Version: -1, VersionLookup: versionLookup, @@ -30,6 +31,7 @@ export const releaseVersionReducer = createReducer({ UpgradeAvailable: false, UpgradeDismissed: false, UpgradeData: null, + UpgradeVersion: null, }; }, [Actions.SET_ACTIVE_RELEASE]: (state, action) => { @@ -64,11 +66,12 @@ export const releaseVersionReducer = createReducer({ ReleaseUpgradeAvailable: action.payload, }; }, - [Actions.setUIUpgradeData]: (state, action) => { + [Actions.SET_UI_UPGRADE_DATA]: (state, action) => { return { ...state, UpgradeAvailable: true, - UpgradeData: action.payload, + UpgradeData: action.payload.upgrade_data, + UpgradeVersion: action.payload.version, UpgradeDismissed: false, }; }