forked from cromer/pamac-classic
add files db support
This commit is contained in:
parent
a00d5ca83c
commit
bfee1fcc52
@ -187,6 +187,20 @@ class AlpmConfig {
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Alpm.Handle? get_files_handle () {
|
||||||
|
Alpm.Handle? handle = new Alpm.Handle (rootdir, dbpath, null);
|
||||||
|
if (handle == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// define options
|
||||||
|
handle.dbext = ".files";
|
||||||
|
// register dbs
|
||||||
|
foreach (unowned AlpmRepo repo in repo_order) {
|
||||||
|
handle.register_syncdb (repo.name, 0);
|
||||||
|
}
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
void parse_file (string path, string? section = null) {
|
void parse_file (string path, string? section = null) {
|
||||||
string? current_section = section;
|
string? current_section = section;
|
||||||
var file = GLib.File.new_for_path (path);
|
var file = GLib.File.new_for_path (path);
|
||||||
|
@ -96,6 +96,7 @@ namespace Pamac {
|
|||||||
public class Daemon: Object {
|
public class Daemon: Object {
|
||||||
private AlpmConfig alpm_config;
|
private AlpmConfig alpm_config;
|
||||||
private Alpm.Handle? alpm_handle;
|
private Alpm.Handle? alpm_handle;
|
||||||
|
private Alpm.Handle? files_handle;
|
||||||
public Cond provider_cond;
|
public Cond provider_cond;
|
||||||
public Mutex provider_mutex;
|
public Mutex provider_mutex;
|
||||||
public int? choosen_provider;
|
public int? choosen_provider;
|
||||||
@ -230,6 +231,7 @@ namespace Pamac {
|
|||||||
alpm_handle.logcb = (Alpm.LogCallBack) cb_log;
|
alpm_handle.logcb = (Alpm.LogCallBack) cb_log;
|
||||||
lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
|
lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
|
||||||
}
|
}
|
||||||
|
files_handle = alpm_config.get_files_handle ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool check_pacman_running () {
|
private bool check_pacman_running () {
|
||||||
@ -433,6 +435,7 @@ namespace Pamac {
|
|||||||
uint success = 0;
|
uint success = 0;
|
||||||
cancellable.reset ();
|
cancellable.reset ();
|
||||||
init_curl ();
|
init_curl ();
|
||||||
|
string[] dbexts = {".db", ".files"};
|
||||||
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;
|
||||||
@ -442,6 +445,8 @@ namespace Pamac {
|
|||||||
databases_lock_mutex.unlock ();
|
databases_lock_mutex.unlock ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
foreach (unowned string dbext in dbexts) {
|
||||||
|
alpm_handle.dbext = dbext;
|
||||||
if (db.update (force) >= 0) {
|
if (db.update (force) >= 0) {
|
||||||
success++;
|
success++;
|
||||||
} else {
|
} else {
|
||||||
@ -451,6 +456,7 @@ namespace Pamac {
|
|||||||
current_error.details = { Alpm.strerror (errno) };
|
current_error.details = { Alpm.strerror (errno) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
syncdbs.next ();
|
syncdbs.next ();
|
||||||
}
|
}
|
||||||
delete curl;
|
delete curl;
|
||||||
@ -1188,7 +1194,6 @@ namespace Pamac {
|
|||||||
string installdate = "";
|
string installdate = "";
|
||||||
string[] groups = {};
|
string[] groups = {};
|
||||||
string[] backups = {};
|
string[] backups = {};
|
||||||
string[] files = {};
|
|
||||||
string[] licenses = {};
|
string[] licenses = {};
|
||||||
string[] depends = {};
|
string[] depends = {};
|
||||||
string[] optdepends = {};
|
string[] optdepends = {};
|
||||||
@ -1273,14 +1278,6 @@ namespace Pamac {
|
|||||||
list.next ();
|
list.next ();
|
||||||
}
|
}
|
||||||
pkg_optionalfor.free_inner (GLib.free);
|
pkg_optionalfor.free_inner (GLib.free);
|
||||||
// files
|
|
||||||
unowned Alpm.FileList filelist = alpm_pkg.files;
|
|
||||||
Alpm.File* file_ptr = filelist.files;
|
|
||||||
for (size_t i = 0; i < filelist.count; i++, file_ptr++) {
|
|
||||||
if (!file_ptr->name.has_suffix ("/")) {
|
|
||||||
files += "/" + file_ptr->name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// sync pkg
|
// sync pkg
|
||||||
} else if (alpm_pkg.origin == Alpm.Package.From.SYNCDB) {
|
} else if (alpm_pkg.origin == Alpm.Package.From.SYNCDB) {
|
||||||
// repos
|
// repos
|
||||||
@ -1339,10 +1336,41 @@ namespace Pamac {
|
|||||||
details.conflicts = (owned) conflicts;
|
details.conflicts = (owned) conflicts;
|
||||||
details.groups = (owned) groups;
|
details.groups = (owned) groups;
|
||||||
details.backups = (owned) backups;
|
details.backups = (owned) backups;
|
||||||
details.files = (owned) files;
|
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string[] get_pkg_files (string pkgname) {
|
||||||
|
string[] files = {};
|
||||||
|
unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname);
|
||||||
|
if (alpm_pkg != null) {
|
||||||
|
unowned Alpm.FileList filelist = alpm_pkg.files;
|
||||||
|
Alpm.File* file_ptr = filelist.files;
|
||||||
|
for (size_t i = 0; i < filelist.count; i++, file_ptr++) {
|
||||||
|
if (!file_ptr->name.has_suffix ("/")) {
|
||||||
|
files += "/" + file_ptr->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unowned Alpm.List<unowned Alpm.DB> syncdbs = files_handle.syncdbs;
|
||||||
|
while (syncdbs != null) {
|
||||||
|
unowned Alpm.DB db = syncdbs.data;
|
||||||
|
unowned Alpm.Package? files_pkg = db.get_pkg (pkgname);
|
||||||
|
if (files_pkg != null) {
|
||||||
|
unowned Alpm.FileList filelist = files_pkg.files;
|
||||||
|
Alpm.File* file_ptr = filelist.files;
|
||||||
|
for (size_t i = 0; i < filelist.count; i++, file_ptr++) {
|
||||||
|
if (!file_ptr->name.has_suffix ("/")) {
|
||||||
|
files += "/" + file_ptr->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
syncdbs.next ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
public void start_get_updates (bool check_aur_updates) {
|
public void start_get_updates (bool check_aur_updates) {
|
||||||
UpdateInfos[] updates_infos = {};
|
UpdateInfos[] updates_infos = {};
|
||||||
unowned Alpm.Package? pkg = null;
|
unowned Alpm.Package? pkg = null;
|
||||||
@ -2410,6 +2438,9 @@ private int cb_fetch (string fileurl, string localpath, int force) {
|
|||||||
pamac_daemon.curl->setopt (Curl.Option.ERRORBUFFER, error_buffer);
|
pamac_daemon.curl->setopt (Curl.Option.ERRORBUFFER, error_buffer);
|
||||||
pamac_daemon.curl->setopt (Curl.Option.NOPROGRESS, 0L);
|
pamac_daemon.curl->setopt (Curl.Option.NOPROGRESS, 0L);
|
||||||
pamac_daemon.curl->setopt (Curl.Option.XFERINFODATA, (void*) url.get_basename ());
|
pamac_daemon.curl->setopt (Curl.Option.XFERINFODATA, (void*) url.get_basename ());
|
||||||
|
pamac_daemon.curl->setopt (Curl.Option.TIMECONDITION, Curl.TimeCond.NONE);
|
||||||
|
pamac_daemon.curl->setopt (Curl.Option.TIMEVALUE, 0);
|
||||||
|
pamac_daemon.curl->setopt (Curl.Option.RESUME_FROM_LARGE, 0);
|
||||||
|
|
||||||
bool remove_partial_download = true;
|
bool remove_partial_download = true;
|
||||||
if (fileurl.contains (".pkg.tar.") && !fileurl.has_suffix (".sig")) {
|
if (fileurl.contains (".pkg.tar.") && !fileurl.has_suffix (".sig")) {
|
||||||
@ -2545,8 +2576,8 @@ private int cb_fetch (string fileurl, string localpath, int force) {
|
|||||||
} catch (GLib.Error e) {
|
} catch (GLib.Error e) {
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
}
|
}
|
||||||
// do not report error for missing sig with db
|
// do not report error for missing sig
|
||||||
if (!fileurl.has_suffix ("db.sig")) {
|
if (!fileurl.has_suffix (".sig")) {
|
||||||
string hostname = url.get_uri ().split("/")[2];
|
string hostname = url.get_uri ().split("/")[2];
|
||||||
pamac_daemon.emit_log ((uint) Alpm.LogLevel.ERROR,
|
pamac_daemon.emit_log ((uint) Alpm.LogLevel.ERROR,
|
||||||
_("failed retrieving file '%s' from %s : %s\n").printf (
|
_("failed retrieving file '%s' from %s : %s\n").printf (
|
||||||
|
@ -79,6 +79,8 @@ namespace Pamac {
|
|||||||
[GtkChild]
|
[GtkChild]
|
||||||
Gtk.StackSwitcher packages_stackswitcher;
|
Gtk.StackSwitcher packages_stackswitcher;
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
|
Gtk.Stack properties_stack;
|
||||||
|
[GtkChild]
|
||||||
Gtk.StackSwitcher properties_stackswitcher;
|
Gtk.StackSwitcher properties_stackswitcher;
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
Gtk.Grid deps_grid;
|
Gtk.Grid deps_grid;
|
||||||
@ -300,6 +302,7 @@ namespace Pamac {
|
|||||||
main_stack.notify["visible-child"].connect (on_main_stack_visible_child_changed);
|
main_stack.notify["visible-child"].connect (on_main_stack_visible_child_changed);
|
||||||
filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
|
filters_stack.notify["visible-child"].connect (on_filters_stack_visible_child_changed);
|
||||||
packages_stack.notify["visible-child"].connect (on_packages_stack_visible_child_changed);
|
packages_stack.notify["visible-child"].connect (on_packages_stack_visible_child_changed);
|
||||||
|
properties_stack.notify["visible-child"].connect (on_properties_stack_visible_child_changed);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -622,18 +625,9 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
deps_grid.show_all ();
|
deps_grid.show_all ();
|
||||||
// files
|
// files
|
||||||
if (details.files.length > 0) {
|
// will be populated on properties_stack switch
|
||||||
files_scrolledwindow.visible = true;
|
if (properties_stack.visible_child_name == "files") {
|
||||||
StringBuilder text = new StringBuilder ();
|
on_properties_stack_visible_child_changed ();
|
||||||
foreach (unowned string file in details.files) {
|
|
||||||
if (text.len > 0) {
|
|
||||||
text.append ("\n");
|
|
||||||
}
|
|
||||||
text.append (file);
|
|
||||||
}
|
|
||||||
files_textview.buffer.set_text (text.str, (int) text.len);
|
|
||||||
} else {
|
|
||||||
files_scrolledwindow.visible = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,6 +865,7 @@ namespace Pamac {
|
|||||||
|
|
||||||
void display_package_properties (string pkgname) {
|
void display_package_properties (string pkgname) {
|
||||||
current_package_displayed = pkgname;
|
current_package_displayed = pkgname;
|
||||||
|
files_scrolledwindow.visible = true;
|
||||||
set_package_details (current_package_displayed);
|
set_package_details (current_package_displayed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,12 +878,17 @@ namespace Pamac {
|
|||||||
[GtkCallback]
|
[GtkCallback]
|
||||||
void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
|
void on_packages_treeview_row_activated (Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn column) {
|
||||||
if (column.title == dgettext (null, "Name")) {
|
if (column.title == dgettext (null, "Name")) {
|
||||||
|
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||||
|
while (Gtk.events_pending ()) {
|
||||||
|
Gtk.main_iteration ();
|
||||||
|
}
|
||||||
main_stack.visible_child_name = "details";
|
main_stack.visible_child_name = "details";
|
||||||
Gtk.TreeIter iter;
|
Gtk.TreeIter iter;
|
||||||
packages_list.get_iter (out iter, path);
|
packages_list.get_iter (out iter, path);
|
||||||
string pkgname;
|
string pkgname;
|
||||||
packages_list.get (iter, 1, out pkgname);
|
packages_list.get (iter, 1, out pkgname);
|
||||||
display_package_properties (pkgname);
|
display_package_properties (pkgname);
|
||||||
|
this.get_window ().set_cursor (null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,6 +939,29 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void on_properties_stack_visible_child_changed () {
|
||||||
|
switch (properties_stack.visible_child_name) {
|
||||||
|
case "files":
|
||||||
|
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
|
||||||
|
while (Gtk.events_pending ()) {
|
||||||
|
Gtk.main_iteration ();
|
||||||
|
}
|
||||||
|
string[] files = transaction.get_pkg_files (current_package_displayed);
|
||||||
|
StringBuilder text = new StringBuilder ();
|
||||||
|
foreach (unowned string file in files) {
|
||||||
|
if (text.len > 0) {
|
||||||
|
text.append ("\n");
|
||||||
|
}
|
||||||
|
text.append (file);
|
||||||
|
}
|
||||||
|
files_textview.buffer.set_text (text.str, (int) text.len);
|
||||||
|
this.get_window ().set_cursor (null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void on_packages_state_icon_activated (Gtk.TreePath path) {
|
void on_packages_state_icon_activated (Gtk.TreePath path) {
|
||||||
Gtk.TreeIter iter;
|
Gtk.TreeIter iter;
|
||||||
packages_list.get_iter (out iter, path);
|
packages_list.get_iter (out iter, path);
|
||||||
|
@ -49,7 +49,6 @@ namespace Pamac {
|
|||||||
public string[] conflicts;
|
public string[] conflicts;
|
||||||
public string[] groups;
|
public string[] groups;
|
||||||
public string[] backups;
|
public string[] backups;
|
||||||
public string[] files;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct AURPackage {
|
public struct AURPackage {
|
||||||
|
@ -52,6 +52,7 @@ namespace Pamac {
|
|||||||
public abstract string[] get_groups_names () throws IOError;
|
public abstract string[] get_groups_names () throws IOError;
|
||||||
public abstract async AlpmPackage[] get_group_pkgs (string groupname) throws IOError;
|
public abstract async AlpmPackage[] get_group_pkgs (string groupname) throws IOError;
|
||||||
public abstract AlpmPackageDetails get_pkg_details (string pkgname) throws IOError;
|
public abstract AlpmPackageDetails get_pkg_details (string pkgname) throws IOError;
|
||||||
|
public abstract string[] get_pkg_files (string pkgname) throws IOError;
|
||||||
public abstract async AURPackageDetails get_aur_details (string pkgname) throws IOError;
|
public abstract async AURPackageDetails get_aur_details (string pkgname) throws IOError;
|
||||||
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
|
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
|
||||||
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
|
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
|
||||||
@ -690,6 +691,15 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string[] get_pkg_files (string pkgname) {
|
||||||
|
try {
|
||||||
|
return daemon.get_pkg_files (pkgname);
|
||||||
|
} catch (IOError e) {
|
||||||
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async AURPackageDetails get_aur_details (string pkgname) {
|
public async AURPackageDetails get_aur_details (string pkgname) {
|
||||||
var pkg = AURPackageDetails () {
|
var pkg = AURPackageDetails () {
|
||||||
name = "",
|
name = "",
|
||||||
|
Loading…
Reference in New Issue
Block a user