Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-26.04

steps:
- uses: actions/checkout@v7
Expand Down
30 changes: 30 additions & 0 deletions common/coroutines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* coroutines.h
*
* Copyright (c) 2026 Andrey Kutejko <andy128k@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/

#ifndef _COROUTINES_H_
#define _COROUTINES_H_

#include <coroutine>
#include <beman/task/task.hpp>

template<class T = void>
using task = beman::execution::task<T>;

#endif
2 changes: 1 addition & 1 deletion common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ libsynaptic = static_library(
'synaptic',
common_sources,
cpp_args: base_cpp_args + rpm_compile_args,
dependencies: common_deps,
dependencies: common_deps + [task_dep],
include_directories: [root_inc, common_inc],
)

Expand Down
14 changes: 7 additions & 7 deletions common/rinstallprogress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const char* RInstallProgress::getResultStr(pkgPackageManager::OrderResult res)
return "Unknown install result.";
}

pkgPackageManager::OrderResult RInstallProgress::start(pkgPackageManager *pm,
task<pkgPackageManager::OrderResult> RInstallProgress::start(pkgPackageManager *pm,
int numPackages,
int numPackagesTotal)
{
Expand All @@ -85,7 +85,7 @@ pkgPackageManager::OrderResult RInstallProgress::start(pkgPackageManager *pm,

res = pm->DoInstallPreFork();
if (res == pkgPackageManager::Failed)
return res;
co_return res;

/*
* This will make a pipe from where we can read child's output
Expand Down Expand Up @@ -124,7 +124,7 @@ pkgPackageManager::OrderResult RInstallProgress::start(pkgPackageManager *pm,

res = pm->DoInstallPreFork();
if (res == pkgPackageManager::Failed)
return res;
co_return res;

_child_id = fork();

Expand All @@ -135,19 +135,19 @@ pkgPackageManager::OrderResult RInstallProgress::start(pkgPackageManager *pm,
}
#endif

startUpdate();
co_await startUpdate();
while (waitpid(_child_id, &ret, WNOHANG) == 0)
updateInterface();
co_await updateInterface();

res = (pkgPackageManager::OrderResult) WEXITSTATUS(ret);

finishUpdate();
co_await finishUpdate();

#ifdef HAVE_RPM
close(_childin);
#endif

return res;
co_return res;
}

// vim:sts=4:sw=4
14 changes: 10 additions & 4 deletions common/rinstallprogress.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include <string>

#include "coroutines.h"

class RInstallProgress {
protected:
int _stdout;
Expand All @@ -49,22 +51,26 @@ class RInstallProgress {
static std::string errorMsg;
static std::string incompleteMsg;

virtual void startUpdate() {
[[nodiscard]] virtual task<void> startUpdate() {
co_return;
}
virtual void updateInterface() {
[[nodiscard]] virtual task<void> updateInterface() {
co_return;
}
virtual void finishUpdate() {
[[nodiscard]] virtual task<void> finishUpdate() {
co_return;
}

public:
// get a str feed to the user with the result of the install run
virtual const char* getResultStr(pkgPackageManager::OrderResult);
virtual pkgPackageManager::OrderResult start(pkgPackageManager *pm,
[[nodiscard]] virtual task<pkgPackageManager::OrderResult> start(pkgPackageManager *pm,
int numPackages = 0,
int numPackagesTotal = 0);


RInstallProgress():_donePackagesTotal(0), _numPackagesTotal(0),_updateFinished(false) {}
virtual ~RInstallProgress() {}
};


Expand Down
16 changes: 8 additions & 8 deletions common/rpackagelister.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ bool RPackageLister::getDownloadUris(vector<string> &uris)
return true;
}

bool RPackageLister::commitChanges(pkgAcquireStatus *status,
task<bool> RPackageLister::commitChanges(pkgAcquireStatus *status,
RInstallProgress *iprog)
{
FileFd lock;
Expand All @@ -1417,7 +1417,7 @@ bool RPackageLister::commitChanges(pkgAcquireStatus *status,
_updating = true;

if (!lockPackageCache(lock))
return false;
co_return false;

if(_config->FindB("Synaptic::Log::Changes",true))
makeCommitLog();
Expand All @@ -1427,7 +1427,7 @@ bool RPackageLister::commitChanges(pkgAcquireStatus *status,
assert(_cache->list() != NULL);
// Read the source list
if (_cache->list()->ReadMainList() == false) {
_userDialog->
co_await _userDialog->
warning(_("Ignoring invalid record(s) in sources.list file!"));
}

Expand Down Expand Up @@ -1490,7 +1490,7 @@ bool RPackageLister::commitChanges(pkgAcquireStatus *status,

if (_config->FindB("Volatile::Download-Only", false)) {
_updating = false;
return !Failed;
co_return !Failed;
}

if (Failed) {
Expand All @@ -1508,7 +1508,7 @@ bool RPackageLister::commitChanges(pkgAcquireStatus *status,
message += "(" + serverError + ")\n";
message += _("Do you want to continue, ignoring these packages?");

if (!_userDialog->confirm(message.c_str()))
if (!co_await _userDialog->confirm(message.c_str()))
goto gave_wood;
}
// Try to deal with missing package files
Expand All @@ -1527,7 +1527,7 @@ bool RPackageLister::commitChanges(pkgAcquireStatus *status,

_system->UnLockInner();
pkgPackageManager::OrderResult Res =
iprog->start(rPM, numPackages, numPackagesTotal);
co_await iprog->start(rPM, numPackages, numPackagesTotal);
_system->LockInner();
if (Res == pkgPackageManager::Failed || _error->PendingError()) {
if (Transient == false)
Expand Down Expand Up @@ -1562,11 +1562,11 @@ bool RPackageLister::commitChanges(pkgAcquireStatus *status,
writeCommitLog();

delete rPM;
return Ret;
co_return Ret;

gave_wood:
delete rPM;
return false;
co_return false;
}

void RPackageLister::writeCommitLog()
Expand Down
3 changes: 2 additions & 1 deletion common/rpackagelister.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "rpackagecache.h"
#include "rpackagestatus.h"
#include "coroutines.h"

#include <apt-pkg/pkgcache.h>
#include <apt-pkg/progress.h>
Expand Down Expand Up @@ -295,7 +296,7 @@ class RPackageLister {
bool distUpgrade();
bool cleanPackageCache(bool forceClean = false);
bool updateCache(pkgAcquireStatus *status, std::string &error);
bool commitChanges(pkgAcquireStatus *status, RInstallProgress *iprog);
[[nodiscard]] task<bool> commitChanges(pkgAcquireStatus *status, RInstallProgress *iprog);

// some information
bool getDownloadUris(std::vector<std::string> &uris);
Expand Down
10 changes: 5 additions & 5 deletions common/ruserdialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include <string>
#include "ruserdialog.h"

bool RUserDialog::showErrors()
task<bool> RUserDialog::showErrors()
{
if (_error->empty())
return false;
co_return false;

while (!_error->empty()) {
std::string message;
Expand All @@ -42,13 +42,13 @@ bool RUserDialog::showErrors()

if (!message.empty()) {
if (iserror)
error(message.c_str());
co_await error(message.c_str());
else
warning(message.c_str());
co_await warning(message.c_str());
}
}

return true;
co_return true;
}

// vim:ts=3:sw=3:et
26 changes: 15 additions & 11 deletions common/ruserdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "config.h" // IWYU pragma: associated

#include "coroutines.h"

class RUserDialog {
public:
enum ButtonsType {
Expand All @@ -42,29 +44,31 @@ class RUserDialog {
DialogError
};

virtual bool message(const char *msg,
[[nodiscard]] virtual task<bool> message(const char *msg,
DialogType dialog = DialogInfo,
ButtonsType buttons = ButtonsDefault,
bool defaultResponse = true) = 0;

virtual bool confirm(const char *msg, bool defaultResponse = true) {
return message(msg, DialogQuestion, ButtonsYesNo, defaultResponse);
[[nodiscard]] virtual task<bool> confirm(const char *msg, bool defaultResponse = true) {
co_return co_await message(msg, DialogQuestion, ButtonsYesNo, defaultResponse);
}

virtual bool proceed(const char *msg, bool defaultResponse = true) {
return message(msg, DialogInfo, ButtonsOkCancel, defaultResponse);
[[nodiscard]] virtual task<bool> proceed(const char *msg, bool defaultResponse = true) {
co_return co_await message(msg, DialogInfo, ButtonsOkCancel, defaultResponse);
}

virtual bool warning(const char *msg, bool nocancel = true) {
return nocancel ? message(msg, DialogWarning)
: message(msg, DialogWarning, ButtonsOkCancel, false);
[[nodiscard]] virtual task<bool> warning(const char *msg, bool nocancel = true) {
if (nocancel)
co_return co_await message(msg, DialogWarning);
else
co_return co_await message(msg, DialogWarning, ButtonsOkCancel, false);
}

virtual void error(const char *msg) {
message(msg, DialogError);
[[nodiscard]] virtual task<void> error(const char *msg) {
co_await message(msg, DialogError);
}

virtual bool showErrors();
[[nodiscard]] virtual task<bool> showErrors();

};

Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: synaptic
Section: admin
Priority: optional
Maintainer: Michael Vogt <mvo@debian.org>
Build-Depends: debhelper-compat (= 12), gettext, meson, ninja-build, libapt-pkg-dev, libgtk-3-dev, libvte-2.91-dev, libpolkit-gobject-1-dev, libsm-dev, lsb-release, libxapian-dev, xmlto
Build-Depends: debhelper-compat (= 12), gettext, meson, ninja-build, cmake, libapt-pkg-dev, libgtk-4-dev, libvte-2.91-gtk4-dev, libpolkit-gobject-1-dev, libsm-dev, lsb-release, libxapian-dev, libtbb-dev, xmlto
Build-Conflicts: librpm-dev
Standards-Version: 4.5.0
Vcs-Git: https://github.com/mvo5/synaptic.git
Expand Down
Loading