Fix compilation errors

This commit is contained in:
matthiakl 2021-07-09 14:00:59 +02:00
parent fb8724826e
commit 10722140f3
5 changed files with 72 additions and 77 deletions

View File

@ -51,7 +51,6 @@ public class AlpmConfig {
string? dbpath; string? dbpath;
string? logfile; string? logfile;
string? gpgdir; string? gpgdir;
string? arch;
int usesyslog; int usesyslog;
public int checkspace; public int checkspace;
GLib.List<string> cachedirs; GLib.List<string> cachedirs;
@ -62,6 +61,7 @@ public class AlpmConfig {
GLib.List<string> noupgrades; GLib.List<string> noupgrades;
GLib.List<string> holdpkgs; GLib.List<string> holdpkgs;
GLib.List<string> syncfirsts; GLib.List<string> syncfirsts;
GLib.List<string> architectures;
Alpm.Signature.Level siglevel; Alpm.Signature.Level siglevel;
Alpm.Signature.Level localfilesiglevel; Alpm.Signature.Level localfilesiglevel;
Alpm.Signature.Level remotefilesiglevel; Alpm.Signature.Level remotefilesiglevel;
@ -93,6 +93,7 @@ public class AlpmConfig {
noupgrades = new GLib.List<string> (); noupgrades = new GLib.List<string> ();
holdpkgs = new GLib.List<string> (); holdpkgs = new GLib.List<string> ();
syncfirsts = new GLib.List<string> (); syncfirsts = new GLib.List<string> ();
architectures = new GLib.List<string> ();
usesyslog = 0; usesyslog = 0;
checkspace = 0; checkspace = 0;
siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL; siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL;
@ -130,8 +131,8 @@ public class AlpmConfig {
// rootdir is defined because it contains configuration data. // rootdir is defined because it contains configuration data.
gpgdir = "/etc/pacman.d/gnupg/"; gpgdir = "/etc/pacman.d/gnupg/";
} }
if (arch == null) { if (architectures.length () == 0) {
arch = Posix.utsname().machine; architectures.append (Posix.utsname().machine);
} }
} }
@ -171,7 +172,9 @@ public class AlpmConfig {
handle.logfile = logfile; handle.logfile = logfile;
} }
handle.gpgdir = gpgdir; handle.gpgdir = gpgdir;
handle.arch = arch; foreach (unowned string arch in architectures) {
handle.add_architecture (arch);
}
handle.usesyslog = usesyslog; handle.usesyslog = usesyslog;
handle.checkspace = checkspace; handle.checkspace = checkspace;
handle.defaultsiglevel = siglevel; handle.defaultsiglevel = siglevel;
@ -202,7 +205,9 @@ public class AlpmConfig {
repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask); repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask);
unowned Alpm.DB db = handle.register_syncdb (repo.name, repo.siglevel); unowned Alpm.DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (unowned string url in repo.urls) { foreach (unowned string url in repo.urls) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch)); foreach (unowned string arch in architectures) {
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", arch));
}
} }
if (repo.usage == 0) { if (repo.usage == 0) {
db.usage = Alpm.DB.Usage.ALL; db.usage = Alpm.DB.Usage.ALL;
@ -272,10 +277,12 @@ public class AlpmConfig {
} else if (key == "LogFile") { } else if (key == "LogFile") {
logfile = val; logfile = val;
} else if (key == "Architecture") { } else if (key == "Architecture") {
foreach (unowned string arch in val.split (" ")) {
if (val == "auto") { if (val == "auto") {
arch = Posix.utsname ().machine; architectures.append (Posix.utsname ().machine);
} else { } else {
arch = val; architectures.append (arch);
}
} }
} else if (key == "UseSysLog") { } else if (key == "UseSysLog") {
usesyslog = 1; usesyslog = 1;

View File

@ -183,12 +183,12 @@ namespace Pamac {
trans_commit_finished (false); trans_commit_finished (false);
return; return;
} else { } else {
alpm_handle.eventcb = (Alpm.EventCallBack) cb_event; alpm_handle.set_eventcb((Alpm.EventCallBack) cb_event, null);
alpm_handle.progresscb = (Alpm.ProgressCallBack) cb_progress; alpm_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null);
alpm_handle.questioncb = (Alpm.QuestionCallBack) cb_question; alpm_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
alpm_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; alpm_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null);
alpm_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload; alpm_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null);
alpm_handle.logcb = (Alpm.LogCallBack) cb_log; alpm_handle.set_logcb((Alpm.LogCallBack) cb_log, null);
lockfile = GLib.File.new_for_path (alpm_handle.lockfile); lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
var pamac_config = new Pamac.Config (); var pamac_config = new Pamac.Config ();
if (pamac_config.update_files_db) { if (pamac_config.update_files_db) {
@ -196,12 +196,12 @@ namespace Pamac {
} else { } else {
files_handle = alpm_config.get_handle (false); files_handle = alpm_config.get_handle (false);
} }
files_handle.eventcb = (Alpm.EventCallBack) cb_event; files_handle.set_eventcb((Alpm.EventCallBack) cb_event, null);
files_handle.progresscb = (Alpm.ProgressCallBack) cb_progress; files_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null);
files_handle.questioncb = (Alpm.QuestionCallBack) cb_question; files_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
files_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; files_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null);
files_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload; files_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null);
files_handle.logcb = (Alpm.LogCallBack) cb_log; files_handle.set_logcb((Alpm.LogCallBack) cb_log, null);
} }
} }
@ -475,12 +475,7 @@ namespace Pamac {
private bool update_dbs (Alpm.Handle handle, int force) { private bool update_dbs (Alpm.Handle handle, int force) {
bool success = false; bool success = false;
unowned Alpm.List<unowned Alpm.DB> syncdbs = handle.syncdbs; unowned Alpm.List<unowned Alpm.DB> syncdbs = handle.syncdbs;
while (syncdbs != null) { if (handle.update_dbs (syncdbs, force) >= 0) {
if (cancellable.is_cancelled ()) {
break;
}
unowned Alpm.DB db = syncdbs.data;
if (db.update (force) >= 0) {
// We should always succeed if at least one DB was upgraded - we may possibly // We should always succeed if at least one DB was upgraded - we may possibly
// fail later with unresolved deps, but that should be rare, and would be expected // fail later with unresolved deps, but that should be rare, and would be expected
success = true; success = true;
@ -494,8 +489,6 @@ namespace Pamac {
} }
} }
} }
syncdbs.next ();
}
return success; return success;
} }
@ -1268,7 +1261,7 @@ namespace Pamac {
}; };
trans_commit_finished (false); trans_commit_finished (false);
} else { } else {
alpm_handle.questioncb = (Alpm.QuestionCallBack) cb_question; alpm_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
lockfile = GLib.File.new_for_path (alpm_handle.lockfile); lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
// fake aur db // fake aur db
alpm_handle.register_syncdb ("aur", 0); alpm_handle.register_syncdb ("aur", 0);
@ -1720,7 +1713,7 @@ private void write_log_file (string event) {
} }
} }
private void cb_event (Alpm.Event.Data data) { private void cb_event (void *ctx, Alpm.Event.Data data) {
string[] details = {}; string[] details = {};
uint secondary_type = 0; uint secondary_type = 0;
switch (data.type) { switch (data.type) {
@ -1778,7 +1771,7 @@ private void cb_event (Alpm.Event.Data data) {
case Alpm.Event.Type.SCRIPTLET_INFO: case Alpm.Event.Type.SCRIPTLET_INFO:
details += data.scriptlet_info_line; details += data.scriptlet_info_line;
break; break;
case Alpm.Event.Type.PKGDOWNLOAD_START: case Alpm.Event.Type.PKG_RETRIEVE_START:
// do not emit event when download is cancelled // do not emit event when download is cancelled
if (system_daemon.cancellable.is_cancelled ()) { if (system_daemon.cancellable.is_cancelled ()) {
return; return;
@ -1804,7 +1797,7 @@ private void cb_event (Alpm.Event.Data data) {
system_daemon.emit_event ((uint) data.type, secondary_type, details); system_daemon.emit_event ((uint) data.type, secondary_type, details);
} }
private void cb_question (Alpm.Question.Data data) { private void cb_question (void *ctx, Alpm.Question.Data data) {
switch (data.type) { switch (data.type) {
case Alpm.Question.Type.INSTALL_IGNOREPKG: case Alpm.Question.Type.INSTALL_IGNOREPKG:
// Do not install package in IgnorePkg/IgnoreGroup // Do not install package in IgnorePkg/IgnoreGroup
@ -1861,7 +1854,7 @@ private void cb_question (Alpm.Question.Data data) {
} }
} }
private void cb_progress (Alpm.Progress progress, string pkgname, int percent, uint n_targets, uint current_target) { private void cb_progress (void *ctx, Alpm.Progress progress, string pkgname, int percent, uint n_targets, uint current_target) {
if (percent == 0) { if (percent == 0) {
system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target); system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target);
system_daemon.timer.start (); system_daemon.timer.start ();
@ -1878,7 +1871,7 @@ private void cb_progress (Alpm.Progress progress, string pkgname, int percent, u
private uint64 prevprogress; private uint64 prevprogress;
private int cb_download (void* data, uint64 dltotal, uint64 dlnow, uint64 ultotal, uint64 ulnow) { private int cb_curldownload (void* data, uint64 dltotal, uint64 dlnow, uint64 ultotal, uint64 ulnow) {
if (unlikely (system_daemon.cancellable.is_cancelled ())) { if (unlikely (system_daemon.cancellable.is_cancelled ())) {
return 1; return 1;
@ -1907,7 +1900,7 @@ private int cb_download (void* data, uint64 dltotal, uint64 dlnow, uint64 ultota
return 0; return 0;
} }
private int cb_fetch (string fileurl, string localpath, int force) { private int cb_fetch (void *ctx, string fileurl, string localpath, int force) {
if (system_daemon.cancellable.is_cancelled ()) { if (system_daemon.cancellable.is_cancelled ()) {
return -1; return -1;
} }
@ -1922,7 +1915,7 @@ private int cb_fetch (string fileurl, string localpath, int force) {
system_daemon.curl.setopt (Curl.Option.CONNECTTIMEOUT, 30L); system_daemon.curl.setopt (Curl.Option.CONNECTTIMEOUT, 30L);
system_daemon.curl.setopt (Curl.Option.FILETIME, 1L); system_daemon.curl.setopt (Curl.Option.FILETIME, 1L);
system_daemon.curl.setopt (Curl.Option.FOLLOWLOCATION, 1L); system_daemon.curl.setopt (Curl.Option.FOLLOWLOCATION, 1L);
system_daemon.curl.setopt (Curl.Option.XFERINFOFUNCTION, cb_download); system_daemon.curl.setopt (Curl.Option.XFERINFOFUNCTION, cb_curldownload);
system_daemon.curl.setopt (Curl.Option.LOW_SPEED_LIMIT, 1L); system_daemon.curl.setopt (Curl.Option.LOW_SPEED_LIMIT, 1L);
system_daemon.curl.setopt (Curl.Option.LOW_SPEED_TIME, 30L); system_daemon.curl.setopt (Curl.Option.LOW_SPEED_TIME, 30L);
system_daemon.curl.setopt (Curl.Option.NETRC, Curl.NetRCOption.OPTIONAL); system_daemon.curl.setopt (Curl.Option.NETRC, Curl.NetRCOption.OPTIONAL);
@ -2082,11 +2075,13 @@ private int cb_fetch (string fileurl, string localpath, int force) {
return ret; return ret;
} }
private void cb_totaldownload (uint64 total) { private void cb_download (void* ctx, string filename, Alpm.Download.Event event_type, void* event_data) {
system_daemon.emit_totaldownload (total); // TODO: implement alpm_cb_download
// if (event_type == Alpm.Download.Event.COMPLETED)...
// system_daemon.emit_totaldownload (total);
} }
private void cb_log (Alpm.LogLevel level, string fmt, va_list args) { private void cb_log (void *ctx, Alpm.LogLevel level, string fmt, va_list args) {
// do not log errors when download is cancelled // do not log errors when download is cancelled
if (system_daemon.cancellable.is_cancelled ()) { if (system_daemon.cancellable.is_cancelled ()) {
return; return;

View File

@ -214,9 +214,9 @@ namespace Pamac {
unowned Alpm.Package alpm_pkg = pkgcache.data; unowned Alpm.Package alpm_pkg = pkgcache.data;
if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) { if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) {
Alpm.List<string> requiredby = alpm_pkg.compute_requiredby (); Alpm.List<string> requiredby = alpm_pkg.compute_requiredby ();
if (requiredby.length == 0) { if (requiredby.length () == 0) {
Alpm.List<string> optionalfor = alpm_pkg.compute_optionalfor (); Alpm.List<string> optionalfor = alpm_pkg.compute_optionalfor ();
if (optionalfor.length == 0) { if (optionalfor.length () == 0) {
pkgs += initialise_pkg_struct (alpm_pkg); pkgs += initialise_pkg_struct (alpm_pkg);
} else { } else {
optionalfor.free_inner (GLib.free); optionalfor.free_inner (GLib.free);
@ -280,22 +280,26 @@ namespace Pamac {
foreach (unowned string part in splitted) { foreach (unowned string part in splitted) {
needles.add (part); needles.add (part);
} }
Alpm.List<unowned Alpm.Package> result = alpm_handle.localdb.search (needles); Alpm.List<unowned Alpm.Package> result;
// TODO: handle return value
alpm_handle.localdb.search (needles, out result);
Alpm.List<unowned Alpm.Package> syncpkgs = null; Alpm.List<unowned Alpm.Package> syncpkgs = null;
unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs; unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs;
while (syncdbs != null) { while (syncdbs != null) {
unowned Alpm.DB db = syncdbs.data; unowned Alpm.DB db = syncdbs.data;
if (syncpkgs.length == 0) { if (syncpkgs.length () == 0) {
syncpkgs = db.search (needles); db.search (needles, out syncpkgs);
} else { } else {
syncpkgs.join (db.search (needles).diff (syncpkgs, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); Alpm.List<unowned Alpm.Package> newsyncpkgs = null;
db.search (needles, out newsyncpkgs);
syncpkgs.join (newsyncpkgs.diff (syncpkgs, (Alpm.List.CompareFunc) alpm_pkg_compare_name));
} }
syncdbs.next (); syncdbs.next ();
} }
result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) alpm_pkg_compare_name)); result.join (syncpkgs.diff (result, (Alpm.List.CompareFunc) alpm_pkg_compare_name));
// use custom sort function // use custom sort function
global_search_string = search_string; global_search_string = search_string;
result.sort (result.length, (Alpm.List.CompareFunc) alpm_pkg_sort_search_by_relevance); result.sort (result.length (), (Alpm.List.CompareFunc) alpm_pkg_sort_search_by_relevance);
return result; return result;
} }
@ -828,29 +832,18 @@ namespace Pamac {
var tmp_handle = alpm_config.get_handle (false, true); var tmp_handle = alpm_config.get_handle (false, true);
// refresh tmp dbs // refresh tmp dbs
unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs; unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs;
while (syncdbs != null) { // TODO: read return value
unowned Alpm.DB db = syncdbs.data; tmp_handle.update_dbs(syncdbs, 0);
db.update (0);
syncdbs.next ();
}
// refresh file dbs // refresh file dbs
var pamac_config = new Pamac.Config (); var pamac_config = new Pamac.Config ();
if (pamac_config.update_files_db) { if (pamac_config.update_files_db) {
var tmp_files_handle = alpm_config.get_handle (true, true); var tmp_files_handle = alpm_config.get_handle (true, true);
syncdbs = tmp_files_handle.syncdbs; syncdbs = tmp_files_handle.syncdbs;
while (syncdbs != null) { tmp_files_handle.update_dbs(syncdbs, 0);
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
}
} else { } else {
var tmp_files_handle = alpm_config.get_handle (false, true); var tmp_files_handle = alpm_config.get_handle (false, true);
syncdbs = tmp_files_handle.syncdbs; syncdbs = tmp_files_handle.syncdbs;
while (syncdbs != null) { tmp_files_handle.update_dbs(syncdbs, 0);
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
}
} }
#if DISABLE_AUR #if DISABLE_AUR
#else #else

View File

@ -1548,15 +1548,15 @@ namespace Pamac {
detailed_action = details[0].replace ("\n", ""); detailed_action = details[0].replace ("\n", "");
important_details_outpout (false); important_details_outpout (false);
break; break;
case Alpm.Event.Type.RETRIEVE_START: case Alpm.Event.Type.DB_RETRIEVE_START:
start_downloading (); start_downloading ();
action = dgettext (null, "Downloading") + "..."; action = dgettext (null, "Downloading") + "...";
break; break;
case Alpm.Event.Type.RETRIEVE_DONE: case Alpm.Event.Type.DB_RETRIEVE_DONE:
case Alpm.Event.Type.RETRIEVE_FAILED: case Alpm.Event.Type.DB_RETRIEVE_FAILED:
stop_downloading (); stop_downloading ();
break; break;
case Alpm.Event.Type.PKGDOWNLOAD_START: case Alpm.Event.Type.PKG_RETRIEVE_START:
// special case handle differently // special case handle differently
show_in_term (dgettext (null, "Downloading %s").printf (details[0]) + "..."); show_in_term (dgettext (null, "Downloading %s").printf (details[0]) + "...");
string name_version_release = details[0].slice (0, details[0].last_index_of_char ('-')); string name_version_release = details[0].slice (0, details[0].last_index_of_char ('-'));

View File

@ -428,7 +428,7 @@ namespace Alpm {
public unowned Package? get_pkg(string name); public unowned Package? get_pkg(string name);
public unowned Group? get_group(string name); public unowned Group? get_group(string name);
public Alpm.List<unowned Package> search(Alpm.List<unowned string> needles); public int search(Alpm.List<unowned string> needles, out Alpm.List<unowned Package> ret);
public int check_pgp_signature(out SigList siglist); public int check_pgp_signature(out SigList siglist);
} }