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

develmaster: first round of commits for v3.11.0 #115

Merged
merged 34 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e33d7aa
Update README.md
Olf0 Mar 20, 2023
b48eb4b
Use POSIX shell arithmetic, `printf` instead of `echo`, omit quoting …
Olf0 Mar 22, 2023
5a273cd
Do it correctly, use `eval`, see
Olf0 Mar 26, 2023
b295d05
`grep -vx ''`→`fgrep -vx ''`
Olf0 Mar 29, 2023
413e4c0
Unify quoting
Olf0 Mar 29, 2023
99ab6a4
Unify quoting
Olf0 Mar 29, 2023
1973ef4
Unify
Olf0 Mar 29, 2023
aef52df
Unify quoting
Olf0 Mar 29, 2023
44681e5
Update post_sfos-upgrade
Olf0 Apr 1, 2023
ee4fadf
New intro
Olf0 Apr 3, 2023
506218d
New intro
Olf0 Apr 3, 2023
d1695be
Update tidy_log-dupes
Olf0 Apr 3, 2023
31c43da
Update post_sfos-upgrade
Olf0 Apr 3, 2023
248edd9
Update sfos-upgrade
Olf0 Apr 3, 2023
8b22e42
Update tidy_log-dupes
Olf0 Apr 3, 2023
6147d48
Update post_sfos-upgrade
Olf0 Apr 3, 2023
37c63e3
Move up from `/usr/bin` to `/bin` (#113)
Olf0 Apr 3, 2023
593f913
Call it "SailfishOS:Chum metadata definition"
Olf0 Apr 3, 2023
b3bbdc0
Update sfos-upgrade.spec
Olf0 Apr 3, 2023
8acd95e
Move icon from `icon` to `.icon` (#114)
Olf0 Apr 3, 2023
6ccb592
Update according to version 1 of the SailfishOS:Chum metadata definition
Olf0 Apr 4, 2023
a98dcff
Remove entries obsoleted by commit 6ccb592
Olf0 Apr 4, 2023
df74d8e
Revert commit b3bbdc0
Olf0 Apr 4, 2023
d22f961
Simplify some `cut`s to `${foo%…}` rsp. `${bar#…}`
Olf0 Apr 5, 2023
1fc4f91
Adapting to Jolla's perpetual changing of formats …
Olf0 Apr 6, 2023
0ebe1b5
Expand comment
Olf0 Apr 8, 2023
41e4349
Enhance comments with new knowledge about `sort`
Olf0 Apr 9, 2023
9a93222
Move check for root after options evaluation (#116)
Olf0 Apr 29, 2023
6965083
`basename $0`→`${0##*/}`
Olf0 Apr 30, 2023
7cc86d7
`basename $0`→`${0##*/}`
Olf0 Apr 30, 2023
0e1c7c9
"per"→"by" in comments
Olf0 May 1, 2023
e2f43c5
Add comment
Olf0 May 1, 2023
3ee688f
Enhance comment
Olf0 May 1, 2023
3ebd90f
Better wording: "field" -> "tag"
Olf0 May 3, 2023
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
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<br />

Upgrading SailfishOS at the GUI (per *Settings -> SailfishOS updates*) provides very little information about its progress / process / success, beyond reading `/var/log/systemupdate.log` after an upgrade. This can make troubleshooting issues hard.<br />
Upgrading SailfishOS at the GUI (per *SettingsSailfishOS updates*) provides very little information about its progress / process / success, beyond reading `/var/log/systemupdate.log` after an upgrade. This can make troubleshooting issues hard.<br />
Furthermore the GUI offers no control which SailfishOS version to upgrade to.

In contrast to that, Jolla's [guide how to upgrade SailfishOS at the command line](https://docs.sailfishos.org/Support/Help_Articles/Updating_Sailfish_OS/#update-using-the-command-line) offers full control, while lacking any logs or safety checks.<br />
Expand Down
83 changes: 83 additions & 0 deletions bin/post_sfos-upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
set -ufC # "-u" (error when using uninitialised variables),
# "-f" (disable pathname expansion) and "-C" (no-clobber / -overwrite).
# Ultimately decided against "-e", because this script better runs through,
# despite minor errors.
# set -o pipefail # May not be supported, busybox's ash and bash do; but
# unnecessary for this script.
# Using bash (formally) because it is "always there" on SailfishOS: Either the
# real bash 3.2.57 (the last GPLv2 version) on SailfishOS less than v4 or via
# busybox's bash-symlink (which is deployed by the busybox-symlinks-bash RPM)
# since SailfishOS 4. Note that busybox's ash support "-o pipefail", but not
# "-o posix"; setting POSIXLY_CORRECT seems to achive the same without
# compatibility issues, plus (when exported) also for a number of other GNU
# utilities.
# Nevertheless, this script is still a Bourne (not-"Again") Shell script and
# shall stay free of bashisms.
export LC_ALL=POSIX # For details see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_02
export POSIXLY_CORRECT=1 # Can have side-effects, see e.g., https://github.com/Olf0/sfos-upgrade/issues/73
# Ultimately this ensures an almost consistent behaviour across shell implementations.

called="${0##*/}"
if ! printf '%s' " $(id -un) $(id -Gn) " | fgrep -q ' root '
then
printf '%s\n' "Aborting: $called must be started with root privileges."
exit 1
fi

if ! [ "$(uptime | cut -f 1 -d ',' | rev | grep '^nim ' | cut -f 2 -d ' ' | rev)" -lt 4 ] 2> /dev/null
then
printf '%s\n\n' "Notice: Mind that $called is best run on a freshly rebooted device."
fi

printf '%s\n' "- Cleaning logfiles of duplicate entries."
tidy_log-dupes "$@"
printf '\n'

if command -v store-client > /dev/null 2>&1
then
printf '%s\n' "- Removing outdated Store version info."
for i in '-TERM' '-INT' '-TERM' '-HUP' '-KILL' '-Failed_to_kill_store-client'
do
if pgrep store-client > /dev/null
then eval pkill "$i" store-client # Or using the classic: `pkill "$(echo $i)" store-client`
else break
fi
sleep 1
done
printf '\n'
fi
# See troubleshooting section "Cleaning up" at https://docs.sailfishos.org/Support/Help_Articles/Updating_Sailfish_OS/#update-using-the-command-line
rm -f /home/.pk-zypp-dist-upgrade-cache/*
# See https://github.com/sailfishos/udisks2/commit/bcc6437ff35a3cc1e8c4777ee80d85a9c112e63e#diff-be2415d9a1095d0aa0d9dc7977c388a7ab5bb3ff7b3e4c38713062bd03165cee
primuser="$(loginctl list-sessions | fgrep seat0 | tr -s ' ' | cut -d ' ' -f 4)"
# Paths for SailfishOS ≥ 2.2.1 rsp. SailfishOS < 2.2.1, see chapter "Final clean up" at https://docs.sailfishos.org/Support/Help_Articles/Updating_Sailfish_OS/#final-clean-up
rm -f "/home/${primuser}/.cache/sailfish-osupdateservice/os-info" "/home/${primuser}/.cache/store-client/os-info"

if command -v zypper > /dev/null 2>&1
then
# No need to be "brutal":
# printf '%s\n' "- Cleaning zypper's caches:"
# zypper clean -m || exit $?
printf '%s\n' "- Refreshing zypper's caches:"
zypper refresh || exit $?
printf '\n'
# Syncing, as I could not determine if zypper already does that:
sync
printf '%s\n' "- Checking for updates by zypper:"
# As of SailfishOS 4.1.0, `version --dup` does not seem to always update all packages, any more:
zypper update -y -l
printf '\n'
fi

# This may have become superfluous with SFOS 3.2.0, see
# https://together.jolla.com/question/214572/changelog-320-torronsuo/#214572-packagekit
# Would need to investigate, but refreshing twice will do no harm, anyway.
printf '%s\n' "- Refreshing pkcon's caches:"
pkcon refresh || exit $?
# Syncing, as I could not determine if pkcon already does that:
sync
printf '%s\n' "- Checking for updates by pkcon:"
# As of SailfishOS 4.1.0, `version --dup` does not seem to always update all packages, any more:
pkcon -y update

Loading