Browse Source

Fix compilation errors

pull/10/head
matthiakl 5 months ago
parent
commit
10722140f3
  1. 25
      src/alpm_config.vala
  2. 77
      src/pamac-system-daemon/system_daemon.vala
  3. 37
      src/pamac-user-daemon/user_daemon.vala
  4. 8
      src/transaction.vala
  5. 2
      src/vapis/libalpm.vapi

25
src/alpm_config.vala

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

77
src/pamac-system-daemon/system_daemon.vala

@ -183,12 +183,12 @@ namespace Pamac {
trans_commit_finished (false);
return;
} else {
alpm_handle.eventcb = (Alpm.EventCallBack) cb_event;
alpm_handle.progresscb = (Alpm.ProgressCallBack) cb_progress;
alpm_handle.questioncb = (Alpm.QuestionCallBack) cb_question;
alpm_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch;
alpm_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload;
alpm_handle.logcb = (Alpm.LogCallBack) cb_log;
alpm_handle.set_eventcb((Alpm.EventCallBack) cb_event, null);
alpm_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null);
alpm_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
alpm_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null);
alpm_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null);
alpm_handle.set_logcb((Alpm.LogCallBack) cb_log, null);
lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
var pamac_config = new Pamac.Config ();
if (pamac_config.update_files_db) {
@ -196,12 +196,12 @@ namespace Pamac {
} else {
files_handle = alpm_config.get_handle (false);
}
files_handle.eventcb = (Alpm.EventCallBack) cb_event;
files_handle.progresscb = (Alpm.ProgressCallBack) cb_progress;
files_handle.questioncb = (Alpm.QuestionCallBack) cb_question;
files_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch;
files_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload;
files_handle.logcb = (Alpm.LogCallBack) cb_log;
files_handle.set_eventcb((Alpm.EventCallBack) cb_event, null);
files_handle.set_progresscb((Alpm.ProgressCallBack) cb_progress, null);
files_handle.set_questioncb((Alpm.QuestionCallBack) cb_question, null);
files_handle.set_fetchcb((Alpm.FetchCallBack) cb_fetch, null);
files_handle.set_dlcb((Alpm.DownloadCallBack) cb_download, null);
files_handle.set_logcb((Alpm.LogCallBack) cb_log, null);
}
}
@ -475,26 +475,19 @@ namespace Pamac {
private bool update_dbs (Alpm.Handle handle, int force) {
bool success = false;
unowned Alpm.List<unowned Alpm.DB> syncdbs = handle.syncdbs;
while (syncdbs != null) {
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
// fail later with unresolved deps, but that should be rare, and would be expected
success = true;
} else {
Alpm.Errno errnos = handle.errno ();
current_error.errnos = (uint) errnos;
if (errnos != 0) {
// download error details are set in cb_fetch
if (errnos != Alpm.Errno.EXTERNAL_DOWNLOAD) {
current_error.details = { Alpm.strerror (errnos) };
}
if (handle.update_dbs (syncdbs, force) >= 0) {
// 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
success = true;
} else {
Alpm.Errno errnos = handle.errno ();
current_error.errnos = (uint) errnos;
if (errnos != 0) {
// download error details are set in cb_fetch
if (errnos != Alpm.Errno.EXTERNAL_DOWNLOAD) {
current_error.details = { Alpm.strerror (errnos) };
}
}
syncdbs.next ();
}
return success;
}
@ -1268,7 +1261,7 @@ namespace Pamac {
};
trans_commit_finished (false);
} 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);
// fake aur db
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 = {};
uint secondary_type = 0;
switch (data.type) {
@ -1778,7 +1771,7 @@ private void cb_event (Alpm.Event.Data data) {
case Alpm.Event.Type.SCRIPTLET_INFO:
details += data.scriptlet_info_line;
break;
case Alpm.Event.Type.PKGDOWNLOAD_START:
case Alpm.Event.Type.PKG_RETRIEVE_START:
// do not emit event when download is cancelled
if (system_daemon.cancellable.is_cancelled ()) {
return;
@ -1804,7 +1797,7 @@ private void cb_event (Alpm.Event.Data data) {
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) {
case Alpm.Question.Type.INSTALL_IGNOREPKG:
// 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) {
system_daemon.emit_progress ((uint) progress, pkgname, (uint) percent, n_targets, current_target);
system_daemon.timer.start ();
@ -1878,7 +1871,7 @@ private void cb_progress (Alpm.Progress progress, string pkgname, int percent, u
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 ())) {
return 1;
@ -1907,7 +1900,7 @@ private int cb_download (void* data, uint64 dltotal, uint64 dlnow, uint64 ultota
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 ()) {
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.FILETIME, 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_TIME, 30L);
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;
}
private void cb_totaldownload (uint64 total) {
system_daemon.emit_totaldownload (total);
private void cb_download (void* ctx, string filename, Alpm.Download.Event event_type, void* event_data) {
// 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
if (system_daemon.cancellable.is_cancelled ()) {
return;

37
src/pamac-user-daemon/user_daemon.vala

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

8
src/transaction.vala

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

2
src/vapis/libalpm.vapi

@ -428,7 +428,7 @@ namespace Alpm {
public unowned Package? get_pkg(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);
}

Loading…
Cancel
Save