Commit 5dc0f291 authored by guinux's avatar guinux

add clean_build_files

parent acebeec3
......@@ -192,7 +192,7 @@ namespace Pamac {
}
}
internal void clean_cache (keep_nb, only_uninstalled) {
internal void clean_cache (uint64 keep_nb, bool only_uninstalled) {
var database = new Pamac.Database (config);
HashTable<string, int64?> details = database.get_clean_cache_details (keep_nb, only_uninstalled);
var iter = HashTableIter<string, int64?> (details);
......@@ -207,6 +207,15 @@ namespace Pamac {
}
}
internal void clean_build_files (string build_dir) {
try {
Process.spawn_command_line_sync ("rm -rf %s".printf (build_dir));
Process.spawn_command_line_sync ("mkdir -p %s".printf (build_dir));
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
}
unowned Alpm.Package? get_syncpkg (string name) {
unowned Alpm.Package? pkg = null;
unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs;
......
......@@ -236,6 +236,30 @@ namespace Pamac {
return filenames_size;
}
void enumerate_directory (string directory_path, ref HashTable<string, int64?> filenames_size) {
var directory = GLib.File.new_for_path (directory_path);
try {
FileEnumerator enumerator = directory.enumerate_children ("standard::*", FileQueryInfoFlags.NONE);
FileInfo info;
while ((info = enumerator.next_file (null)) != null) {
string absolute_filename = Path.build_path ("/", directory.get_path (), info.get_name ());
if (info.get_file_type () == FileType.DIRECTORY) {
enumerate_directory (absolute_filename, ref filenames_size);
} else {
filenames_size.insert (absolute_filename, info.get_size ());
}
}
} catch (GLib.Error e) {
stderr.printf ("Error: %s\n", e.message);
}
}
public HashTable<string, int64?> get_build_files_details (string aur_build_dir) {
var filenames_size = new HashTable<string, int64?> (str_hash, str_equal);
enumerate_directory (aur_build_dir, ref filenames_size);
return filenames_size;
}
public List<string> get_ignorepkgs () {
var result = new List<string> ();
unowned Alpm.List<unowned string> ignorepkgs = alpm_handle.ignorepkgs;
......
......@@ -34,20 +34,6 @@ common_sources = ['common.vala', 'package.vala', 'pamac_config.vala']
transaction_gtk_sources = ['transaction-gtk.vala', 'choose_provider_dialog.vala', 'choose_pkgs_dialog.vala', 'transaction_sum_dialog.vala', 'progress_box.vala']
preferences_sources = ['preferences_dialog.vala']
executable('pamac-clean-cache',
sources: ['pamac_config.vala', 'clean_cache.vala'],
dependencies: [gio],
vala_args: common_vala_args,
c_args: common_c_args,
install: true)
executable('pamac-system-daemon',
sources: ['common_daemon.vala', 'pamac_config.vala', 'alpm_config.vala', 'alpm_utils.vala', 'system_daemon.vala'],
dependencies: [vala_deps, alpm_deps, json, libsoup, polkit, libcurl, appstream],
vala_args: [common_vala_args, alpm_vala_args],
c_args: [common_c_args, alpm_c_args],
install : true)
libpamac = library('pamac',
sources: [common_sources, 'error.vala', 'alpm_config.vala', 'aur.vala', 'database.vala', 'transaction_interface.vala', 'alpm_utils.vala', 'transaction_interface_root.vala', 'transaction_interface_daemon.vala', 'transaction.vala'],
dependencies: [alpm_deps, math, json, appstream, libsoup, libcurl],
......@@ -59,6 +45,20 @@ libpamac = library('pamac',
libpamac_dep = declare_dependency(link_with: libpamac)
executable('pamac-clean-cache',
sources: ['clean_cache.vala'],
dependencies: [gio, libpamac_dep],
vala_args: common_vala_args,
c_args: common_c_args,
install: true)
executable('pamac-system-daemon',
sources: ['common_daemon.vala', 'alpm_utils.vala', 'alpm_config.vala', 'system_daemon.vala'],
dependencies: [vala_deps, alpm_deps, json, libsoup, polkit, libcurl, appstream, libpamac_dep],
vala_args: [common_vala_args, alpm_vala_args],
c_args: [common_c_args, alpm_c_args],
install : true)
executable('pamac',
sources: ['version.vala', 'transaction-cli.vala', 'cli.vala'],
dependencies: [gio, posix, math, libpamac_dep],
......
......@@ -361,6 +361,15 @@ namespace Pamac {
});
}
public void clean_build_files (string build_dir, GLib.BusName sender) throws Error {
check_authorization.begin (sender, (obj, res) => {
bool authorized = check_authorization.end (res);
if (authorized) {
alpm_utils.clean_build_files (build_dir);
}
});
}
public void start_set_pkgreason (string pkgname, uint reason, GLib.BusName sender) throws Error {
check_authorization.begin (sender, (obj, res) => {
bool authorized = check_authorization.end (res);
......
......@@ -27,6 +27,7 @@ namespace Pamac {
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf);
public abstract void start_generate_mirrors_list (string country);
public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled);
public abstract void clean_build_files (string build_dir);
public abstract void start_set_pkgreason (string pkgname, uint reason);
public abstract void start_refresh (bool force);
public abstract void start_downloading_updates ();
......
......@@ -29,6 +29,7 @@ namespace Pamac {
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws Error;
public abstract void start_generate_mirrors_list (string country) throws Error;
public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled) throws Error;
public abstract void clean_build_files (string build_dir) throws Error;
public abstract void start_set_pkgreason (string pkgname, uint reason) throws Error;
public abstract void start_refresh (bool force) throws Error;
public abstract void start_downloading_updates () throws Error;
......@@ -174,6 +175,14 @@ namespace Pamac {
}
}
public void clean_build_files (string build_dir) {
try {
system_daemon.clean_build_files (build_dir);
} catch (Error e) {
stderr.printf ("clean_build_files: %s\n", e.message);
}
}
public void start_set_pkgreason (string pkgname, uint reason) {
try {
system_daemon.start_set_pkgreason (pkgname, reason);
......
......@@ -137,6 +137,10 @@ namespace Pamac {
alpm_utils.clean_cache (keep_nb, only_uninstalled);
}
public void clean_build_files (string build_dir) {
alpm_utils.clean_build_files (build_dir);
}
async void set_pkgreason (string pkgname, uint reason) {
alpm_utils.set_pkgreason (pkgname, reason);
database_modified ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment