Skip to content

Commit

Permalink
develmaster: Commits for v3.9.12 (#75)
Browse files Browse the repository at this point in the history
* Update post_sfos-upgrade

* Update README.md

* Update README.md

* Add missing quoting, twice

* Insert missing `-n` option for `echo`, twice

* More specific test for "outdated stop releases list"

* Clarify comment

* Enhance comment

* Use `df` POSIXly / in a portable manner … (#74)

… which works for both, GNU's `df` (part of gnu-coreutils package) and busybox's df (activated by the busybox-symlink-df package), plus presumably other POSIX compatible 'df' implementations.
Fixes #73

* Fix two typos in recently created comment

* Fix copy'o

* Remove concluding `&& true`s after `if` statements

* Post release version increase
  • Loading branch information
Olf0 authored Dec 6, 2022
2 parents 4ce148c + 24e6345 commit 13403c3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Usage (as root user):
Emits a brief usage description.

When an upgrade succeeded, reboot, and do not miss to run **post_sfos-upgrade** (as root) then!<br />
Not running it will result in an huge upgrade log file (containing many duplicate entries), plus may result (as any SailfishOS upgrade at the command line without tidying efforts afterwards) in RPMs failing to install (with "unmet dependency" / "Fatal error: nothing provides X needed by Y" errors) and annoying notifications from the store-client that an upgrade to the installed version is available.
When **sfos-upgrade** failed, run **post_sfos-upgrade** immediately (as root), reboot and try running **sfos-upgrade** again.<br />
Not running **post_sfos-upgrade** will result in an huge upgrade log file (containing many duplicate entries), plus may result (as any SailfishOS upgrade at the command line without tidying efforts afterwards) in RPMs failing to install (with "unmet dependency" / "Fatal error: nothing provides X needed by Y" errors) and annoying notifications from the store-client that an upgrade to the installed version is available.

Logs are originally written to `/var/log/systemupdate_*.log-dupes.txt` and tidied by **tidy_log-dupes** (which is called by **post_sfos-upgrade**) to `/var/log/systemupdate_*.log.txt`.<br />
<br />
Expand All @@ -55,4 +56,4 @@ Simply run `sfos-upgrade <intended version>`, reboot, and repeat: it will guide
When upgrading to SailfishOS releases < 4.1.0, you may omit running `post_sfos-upgrade` between consecutive SailfishOS upgrades (but do reboot each time!). But you shall run it after having upgraded to any SailfishOS release ≥ 4.1.0 or the ultimately intended version.
* To ensure that a SailfishOS installation is complete and up to date, use `sfos-upgrade --verify`; this will "samegrade" to the installed version, which is as close as one can get to the `version --verify` lost [since SailfishOS 2.2.1](https://together.jolla.com/question/187243/changelog-221-nurmonjoki/#187243-sailfish-version) (which only checked for missing or not up-to-date RPMs, while "samegrading" will also install them) without **zypper**. With it (per `pkcon install zypper`), a `zypper refresh && zypper verify --dry-run` comes closer to what `version --verify` did (only checking). While **zypper** can also be used for up-/down-/same-grading, that is [rather a "last resort"-measure than the primary recommendation](https://together.jolla.com/question/117335/verify-integrity-of-installed-packages-after-upgrade-or-later/?answer=214905#post-id-214905), hence use **sfos-upgrade** for that.
* **sfos-upgrade** supports [all public SailfishOS releases](https://coderus.openrepos.net/whitesoft/sailversion) and should work fine for upgrading from / to any release (it accepts only version numbers of at least 1.0.0.0 at the command line, but omits this check when called without a parameter after utilising **ssu** to pre-set a version to upgrade to).
* **sfos-upgrade** is simply a frontend for `ssu re` and `version --dup`, performing a multitude of checks before initiating the upgrade proper, while **post_sfos-upgrade** carries out the "Final clean up" steps from [Jolla's guide](https://jolla.zendesk.com/hc/en-us/articles/360005795474) and an also necessary `pkcon refresh`, which some seem to omit when upgrading manually at the command line (often running into aforementioned issues later, then).
* **sfos-upgrade** is simply a frontend for `ssu re` and `version --dup`, performing a multitude of checks before initiating the upgrade proper, while **post_sfos-upgrade** carries out the "Final clean up" steps from [Jolla's manual upgrade guide](https://jolla.zendesk.com/hc/en-us/articles/360005795474) plus an also necessary `pkcon refresh`, which some seem to omit when upgrading manually at the command line (often running into aforementioned issues later, then).
4 changes: 2 additions & 2 deletions rpm/sfos-upgrade.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Summary: Scripts for fail-safe upgrading of SailfishOS at the command line
# is comprised of {alpha,beta,rc,release} postfixed with a natural number
# greater or equal to 1 (e.g. "beta3"). For details and reasons, see
# https://github.com/Olf0/sfos-upgrade/wiki/Git-tag-format
Version: 3.9.11
Release: release4
Version: 3.9.12
Release: release5
Group: Applications/System
Distribution: SailfishOS
License: LGPL-2.1-only
Expand Down
3 changes: 3 additions & 0 deletions usr/bin/post_sfos-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ then
done
echo
fi
# See troubleshooting section "a) Cleaning up" at https://jolla.zendesk.com/hc/en-us/articles/360005795474
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 "4. Final clean up" at https://jolla.zendesk.com/hc/en-us/articles/360005795474
rm -f "/home/${primuser}/.cache/sailfish-osupdateservice/os-info" "/home/${primuser}/.cache/store-client/os-info"

if command -v zypper > /dev/null 2>&1
Expand Down
40 changes: 24 additions & 16 deletions usr/bin/sfos-upgrade
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/bin/bash
set -euC # Omitting -f (aka -o noglob), because bash 3.2.57(1)-release does not perform a set +f (or +o noglob; plus setopt is not built-in) correctly, which would be needed later!
export POSIXLY_CORRECT=1
export LC_ALL=POSIX # For details see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_02
export POSIXLY_CORRECT=1 # Also necessary for a sane `df` output, see https://github.com/Olf0/sfos-upgrade/issues/73
export BLOCKSIZE=512 # For `df` et al, see POSIX's `df` man-page and man-page for GNU `df`
export BLOCK_SIZE=512 # For `df` et al, see man-page for GNU `df`
export DF_BLOCK_SIZE=512 # For `df` et al, see mmn-page for GNU `df`

# Switched to use bash since version 2.1 of this script (in its first line), as this ensures that "-o pipefail"
# (in line 644) is available, after checking that bash seems to be present in mer-core at least since 2011-10-04
# (in line 648) is available, after checking that bash seems to be present in mer-core at least since 2011-10-04
# (see https://git.sailfishos.org/mer-core/bash / https://git.merproject.org/mer-core/bash ) and consequently in
# SailfishOS since its beginnings (checked v1.0.0.5 per
# curl https://releases.sailfishos.org/sources/sailfish-1.0.0.5-oss.tar.bz2 | tar -tv | fgrep 'bash' , as no earlier
# released version is available there, e.g. the first ones at https://coderus.openrepos.net/whitesoft/sailversion ).
# In SailfishOS releases before 4.0, /bin/sh is just a symbolic link to /bin/bash anyway; though I have not checked
# that for ancient releases (which might be re-deployed after a "factory reset"), likely SailfishOS inherited that
# from Fedora, via MeeGo and Mer (MeeGo reconstructed), too (i.e., in addition to the presence of bash by default).
# Since SailfishOS 4.0, the busybox variant of ash has become the shell installed by default, which provides some
# bash compatibility when called via its bash-symlink (which is deployed by the busybox-symlinks-bash RPM),
# Since SailfishOS 4.0, the busybox variant of ash has become the shell installed by default, which provides some bash
# compatibility (implicitly, when called via its bash-symlink, which is deployed by the busybox-symlinks-bash RPM),
# including "-o pipefail" (hurray!). But not "-o posix" (which was used to ensure shell behaviour as defined
# by POSIX up to sfos-upgrade 3.8.1), which hopefully causes no difference in the behaviour of bash-3.2, bash-5 and
# a 2020s busybox-ash (because any one of these may be installed). BTW, setting POSIXLY_CORRECT achives the same
# without compatibility issues and (when exported) also for a number of other GNU utilities.
# a 2020s busybox-ash (because any one of these may be installed). BTW, 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.

# Exit codes:
Expand All @@ -34,6 +37,8 @@ export LC_ALL=POSIX # For details see https://pubs.opengroup.org/onlinepubs/969
# 42 "Should never be reached" *) case #3


# Functions: askyes & compare_versions

askyes ()
{
# All its regular output goes to STDOUT (only warnings go to STDERR)
Expand Down Expand Up @@ -95,6 +100,7 @@ compare_versions ()
return "$retc"
}


# Main script

called="$(basename "$0")"
Expand Down Expand Up @@ -177,7 +183,7 @@ fi
if sailversion_sfos_releases="$(curl -sSk https://coderus.openrepos.net/whitesoft/sailversion | cut -f 1 -d ' ' | grep '^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$')"
then sailversion_fail="n"
fi
if [ "$sailfishdocs_fail" = "y" ] && [ "$sailversion_fail" = "y" ] && true
if [ "$sailfishdocs_fail" = "y" ] && [ "$sailversion_fail" = "y" ]
then
echo "Notice: Failed to retrieve a list of recent SailfishOS releases, hence might be unable to check the validity of version number \"${upgrade_release}\"." >&2
echo >&2
Expand All @@ -202,10 +208,10 @@ else
# But 2.0.5.6 seems to be a "stop release", at least on some devices, see comments thread to
# https://together.jolla.com/question/207172/downgrade-sailfish-os/?answer=207190#post-id-207190
sailfishdocs_stop_releases="$(echo "$sailfishdocs_sfos_list" | fgrep -i 'stoprelease' | cut -s -d '|' -f 1 | grep '^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$')"
if [ -z "$sailfishdocs_stop_releases" ]
if [ -z "$sailfishdocs_stop_releases" ] && echo "$mylist_sfos_releases" | grep -qvF "$upgrade_version"
then
echo "Warning: Failed to extract the current \"stop releases\" from https://github.com/sailfishos/docs.sailfishos.org/tree/master/Support/Releases#readme" >&2
echo "Hence using an internal, potentially outdated list of stop releases instead." >&2
echo "Hence using an internal, likely outdated list of stop releases instead." >&2
if [ -z "$set_ssu" ]
then echo -n "Do you want to continue?" >&2
else echo -n "Do you really want to continue?" >&2
Expand Down Expand Up @@ -400,7 +406,9 @@ then
exit 5
fi
else
free_space="$(df -k / | sed -n '2p' | rev | grep '^/ ' | tr -s ' ' | cut -s -f 3 -d ' ' | rev)"
# Formula "(<df in 0.5 K blocks> + 1) / 2" is slightly off for negative values (which `df` may really emit): It would then have to be
# "(<df in 0.5 K blocks> - 1) / 2" instead, but the deviation is negligible: 1 KByte too much free space indicated for negative values.
free_space="$(expr \( "$(df -P / | sed -n '2p' | rev | grep '^/ ' | tr -s ' ' | cut -s -f 3 -d ' ' | rev)" '+' 1 \) '/' 2)"
# Note that in contrast to upgrading at the GUI, the RPMs for upgrading are not all downloaded first (and installed after booting into the system-update mode),
# but downloaded and installed one by one, hence requiring much less space on persistent storage (i.e., the root filesystem) for upgrading.
# OTOH, be aware that the download sizes Jolla mentions in their release notes are only valid for upgrading from the direct predecessor release,
Expand Down Expand Up @@ -444,7 +452,7 @@ for battery_uevents in $battery_path
do
# Workaround for Gemini's kernel broken battery information, which contains spaces: Use eval & sed instead of source / ".".
# For details, see https://github.com/Olf0/sfos-upgrade/issues/39
if [ "$battery_uevents" != "$battery_path" ] && [ -s "${battery_uevents}/uevent" ] && eval "$(tr '"' "'" < "${battery_uevents}/uevent" | sed 's/\([]_[:alnum:]]=\)\(.*\)/\1"\2"/')" > /dev/null 2>&1 && true
if [ "$battery_uevents" != "$battery_path" ] && [ -s "${battery_uevents}/uevent" ] && eval "$(tr '"' "'" < "${battery_uevents}/uevent" | sed 's/\([]_[:alnum:]]=\)\(.*\)/\1"\2"/')" > /dev/null 2>&1
then
battery_info="sourced"
break
Expand Down Expand Up @@ -538,14 +546,14 @@ Charging-*-[0-9]*|Full-*-[0-9]*)
;;
?*-*-*)
echo "Warning: Failed to determine battery charge!" >&2
echo "Check your device before " >&2
echo -n "Check your device before " >&2
if [ -z "$set_ssu" ]
then battery_check="ask"
fi
;;
*-*-*)
echo "Warning: Failed to determine battery charging state!" >&2
echo "Check your device before " >&2
echo -n "Check your device before " >&2
if [ -z "$set_ssu" ]
then battery_check="ask"
fi
Expand Down Expand Up @@ -592,19 +600,19 @@ g?)
g4)
echo "Notice: About to DOWNGRADE SailfishOS from $installed_release to ${upgrade_release}, which just carries a smaller \"point release\" number." >&2
echo "Nevertheless this may make this SailfishOS installation not working properly." >&2
echo "Note that the "official" (i.e. approved by Jolla) way to achieve this is to execute a \"factory reset\", followed by UPgrading to the intended version." >&2
echo "Note that the \"official\" (i.e. approved by Jolla) way to achieve this is to execute a \"factory reset\", followed by UPgrading to the intended version." >&2
echo "Though you can try downgrading and if it fails or breaks some functionality, perform a \"factory reset\" then (in the worst case at the recovery console)." >&2
echo -n "Do you want to do that?" >&2
;;
g4?*)
echo "Warning: About to DOWNGRADE SailfishOS from $installed_release to ${upgrade_release}, which just carries a smaller \"point release\" number." >&2
echo "Nevertheless this may make this SailfishOS installation not working properly." >&2
echo "Note that the "official" (i.e. approved by Jolla) way to achieve this is to execute a \"factory reset\", followed by UPgrading to the intended version." >&2
echo "Note that the \"official\" (i.e. approved by Jolla) way to achieve this is to execute a \"factory reset\", followed by UPgrading to the intended version." >&2
echo "Though you may try downgrading and if it fails or breaks some functionality, perform a \"factory reset\" then (in the worst case at the recovery console)." >&2
echo -n "Do you really want to do that?" >&2
;;
g?)
echo "Warning: About to DOWNGRADE SailfishOS from $installed_release to ${upgrade_release}, which differ in at least their \"second minor\" version (i.e., their third field)." >&2
echo "Warning: About to DOWNGRADE SailfishOS from $installed_release to ${upgrade_release}, which differ in at least their \"micro\" version (i.e., their third field)." >&2
echo "This might make this SailfishOS installation not working properly!" >&2
echo "Note that the proper way to achieve this is to execute a \"factory reset\", followed by UPgrading to the intended version." >&2
echo "Although you may try downgrading and if it fails or breaks some functionality, perform a \"factory reset\" then (in the worst case at the recovery console)." >&2
Expand Down

0 comments on commit 13403c3

Please sign in to comment.