forked from cromer/pamac-classic
save cache options in pamac.conf
This commit is contained in:
parent
9d138d0447
commit
20e42b6a75
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@ src/*.c
|
|||||||
src/pamac.h
|
src/pamac.h
|
||||||
src/pamac.vapi
|
src/pamac.vapi
|
||||||
src/libpamac.so
|
src/libpamac.so
|
||||||
|
src/pamac-clean-cache
|
||||||
src/pamac-user-daemon
|
src/pamac-user-daemon
|
||||||
src/pamac-system-daemon
|
src/pamac-system-daemon
|
||||||
src/pamac-tray
|
src/pamac-tray
|
||||||
|
2
Makefile
2
Makefile
@ -28,6 +28,7 @@ install: install_pamac-tray-appindicator
|
|||||||
install -Dm644 src/pamac.h $(includedir)/pamac.h
|
install -Dm644 src/pamac.h $(includedir)/pamac.h
|
||||||
install -Dm644 src/pamac.vapi $(datadir)/vala/vapi/pamac.vapi
|
install -Dm644 src/pamac.vapi $(datadir)/vala/vapi/pamac.vapi
|
||||||
install -Dm755 src/libpamac.so $(libdir)/libpamac.so
|
install -Dm755 src/libpamac.so $(libdir)/libpamac.so
|
||||||
|
install -Dm755 src/pamac-clean-cache $(bindir)/pamac-clean-cache
|
||||||
install -Dm755 src/pamac-user-daemon $(bindir)/pamac-user-daemon
|
install -Dm755 src/pamac-user-daemon $(bindir)/pamac-user-daemon
|
||||||
install -Dm744 src/pamac-system-daemon $(bindir)/pamac-system-daemon
|
install -Dm744 src/pamac-system-daemon $(bindir)/pamac-system-daemon
|
||||||
install -Dm755 src/pamac-tray $(bindir)/pamac-tray
|
install -Dm755 src/pamac-tray $(bindir)/pamac-tray
|
||||||
@ -66,6 +67,7 @@ uninstall:
|
|||||||
rm -f $(includedir)/pamac.h
|
rm -f $(includedir)/pamac.h
|
||||||
rm -f $(datadir)/vala/vapi/pamac.vapi
|
rm -f $(datadir)/vala/vapi/pamac.vapi
|
||||||
rm -f $(libdir)/libpamac.so
|
rm -f $(libdir)/libpamac.so
|
||||||
|
rm -f $(bindir)/pamac-clean-cache
|
||||||
rm -f $(bindir)/pamac-user-daemon
|
rm -f $(bindir)/pamac-user-daemon
|
||||||
rm -f $(bindir)/pamac-system-daemon
|
rm -f $(bindir)/pamac-system-daemon
|
||||||
rm -f $(bindir)/pamac-tray
|
rm -f $(bindir)/pamac-tray
|
||||||
|
@ -18,3 +18,9 @@ RefreshPeriod = 6
|
|||||||
|
|
||||||
## AUR build directory:
|
## AUR build directory:
|
||||||
BuildDirectory = /tmp
|
BuildDirectory = /tmp
|
||||||
|
|
||||||
|
## Number of versions of each package to keep in the cache:
|
||||||
|
KeepNumPackages = 3
|
||||||
|
|
||||||
|
## Remove only the versions of uninstalled packages when clean cache:
|
||||||
|
#OnlyRmUninstalled
|
||||||
|
@ -3,4 +3,4 @@ Description=Clean packages cache
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/paccache -r
|
ExecStart=/usr/bin/pamac-clean-cache
|
||||||
|
@ -39,11 +39,18 @@ MANAGER_GRESOURCE_FILE = ../resources/pamac.manager.gresource.xml
|
|||||||
|
|
||||||
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
|
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
|
||||||
|
|
||||||
binaries: pamac-user-daemon pamac-system-daemon pamac-tray pamac-manager pamac-install
|
binaries: pamac-clean-cache pamac-user-daemon pamac-system-daemon pamac-tray pamac-manager pamac-install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.c pamac.h pamac.vapi libpamac.so pamac-user-daemon pamac-system-daemon pamac-tray pamac-tray-appindicator pamac-manager pamac-install
|
rm -f *.c pamac.h pamac.vapi libpamac.so pamac-user-daemon pamac-system-daemon pamac-tray pamac-tray-appindicator pamac-manager pamac-install
|
||||||
|
|
||||||
|
pamac-clean-cache: pamac_config.vala clean_cache.vala
|
||||||
|
valac -o pamac-clean-cache \
|
||||||
|
$(COMMON_VALA_FLAGS) \
|
||||||
|
--pkg=gio-2.0 \
|
||||||
|
pamac_config.vala \
|
||||||
|
clean_cache.vala
|
||||||
|
|
||||||
pamac-tray: $(COMMON_SOURCES) alpm_config.vala tray.vala tray-gtk.vala
|
pamac-tray: $(COMMON_SOURCES) alpm_config.vala tray.vala tray-gtk.vala
|
||||||
valac -o pamac-tray \
|
valac -o pamac-tray \
|
||||||
$(COMMON_VALA_FLAGS) \
|
$(COMMON_VALA_FLAGS) \
|
||||||
|
32
src/clean_cache.vala
Normal file
32
src/clean_cache.vala
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* pamac-vala
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
|
||||||
|
*
|
||||||
|
* 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 3 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 get of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||||
|
string rm_only_uninstalled_str = "";
|
||||||
|
if (pamac_config.rm_only_uninstalled) {
|
||||||
|
rm_only_uninstalled_str = "-u";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Process.spawn_command_line_sync ("paccache -q --nocolor %s -r -k %llu".printf (rm_only_uninstalled_str, pamac_config.keep_num_pkgs));
|
||||||
|
} catch (SpawnError e) {
|
||||||
|
stderr.printf ("SpawnError: %s\n", e.message);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -28,6 +28,8 @@ namespace Pamac {
|
|||||||
public bool enable_aur { get; private set; }
|
public bool enable_aur { get; private set; }
|
||||||
public string aur_build_dir { get; private set; }
|
public string aur_build_dir { get; private set; }
|
||||||
public bool check_aur_updates { get; private set; }
|
public bool check_aur_updates { get; private set; }
|
||||||
|
public uint64 keep_num_pkgs { get; private set; }
|
||||||
|
public bool rm_only_uninstalled { get; private set; }
|
||||||
public unowned HashTable<string,string> environment_variables {
|
public unowned HashTable<string,string> environment_variables {
|
||||||
get {
|
get {
|
||||||
return _environment_variables;
|
return _environment_variables;
|
||||||
@ -72,6 +74,8 @@ namespace Pamac {
|
|||||||
enable_aur = false;
|
enable_aur = false;
|
||||||
aur_build_dir = "/tmp";
|
aur_build_dir = "/tmp";
|
||||||
check_aur_updates = false;
|
check_aur_updates = false;
|
||||||
|
keep_num_pkgs = 3;
|
||||||
|
rm_only_uninstalled = false;
|
||||||
parse_file (conf_path);
|
parse_file (conf_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +107,13 @@ namespace Pamac {
|
|||||||
unowned string val = splitted[1]._strip ();
|
unowned string val = splitted[1]._strip ();
|
||||||
refresh_period = uint64.parse (val);
|
refresh_period = uint64.parse (val);
|
||||||
}
|
}
|
||||||
|
} else if (key == "KeepNumPackages") {
|
||||||
|
if (splitted.length == 2) {
|
||||||
|
unowned string val = splitted[1]._strip ();
|
||||||
|
keep_num_pkgs = uint64.parse (val);
|
||||||
|
}
|
||||||
|
} else if (key == "OnlyRmUninstalled") {
|
||||||
|
rm_only_uninstalled = true;
|
||||||
} else if (key == "NoUpdateHideIcon") {
|
} else if (key == "NoUpdateHideIcon") {
|
||||||
no_update_hide_icon = true;
|
no_update_hide_icon = true;
|
||||||
} else if (key == "EnableAUR") {
|
} else if (key == "EnableAUR") {
|
||||||
@ -157,6 +168,24 @@ namespace Pamac {
|
|||||||
} else {
|
} else {
|
||||||
data.append (line + "\n");
|
data.append (line + "\n");
|
||||||
}
|
}
|
||||||
|
} else if (line.contains ("KeepNumPackages")) {
|
||||||
|
if (new_conf.lookup_extended ("KeepNumPackages", null, out variant)) {
|
||||||
|
data.append ("KeepNumPackages = %llu\n".printf (variant.get_uint64 ()));
|
||||||
|
new_conf.remove ("KeepNumPackages");
|
||||||
|
} else {
|
||||||
|
data.append (line + "\n");
|
||||||
|
}
|
||||||
|
} else if (line.contains ("OnlyRmUninstalled")) {
|
||||||
|
if (new_conf.lookup_extended ("OnlyRmUninstalled", null, out variant)) {
|
||||||
|
if (variant.get_boolean ()) {
|
||||||
|
data.append ("OnlyRmUninstalled\n");
|
||||||
|
} else {
|
||||||
|
data.append ("#OnlyRmUninstalled\n");
|
||||||
|
}
|
||||||
|
new_conf.remove ("OnlyRmUninstalled");
|
||||||
|
} else {
|
||||||
|
data.append (line + "\n");
|
||||||
|
}
|
||||||
} else if (line.contains ("NoUpdateHideIcon")) {
|
} else if (line.contains ("NoUpdateHideIcon")) {
|
||||||
if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) {
|
if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) {
|
||||||
if (variant.get_boolean ()) {
|
if (variant.get_boolean ()) {
|
||||||
@ -224,6 +253,14 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
} else if (key == "RefreshPeriod") {
|
} else if (key == "RefreshPeriod") {
|
||||||
data.append ("RefreshPeriod = %llu\n".printf (val.get_uint64 ()));
|
data.append ("RefreshPeriod = %llu\n".printf (val.get_uint64 ()));
|
||||||
|
} else if (key == "KeepNumPackages") {
|
||||||
|
data.append ("KeepNumPackages = %llu\n".printf (val.get_uint64 ()));
|
||||||
|
} else if (key == "OnlyRmUninstalled") {
|
||||||
|
if (val.get_boolean ()) {
|
||||||
|
data.append ("OnlyRmUninstalled\n");
|
||||||
|
} else {
|
||||||
|
data.append ("#OnlyRmUninstalled\n");
|
||||||
|
}
|
||||||
} else if (key =="NoUpdateHideIcon") {
|
} else if (key =="NoUpdateHideIcon") {
|
||||||
if (val.get_boolean ()) {
|
if (val.get_boolean ()) {
|
||||||
data.append ("NoUpdateHideIcon\n");
|
data.append ("NoUpdateHideIcon\n");
|
||||||
|
@ -91,6 +91,8 @@ namespace Pamac {
|
|||||||
previous_refresh_period = transaction.refresh_period;
|
previous_refresh_period = transaction.refresh_period;
|
||||||
}
|
}
|
||||||
no_update_hide_icon_checkbutton.active = transaction.no_update_hide_icon;
|
no_update_hide_icon_checkbutton.active = transaction.no_update_hide_icon;
|
||||||
|
cache_keep_nb_spin_button.value = transaction.keep_num_pkgs;
|
||||||
|
cache_only_uninstalled_checkbutton.active = transaction.rm_only_uninstalled;
|
||||||
|
|
||||||
// populate ignorepkgs_liststore
|
// populate ignorepkgs_liststore
|
||||||
ignorepkgs_liststore = new Gtk.ListStore (1, typeof (string));
|
ignorepkgs_liststore = new Gtk.ListStore (1, typeof (string));
|
||||||
@ -104,6 +106,8 @@ namespace Pamac {
|
|||||||
check_updates_button.state_set.connect (on_check_updates_button_state_set);
|
check_updates_button.state_set.connect (on_check_updates_button_state_set);
|
||||||
refresh_period_spin_button.value_changed.connect (on_refresh_period_spin_button_value_changed);
|
refresh_period_spin_button.value_changed.connect (on_refresh_period_spin_button_value_changed);
|
||||||
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
|
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
|
||||||
|
cache_keep_nb_spin_button.value_changed.connect (on_cache_keep_nb_spin_button_value_changed);
|
||||||
|
cache_only_uninstalled_checkbutton.toggled.connect (on_cache_only_uninstalled_checkbutton_toggled);
|
||||||
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
||||||
|
|
||||||
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrors");
|
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrors");
|
||||||
@ -181,6 +185,18 @@ namespace Pamac {
|
|||||||
transaction.start_write_pamac_config (new_pamac_conf);
|
transaction.start_write_pamac_config (new_pamac_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void on_cache_keep_nb_spin_button_value_changed () {
|
||||||
|
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||||
|
new_pamac_conf.insert ("KeepNumPackages", new Variant.uint64 (cache_keep_nb_spin_button.get_value_as_int ()));
|
||||||
|
transaction.start_write_pamac_config (new_pamac_conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_cache_only_uninstalled_checkbutton_toggled () {
|
||||||
|
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||||
|
new_pamac_conf.insert ("OnlyRmUninstalled", new Variant.boolean (cache_only_uninstalled_checkbutton.active));
|
||||||
|
transaction.start_write_pamac_config (new_pamac_conf);
|
||||||
|
}
|
||||||
|
|
||||||
void on_no_update_hide_icon_checkbutton_toggled () {
|
void on_no_update_hide_icon_checkbutton_toggled () {
|
||||||
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
||||||
new_pamac_conf.insert ("NoUpdateHideIcon", new Variant.boolean (no_update_hide_icon_checkbutton.active));
|
new_pamac_conf.insert ("NoUpdateHideIcon", new Variant.boolean (no_update_hide_icon_checkbutton.active));
|
||||||
@ -365,8 +381,7 @@ namespace Pamac {
|
|||||||
|
|
||||||
[GtkCallback]
|
[GtkCallback]
|
||||||
void on_cache_clean_button_clicked () {
|
void on_cache_clean_button_clicked () {
|
||||||
transaction.clean_cache ((uint) cache_keep_nb_spin_button.get_value_as_int (),
|
transaction.clean_cache (transaction.keep_num_pkgs, transaction.rm_only_uninstalled);
|
||||||
cache_only_uninstalled_checkbutton.active);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,12 +397,12 @@ namespace Pamac {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clean_cache (uint keep_nb, bool only_uninstalled, GLib.BusName sender) {
|
public void clean_cache (uint64 keep_nb, bool only_uninstalled, GLib.BusName sender) {
|
||||||
check_authorization.begin (sender, (obj, res) => {
|
check_authorization.begin (sender, (obj, res) => {
|
||||||
bool authorized = check_authorization.end (res);
|
bool authorized = check_authorization.end (res);
|
||||||
if (authorized) {
|
if (authorized) {
|
||||||
string[] commands = {"paccache", "-rq"};
|
string[] commands = {"paccache", "--nocolor", "-rq"};
|
||||||
commands += "-k%u".printf (keep_nb);
|
commands += "-k%llu".printf (keep_nb);
|
||||||
if (only_uninstalled) {
|
if (only_uninstalled) {
|
||||||
commands += "-u";
|
commands += "-u";
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace Pamac {
|
|||||||
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError;
|
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError;
|
||||||
public abstract void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError;
|
public abstract void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError;
|
||||||
public abstract void start_generate_mirrors_list () throws IOError;
|
public abstract void start_generate_mirrors_list () throws IOError;
|
||||||
public abstract void clean_cache (uint keep_nb, bool only_uninstalled) throws IOError;
|
public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled) throws IOError;
|
||||||
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
|
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
|
||||||
public abstract void start_refresh (bool force) throws IOError;
|
public abstract void start_refresh (bool force) throws IOError;
|
||||||
public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs) throws IOError;
|
public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs) throws IOError;
|
||||||
@ -121,6 +121,8 @@ namespace Pamac {
|
|||||||
public bool recurse { get { return pamac_config.recurse; } }
|
public bool recurse { get { return pamac_config.recurse; } }
|
||||||
public uint64 refresh_period { get { return pamac_config.refresh_period; } }
|
public uint64 refresh_period { get { return pamac_config.refresh_period; } }
|
||||||
public string aur_build_dir { get { return pamac_config.aur_build_dir; } }
|
public string aur_build_dir { get { return pamac_config.aur_build_dir; } }
|
||||||
|
public uint64 keep_num_pkgs { get { return pamac_config.keep_num_pkgs; } }
|
||||||
|
public bool rm_only_uninstalled { get { return pamac_config.rm_only_uninstalled; } }
|
||||||
|
|
||||||
//Alpm.TransFlag
|
//Alpm.TransFlag
|
||||||
int flags;
|
int flags;
|
||||||
@ -448,7 +450,7 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clean_cache (uint keep_nb, bool only_uninstalled) {
|
public void clean_cache (uint64 keep_nb, bool only_uninstalled) {
|
||||||
try {
|
try {
|
||||||
system_daemon.clean_cache (keep_nb, only_uninstalled);
|
system_daemon.clean_cache (keep_nb, only_uninstalled);
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user