Skip to content

Commit

Permalink
Squashed commit of recover-failures
Browse files Browse the repository at this point in the history
commit 9627714
Merge: 50d3293 e74cf3e
Author: nephros <nemo@pgxperiiia10>
Date:   Tue Jun 13 23:54:10 2023 +0200

    Merge branch 'master' into recover-failures

commit 50d3293
Author: nephros <nemo@pgxperiiia10>
Date:   Thu Jun 1 08:29:02 2023 +0200

    [tool]: fix syntax

commit ac9b31c
Merge: d24ee1e 3974d0f
Author: nephros <nemo@pgxperiiia10>
Date:   Thu Jun 1 08:25:36 2023 +0200

    Merge branch 'recover-failures' of git+ssh://github.com/nephros/patchmanager into recover-failures

commit 3974d0f
Merge: 7c6611a ae85a89
Author: Peter G <[email protected]>
Date:   Tue May 30 05:16:55 2023 +0000

    Merge branch 'master' into recover-failures

commit d24ee1e
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 12:24:40 2023 +0200

    refresh after setting good list

commit 0fe5d47
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 12:24:11 2023 +0200

    only set good patches if we have any

commit 7c6611a
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 12:14:47 2023 +0200

    [trivial] whitespace-align help output

commit a73a4fc
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 12:14:20 2023 +0200

    Add "load known-good" to command line options

commit 3acc095
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 10:37:34 2023 +0200

    fixup! Add call to save current set as KnownGood

commit adaed74
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 10:27:46 2023 +0200

    Add "save as good" to command line options

commit 9c1f07d
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 10:19:18 2023 +0200

    Add call to save current set as KnownGood

commit 2b04ab6
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 09:40:44 2023 +0200

    Add option to load last-know-good patch list

    Contributes-To: sailfishos-patches#277

commit 777d43d
Author: nephros <nemo@pgxperiiia10>
Date:   Fri May 26 09:23:28 2023 +0200

    if auto applying succeded, save a known good state
  • Loading branch information
nephros committed Jul 14, 2023
1 parent 4b4fdb2 commit 5f50048
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
<method name="getLoaded">
<arg name="loaded" type="b" direction="out" />
</method>
<method name="revertToLastGood">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="setKnownGood">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="resolveFailure">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
Expand Down
12 changes: 7 additions & 5 deletions src/bin/patchmanager-daemon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ void help()
{
std::cout << "Patchmanager " << BUILD_VERSION << std::endl;
std::cout << "Usage:" << std::endl;
std::cout << " patchmanager [--help] : Print this help text" << std::endl;
std::cout << " patchmanager -a <Patch> : Enable and activate a Patch" << std::endl;
std::cout << " patchmanager -u <Patch> : Deactivate and disable (unapply) a Patch" << std::endl;
std::cout << " patchmanager --unapply-all : Deactivate and disable (unapply) all Patches" << std::endl;
std::cout << " patchmanager --daemon : Start Patchmanager as daemon" << std::endl;
std::cout << " patchmanager [--help] : Print this help text" << std::endl;
std::cout << " patchmanager -a <Patch> : Enable and activate a Patch" << std::endl;
std::cout << " patchmanager -u <Patch> : Deactivate and disable (unapply) a Patch" << std::endl;
std::cout << " patchmanager --unapply-all : Deactivate and disable (unapply) all Patches" << std::endl;
std::cout << " patchmanager --save-as-good : Save list of enabled Patches as 'known good'" << std::endl;
std::cout << " patchmanager --load-known-good : Enable 'known good' Patches" << std::endl;
std::cout << " patchmanager --daemon : Start Patchmanager as daemon" << std::endl;
}

int main(int argc, char **argv)
Expand Down
43 changes: 38 additions & 5 deletions src/bin/patchmanager-daemon/patchmanagerobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,21 @@ void PatchManagerObject::setAppliedPatches(const QSet<QString> &patches)
putSettings(QStringLiteral("applied"), QStringList(patches.toList()));
}

QSet<QString> PatchManagerObject::getLastGoodPatches() const
{
return getSettings(QStringLiteral("lastknowngood"), QStringList()).toStringList().toSet();
}

void PatchManagerObject::setLastGoodPatches(const QSet<QString> &patches)
{
putSettings(QStringLiteral("lastknowngood"), QStringList(patches.toList()));
}

void PatchManagerObject::setKnownGood()
{
setLastGoodPatches(getAppliedPatches());
}

QStringList PatchManagerObject::getMangleCandidates()
{
if (m_mangleCandidates.empty()) {
Expand Down Expand Up @@ -592,6 +607,10 @@ void PatchManagerObject::doPrepareCacheRoot()
emit m_adaptor->autoApplyingFinished(success);
}

if (success) {
setLastGoodPatches(m_appliedPatches);
}

if (!success) {
setAppliedPatches(m_appliedPatches);
refreshPatchList();
Expand Down Expand Up @@ -1113,6 +1132,10 @@ void PatchManagerObject::process()
}
} else if (args[1] == QStringLiteral("--unapply-all")) {
method = QStringLiteral("unapplyAllPatches");
} else if (args[1] == QStringLiteral("--save-as-good")) {
method = QStringLiteral("setKnownGood");
} else if (args[1] == QStringLiteral("--load-known-good")) {
method = QStringLiteral("revertToLastGood");
} else {
return;
}
Expand Down Expand Up @@ -1562,20 +1585,30 @@ bool PatchManagerObject::getToggleServices() const
/*! Returns the internal failure state. */
bool PatchManagerObject::getFailure() const
{
return m_failed;
return m_failed;
}

/*! Returns the internal state whether the server thread is running. */
bool PatchManagerObject::getLoaded() const
{
return m_serverThread->isRunning();
return m_serverThread->isRunning();
}

/*!
Reset internal failure state and re-initialize.
Reset internal failure state and re-initialize.
\sa loadRequest()
*/
void PatchManagerObject::revertToLastGood()
{
QSet<QString> patches = getLastGoodPatches();
if (!patches.empty()) {
m_appliedPatches = patches;
setAppliedPatches(patches);
refreshPatchList();
}
}

\sa loadRequest()
*/
void PatchManagerObject::resolveFailure()
{
qDebug() << Q_FUNC_INFO;
Expand Down
5 changes: 5 additions & 0 deletions src/bin/patchmanager-daemon/patchmanagerobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public slots:
bool getFailure() const;
bool getLoaded() const;
void resolveFailure();
void revertToLastGood();
void loadRequest(bool apply);

void lipstickChanged(const QString &state);
Expand Down Expand Up @@ -216,6 +217,10 @@ private slots:
QSet<QString> getAppliedPatches() const;
void setAppliedPatches(const QSet<QString> &patches);

QSet<QString> getLastGoodPatches() const;
void setLastGoodPatches(const QSet<QString> &patches);
void setKnownGood();

void getVersion();

void lateInitialize();
Expand Down
6 changes: 6 additions & 0 deletions src/qml/PatchManagerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ Page {
onClicked: pageStack.push(Qt.resolvedUrl("RestartServicesDialog.qml"))
}

MenuItem {
text: qsTranslate("", "Load Pre-Failure List")
visible: PatchManager.failure
onClicked: menuRemorse.execute( text, function() { PatchManager.call(PatchManager.revertToLastGood()) } )
}

MenuItem {
text: qsTranslate("", "Resolve failure")
visible: PatchManager.failure
Expand Down
14 changes: 14 additions & 0 deletions src/qml/patchmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,20 @@ void PatchManager::onLoadedChanged(bool loaded)
}

/*! Calls the \e resolveFailure method on D-Bus */
void PatchManager::revertToLastGood()
{
qDebug() << Q_FUNC_INFO;

m_interface->revertToLastGood();
}

void PatchManager::setKnownGood()
{
qDebug() << Q_FUNC_INFO;

m_interface->setKnownGood();
}

void PatchManager::resolveFailure()
{
qDebug() << Q_FUNC_INFO;
Expand Down
2 changes: 2 additions & 0 deletions src/qml/patchmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public slots:
void onFailureChanged(bool failed);
void onLoadedChanged(bool loaded);

void setKnownGood();
void revertToLastGood();
void resolveFailure();

signals:
Expand Down
12 changes: 12 additions & 0 deletions src/tools/patchmanager-tool
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ function usage() {
printf "\t-A | --activate-all\t\tActivate / apply all Patches formerly marked as active.\n"
printf "\t-d | --deactivate\t\tDeactivate / unapply Patches from list or file (via -f).\n"
printf "\t-D | --deactivate-all\t\tDeactivate / unapply all Patches.\n"
printf "\t-S | --save-as-good\t\tSave list of enabled Patches as 'known good'\n"
printf "\t-G | --load-known-good\t\tEnable 'known good' Patches\n"
printf "\t-f | --file <filepath>\t\tUse <filepath> for the list of Patches.\n"
printf "\t-e | --export\t\t\tExport list of Patches marked as active either to STDout or (via -f) to a file.\n"
printf "\t-h | --help\t\t\tPrint this help.\n"
Expand Down Expand Up @@ -93,6 +95,16 @@ case "$1" in
shift
surplus "$*"
;;
-S|--save-as-good)
operation="--save-as-good"
shift
surplus "$*"
;;
-G|--load-known-good)
operation="--load-known-good"
shift
surplus "$*"
;;
--reset-system)
operation="--reset-system"
shift
Expand Down

0 comments on commit 5f50048

Please sign in to comment.