Skip to content

Commit

Permalink
feat: Remove rebase step now that ISOs are nearly ready (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo authored Feb 23, 2024
2 parents d45c40f + 9729de3 commit 1e670f0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 160 deletions.
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Universal Blue Update

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)
Small update program written in python intended for use in Universal Blue that uses [`topgrade`](https://github.com/topgrade-rs/topgrade) for executing updates.

Includes systemd timers and services for auto update

Expand Down Expand Up @@ -75,20 +75,15 @@ $ journalctl -exu 'ublue-update.service'
# Configuration

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

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

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

### `/etc/ublue-update.d/system`

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


## Location
Expand Down
116 changes: 0 additions & 116 deletions files/etc/ublue-update.d/system/00-system-update.py

This file was deleted.

47 changes: 20 additions & 27 deletions src/ublue_update/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,6 @@ def hardware_inhibitor_checks_failed(
raise Exception(f"update failed to pass checks: \n - {exception_log}")


def run_update_scripts(root_dir: str):
for root, dirs, files in os.walk(root_dir):
for file in files:
full_path = root_dir + str(file)
executable = os.access(full_path, os.X_OK)
if executable:
log.info(f"Running update script: {full_path}")
out = subprocess.run(
[full_path],
capture_output=True,
)
if out.returncode != 0:
log.error(
f"{full_path} returned error code: {out.returncode}, program output:" # noqa: E501
)
log.error(out.stdout.decode("utf-8"))
notify(
"System Updater",
f"Error in update script: {file}, check logs for more info",
)
else:
log.info(f"could not execute file {full_path}")


def run_updates(system, system_update_available):
process_uid = os.getuid()
filelock_path = "/run/ublue-update.lock"
Expand All @@ -120,7 +96,6 @@ def run_updates(system, system_update_available):
fd = acquire_lock(filelock_path)
if fd is None:
raise Exception("updates are already running for this user")
root_dir = "/etc/ublue-update.d"

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

run_update_scripts(f"{root_dir}/system/")
"""System"""
out = subprocess.run(
[
"/usr/bin/topgrade",
"--config",
"/usr/share/ublue-update/topgrade-system.toml",
],
capture_output=True,
)
log.debug(out.stdout.decode("utf-8"))

if out.returncode != 0:
print(
f"topgrade returned code {out.returncode}, program output:"
)
print(out.stdout.decode("utf-8"))
os._exit(out.returncode)

"""Users"""
for user in users:
try:
xdg_runtime_dir = get_xdg_runtime_dir(user["User"])
Expand All @@ -160,7 +153,7 @@ def run_updates(system, system_update_available):
f"DBUS_SESSION_BUS_ADDRESS=unix:path={xdg_runtime_dir}/bus",
"/usr/bin/topgrade",
"--config",
"/etc/ublue-update/topgrade-user.toml",
"/usr/share/ublue-update/topgrade-user.toml",
],
capture_output=True,
)
Expand Down
8 changes: 3 additions & 5 deletions ublue-update.spec
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ ls
ls src
black src
flake8 src
black files/etc/%{NAME}.d/system/*.py
flake8 files/etc/%{NAME}.d/system/*.py
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files ublue_update
cp -rp files/etc files/usr %{buildroot}
cp -rp files/usr %{buildroot}

%pre
if [ ! -x /usr/bin/topgrade ]
Expand All @@ -72,8 +70,8 @@ fi
%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}/*.toml
%attr(0755,root,root) %{_sysconfdir}/%{NAME}.d/system/*
%attr(0644,root,root) %{_exec_prefix}/etc/polkit-1/rules.d/%{NAME}.rules
%attr(0644,root,root) %{_datadir}/%{NAME}/*.toml
%attr(0644,root,root) %{_datadir}/polkit-1/rules.d/%{NAME}.rules

%changelog
%autochangelog

0 comments on commit 1e670f0

Please sign in to comment.