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 23, 2024
1 parent 593382b commit d0d8536
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,3 @@ def check_for_rebase():
else:
print("rebase failed!, command output:")
print(rebase_out.stdout.decode("utf-8"))
update_cmd = ["rpm-ostree", "upgrade"]
update_out = run(update_cmd, capture_output=True)
if update_out.returncode != 0:
print(
f"rpm-ostree upgrade returned code {update_out.returncode}, program output:"
)
print(update_out.stdout.decode("utf-8"))
os._exit(update_out.returncode)
3 changes: 0 additions & 3 deletions files/etc/ublue-update.d/system/01-flatpak-system-update.sh

This file was deleted.

3 changes: 3 additions & 0 deletions files/etc/ublue-update.d/system/01-topgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/bash

/usr/bin/topgrade --config /etc/ublue-update/topgrade-system.toml

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
5 changes: 2 additions & 3 deletions src/ublue_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ 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 +181,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
11 changes: 8 additions & 3 deletions ublue-update.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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
Expand All @@ -56,6 +55,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 +73,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 d0d8536

Please sign in to comment.