From 4ba597802743bbd1154956c5c68d38bbfe2bd9e3 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Thu, 26 Oct 2017 13:45:40 -0300 Subject: [PATCH] reuse more code --- data/polkit/org.pamac.policy | 59 --- pamac.avprj | 21 +- po/POTFILES.in | 2 +- src/CMakeLists.txt | 6 +- src/Pamac.pc | 2 +- src/alpm_config.vala | 151 ++++++ src/aur/AUR.pc | 2 +- src/aur/CMakeLists.txt | 6 +- src/aur/meson.build | 6 +- src/meson.build | 6 +- src/mirrors_config.vala | 52 +++ src/pamac-clean-cache/CMakeLists.txt | 4 +- src/pamac-clean-cache/meson.build | 2 +- src/pamac-install/CMakeLists.txt | 4 +- src/pamac-install/meson.build | 2 +- src/pamac-manager/CMakeLists.txt | 4 +- src/pamac-manager/meson.build | 2 +- src/pamac-system-daemon/CMakeLists.txt | 4 +- src/pamac-system-daemon/alpm_config.vala | 490 +------------------- src/pamac-system-daemon/meson.build | 2 +- src/pamac-system-daemon/mirrors_config.vala | 132 +----- src/pamac-tray/CMakeLists.txt | 7 +- src/pamac-tray/alpm_config.vala | 1 + src/pamac-tray/meson.build | 5 +- src/pamac-tray/tray.vala | 12 + src/pamac-tray/user_daemon.vala | 61 --- src/pamac-user-daemon/CMakeLists.txt | 4 +- src/pamac-user-daemon/alpm_config.vala | 2 +- src/pamac-user-daemon/meson.build | 2 +- 29 files changed, 267 insertions(+), 786 deletions(-) mode change 100644 => 120000 src/pamac-system-daemon/alpm_config.vala mode change 100644 => 120000 src/pamac-system-daemon/mirrors_config.vala create mode 120000 src/pamac-tray/alpm_config.vala delete mode 100644 src/pamac-tray/user_daemon.vala diff --git a/data/polkit/org.pamac.policy b/data/polkit/org.pamac.policy index ea042f8..e69de29 100644 --- a/data/polkit/org.pamac.policy +++ b/data/polkit/org.pamac.policy @@ -1,59 +0,0 @@ - - - - Pamac - https://github.com/cromnix/pamac-classic/ - package-x-generic - - Authentication is required - صلاحيات مطلوبة - Ríquese l'autenticación - Kimlik tələb olunur - Изисква се идентификация - Cal autenticació - Cal autenticació - Je vyžadováno ověření - Godkendelse er påkrævet - Authentifizierung erforderlich - Απαιτείται πιστοποίηση - Απαιτείται πιστοποίηση - Se necesita autenticación - Se requiere autenticación - Se requiere autenticación - Autentifikazioa behar da - تائید هویت شکست خورد - Authentification nécessaire - A autenticación é necesaria - נדרש אישור - प्रमाणीकरण की आवश्यकता है - Potrebna je autorizacija - Hitelesítés szükséges - Membutuhkan Otentifikasi - Auðkenningar er krafist - Autenticazione richiesta - 認証が必要です - 인증이 필요합니다 - Reikalingas tapatybės nustatymas - Autentisering kreves - Verificatie vereist - Authenticatie vereist - Wymagane jest uwierzytelnienie - Autenticação necessária - Autenticação necessária - Autenticação necessária - Запрошена авторизация - Vyžaduje sa overenie totožnosti - Zahtevana je overitev - Autentifikacija je neophodna - Autentisering krävs - Kimlik doğrulaması gerekli - Потрібна авторизація - 需要验证 - 需要授權 - - no - auth_admin_keep - auth_admin_keep - - - diff --git a/pamac.avprj b/pamac.avprj index 9b00381..849dd6c 100644 --- a/pamac.avprj +++ b/pamac.avprj @@ -29,7 +29,7 @@ define: KDE_TRAY vapidir: src/vapis vala_binary: src/pamac-clean-cache/pamac-clean-cache -version: 6.3.1 +version: 6.3.3 vala_local_package: Pamac vala_package: posix vala_check_package: gtk+-3.0 @@ -40,7 +40,7 @@ vala_check_package: gtk+-3.0 *vala_source: pamac_config.vala vala_binary: src/pamac-install/pamac-install -version: 6.3.1 +version: 6.3.3 use_gresource: pamac_installer_gresource_xml vala_local_package: Pamac vala_check_package: gtk+-3.0 @@ -51,7 +51,7 @@ vala_check_package: gtk+-3.0 *vala_source: progress_dialog.vala vala_binary: src/pamac-manager/pamac-manager -version: 6.3.1 +version: 6.3.3 alias: pamac-updater use_gresource: pamac_manager_gresource_xml vala_local_package: Pamac @@ -64,7 +64,7 @@ vala_check_package: gtk+-3.0 *vala_source: manager_window.vala vala_binary: src/pamac-system-daemon/pamac-system-daemon -version: 6.3.1 +version: 6.3.3 vala_local_package: Pamac if NOT DISABLE_AUR vala_local_package: AUR @@ -85,13 +85,14 @@ vala_check_package: polkit-gobject-1 *vala_source: system_daemon.vala vala_binary: src/pamac-tray/pamac-tray -version: 6.3.1 +version: 6.3.3 vala_local_package: Pamac if NOT DISABLE_AUR vala_local_package: AUR end vala_package: posix vala_check_package: json-glib-1.0 +vala_check_package: libalpm vala_check_package: libnotify if KDE_TRAY vala_check_package: appindicator3-0.1 @@ -106,12 +107,12 @@ vala_source: tray-appindicator.vala else vala_source: tray-gtk.vala end +*vala_source: alpm_config.vala *vala_source: pamac_config.vala *vala_source: tray.vala -*vala_source: user_daemon.vala vala_binary: src/pamac-user-daemon/pamac-user-daemon -version: 6.3.1 +version: 6.3.3 vala_local_package: Pamac if NOT DISABLE_AUR vala_local_package: AUR @@ -129,7 +130,7 @@ vala_check_package: libsoup-2.4 vala_library: src/pamac -version: 6.3.1 +version: 6.3.3 *namespace: Pamac use_gresource: pamac_transaction_gresource_xml vala_package: posix @@ -155,7 +156,7 @@ vala_check_package: vte-2.91 *vala_source: transaction_sum_dialog.vala vala_library: src/aur/aur -version: 6.3.1 +version: 6.3.3 *namespace: AUR vala_check_package: json-glib-1.0 vala_check_package: libsoup-2.4 @@ -191,9 +192,9 @@ vala_check_package: libsoup-2.4 *translate: vala src/pamac-system-daemon/mirrors_config.vala *translate: vala src/pamac-system-daemon/pamac_config.vala *translate: vala src/pamac-system-daemon/system_daemon.vala +*translate: vala src/pamac-tray/alpm_config.vala *translate: vala src/pamac-tray/pamac_config.vala *translate: vala src/pamac-tray/tray.vala -*translate: vala src/pamac-tray/user_daemon.vala *translate: vala src/pamac-user-daemon/alpm_config.vala *translate: vala src/pamac-user-daemon/user_daemon.vala *translate: vala src/pamac_config.vala diff --git a/po/POTFILES.in b/po/POTFILES.in index 26962fb..3a31a0b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -11,9 +11,9 @@ src/pamac-system-daemon/pamac_config.vala src/pamac-system-daemon/system_daemon.vala src/pamac-tray/tray-appindicator.vala src/pamac-tray/tray-gtk.vala +src/pamac-tray/alpm_config.vala src/pamac-tray/pamac_config.vala src/pamac-tray/tray.vala -src/pamac-tray/user_daemon.vala src/pamac-user-daemon/alpm_config.vala src/pamac-user-daemon/user_daemon.vala src/alpm_config.vala diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d80d02a..93013fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") @@ -15,7 +15,7 @@ configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.base ${CMAKE_BINARY_DIR}/src add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Pamac.pc ${CMAKE_CURRENT_BINARY_DIR}/Pamac.pc) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Pamac.deps ${CMAKE_CURRENT_BINARY_DIR}/Pamac.deps) -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) link_libraries ( ${DEPS_LIBRARIES} ) link_directories ( ${DEPS_LIBRARY_DIRS} ) @@ -86,7 +86,7 @@ add_dependencies( Pamac ${Pamac_DEPENDENCIES} ) target_link_libraries( Pamac m ) set_target_properties( Pamac PROPERTIES VERSION - 6.3.1 + 6.3.3 SOVERSION 6 ) diff --git a/src/Pamac.pc b/src/Pamac.pc index 383fe15..3b50624 100644 --- a/src/Pamac.pc +++ b/src/Pamac.pc @@ -6,7 +6,7 @@ includedir=@DOLLAR@{exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR} Name: Pamac Description: Pamac -Version: 6.3.1 +Version: 6.3.3 Libs: -L@DOLLAR@{libdir} -lPamac Cflags: -I@DOLLAR@{includedir} Requires: gdk-3.0 gtk+-3.0 libalpm libnotify vte-2.91 gio-2.0 glib-2.0 gobject-2.0 diff --git a/src/alpm_config.vala b/src/alpm_config.vala index 8fea5ce..2c40be3 100644 --- a/src/alpm_config.vala +++ b/src/alpm_config.vala @@ -74,6 +74,14 @@ class AlpmConfig { reload (); } + public unowned GLib.List get_holdpkgs () { + return holdpkgs; + } + + public unowned GLib.List get_syncfirsts () { + return syncfirsts; + } + public void reload () { // set default options cachedirs = new GLib.List (); @@ -127,6 +135,85 @@ class AlpmConfig { } } + public Alpm.Handle? get_handle (bool files_db = false, bool tmp_db = false) { + Alpm.Errno error = 0; + Alpm.Handle? handle = null; + if (tmp_db) { + string tmp_dbpath = "/tmp/pamac-checkdbs"; + try { + Process.spawn_command_line_sync ("mkdir -p %s/sync".printf (tmp_dbpath)); + Process.spawn_command_line_sync ("ln -sf %s/local %s".printf (dbpath, tmp_dbpath)); + Process.spawn_command_line_sync ("chmod -R 777 %s/sync".printf (tmp_dbpath)); + handle = new Alpm.Handle (rootdir, tmp_dbpath, out error); + } catch (SpawnError e) { + stderr.printf ("SpawnError: %s\n", e.message); + } + } else { + handle = new Alpm.Handle (rootdir, dbpath, out error); + } + if (error == Alpm.Errno.DB_VERSION) { + try { + Process.spawn_command_line_sync ("pacman-db-upgrade", null, null, null); + } catch (SpawnError e) { + stdout.printf ("Error: %s\n", e.message); + } + handle = new Alpm.Handle (rootdir, dbpath, out error); + } + if (handle == null) { + stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf (Alpm.strerror (error))); + return null; + } + // define options + if (files_db) { + handle.dbext = ".files"; + } + if (!tmp_db) { + handle.logfile = logfile; + } + handle.gpgdir = gpgdir; + handle.arch = arch; + handle.deltaratio = deltaratio; + handle.usesyslog = usesyslog; + handle.checkspace = checkspace; + handle.defaultsiglevel = siglevel; + localfilesiglevel = merge_siglevel (siglevel, localfilesiglevel, localfilesiglevel_mask); + remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask); + handle.localfilesiglevel = localfilesiglevel; + handle.remotefilesiglevel = remotefilesiglevel; + foreach (unowned string cachedir in cachedirs) { + handle.add_cachedir (cachedir); + } + foreach (unowned string hookdir in hookdirs) { + handle.add_hookdir (hookdir); + } + foreach (unowned string ignoregroup in ignoregroups) { + handle.add_ignoregroup (ignoregroup); + } + foreach (unowned string ignorepkg in ignorepkgs) { + handle.add_ignorepkg (ignorepkg); + } + foreach (unowned string noextract in noextracts) { + handle.add_noextract (noextract); + } + foreach (unowned string noupgrade in noupgrades) { + handle.add_noupgrade (noupgrade); + } + // register dbs + foreach (unowned AlpmRepo repo in repo_order) { + 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)); + } + if (repo.usage == 0) { + db.usage = Alpm.DB.Usage.ALL; + } else { + db.usage = repo.usage; + } + } + return handle; + } + void parse_file (string path, string? section = null) { string? current_section = section; var file = GLib.File.new_for_path (path); @@ -250,6 +337,66 @@ class AlpmConfig { } } + public void write (HashTable new_conf) { + var file = GLib.File.new_for_path (conf_path); + if (file.query_exists ()) { + try { + // Open file for reading and wrap returned FileInputStream into a + // DataInputStream, so we can read line by line + var dis = new DataInputStream (file.read ()); + string? line; + string[] data = {}; + // Read lines until end of file (null) is reached + while ((line = dis.read_line ()) != null) { + if (line.length == 0) { + data += "\n"; + continue; + } + if (line.contains ("IgnorePkg")) { + if (new_conf.contains ("IgnorePkg")) { + string val = new_conf.get ("IgnorePkg").get_string (); + if (val == "") { + data += "#IgnorePkg =\n"; + } else { + data += "IgnorePkg = %s\n".printf (val); + } + new_conf.remove ("IgnorePkg"); + } else { + data += line + "\n"; + } + } else if (line.contains ("CheckSpace")) { + if (new_conf.contains ("CheckSpace")) { + bool val = new_conf.get ("CheckSpace").get_boolean (); + if (val) { + data += "CheckSpace\n"; + } else { + data += "#CheckSpace\n"; + } + new_conf.remove ("CheckSpace"); + } else { + data += line + "\n"; + } + } else { + data += line + "\n"; + } + } + // delete the file before rewrite it + file.delete (); + // creating a DataOutputStream to the file + var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); + foreach (unowned string new_line in data) { + // writing a short string to the stream + dos.put_string (new_line); + } + reload (); + } catch (GLib.Error e) { + GLib.stderr.printf("%s\n", e.message); + } + } else { + GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path); + } + } + Alpm.DB.Usage define_usage (string conf_string) { Alpm.DB.Usage usage = 0; foreach (unowned string directive in conf_string.split(" ")) { @@ -335,4 +482,8 @@ class AlpmConfig { } siglevel &= ~Alpm.Signature.Level.USE_DEFAULT; } + + Alpm.Signature.Level merge_siglevel(Alpm.Signature.Level sigbase, Alpm.Signature.Level sigover, Alpm.Signature.Level sigmask) { + return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover; + } } diff --git a/src/aur/AUR.pc b/src/aur/AUR.pc index 86d4e29..665a334 100644 --- a/src/aur/AUR.pc +++ b/src/aur/AUR.pc @@ -6,7 +6,7 @@ includedir=@DOLLAR@{exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR} Name: AUR Description: AUR -Version: 6.3.1 +Version: 6.3.3 Libs: -L@DOLLAR@{libdir} -lAUR Cflags: -I@DOLLAR@{includedir} Requires: json-glib-1.0 libsoup-2.4 glib-2.0 diff --git a/src/aur/CMakeLists.txt b/src/aur/CMakeLists.txt index 621b429..961a82a 100644 --- a/src/aur/CMakeLists.txt +++ b/src/aur/CMakeLists.txt @@ -7,7 +7,7 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") @@ -15,7 +15,7 @@ configure_file (${CMAKE_SOURCE_DIR}/src/aur/Config.vala.base ${CMAKE_BINARY_DIR} add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") configure_file (${CMAKE_CURRENT_SOURCE_DIR}/AUR.pc ${CMAKE_CURRENT_BINARY_DIR}/AUR.pc) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/AUR.deps ${CMAKE_CURRENT_BINARY_DIR}/AUR.deps) -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) link_libraries ( ${DEPS_LIBRARIES} ) link_directories ( ${DEPS_LIBRARY_DIRS} ) @@ -65,7 +65,7 @@ add_library(AUR SHARED ${VALA_C}) set_target_properties( AUR PROPERTIES VERSION - 6.3.1 + 6.3.3 SOVERSION 6 ) diff --git a/src/aur/meson.build b/src/aur/meson.build index 6bb11a1..a42b3b1 100644 --- a/src/aur/meson.build +++ b/src/aur/meson.build @@ -4,7 +4,7 @@ cfg_aur.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('datadir'), cfg_aur.set('GETTEXT_PACKAGE', 'pamac') cfg_aur.set('RELEASE_NAME', 'pamac') cfg_aur.set('PREFIX', get_option('prefix')) -cfg_aur.set('VERSION', '6.3.1') +cfg_aur.set('VERSION', '6.3.3') cfg_aur.set('TESTSRCDIR', meson.source_root()) cfgfile_2 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_aur) @@ -27,7 +27,7 @@ endif aur_vala_args += ['--gir=AUR-6.0.gir'] -AUR_library = shared_library('AUR',aur_sources,dependencies: aur_deps,vala_args: aur_vala_args,c_args: aur_c_args,version: '6.3.1',soversion: '6',install: true) +AUR_library = shared_library('AUR',aur_sources,dependencies: aur_deps,vala_args: aur_vala_args,c_args: aur_c_args,version: '6.3.3',soversion: '6',install: true) aur_requires = [] aur_requires += ['json-glib-1.0'] @@ -35,7 +35,7 @@ aur_requires += ['libsoup-2.4'] aur_requires += ['glib-2.0'] pkg_mod = import('pkgconfig') pkg_mod.generate(libraries : AUR_library, - version : '6.3.1', + version : '6.3.3', name : 'AUR', filebase : 'AUR', description : 'AUR', diff --git a/src/meson.build b/src/meson.build index de16867..95aaf74 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,7 +4,7 @@ cfg_pamac.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('datadir' cfg_pamac.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac.set('RELEASE_NAME', 'pamac') cfg_pamac.set('PREFIX', get_option('prefix')) -cfg_pamac.set('VERSION', '6.3.1') +cfg_pamac.set('VERSION', '6.3.3') cfg_pamac.set('TESTSRCDIR', meson.source_root()) cfgfile_1 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac) @@ -46,7 +46,7 @@ pamac_deps += [meson.get_compiler('c').find_library('m', required : false)] pamac_vala_args += ['--gir=Pamac-6.0.gir'] -Pamac_library = shared_library('Pamac',pamac_sources,dependencies: pamac_deps,vala_args: pamac_vala_args,c_args: pamac_c_args,version: '6.3.1',soversion: '6',install: true) +Pamac_library = shared_library('Pamac',pamac_sources,dependencies: pamac_deps,vala_args: pamac_vala_args,c_args: pamac_c_args,version: '6.3.3',soversion: '6',install: true) pamac_requires = [] pamac_requires += ['gdk-3.0'] @@ -59,7 +59,7 @@ pamac_requires += ['glib-2.0'] pamac_requires += ['gobject-2.0'] pkg_mod = import('pkgconfig') pkg_mod.generate(libraries : Pamac_library, - version : '6.3.1', + version : '6.3.3', name : 'Pamac', filebase : 'Pamac', description : 'Pamac', diff --git a/src/mirrors_config.vala b/src/mirrors_config.vala index 044c38e..b237e95 100644 --- a/src/mirrors_config.vala +++ b/src/mirrors_config.vala @@ -75,5 +75,57 @@ namespace Pamac { GLib.stderr.printf ("File '%s' doesn't exist.\n", path); } } + + public void write (HashTable new_conf) { + var file = GLib.File.new_for_path (conf_path); + if (file.query_exists ()) { + try { + // Open file for reading and wrap returned FileInputStream into a + // DataInputStream, so we can read line by line + var dis = new DataInputStream (file.read ()); + string? line; + var data = new GLib.List (); + // Read lines until end of file (null) is reached + while ((line = dis.read_line ()) != null) { + if (line.length == 0) { + data.append ("\n"); + continue; + } + unowned Variant variant; + if (line.contains ("Method")) { + if (new_conf.lookup_extended ("Method", null, out variant)) { + data.append ("Method = %s\n".printf (variant.get_string ())); + } else { + data.append (line + "\n"); + } + } else if (line.contains ("OnlyCountry")) { + if (new_conf.lookup_extended ("OnlyCountry", null, out variant)) { + if (variant.get_string () == "ALL") { + data.append ("#%s\n".printf (line)); + } else { + data.append ("OnlyCountry = %s\n".printf (variant.get_string ())); + } + } else { + data.append (line + "\n"); + } + } else { + data.append (line + "\n"); + } + } + // delete the file before rewrite it + file.delete (); + // creating a DataOutputStream to the file + var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); + foreach (unowned string new_line in data) { + // writing a short string to the stream + dos.put_string (new_line); + } + } catch (GLib.Error e) { + GLib.stderr.printf("%s\n", e.message); + } + } else { + GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ()); + } + } } } diff --git a/src/pamac-clean-cache/CMakeLists.txt b/src/pamac-clean-cache/CMakeLists.txt index 2c5e1b6..2f0841a 100644 --- a/src/pamac-clean-cache/CMakeLists.txt +++ b/src/pamac-clean-cache/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-clean-cache/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-clean-cache/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lPamac ) diff --git a/src/pamac-clean-cache/meson.build b/src/pamac-clean-cache/meson.build index c7b44dd..49f8fbc 100644 --- a/src/pamac-clean-cache/meson.build +++ b/src/pamac-clean-cache/meson.build @@ -4,7 +4,7 @@ cfg_pamac_clean_cache.set('PKGDATADIR', join_paths(get_option('prefix'),get_opti cfg_pamac_clean_cache.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_clean_cache.set('RELEASE_NAME', 'pamac') cfg_pamac_clean_cache.set('PREFIX', get_option('prefix')) -cfg_pamac_clean_cache.set('VERSION', '6.3.1') +cfg_pamac_clean_cache.set('VERSION', '6.3.3') cfg_pamac_clean_cache.set('TESTSRCDIR', meson.source_root()) cfgfile_5 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_clean_cache) diff --git a/src/pamac-install/CMakeLists.txt b/src/pamac-install/CMakeLists.txt index 1e55d6b..24cd19e 100644 --- a/src/pamac-install/CMakeLists.txt +++ b/src/pamac-install/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-install/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-install/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lPamac ) diff --git a/src/pamac-install/meson.build b/src/pamac-install/meson.build index b38df44..7ea2b34 100644 --- a/src/pamac-install/meson.build +++ b/src/pamac-install/meson.build @@ -4,7 +4,7 @@ cfg_pamac_install.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_install.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_install.set('RELEASE_NAME', 'pamac') cfg_pamac_install.set('PREFIX', get_option('prefix')) -cfg_pamac_install.set('VERSION', '6.3.1') +cfg_pamac_install.set('VERSION', '6.3.3') cfg_pamac_install.set('TESTSRCDIR', meson.source_root()) cfgfile_6 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_install) diff --git a/src/pamac-manager/CMakeLists.txt b/src/pamac-manager/CMakeLists.txt index 113c0ec..7e45e39 100644 --- a/src/pamac-manager/CMakeLists.txt +++ b/src/pamac-manager/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-manager/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-manager/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ) link_libraries ( ${DEPS_LIBRARIES} -lPamac ) diff --git a/src/pamac-manager/meson.build b/src/pamac-manager/meson.build index 8f94a40..beca807 100644 --- a/src/pamac-manager/meson.build +++ b/src/pamac-manager/meson.build @@ -4,7 +4,7 @@ cfg_pamac_manager.set('PKGDATADIR', join_paths(get_option('prefix'),get_option(' cfg_pamac_manager.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_manager.set('RELEASE_NAME', 'pamac') cfg_pamac_manager.set('PREFIX', get_option('prefix')) -cfg_pamac_manager.set('VERSION', '6.3.1') +cfg_pamac_manager.set('VERSION', '6.3.3') cfg_pamac_manager.set('TESTSRCDIR', meson.source_root()) cfgfile_7 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_manager) diff --git a/src/pamac-system-daemon/CMakeLists.txt b/src/pamac-system-daemon/CMakeLists.txt index 8385eb2..8f4e6a1 100644 --- a/src/pamac-system-daemon/CMakeLists.txt +++ b/src/pamac-system-daemon/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-system-daemon/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-system-daemon/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/src/aur ) link_libraries ( ${DEPS_LIBRARIES} -lPamac -lAUR ) diff --git a/src/pamac-system-daemon/alpm_config.vala b/src/pamac-system-daemon/alpm_config.vala deleted file mode 100644 index 2c40be3..0000000 --- a/src/pamac-system-daemon/alpm_config.vala +++ /dev/null @@ -1,489 +0,0 @@ -/* - * alpm_config - * - * Copyright (C) 2017 Chris Cromer - * Copyright (C) 2014-2017 Guillaume Benoit - * - * 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 . - */ - -[Compact] -class AlpmRepo { - public string name; - public Alpm.Signature.Level siglevel; - public Alpm.Signature.Level siglevel_mask; - public Alpm.DB.Usage usage; - public GLib.List urls; - - public AlpmRepo (string name) { - this.name = name; - siglevel = Alpm.Signature.Level.USE_DEFAULT; - usage = 0; - urls = new GLib.List (); - } - - public static int compare_name (AlpmRepo a, AlpmRepo b) { - return strcmp (a.name, b.name); - } - - public static int search_name (AlpmRepo a, string name) { - return strcmp (a.name, name); - } - -} - -class AlpmConfig { - string conf_path; - string? rootdir; - string? dbpath; - string? logfile; - string? gpgdir; - string? arch; - double deltaratio; - int usesyslog; - public int checkspace; - GLib.List cachedirs; - GLib.List hookdirs; - GLib.List ignoregroups; - GLib.List ignorepkgs; - GLib.List noextracts; - GLib.List noupgrades; - GLib.List holdpkgs; - GLib.List syncfirsts; - Alpm.Signature.Level siglevel; - Alpm.Signature.Level localfilesiglevel; - Alpm.Signature.Level remotefilesiglevel; - Alpm.Signature.Level siglevel_mask; - Alpm.Signature.Level localfilesiglevel_mask; - Alpm.Signature.Level remotefilesiglevel_mask; - GLib.List repo_order; - - public AlpmConfig (string path) { - conf_path = path; - reload (); - } - - public unowned GLib.List get_holdpkgs () { - return holdpkgs; - } - - public unowned GLib.List get_syncfirsts () { - return syncfirsts; - } - - public void reload () { - // set default options - cachedirs = new GLib.List (); - hookdirs = new GLib.List (); - ignoregroups = new GLib.List (); - ignorepkgs = new GLib.List (); - noextracts = new GLib.List (); - noupgrades = new GLib.List (); - holdpkgs = new GLib.List (); - syncfirsts = new GLib.List (); - usesyslog = 0; - checkspace = 0; - deltaratio = 0.7; - siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL; - localfilesiglevel = Alpm.Signature.Level.USE_DEFAULT; - remotefilesiglevel = Alpm.Signature.Level.USE_DEFAULT; - repo_order = new GLib.List (); - // parse conf file - parse_file (conf_path); - // if rootdir is set and dbpath/logfile are not - // set, then set those as well to reside under the root. - if (rootdir != null) { - if (dbpath == null) { - dbpath = Path.build_path ("/", rootdir, "var/lib/pacman/"); - } - if (logfile == null) { - logfile = Path.build_path ("/", rootdir, "var/log/pacman.log"); - } - } else { - rootdir = "/"; - if (dbpath == null) { - dbpath = "/var/lib/pacman/"; - } - if (logfile == null) { - logfile = "/var/log/pacman.log"; - } - } - if (cachedirs.length () == 0) { - cachedirs.append ("/var/cache/pacman/pkg/"); - } - if (hookdirs.length () == 0) { - hookdirs.append ("/etc/pacman.d/hooks/"); - } - if (gpgdir == null) { - // gpgdir it is not relative to rootdir, even if - // rootdir is defined because it contains configuration data. - gpgdir = "/etc/pacman.d/gnupg/"; - } - if (arch == null) { - arch = Posix.utsname().machine; - } - } - - public Alpm.Handle? get_handle (bool files_db = false, bool tmp_db = false) { - Alpm.Errno error = 0; - Alpm.Handle? handle = null; - if (tmp_db) { - string tmp_dbpath = "/tmp/pamac-checkdbs"; - try { - Process.spawn_command_line_sync ("mkdir -p %s/sync".printf (tmp_dbpath)); - Process.spawn_command_line_sync ("ln -sf %s/local %s".printf (dbpath, tmp_dbpath)); - Process.spawn_command_line_sync ("chmod -R 777 %s/sync".printf (tmp_dbpath)); - handle = new Alpm.Handle (rootdir, tmp_dbpath, out error); - } catch (SpawnError e) { - stderr.printf ("SpawnError: %s\n", e.message); - } - } else { - handle = new Alpm.Handle (rootdir, dbpath, out error); - } - if (error == Alpm.Errno.DB_VERSION) { - try { - Process.spawn_command_line_sync ("pacman-db-upgrade", null, null, null); - } catch (SpawnError e) { - stdout.printf ("Error: %s\n", e.message); - } - handle = new Alpm.Handle (rootdir, dbpath, out error); - } - if (handle == null) { - stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf (Alpm.strerror (error))); - return null; - } - // define options - if (files_db) { - handle.dbext = ".files"; - } - if (!tmp_db) { - handle.logfile = logfile; - } - handle.gpgdir = gpgdir; - handle.arch = arch; - handle.deltaratio = deltaratio; - handle.usesyslog = usesyslog; - handle.checkspace = checkspace; - handle.defaultsiglevel = siglevel; - localfilesiglevel = merge_siglevel (siglevel, localfilesiglevel, localfilesiglevel_mask); - remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask); - handle.localfilesiglevel = localfilesiglevel; - handle.remotefilesiglevel = remotefilesiglevel; - foreach (unowned string cachedir in cachedirs) { - handle.add_cachedir (cachedir); - } - foreach (unowned string hookdir in hookdirs) { - handle.add_hookdir (hookdir); - } - foreach (unowned string ignoregroup in ignoregroups) { - handle.add_ignoregroup (ignoregroup); - } - foreach (unowned string ignorepkg in ignorepkgs) { - handle.add_ignorepkg (ignorepkg); - } - foreach (unowned string noextract in noextracts) { - handle.add_noextract (noextract); - } - foreach (unowned string noupgrade in noupgrades) { - handle.add_noupgrade (noupgrade); - } - // register dbs - foreach (unowned AlpmRepo repo in repo_order) { - 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)); - } - if (repo.usage == 0) { - db.usage = Alpm.DB.Usage.ALL; - } else { - db.usage = repo.usage; - } - } - return handle; - } - - void parse_file (string path, string? section = null) { - string? current_section = section; - var file = GLib.File.new_for_path (path); - if (file.query_exists ()) { - try { - // Open file for reading and wrap returned FileInputStream into a - // DataInputStream, so we can read line by line - var dis = new DataInputStream (file.read ()); - string? line; - // Read lines until end of file (null) is reached - while ((line = dis.read_line ()) != null) { - if (line.length == 0) { - continue; - } - // ignore whole line and end of line comments - string[] splitted = line.split ("#", 2); - line = splitted[0].strip (); - if (line.length == 0) { - continue; - } - if (line[0] == '[' && line[line.length-1] == ']') { - current_section = line[1:-1]; - if (current_section != "options") { - var repo = new AlpmRepo (current_section); - if (repo_order.find_custom (repo, AlpmRepo.compare_name) == null) { - repo_order.append ((owned) repo); - } - } - continue; - } - splitted = line.split ("=", 2); - unowned string key = splitted[0]._strip (); - unowned string? val = null; - if (splitted.length == 2) { - val = splitted[1]._strip (); - } - if (key == "Include") { - parse_file (val, current_section); - } - if (current_section == "options") { - if (key == "RootDir") { - rootdir = val; - } else if (key == "DBPath") { - dbpath = val; - } else if (key == "CacheDir") { - foreach (unowned string dir in val.split (" ")) { - cachedirs.append (dir); - } - } else if (key == "HookDir") { - foreach (unowned string dir in val.split (" ")) { - hookdirs.append (dir); - } - } else if (key == "LogFile") { - logfile = val; - } else if (key == "GPGDir") { - gpgdir = val; - } else if (key == "LogFile") { - logfile = val; - } else if (key == "Architecture") { - if (val == "auto") { - arch = Posix.utsname ().machine; - } else { - arch = val; - } - } else if (key == "UseDelta") { - deltaratio = double.parse (val); - } else if (key == "UseSysLog") { - usesyslog = 1; - } else if (key == "CheckSpace") { - checkspace = 1; - } else if (key == "SigLevel") { - process_siglevel (val, ref siglevel, ref siglevel_mask); - } else if (key == "LocalFileSigLevel") { - process_siglevel (val, ref localfilesiglevel, ref localfilesiglevel_mask); - } else if (key == "RemoteFileSigLevel") { - process_siglevel (val, ref remotefilesiglevel, ref remotefilesiglevel_mask); - } else if (key == "HoldPkg") { - foreach (unowned string name in val.split (" ")) { - holdpkgs.append (name); - } - } else if (key == "SyncFirst") { - foreach (unowned string name in val.split (" ")) { - syncfirsts.append (name); - } - } else if (key == "IgnoreGroup") { - foreach (unowned string name in val.split (" ")) { - ignoregroups.append (name); - } - } else if (key == "IgnorePkg") { - foreach (unowned string name in val.split (" ")) { - ignorepkgs.append (name); - } - } else if (key == "Noextract") { - foreach (unowned string name in val.split (" ")) { - noextracts.append (name); - } - } else if (key == "NoUpgrade") { - foreach (unowned string name in val.split (" ")) { - noupgrades.append (name); - } - } - } else { - unowned GLib.List? found = repo_order.search (current_section, (SearchFunc) AlpmRepo.search_name); - if (found != null) { - unowned AlpmRepo repo = found.data; - if (key == "Server") { - repo.urls.append (val); - } else if (key == "SigLevel") { - process_siglevel (val, ref repo.siglevel, ref repo.siglevel_mask); - } else if (key == "Usage") { - repo.usage = define_usage (val); - } - } - } - } - } catch (GLib.Error e) { - GLib.stderr.printf("%s\n", e.message); - } - } else { - GLib.stderr.printf ("File '%s' doesn't exist.\n", path); - } - } - - public void write (HashTable new_conf) { - var file = GLib.File.new_for_path (conf_path); - if (file.query_exists ()) { - try { - // Open file for reading and wrap returned FileInputStream into a - // DataInputStream, so we can read line by line - var dis = new DataInputStream (file.read ()); - string? line; - string[] data = {}; - // Read lines until end of file (null) is reached - while ((line = dis.read_line ()) != null) { - if (line.length == 0) { - data += "\n"; - continue; - } - if (line.contains ("IgnorePkg")) { - if (new_conf.contains ("IgnorePkg")) { - string val = new_conf.get ("IgnorePkg").get_string (); - if (val == "") { - data += "#IgnorePkg =\n"; - } else { - data += "IgnorePkg = %s\n".printf (val); - } - new_conf.remove ("IgnorePkg"); - } else { - data += line + "\n"; - } - } else if (line.contains ("CheckSpace")) { - if (new_conf.contains ("CheckSpace")) { - bool val = new_conf.get ("CheckSpace").get_boolean (); - if (val) { - data += "CheckSpace\n"; - } else { - data += "#CheckSpace\n"; - } - new_conf.remove ("CheckSpace"); - } else { - data += line + "\n"; - } - } else { - data += line + "\n"; - } - } - // delete the file before rewrite it - file.delete (); - // creating a DataOutputStream to the file - var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - foreach (unowned string new_line in data) { - // writing a short string to the stream - dos.put_string (new_line); - } - reload (); - } catch (GLib.Error e) { - GLib.stderr.printf("%s\n", e.message); - } - } else { - GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path); - } - } - - Alpm.DB.Usage define_usage (string conf_string) { - Alpm.DB.Usage usage = 0; - foreach (unowned string directive in conf_string.split(" ")) { - if (directive == "Sync") { - usage |= Alpm.DB.Usage.SYNC; - } else if (directive == "Search") { - usage |= Alpm.DB.Usage.SEARCH; - } else if (directive == "Install") { - usage |= Alpm.DB.Usage.INSTALL; - } else if (directive == "Upgrade") { - usage |= Alpm.DB.Usage.UPGRADE; - } else if (directive == "All") { - usage |= Alpm.DB.Usage.ALL; - } - } - return usage; - } - - void process_siglevel (string conf_string, ref Alpm.Signature.Level siglevel, ref Alpm.Signature.Level siglevel_mask) { - foreach (unowned string directive in conf_string.split(" ")) { - bool affect_package = false; - bool affect_database = false; - if ("Package" in directive) { - affect_package = true; - } else if ("Database" in directive) { - affect_database = true; - } else { - affect_package = true; - affect_database = true; - } - if ("Never" in directive) { - if (affect_package) { - siglevel &= ~Alpm.Signature.Level.PACKAGE; - siglevel_mask |= Alpm.Signature.Level.PACKAGE; - } - if (affect_database) { - siglevel &= ~Alpm.Signature.Level.DATABASE; - siglevel_mask |= Alpm.Signature.Level.DATABASE; - } - } else if ("Optional" in directive) { - if (affect_package) { - siglevel |= (Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL); - siglevel_mask |= (Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL); - } - if (affect_database) { - siglevel |= (Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL); - siglevel_mask |= (Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL); - } - } else if ("Required" in directive) { - if (affect_package) { - siglevel |= Alpm.Signature.Level.PACKAGE; - siglevel_mask |= Alpm.Signature.Level.PACKAGE; - siglevel &= ~Alpm.Signature.Level.PACKAGE_OPTIONAL; - siglevel_mask |= Alpm.Signature.Level.PACKAGE_OPTIONAL; - } - if (affect_database) { - siglevel |= Alpm.Signature.Level.DATABASE; - siglevel_mask |= Alpm.Signature.Level.DATABASE; - siglevel &= ~Alpm.Signature.Level.DATABASE_OPTIONAL; - siglevel_mask |= Alpm.Signature.Level.DATABASE_OPTIONAL; - } - } else if ("TrustedOnly" in directive) { - if (affect_package) { - siglevel &= ~(Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK); - siglevel_mask |= (Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK); - } - if (affect_database) { - siglevel &= ~(Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK); - siglevel_mask |= (Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK); - } - } else if ("TrustAll" in directive) { - if (affect_package) { - siglevel |= (Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK); - siglevel_mask |= (Alpm.Signature.Level.PACKAGE_MARGINAL_OK | Alpm.Signature.Level.PACKAGE_UNKNOWN_OK); - } - if (affect_database) { - siglevel |= (Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK); - siglevel_mask |= (Alpm.Signature.Level.DATABASE_MARGINAL_OK | Alpm.Signature.Level.DATABASE_UNKNOWN_OK); - } - } else { - GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string); - } - } - siglevel &= ~Alpm.Signature.Level.USE_DEFAULT; - } - - Alpm.Signature.Level merge_siglevel(Alpm.Signature.Level sigbase, Alpm.Signature.Level sigover, Alpm.Signature.Level sigmask) { - return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover; - } -} diff --git a/src/pamac-system-daemon/alpm_config.vala b/src/pamac-system-daemon/alpm_config.vala new file mode 120000 index 0000000..216718c --- /dev/null +++ b/src/pamac-system-daemon/alpm_config.vala @@ -0,0 +1 @@ +../alpm_config.vala \ No newline at end of file diff --git a/src/pamac-system-daemon/meson.build b/src/pamac-system-daemon/meson.build index 27e6d95..7e1a389 100644 --- a/src/pamac-system-daemon/meson.build +++ b/src/pamac-system-daemon/meson.build @@ -4,7 +4,7 @@ cfg_pamac_system_daemon.set('PKGDATADIR', join_paths(get_option('prefix'),get_op cfg_pamac_system_daemon.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_system_daemon.set('RELEASE_NAME', 'pamac') cfg_pamac_system_daemon.set('PREFIX', get_option('prefix')) -cfg_pamac_system_daemon.set('VERSION', '6.3.1') +cfg_pamac_system_daemon.set('VERSION', '6.3.3') cfg_pamac_system_daemon.set('TESTSRCDIR', meson.source_root()) cfgfile_8 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_system_daemon) diff --git a/src/pamac-system-daemon/mirrors_config.vala b/src/pamac-system-daemon/mirrors_config.vala deleted file mode 100644 index b237e95..0000000 --- a/src/pamac-system-daemon/mirrors_config.vala +++ /dev/null @@ -1,131 +0,0 @@ -/* - * pamac-vala - * - * Copyright (C) 2017 Chris Cromer - * Copyright (C) 2014-2017 Guillaume Benoit - * - * 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 . - */ - -namespace Pamac { - class MirrorsConfig { - string conf_path; - - public string choosen_generation_method { get; private set; } - public string choosen_country { get; private set; } - - public MirrorsConfig (string path) { - conf_path = path; - reload (); - } - - public void reload () { - // set default options - choosen_generation_method = "rank"; - choosen_country = "ALL"; - parse_file (conf_path); - } - - void parse_file (string path) { - var file = GLib.File.new_for_path (path); - if (file.query_exists ()) { - try { - // Open file for reading and wrap returned FileInputStream into a - // DataInputStream, so we can read line by line - var dis = new DataInputStream (file.read ()); - string? line; - // Read lines until end of file (null) is reached - while ((line = dis.read_line ()) != null) { - if (line.length == 0) { - continue; - } - // ignore whole line and end of line comments - string[] splitted = line.split ("#", 2); - line = splitted[0].strip (); - if (line.length == 0) { - continue; - } - splitted = line.split ("=", 2); - unowned string key = splitted[0]._strip (); - unowned string? val = null; - if (splitted.length == 2) { - val = splitted[1]._strip (); - } - if (key == "Method") { - choosen_generation_method = val; - } else if (key == "OnlyCountry") { - choosen_country = val; - } - } - } catch (Error e) { - GLib.stderr.printf("%s\n", e.message); - } - } else { - GLib.stderr.printf ("File '%s' doesn't exist.\n", path); - } - } - - public void write (HashTable new_conf) { - var file = GLib.File.new_for_path (conf_path); - if (file.query_exists ()) { - try { - // Open file for reading and wrap returned FileInputStream into a - // DataInputStream, so we can read line by line - var dis = new DataInputStream (file.read ()); - string? line; - var data = new GLib.List (); - // Read lines until end of file (null) is reached - while ((line = dis.read_line ()) != null) { - if (line.length == 0) { - data.append ("\n"); - continue; - } - unowned Variant variant; - if (line.contains ("Method")) { - if (new_conf.lookup_extended ("Method", null, out variant)) { - data.append ("Method = %s\n".printf (variant.get_string ())); - } else { - data.append (line + "\n"); - } - } else if (line.contains ("OnlyCountry")) { - if (new_conf.lookup_extended ("OnlyCountry", null, out variant)) { - if (variant.get_string () == "ALL") { - data.append ("#%s\n".printf (line)); - } else { - data.append ("OnlyCountry = %s\n".printf (variant.get_string ())); - } - } else { - data.append (line + "\n"); - } - } else { - data.append (line + "\n"); - } - } - // delete the file before rewrite it - file.delete (); - // creating a DataOutputStream to the file - var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - foreach (unowned string new_line in data) { - // writing a short string to the stream - dos.put_string (new_line); - } - } catch (GLib.Error e) { - GLib.stderr.printf("%s\n", e.message); - } - } else { - GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ()); - } - } - } -} diff --git a/src/pamac-system-daemon/mirrors_config.vala b/src/pamac-system-daemon/mirrors_config.vala new file mode 120000 index 0000000..339c997 --- /dev/null +++ b/src/pamac-system-daemon/mirrors_config.vala @@ -0,0 +1 @@ +../mirrors_config.vala \ No newline at end of file diff --git a/src/pamac-tray/CMakeLists.txt b/src/pamac-tray/CMakeLists.txt index 03ef5b8..d00708f 100644 --- a/src/pamac-tray/CMakeLists.txt +++ b/src/pamac-tray/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-tray/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-tray/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/src/aur ) link_libraries ( ${DEPS_LIBRARIES} -lPamac -lAUR ) @@ -25,6 +25,7 @@ include (ValaPrecompile) set (VALA_PACKAGES ${VALA_PACKAGES} posix) set (VALA_PACKAGES ${VALA_PACKAGES} json-glib-1.0) +set (VALA_PACKAGES ${VALA_PACKAGES} libalpm) set (VALA_PACKAGES ${VALA_PACKAGES} libnotify) if (KDE_TRAY) set (VALA_PACKAGES ${VALA_PACKAGES} appindicator3-0.1) @@ -41,9 +42,9 @@ if (KDE_TRAY) else () set (APP_SOURCES ${APP_SOURCES} tray-gtk.vala) endif () +set (APP_SOURCES ${APP_SOURCES} alpm_config.vala) set (APP_SOURCES ${APP_SOURCES} pamac_config.vala) set (APP_SOURCES ${APP_SOURCES} tray.vala) -set (APP_SOURCES ${APP_SOURCES} user_daemon.vala) set (CUSTOM_VAPIS_LIST ${CUSTOM_VAPIS_LIST} ${CMAKE_BINARY_DIR}/src/Pamac.vapi) if (NOT DISABLE_AUR) diff --git a/src/pamac-tray/alpm_config.vala b/src/pamac-tray/alpm_config.vala new file mode 120000 index 0000000..216718c --- /dev/null +++ b/src/pamac-tray/alpm_config.vala @@ -0,0 +1 @@ +../alpm_config.vala \ No newline at end of file diff --git a/src/pamac-tray/meson.build b/src/pamac-tray/meson.build index 35c5dd6..854e98d 100644 --- a/src/pamac-tray/meson.build +++ b/src/pamac-tray/meson.build @@ -4,12 +4,13 @@ cfg_pamac_tray.set('PKGDATADIR', join_paths(get_option('prefix'),get_option('dat cfg_pamac_tray.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_tray.set('RELEASE_NAME', 'pamac') cfg_pamac_tray.set('PREFIX', get_option('prefix')) -cfg_pamac_tray.set('VERSION', '6.3.1') +cfg_pamac_tray.set('VERSION', '6.3.3') cfg_pamac_tray.set('TESTSRCDIR', meson.source_root()) cfgfile_4 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_tray) pamac_tray_deps = [json_glib_1_0_dep] +pamac_tray_deps += [libalpm_dep] pamac_tray_deps += [libnotify_dep] if KDE_TRAY pamac_tray_deps += [appindicator3_0_1_dep] @@ -25,9 +26,9 @@ pamac_tray_sources += ['tray-appindicator.vala'] else pamac_tray_sources += ['tray-gtk.vala'] endif +pamac_tray_sources += ['alpm_config.vala'] pamac_tray_sources += ['pamac_config.vala'] pamac_tray_sources += ['tray.vala'] -pamac_tray_sources += ['user_daemon.vala'] pamac_tray_vala_args = ['--pkg','posix'] pamac_tray_vala_args += ['--vapidir='+join_paths(meson.source_root(),'src/vapis')] pamac_tray_dependencies = [Pamac_library] diff --git a/src/pamac-tray/tray.vala b/src/pamac-tray/tray.vala index c6e366a..27a88c9 100644 --- a/src/pamac-tray/tray.vala +++ b/src/pamac-tray/tray.vala @@ -27,6 +27,18 @@ const string noupdate_info = _("Your system is up-to-date"); namespace Pamac { [DBus (name = "org.pamac.user")] + interface UserDaemon : Object { + public abstract void refresh_handle () throws IOError; + public abstract string get_lockfile () throws IOError; +#if DISABLE_AUR + public abstract void start_get_updates () throws IOError; +#else + public abstract void start_get_updates (bool check_aur_updates) throws IOError; +#endif + [DBus (no_reply = true)] + public abstract void quit () throws IOError; + public signal void get_updates_finished (Updates updates); + } public abstract class TrayIcon: Gtk.Application { Notify.Notification notification; diff --git a/src/pamac-tray/user_daemon.vala b/src/pamac-tray/user_daemon.vala deleted file mode 100644 index 3905afc..0000000 --- a/src/pamac-tray/user_daemon.vala +++ /dev/null @@ -1,61 +0,0 @@ -/* - * pamac-vala - * - * Copyright (C) 2017 Chris Cromer - * Copyright (C) 2014-2017 Guillaume Benoit - * - * 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 . - */ - -namespace Pamac { - [DBus (name = "org.pamac.user")] - interface UserDaemon : Object { - public abstract void refresh_handle () throws IOError; -#if DISABLE_AUR - public abstract void start_get_updates () throws IOError; -#else - public abstract void start_get_updates (bool check_aur_updates) throws IOError; -#endif - [DBus (no_reply = true)] - public abstract void quit () throws IOError; - public signal void get_updates_finished (Updates updates); - public abstract string get_lockfile () throws IOError; - } - [DBus (name = "org.pamac.system")] - interface SystemDaemon : Object { - [DBus (no_reply = true)] - public signal void get_updates_finished (Updates updates); - public signal void emit_event (uint primary_event, uint secondary_event, string[] details); - public signal void emit_providers (string depend, string[] providers); - public signal void emit_progress (uint progress, string pkgname, uint percent, uint n_targets, uint current_target); - public signal void emit_download (string filename, uint64 xfered, uint64 total); - public signal void emit_totaldownload (uint64 total); - public signal void emit_log (uint level, string msg); - public signal void set_pkgreason_finished (); - public signal void refresh_finished (bool success); - public signal void trans_prepare_finished (bool success); - public signal void trans_commit_finished (bool success); - public signal void get_authorization_finished (bool authorized); -#if DISABLE_AUR - public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon); -#else - public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates); -#endif - public signal void write_alpm_config_finished (bool checkspace); - public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); - public signal void generate_mirrors_list_data (string line); - public signal void generate_mirrors_list_finished (); - } -} diff --git a/src/pamac-user-daemon/CMakeLists.txt b/src/pamac-user-daemon/CMakeLists.txt index 48d3f4f..4f44e74 100644 --- a/src/pamac-user-daemon/CMakeLists.txt +++ b/src/pamac-user-daemon/CMakeLists.txt @@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "pamac") set (RELEASE_NAME "pamac") set (CMAKE_C_FLAGS "") set (PREFIX ${CMAKE_INSTALL_PREFIX}) -set (VERSION "6.3.1") +set (VERSION "6.3.3") set (TESTSRCDIR "${CMAKE_SOURCE_DIR}") set (DOLLAR "$") configure_file (${CMAKE_SOURCE_DIR}/src/pamac-user-daemon/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-user-daemon/Config.vala) add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") -set (VERSION "6.3.1") +set (VERSION "6.3.3") add_definitions (${DEPS_CFLAGS}) include_directories ( ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/src/aur ) link_libraries ( ${DEPS_LIBRARIES} -lPamac -lAUR ) diff --git a/src/pamac-user-daemon/alpm_config.vala b/src/pamac-user-daemon/alpm_config.vala index 90ff71b..216718c 120000 --- a/src/pamac-user-daemon/alpm_config.vala +++ b/src/pamac-user-daemon/alpm_config.vala @@ -1 +1 @@ -../pamac-system-daemon/alpm_config.vala \ No newline at end of file +../alpm_config.vala \ No newline at end of file diff --git a/src/pamac-user-daemon/meson.build b/src/pamac-user-daemon/meson.build index 1c7814e..e3f622b 100644 --- a/src/pamac-user-daemon/meson.build +++ b/src/pamac-user-daemon/meson.build @@ -4,7 +4,7 @@ cfg_pamac_user_daemon.set('PKGDATADIR', join_paths(get_option('prefix'),get_opti cfg_pamac_user_daemon.set('GETTEXT_PACKAGE', 'pamac') cfg_pamac_user_daemon.set('RELEASE_NAME', 'pamac') cfg_pamac_user_daemon.set('PREFIX', get_option('prefix')) -cfg_pamac_user_daemon.set('VERSION', '6.3.1') +cfg_pamac_user_daemon.set('VERSION', '6.3.3') cfg_pamac_user_daemon.set('TESTSRCDIR', meson.source_root()) cfgfile_3 = configure_file(input: 'Config.vala.base',output: 'Config.vala',configuration: cfg_pamac_user_daemon)