Skip to content

Commit 1e670f0

Browse files
authored
feat: Remove rebase step now that ISOs are nearly ready (#105)
2 parents d45c40f + 9729de3 commit 1e670f0

File tree

7 files changed

+30
-160
lines changed

7 files changed

+30
-160
lines changed

README.md

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Universal Blue Update
22

3-
Small update program written in python intended for use in Universal Blue, executes update scripts/tasks placed in `/etc/ublue-update.d` (make sure each script has exec perms)
3+
Small update program written in python intended for use in Universal Blue that uses [`topgrade`](https://github.com/topgrade-rs/topgrade) for executing updates.
44

55
Includes systemd timers and services for auto update
66

@@ -75,20 +75,15 @@ $ journalctl -exu 'ublue-update.service'
7575
# Configuration
7676

7777
## Update Scripts
78-
Update scripts are separated into two directories inside of `/etc/ublue-update.d`
78+
Update scripts are separated into two files inside of `/usr/share/ublue-update`
7979

80-
### `/etc/ublue-update.d/user`
80+
### `/usr/share/ublue-update/topgrade-system.toml`
81+
Topgrade config ran as root, handles rpm-ostree and flatpaks.
8182

82-
Update scripts are ran as user. Scripts included:
83-
- per-user flatpak update scripts (uninstalling unused deps and repairing flatpak install for maintenence)
84-
- distrobox update script
85-
- fleek update script
83+
### `/usr/share/ublue-update/topgrade-user.toml`
84+
Topgrade config ran as user, handles flatpaks and distrobox containers.
8685

87-
### `/etc/ublue-update.d/system`
88-
89-
Update scripts are ran as root, these updates are meant to be system-wide. Scripts included:
90-
- OS update script (depends on [`rpm-ostree`](https://github.com/coreos/rpm-ostree))
91-
- system-wide flatpak update scripts (uninstalling unused deps and repairing flatpak install for maintenence)
86+
See [`topgrade`](https://github.com/topgrade-rs/topgrade)'s GitHub for configuring these files.
9287

9388

9489
## Location

files/etc/ublue-update.d/system/00-system-update.py

-116
This file was deleted.

src/ublue_update/cli.py

+20-27
Original file line numberDiff line numberDiff line change
@@ -86,30 +86,6 @@ def hardware_inhibitor_checks_failed(
8686
raise Exception(f"update failed to pass checks: \n - {exception_log}")
8787

8888

89-
def run_update_scripts(root_dir: str):
90-
for root, dirs, files in os.walk(root_dir):
91-
for file in files:
92-
full_path = root_dir + str(file)
93-
executable = os.access(full_path, os.X_OK)
94-
if executable:
95-
log.info(f"Running update script: {full_path}")
96-
out = subprocess.run(
97-
[full_path],
98-
capture_output=True,
99-
)
100-
if out.returncode != 0:
101-
log.error(
102-
f"{full_path} returned error code: {out.returncode}, program output:" # noqa: E501
103-
)
104-
log.error(out.stdout.decode("utf-8"))
105-
notify(
106-
"System Updater",
107-
f"Error in update script: {file}, check logs for more info",
108-
)
109-
else:
110-
log.info(f"could not execute file {full_path}")
111-
112-
11389
def run_updates(system, system_update_available):
11490
process_uid = os.getuid()
11591
filelock_path = "/run/ublue-update.lock"
@@ -120,7 +96,6 @@ def run_updates(system, system_update_available):
12096
fd = acquire_lock(filelock_path)
12197
if fd is None:
12298
raise Exception("updates are already running for this user")
123-
root_dir = "/etc/ublue-update.d"
12499

125100
"""Wait on any existing transactions to complete before updating"""
126101
transaction_wait()
@@ -139,7 +114,25 @@ def run_updates(system, system_update_available):
139114
if system:
140115
users = []
141116

142-
run_update_scripts(f"{root_dir}/system/")
117+
"""System"""
118+
out = subprocess.run(
119+
[
120+
"/usr/bin/topgrade",
121+
"--config",
122+
"/usr/share/ublue-update/topgrade-system.toml",
123+
],
124+
capture_output=True,
125+
)
126+
log.debug(out.stdout.decode("utf-8"))
127+
128+
if out.returncode != 0:
129+
print(
130+
f"topgrade returned code {out.returncode}, program output:"
131+
)
132+
print(out.stdout.decode("utf-8"))
133+
os._exit(out.returncode)
134+
135+
"""Users"""
143136
for user in users:
144137
try:
145138
xdg_runtime_dir = get_xdg_runtime_dir(user["User"])
@@ -160,7 +153,7 @@ def run_updates(system, system_update_available):
160153
f"DBUS_SESSION_BUS_ADDRESS=unix:path={xdg_runtime_dir}/bus",
161154
"/usr/bin/topgrade",
162155
"--config",
163-
"/etc/ublue-update/topgrade-user.toml",
156+
"/usr/share/ublue-update/topgrade-user.toml",
164157
],
165158
capture_output=True,
166159
)

ublue-update.spec

+3-5
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ ls
4444
ls src
4545
black src
4646
flake8 src
47-
black files/etc/%{NAME}.d/system/*.py
48-
flake8 files/etc/%{NAME}.d/system/*.py
4947
%pyproject_wheel
5048

5149
%install
5250
%pyproject_install
5351
%pyproject_save_files ublue_update
54-
cp -rp files/etc files/usr %{buildroot}
52+
cp -rp files/usr %{buildroot}
5553

5654
%pre
5755
if [ ! -x /usr/bin/topgrade ]
@@ -72,8 +70,8 @@ fi
7270
%attr(0644,root,root) %{_exec_prefix}/lib/systemd/system/%{NAME}.timer
7371
%attr(0644,root,root) %{_exec_prefix}/lib/systemd/system-preset/00-%{NAME}.preset
7472
%attr(0644,root,root) %{_exec_prefix}/etc/%{NAME}/*.toml
75-
%attr(0755,root,root) %{_sysconfdir}/%{NAME}.d/system/*
76-
%attr(0644,root,root) %{_exec_prefix}/etc/polkit-1/rules.d/%{NAME}.rules
73+
%attr(0644,root,root) %{_datadir}/%{NAME}/*.toml
74+
%attr(0644,root,root) %{_datadir}/polkit-1/rules.d/%{NAME}.rules
7775

7876
%changelog
7977
%autochangelog

0 commit comments

Comments
 (0)