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

[harbour-storeman.spec] Rework OBS repository handling, part 2: Improve #498

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
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
41 changes: 25 additions & 16 deletions rpm/harbour-storeman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -119,41 +119,50 @@ desktop-file-install --delete-original --dir=%{buildroot}%{_datadir}/application
# Mind to keep these two %%post scripltets synchronised!
# The %%post scriptlet is deliberately run when installing *and* updating:
ssu_ur=no
ssu_lr="$(ssu lr | grep '^ - ' | cut -f 3 -d ' ')"
if echo "$ssu_lr" | grep -Fq mentaljam-obs
if grep -q '^mentaljam-obs=' %{_sysconfdir}/ssu/ssu.ini
then
ssu rr mentaljam-obs
ssu_ur=yes
fi
# Add harbour-storeman-obs repository configuration, depending on the installed
# SailfishOS release (3.1.0 is the lowest supported, see line 35 ff.):
# SailfishOS release (3.1.0 is the lowest supported, see line 35 ff.).
# Set empty default value failing the following tests, because VERSION_ID
# should become overwritten by source'ing /etc/os-release:
VERSION_ID=''
source %{_sysconfdir}/os-release
sailfish_version="$(echo "$VERSION_ID" | cut -s -f 1-3 -d '.' | tr -d '.')"
# Must be an all numerical string of at least three digits:
if echo "$sailfish_version" | grep -q '^[0-9][0-9][0-9][0-9]*$'
# sailfish_version must be an all numerical string of at least three digits:
if ! echo "sailfish_version" | grep -q '^[0-9][0-9][0-9][0-9]*$'
then
if [ "$sailfish_version" -lt 460 ]
then ssu ar %{name}-obs 'https://repo.sailfishos.org/obs/home:/olf:/%{name}/%%(release)_%%(arch)/'
else ssu ar %{name}-obs 'https://repo.sailfishos.org/obs/home:/olf:/%{name}/%%(releaseMajorMinor)_%%(arch)/'
echo "Error: VERSION_ID=$VERSION_ID => sailfish_version=$sailfish_version" >&2
else
# Ensure that the repo config is correct: If it is missing or a fixed
# SFOS-release number was used, set it anew.
release_macro="$(grep '^harbour-storeman-obs=' %{_sysconfdir}/ssu/ssu.ini | grep -o '/[[:graph:]][[:graph:]][[:graph:]][[:graph:]]*/$' | grep -o '%%(release[[:alpha:]]*)')"
if [ $sailfish_version -ge 460 ] && [ "$release_macro" != '%%(releaseMajorMinor)' ]
then
ssu ar harbour-storeman-obs 'https://repo.sailfishos.org/obs/home:/olf:/harbour-storeman/%%(releaseMajorMinor)_%%(arch)/'
ssu_ur=yes
elif [ $sailfish_version -lt 460 ] && [ "$release_macro" != '%%(release)' ]
then
ssu ar harbour-storeman-obs 'https://repo.sailfishos.org/obs/home:/olf:/harbour-storeman/%%(release)_%%(arch)/'
ssu_ur=yes
fi
ssu_ur=yes
# Should be enhanced to proper debug output, also writing to systemd-journal:
else echo "Error: VERSION_ID=$VERSION_ID => sailfish_version=$sailfish_version" >&2
fi
if [ $ssu_ur = yes ]
then ssu ur
fi
# BTW, `ssu`, `rm -f`, `mkdir -p` etc. *always* return with "0" ("success"), hence
# no appended `|| true` needed to satisfy `set -e` for failing commands outside of
# flow control directives (if, while, until etc.). Furthermore on Fedora Docs it
# is indicated that solely the final exit status of a whole scriptlet is crucial:
# flow control directives (if, while, until etc.). Furthermore Fedora Docs etc.
# state that solely the final exit status of a whole scriptlet is crucial:
# See https://docs.pagure.org/packaging-guidelines/Packaging%3AScriptlets.html
# or https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax
# committed on 18 February 2019 by tibbs ( https://pagure.io/user/tibbs ) in
# https://pagure.io/packaging-committee/c/8d0cec97aedc9b34658d004e3a28123f36404324
# Hence I have the impression, that only the main section of a spec file is
# interpreted in a shell invoked with the option `-e', but not the scriptlets
# (`%%pre*`, `%%post*`, `%%trigger*` and `%%file*`).
# Hence only the main section of a spec file and likely also `%%(<shell-script>)`
# statements are executed in a shell invoked with the option `-e', but not the
# scriptlets: `%%pre*`, `%%post*`, `%%trigger*` and `%%file*`
exit 0

%postun
Expand Down
Loading