File: sxmo_upgrade.sh

package info (click to toggle)
sxmo-utils 1.14.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,016 kB
  • sloc: sh: 9,166; ansic: 117; makefile: 68
file content (45 lines) | stat: -rwxr-xr-x 1,157 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"

trap "read -r" EXIT

update_apk() {
	echo "Updating all packages from repositories"
	doas apk update

	echo "Upgrading all packages"
	doas apk upgrade -v

	echo "Upgrade complete - reboot for all changes to take effect"
}

update_pacman() {
	echo "Upgrading all packages"
	doas pacman -Syu

	echo "Upgrade complete - reboot for all changes to take effect"
}

update_nixos() {
	echo "Upgrading all packages"
	# nohup needed because nixos-rebuild might restart the display manager
	# (and thus the terminal we're running in) before the update is complete
	doas nohup nixos-rebuild switch --upgrade > /tmp/sxmo-last-upgrade.log &
	coreutils --coreutils-prog=tail -f /tmp/sxmo-last-upgrade.log --pid=$!

	echo "Upgrade complete - reboot for all changes to take effect"
}

sxmo_wakelock.sh lock upgrading infinite

case "$SXMO_OS" in
	alpine|postmarketos) update_apk;;
	arch|archarm) update_pacman;;
	nixos) update_nixos;;
esac

sxmo_wakelock.sh unlock upgrading