work around get_gpg_verify not working for new_system
This commit is contained in:
parent
09c9161e13
commit
faf4985067
2 changed files with 39 additions and 48 deletions
|
|
@ -246,9 +246,20 @@ class AppstreamSearcher:
|
||||||
packages = []
|
packages = []
|
||||||
metadata = AppStream.Metadata.new()
|
metadata = AppStream.Metadata.new()
|
||||||
metadata.set_format_style(AppStream.FormatStyle.CATALOG)
|
metadata.set_format_style(AppStream.FormatStyle.CATALOG)
|
||||||
#if self.refresh:
|
if self.refresh:
|
||||||
# inst.update_appstream_full_sync(remote.get_name(), None, None, True)
|
if remote.get_name() == "flathub" or remote.get_name() == "flathub-beta":
|
||||||
|
remote.set_gpg_verify(True)
|
||||||
|
inst.modify_remote(remote, None)
|
||||||
|
inst.update_appstream_full_sync(remote.get_name(), None, None, True)
|
||||||
appstream_file = Path(remote.get_appstream_dir().get_path() + "/appstream.xml.gz")
|
appstream_file = Path(remote.get_appstream_dir().get_path() + "/appstream.xml.gz")
|
||||||
|
if not appstream_file.exists() and check_internet():
|
||||||
|
try:
|
||||||
|
if remote.get_name() == "flathub" or remote.get_name() == "flathub-beta":
|
||||||
|
remote.set_gpg_verify(True)
|
||||||
|
inst.modify_remote(remote, None)
|
||||||
|
inst.update_appstream_full_sync(remote.get_name(), None, None, True)
|
||||||
|
except GLib.Error as e:
|
||||||
|
logger.error(f"Failed to update AppStream metadata: {str(e)}")
|
||||||
if appstream_file.exists():
|
if appstream_file.exists():
|
||||||
metadata.parse_file(Gio.File.new_for_path(appstream_file.as_posix()), AppStream.FormatKind.XML)
|
metadata.parse_file(Gio.File.new_for_path(appstream_file.as_posix()), AppStream.FormatKind.XML)
|
||||||
components: AppStream.ComponentBox = metadata.get_components()
|
components: AppStream.ComponentBox = metadata.get_components()
|
||||||
|
|
@ -475,17 +486,14 @@ class AppstreamSearcher:
|
||||||
return self.installed_results, self.updates_results
|
return self.installed_results, self.updates_results
|
||||||
|
|
||||||
|
|
||||||
def retrieve_metadata(self, system=False, refresh=True):
|
def retrieve_metadata(self, system=False):
|
||||||
"""Retrieve and refresh metadata for Flatpak repositories."""
|
"""Retrieve and refresh metadata for Flatpak repositories."""
|
||||||
self._initialize_metadata()
|
self._initialize_metadata()
|
||||||
|
|
||||||
if not check_internet():
|
if not check_internet():
|
||||||
return self._handle_offline_mode()
|
return self._handle_offline_mode()
|
||||||
|
|
||||||
if system:
|
searcher = get_reposearcher(system, True)
|
||||||
refresh = False
|
|
||||||
|
|
||||||
searcher = get_reposearcher(system, refresh)
|
|
||||||
self.all_apps = searcher.get_all_apps()
|
self.all_apps = searcher.get_all_apps()
|
||||||
|
|
||||||
return self._process_categories(searcher, system)
|
return self._process_categories(searcher, system)
|
||||||
|
|
@ -678,14 +686,8 @@ def get_installation(system=False):
|
||||||
return installation
|
return installation
|
||||||
|
|
||||||
def get_reposearcher(system=False, refresh=False):
|
def get_reposearcher(system=False, refresh=False):
|
||||||
if system is False:
|
installation = get_installation(system)
|
||||||
installation = get_installation()
|
searcher = AppstreamSearcher(refresh)
|
||||||
else:
|
|
||||||
installation = get_installation(True)
|
|
||||||
if refresh is True:
|
|
||||||
searcher = AppstreamSearcher(refresh)
|
|
||||||
else:
|
|
||||||
searcher = AppstreamSearcher()
|
|
||||||
searcher.add_installation(installation)
|
searcher.add_installation(installation)
|
||||||
return searcher
|
return searcher
|
||||||
|
|
||||||
|
|
@ -712,10 +714,7 @@ def repotoggle(repo, toggle=True, system=False):
|
||||||
if not repo:
|
if not repo:
|
||||||
return False, "Repository name cannot be empty"
|
return False, "Repository name cannot be empty"
|
||||||
|
|
||||||
if system is False:
|
installation = get_installation(system)
|
||||||
installation = get_installation()
|
|
||||||
else:
|
|
||||||
installation = get_installation(True)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
remote = installation.get_remote_by_name(repo)
|
remote = installation.get_remote_by_name(repo)
|
||||||
|
|
@ -742,27 +741,18 @@ def repotoggle(repo, toggle=True, system=False):
|
||||||
return False, "Operation failed"
|
return False, "Operation failed"
|
||||||
|
|
||||||
def repolist(system=False):
|
def repolist(system=False):
|
||||||
if system is False:
|
installation = get_installation(system)
|
||||||
installation = get_installation()
|
|
||||||
else:
|
|
||||||
installation = get_installation(True)
|
|
||||||
repos = installation.list_remotes()
|
repos = installation.list_remotes()
|
||||||
return repos
|
return repos
|
||||||
|
|
||||||
def repodelete(repo, system=False):
|
def repodelete(repo, system=False):
|
||||||
if system is False:
|
installation = get_installation(system)
|
||||||
installation = get_installation()
|
|
||||||
else:
|
|
||||||
installation = get_installation(True)
|
|
||||||
installation.remove_remote(repo)
|
installation.remove_remote(repo)
|
||||||
|
|
||||||
def repoadd(repofile, system=False):
|
def repoadd(repofile, system=False):
|
||||||
"""Add a new repository using a .flatpakrepo file"""
|
"""Add a new repository using a .flatpakrepo file"""
|
||||||
# Get existing repositories
|
# Get existing repositories
|
||||||
if system is False:
|
installation = get_installation(system)
|
||||||
installation = get_installation()
|
|
||||||
else:
|
|
||||||
installation = get_installation(True)
|
|
||||||
existing_repos = installation.list_remotes()
|
existing_repos = installation.list_remotes()
|
||||||
|
|
||||||
if not repofile.endswith('.flatpakrepo'):
|
if not repofile.endswith('.flatpakrepo'):
|
||||||
|
|
@ -809,11 +799,14 @@ def repoadd(repofile, system=False):
|
||||||
# Check if URL already exists
|
# Check if URL already exists
|
||||||
if new_url in existing_urls:
|
if new_url in existing_urls:
|
||||||
return False, f"A repository with URL '{new_url}' already exists."
|
return False, f"A repository with URL '{new_url}' already exists."
|
||||||
|
user = "user"
|
||||||
|
if system:
|
||||||
|
user = "system"
|
||||||
|
remote.set_gpg_verify(True)
|
||||||
installation.add_remote(remote, True, None)
|
installation.add_remote(remote, True, None)
|
||||||
except GLib.GError as e:
|
except GLib.GError as e:
|
||||||
return False, f"Failed to add repository: {str(e)}"
|
return False, f"Failed to add repository: {str(e)}"
|
||||||
return True, None
|
return True, f"{remote.get_name()} repository successfully added for {user} installation."
|
||||||
|
|
||||||
def repofile_is_url(string):
|
def repofile_is_url(string):
|
||||||
"""Check if a string is a valid URL"""
|
"""Check if a string is a valid URL"""
|
||||||
|
|
@ -937,8 +930,8 @@ def handle_repo_toggle(args):
|
||||||
try:
|
try:
|
||||||
success, message = repotoggle(repo_name, get_status, args.system)
|
success, message = repotoggle(repo_name, get_status, args.system)
|
||||||
print(f"{message}")
|
print(f"{message}")
|
||||||
except GLib.Error:
|
except GLib.Error as e:
|
||||||
print(f"{message}")
|
print(f"{str(e)}")
|
||||||
|
|
||||||
def handle_list_repos(args):
|
def handle_list_repos(args):
|
||||||
repos = repolist(args.system)
|
repos = repolist(args.system)
|
||||||
|
|
@ -950,8 +943,8 @@ def handle_add_repo(args):
|
||||||
try:
|
try:
|
||||||
success, message = repoadd(args.add_repo, args.system)
|
success, message = repoadd(args.add_repo, args.system)
|
||||||
print(f"{message}")
|
print(f"{message}")
|
||||||
except GLib.Error:
|
except GLib.Error as e:
|
||||||
print(f"{message}")
|
print(f"{str(e)}")
|
||||||
|
|
||||||
def handle_remove_repo(args):
|
def handle_remove_repo(args):
|
||||||
repodelete(args.remove_repo, args.system)
|
repodelete(args.remove_repo, args.system)
|
||||||
|
|
@ -963,8 +956,8 @@ def handle_install(args, searcher):
|
||||||
try:
|
try:
|
||||||
success, message = install_flatpak(package, args.repo, args.system)
|
success, message = install_flatpak(package, args.repo, args.system)
|
||||||
print(f"{message}")
|
print(f"{message}")
|
||||||
except GLib.Error:
|
except GLib.Error as e:
|
||||||
print(f"{message}")
|
print(f"{str(e)}")
|
||||||
|
|
||||||
def handle_remove(args, searcher):
|
def handle_remove(args, searcher):
|
||||||
packagelist = searcher.search_flatpak(args.remove, args.repo)
|
packagelist = searcher.search_flatpak(args.remove, args.repo)
|
||||||
|
|
@ -972,8 +965,8 @@ def handle_remove(args, searcher):
|
||||||
try:
|
try:
|
||||||
success, message = remove_flatpak(package, args.repo, args.system)
|
success, message = remove_flatpak(package, args.repo, args.system)
|
||||||
print(f"{message}")
|
print(f"{message}")
|
||||||
except GLib.Error:
|
except GLib.Error as e:
|
||||||
print(f"{message}")
|
print(f"{str(e)}")
|
||||||
|
|
||||||
def handle_list_installed(args, searcher):
|
def handle_list_installed(args, searcher):
|
||||||
installed_apps = searcher.get_installed_apps(args.system)
|
installed_apps = searcher.get_installed_apps(args.system)
|
||||||
|
|
|
||||||
12
main.py
12
main.py
|
|
@ -233,7 +233,7 @@ class MainWindow(Gtk.Window):
|
||||||
if desired_state:
|
if desired_state:
|
||||||
# Request superuser validation
|
# Request superuser validation
|
||||||
try:
|
try:
|
||||||
subprocess.run(['pkexec', 'true'], check=True)
|
#subprocess.run(['pkexec', 'true'], check=True)
|
||||||
self.system_mode = True
|
self.system_mode = True
|
||||||
self.refresh_data()
|
self.refresh_data()
|
||||||
self.refresh_current_page()
|
self.refresh_current_page()
|
||||||
|
|
@ -297,7 +297,7 @@ class MainWindow(Gtk.Window):
|
||||||
searcher = libflatpak_query.get_reposearcher(self.system_mode)
|
searcher = libflatpak_query.get_reposearcher(self.system_mode)
|
||||||
|
|
||||||
# Define thread target function
|
# Define thread target function
|
||||||
def refresh_target():
|
def retrieve_metadata():
|
||||||
try:
|
try:
|
||||||
category_results, collection_results, installed_results, updates_results, all_apps = searcher.retrieve_metadata(self.system_mode)
|
category_results, collection_results, installed_results, updates_results, all_apps = searcher.retrieve_metadata(self.system_mode)
|
||||||
self.category_results = category_results
|
self.category_results = category_results
|
||||||
|
|
@ -306,20 +306,18 @@ class MainWindow(Gtk.Window):
|
||||||
self.updates_results = updates_results
|
self.updates_results = updates_results
|
||||||
self.all_apps = all_apps
|
self.all_apps = all_apps
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
message_type = Gtk.MessageType.ERROR
|
|
||||||
dialog = Gtk.MessageDialog(
|
dialog = Gtk.MessageDialog(
|
||||||
transient_for=None, # Changed from self
|
transient_for=None, # Changed from self
|
||||||
modal=True,
|
modal=True,
|
||||||
destroy_with_parent=True,
|
destroy_with_parent=True,
|
||||||
message_type=message_type,
|
message_type=Gtk.MessageType.ERROR,
|
||||||
buttons=Gtk.ButtonsType.OK,
|
buttons=Gtk.ButtonsType.OK,
|
||||||
text=f"Error updating progress: {str(e)}"
|
text=f"Error retrieving metadata: {str(e)}"
|
||||||
)
|
)
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
# Start the refresh thread
|
# Start the refresh thread
|
||||||
refresh_thread = threading.Thread(target=refresh_target)
|
refresh_thread = threading.Thread(target=retrieve_metadata)
|
||||||
refresh_thread.start()
|
refresh_thread.start()
|
||||||
def update_progress():
|
def update_progress():
|
||||||
while refresh_thread.is_alive():
|
while refresh_thread.is_alive():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue