Closed phillxnet closed 1 year ago
@FroggyFlox The changelog rewrite here is a little odd as I'm not sure why it has been included. But it looks like a switch-out and back-in of the exact same entries. Proceeding with testing this looks to at least add the required proposed fix.
I just noticed that rewrite... Is that the leading hyphens, or is it part of the diff? Sorry I can't see for sure on my phone... 🫤
Is that the leading hyphens,
No idea: only done what I usually do with no change at all, plus done twice with deletes of all in-between and still same result: I'll go with it as looks harmless enought. I've made not changes here and Pycharm does not show these changes to have taken place!! I think it may be an origin thing of sorts.
With the proposed changes we end up not actually executing our .venv wipe!
buildvm:/opt/rockstor # rpm -qi --scripts rockstor
Name : rockstor
Version : 5.0.0
Release : 30
Architecture: x86_64
Install Date: Mon 24 Jul 2023 16:13:05 WEST
Group : Productivity/Networking/File-Sharing
Size : 10055056
License : GPL-3.0-or-later AND (MIT AND Apache-2.0 AND GPL-3.0-or-later AND LGPL-3.0-or-later AND ISC)
Signature : RSA/SHA256, Mon 24 Jul 2023 15:19:46 WEST, Key ID 1c4262f25f043187
Source RPM : rockstor-5.0.0-30.src.rpm
Build Date : Mon 24 Jul 2023 15:19:38 WEST
Build Host : rleap15-4.lan
Relocations : /opt
Packager : https://www.suse.com/
Vendor : YewTreeApps
URL : https://rockstor.com/
Summary : Btrfs Network Attached Storage (NAS) Appliance.
Description :
Software raid, snapshot capable NAS solution with built-in file integrity protection.
Allows for file sharing between network attached devices.
Distribution: (none)
preinstall scriptlet (using /bin/sh):
# Before install/update
# $1 == 1 is before an install
# $1 == 2 is before an update
#
# Before we install, remove non-packaged rockstor legacy/development files:
rm --force /etc/systemd/system/rockstor*
systemctl daemon-reload
# remove legacy bin develop-eggs & eggs directories
rm --force /opt/rockstor/bin
rm --force /opt/rockstor/develop-eggs
rm --force /opt/rockstor/eggs
# https://en.opensuse.org/openSUSE:Systemd_packaging_guidelines#Unit_files
# See: /usr/lib/rpm/macros.d/macros.systemd from systemd-rpm-macros
# rpm --eval macro-name-here
if [ -x /usr/bin/systemctl ]; then
test -n "$FIRST_ARG" || FIRST_ARG="$1"
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || :
for service in rockstor-pre.service rockstor.service rockstor-bootstrap.service ; do
sysv_service=${service%.*}
if [ ! -e /usr/lib/systemd/system/$service ] &&
[ ! -e /etc/init.d/$sysv_service ]; then
mkdir -p /run/systemd/rpm/needs-preset
touch /run/systemd/rpm/needs-preset/$service
elif [ -e /etc/init.d/$sysv_service ] &&
[ ! -e /var/lib/systemd/migrated/$sysv_service ]; then
/usr/sbin/systemd-sysv-convert --save $sysv_service || :
mkdir -p /run/systemd/rpm/needs-sysv-convert
touch /run/systemd/rpm/needs-sysv-convert/$service
fi
done
fi
exit 0
postinstall scriptlet (using /bin/sh):
# After install/update
# $1 == 1 is after an install
# $1 == 2 is after an update
#
if [ "$1" = "2" ]; then # update
# Remove jslibs dir so build.sh (posttrans) will refresh from new rpm rockstor-jslibs.tar.gz
rm -rf /opt/rockstor/jslibs
# Remove collectstatic generated static dir as build.sh (posttrans) will regenerate.
rm -rf /opt/rockstor/static
fi
if [ -x /usr/bin/systemctl ]; then
test -n "$FIRST_ARG" || FIRST_ARG="$1"
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || :
if [ "$YAST_IS_RUNNING" != "instsys" ]; then
/usr/bin/systemctl daemon-reload || :
fi
for service in rockstor-pre.service rockstor.service rockstor-bootstrap.service ; do
sysv_service=${service%.*}
if [ -e /run/systemd/rpm/needs-preset/$service ]; then
/usr/bin/systemctl preset $service || :
rm "/run/systemd/rpm/needs-preset/$service" || :
elif [ -e /run/systemd/rpm/needs-sysv-convert/$service ]; then
/usr/sbin/systemd-sysv-convert --apply $sysv_service || :
rm "/run/systemd/rpm/needs-sysv-convert/$service" || :
touch /var/lib/systemd/migrated/$sysv_service || :
fi
done
fi
exit 0
preuninstall scriptlet (using /bin/sh):
# Before uninstall/update
# $1 == 0 is before an uninstall
# $1 == 1 is before an update
#
test -n "$FIRST_ARG" || FIRST_ARG="$1"
if [ "$FIRST_ARG" -eq 0 -a -x /usr/bin/systemctl ]; then
# Package removal, not upgrade
/usr/bin/systemctl --no-reload disable rockstor-pre.service rockstor.service rockstor-bootstrap.service || :
(
test "$YAST_IS_RUNNING" = instsys && exit 0
test -f /etc/sysconfig/services -a \
-z "$DISABLE_STOP_ON_REMOVAL" && . /etc/sysconfig/services
test "$DISABLE_STOP_ON_REMOVAL" = yes -o \
"$DISABLE_STOP_ON_REMOVAL" = 1 && exit 0
/usr/bin/systemctl stop rockstor-pre.service rockstor.service rockstor-bootstrap.service
) || :
fi
#
if [ "$1" = "1" ]; then # update
# Remove our prior versions .venv.
rm -rf /opt/rockstor/.venv
fi
exit 0
postuninstall scriptlet (using /bin/sh):
#After uninstall/update
# $1 == 0 is after an uninstall
# $1 == 1 is after an update
#
# During package update, % service_del_postun restarts units.
# If units are not to be restarted, % service_del_postun_without_restart should be used instead.
if [ $1 -eq 0 ]; then
# Package removal
for service in rockstor-pre.service rockstor.service rockstor-bootstrap.service ; do
sysv_service="${service%.*}"
rm -f "/var/lib/systemd/migrated/$sysv_service" || :
done
fi
if [ -x /usr/bin/systemctl ]; then
/usr/bin/systemctl daemon-reload || :
fi
# We need to restart the nginx service as we removed our nginx override file.
if [ "$1" = "0" ]; then # uninstall so clean up build.sh generated files and other dynamic files.
systemctl restart nginx
# Remove jslibs directory from rockstor-jslibs.tar.gz
rm -rf /opt/rockstor/jslibs
# remove collectstatic generated static dir
rm -rf /opt/rockstor/static
# remove Poetry installed .venv directory.
rm -rf /opt/rockstor/.venv
# remove poetry-install.txt
rm -rf /opt/rockstor/poetry-install.txt
# remove all pyc files (Python interpreter generated)
find /opt/rockstor/src -name '*.pyc' -delete
# remove all empty directories
find /opt/rockstor/src -type d -empty -delete
# remove Huey db file:
rm /opt/rockstor/rockstor-tasks-huey.db
# remove top level directory but only if empty
rmdir /opt/rockstor
fi
exit 0
posttrans scriptlet (using /bin/sh):
# From: https://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets
# the posttrans scriptlet is available form rpm version 4.4 onwards.
#
# Last scriptlet to execute from old or new package versions.
# Executed from new package version during install & upgrade similarly.
#
# Run build.sh
# 1. Install poerty to system.
# 2. Use it to populate/refresh .venv.
# 3. if no jslibs dir exists:
# un-tar rockstor-jslibs.tar.gz
# 4. Regenerate static dir via collectstatic.
#
# We have a minimal path available so add system poetry explicitly.
PATH="$HOME/.local/bin:$PATH"
export LANG=C.UTF-8
cd /opt/rockstor
./build.sh
exit 0
It was initially suspected that install / update is derived from the command, not the implied update of an install applied to a system that already has an earlier package installed, such as we invoke via the Web-UI update.
But neither 'zypper in', nor 'zypper up' resulting in the new scriptlet being executed.
Trialing 'other' personality of this script.
rpm -qi --scripts rockstor
Name : rockstor
Version : 5.0.0
Release : 30
Architecture: x86_64
Install Date: Mon 24 Jul 2023 17:22:30 WEST
Group : Productivity/Networking/File-Sharing
Size : 10054998
License : GPL-3.0-or-later AND (MIT AND Apache-2.0 AND GPL-3.0-or-later AND LGPL-3.0-or-later AND ISC)
Signature : RSA/SHA256, Mon 24 Jul 2023 17:02:51 WEST, Key ID 1c4262f25f043187
Source RPM : rockstor-5.0.0-30.src.rpm
Build Date : Mon 24 Jul 2023 17:02:43 WEST
...
#
if [ "$1" = "0" ]; then # update
# Remove our prior versions .venv.
rm -rf /opt/rockstor/.venv
fi
exit 0
and still no removal of prior .venv !!
The reason neither version of %preun was effective was down to that script being run from the package being removed. We need a fix to be effective from the version we install, i.e. with a pending update - not from one already installed.
Using the %post script should enable us to deliver the fix in the update being installed. As that scriptlet is run from the new package. Not from the scriptlet of the package being uninstalled.
OK, so %post looks to work for our requried delivering. From a testing 4.6.1-0 install we have a Web-UI update with the following results:
buildvm:/opt/rockstor # poetry env info
Virtualenv
Python: 3.6.15
Implementation: CPython
Path: /opt/rockstor/.venv
Valid: True
System
Platform: linux
OS: posix
Python: /usr
buildvm:/opt/rockstor # less poetry-install.txt
buildvm:/opt/rockstor # cat poetry-install.txt
Creating virtualenv rockstor in /opt/rockstor/.venv
Installing dependencies from lock file
Package operations: 30 installs, 0 updates, 0 removals
• Installing certifi (2023.5.7)
• Installing charset-normalizer (2.0.12)
• Installing greenlet (2.0.2)
• Installing idna (3.4)
• Installing pytz (2023.3)
• Installing six (1.16.0)
• Installing urllib3 (1.26.16)
• Installing zope.event (4.6)
• Installing zope.interface (5.5.2)
• Installing django (1.11.29)
• Installing gevent (22.10.2)
• Installing oauthlib (3.1.0)
• Installing python-engineio (2.3.2)
• Installing requests (2.27.1)
• Installing dbus-python (1.2.18)
• Installing distro (1.8.0)
• Installing django-oauth-toolkit (1.1.2)
• Installing django-pipeline (1.6.9)
• Installing djangorestframework (3.9.3)
• Installing django-braces (1.13.0)
• Installing gevent-websocket (0.10.1)
• Installing gunicorn (19.10.0)
• Installing huey (2.3.0)
• Installing psutil (5.9.4)
• Installing psycogreen (1.0)
• Installing psycopg2 (2.8.6)
• Installing python-socketio (1.6.0)
• Installing pyzmq (19.0.2)
• Installing supervisor (4.2.4)
• Installing urlobject (2.1.1)
Installing the current project: rockstor (5.0.0)
Closing pr as draft work-in-progress/dev to re-present as single commit commit and updated intro text.
Use %preun scriptlet, during update, to remove the prior versions .venv. Brute force approach for now.