Skip to content

Commit

Permalink
feat: Add topgrade support
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Jan 26, 2024
1 parent 593382b commit 89bfa87
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 45 deletions.
4 changes: 2 additions & 2 deletions files/etc/ublue-update.d/system/00-system-update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/python3

from subprocess import run
from json import loads, load
Expand Down Expand Up @@ -106,7 +106,7 @@ def check_for_rebase():
else:
print("rebase failed!, command output:")
print(rebase_out.stdout.decode("utf-8"))
update_cmd = ["rpm-ostree", "upgrade"]
update_cmd = ["/usr/bin/topgrade", "--config", "/etc/ublue-update/topgrade-system.toml"]
update_out = run(update_cmd, capture_output=True)
if update_out.returncode != 0:
print(
Expand Down
3 changes: 0 additions & 3 deletions files/etc/ublue-update.d/system/01-flatpak-system-update.sh

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions files/etc/ublue-update.d/user/00-flatpak-user-update.sh

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions files/etc/ublue-update.d/user/02-distrobox-user-update.sh

This file was deleted.

5 changes: 0 additions & 5 deletions files/etc/ublue-update.d/user/03-fleek-user-update.sh

This file was deleted.

5 changes: 0 additions & 5 deletions files/etc/ublue-update.d/user/04-brew-update.sh

This file was deleted.

10 changes: 10 additions & 0 deletions files/usr/etc/ublue-update/topgrade-system.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[misc]
only = ["system", "flatpak"]
ignore_failures = ["flatpak"]
skip_notify = true
assume_yes = true
no_retry = true
no_self_update = true

[linux]
rpm_ostree = true
13 changes: 13 additions & 0 deletions files/usr/etc/ublue-update/topgrade-user.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[misc]
only = ["flatpak", "distrobox"]
ignore_failures = ["flatpak", "distrobox"]
skip_notify = true
assume_yes = true
no_retry = true
no_self_update = true

[distrobox]
use_root = false

[flatpak]
use_sudo = false
1 change: 0 additions & 1 deletion files/usr/etc/ublue-update/ublue-update.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
max_mem_percent = 90.0
[notify]
dbus_notify = true

10 changes: 4 additions & 6 deletions src/ublue_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ def run_updates(system, system_update_available):
log.error(f"failed to get xdg_runtime_dir for user: {user['Name']}", e)
break
log.info(
f"""Running update for user: '{user['Name']}',
update script directory: '{root_dir}/user'
"""
f"""Running update for user: '{user['Name']}'"""
)

out = subprocess.run(
Expand All @@ -160,8 +158,9 @@ def run_updates(system, system_update_available):
"DISPLAY=:0",
f"XDG_RUNTIME_DIR={xdg_runtime_dir}",
f"DBUS_SESSION_BUS_ADDRESS=unix:path={xdg_runtime_dir}/bus",
"/usr/bin/ublue-update",
"-f",
"/usr/bin/topgrade",
"--config",
"/etc/ublue-update/topgrade-user.toml",
],
capture_output=True,
)
Expand All @@ -181,7 +180,6 @@ def run_updates(system, system_update_available):
raise Exception(
"ublue-update needs to be run as root to perform system updates!"
)
run_update_scripts(f"{root_dir}/user/")
release_lock(fd)
os._exit(0)

Expand Down
13 changes: 8 additions & 5 deletions ublue-update.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Supplements: rpm-ostree flatpak
BuildRequires: make
BuildRequires: systemd-rpm-macros
BuildRequires: black
BuildRequires: ShellCheck
BuildRequires: python-flake8
BuildRequires: python-build
BuildRequires: python-setuptools
Expand All @@ -45,8 +44,6 @@ ls
ls src
black src
flake8 src
shellcheck files/etc/%{NAME}.d/user/*.sh
shellcheck files/etc/%{NAME}.d/system/*.sh
black files/etc/%{NAME}.d/system/*.py
flake8 files/etc/%{NAME}.d/system/*.py
%pyproject_wheel
Expand All @@ -56,6 +53,13 @@ flake8 files/etc/%{NAME}.d/system/*.py
%pyproject_save_files ublue_update
cp -rp files/etc files/usr %{buildroot}

%pre
if [ ! -x /usr/bin/topgrade ]
then
echo "Topgrade not installed. Please install Topgrade (https://github.com/topgrade-rs/topgrade) to use %{NAME}."
exit 1
fi

%post
%systemd_post %{NAME}.timer

Expand All @@ -67,8 +71,7 @@ cp -rp files/etc files/usr %{buildroot}
%attr(0644,root,root) %{_exec_prefix}/lib/systemd/system/%{NAME}.service
%attr(0644,root,root) %{_exec_prefix}/lib/systemd/system/%{NAME}.timer
%attr(0644,root,root) %{_exec_prefix}/lib/systemd/system-preset/00-%{NAME}.preset
%attr(0644,root,root) %{_exec_prefix}/etc/%{NAME}/%{NAME}.toml
%attr(0755,root,root) %{_sysconfdir}/%{NAME}.d/user/*
%attr(0644,root,root) %{_exec_prefix}/etc/%{NAME}/*.toml
%attr(0755,root,root) %{_sysconfdir}/%{NAME}.d/system/*
%attr(0644,root,root) %{_exec_prefix}/etc/polkit-1/rules.d/%{NAME}.rules

Expand Down

0 comments on commit 89bfa87

Please sign in to comment.