Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add topgrade support #102

Merged
merged 2 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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,11 +106,11 @@ 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(
f"rpm-ostree upgrade returned code {update_out.returncode}, program output:"
f"topgrade 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.

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

2 changes: 1 addition & 1 deletion rpkg.macros
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function ublue_update_version {
if [ "$GITHUB_REF_NAME" = "" ]; then
echo "1.1.3+$(git rev-parse --short HEAD)"
echo "1.2.3+$(git rev-parse --short HEAD)"
else
echo "$GITHUB_REF_NAME"
fi
Expand Down
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,
)
KyleGospo marked this conversation as resolved.
Show resolved Hide resolved
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
Loading