Skip to content

Commit

Permalink
Use DBus API to check for final release
Browse files Browse the repository at this point in the history
Live images don't have a /.bootstamp file.

Rather than working arround this use the newly added
DBus API in the Anaconda backend.
  • Loading branch information
M4rtinK committed Jul 20, 2023
1 parent 99cd49a commit 2c296f5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 40 deletions.
61 changes: 61 additions & 0 deletions ui/webui/src/apis/runtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2023 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with This program; If not, see <http://www.gnu.org/licenses/>.
*/

import cockpit from "cockpit";

export class RuntimeClient {
constructor (address) {
if (RuntimeClient.instance && (!address || RuntimeClient.instance.address === address)) {
return RuntimeClient.instance;
}

RuntimeClient.instance?.client.close();

RuntimeClient.instance = this;

this.client = cockpit.dbus(
"org.fedoraproject.Anaconda.Modules.Runtime",
{ superuser: "try", bus: "none", address }
);
this.address = address;
}

init () {
this.client.addEventListener(
"close", () => console.error("Runtime client closed")
);
}
}

/**
*
* @returns {Promise} Reports if the given OS release is considered final
*/
export const getIsFinal = () => {
return (
new RuntimeClient().client.call(
"/org/fedoraproject/Anaconda/Modules/Runtime/UserInterface",
"org.freedesktop.DBus.Properties",
"Get",
[
"org.fedoraproject.Anaconda.Modules.Runtime.UserInterface",
"IsFinal",
]
)
.then(res => res[0].v)
);
};
13 changes: 7 additions & 6 deletions ui/webui/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { BossClient } from "../apis/boss.js";
import { LocalizationClient, initDataLocalization, startEventMonitorLocalization } from "../apis/localization.js";
import { StorageClient, initDataStorage, startEventMonitorStorage } from "../apis/storage.js";
import { PayloadsClient } from "../apis/payloads";
import { RuntimeClient, getIsFinal } from "../apis/runtime";

import { readBuildstamp, getIsFinal } from "../helpers/betanag.js";
import { readConf } from "../helpers/conf.js";
import { useReducerWithThunk, reducer, initialState } from "../reducer.js";

Expand All @@ -61,6 +61,7 @@ export const Application = () => {
new LocalizationClient(address),
new StorageClient(address),
new PayloadsClient(address),
new RuntimeClient(address),
new BossClient(address)
];
clients.forEach(c => c.init());
Expand All @@ -77,18 +78,18 @@ export const Application = () => {
startEventMonitorStorage({ dispatch });
startEventMonitorLocalization({ dispatch });
}, setCriticalError);

getIsFinal().then(
isFinal => setBeta(!isFinal),
setCriticalError
);
});

readConf().then(
setConf,
setCriticalError
);

readBuildstamp().then(
buildstamp => setBeta(!getIsFinal(buildstamp)),
setCriticalError
);

readOsRelease().then(osRelease => setPrettyName(osRelease.PRETTY_NAME));
}, [dispatch]);

Expand Down
34 changes: 0 additions & 34 deletions ui/webui/src/helpers/betanag.js

This file was deleted.

0 comments on commit 2c296f5

Please sign in to comment.