--- rpms/nextcloud/contribs9/nextcloud.spec 2019/01/08 02:49:07 1.8 +++ rpms/nextcloud/contribs9/nextcloud.spec 2019/01/08 03:56:26 1.9 @@ -74,20 +74,62 @@ then installedver=`php -r 'require("/usr/share/nextcloud/version.php"); print "$OC_VersionString";'`; majvers=`echo %{version} | cut -d. -f1` majcurvers=`echo $installedver | cut -d. -f1` - echo "and the version is $installedver" # we should fail with exit 1 if # installed version > rpm version - if ( verlte $installedver %{version} ) + if ( verlte %{version} $installedver ) then - echo "Installed version has been upgraded and is most recent than this rpm" + echo "Installed version has $installedver been upgraded and is most recent than this rpm %{version} version" +# echo "backup current install to /usr/share/nextcloud_back" +# mkdir /usr/share/nextcloud_back +# rsync -ar /usr/share/nextcloud/ /usr/share/nextcloud_back exit 1 - elif [ $(($majvers-1)) > $majcurvers  ] + elif [ $(($majvers-1)) -gt $majcurvers ] then # installed version < rpm version -1 - echo "can not upgrade from $installedver to %{version}, please do a manual update with intermediate version" + echo "can not upgrade from $installedver to %{version}, please do a manual or web update with intermediate version" +# echo "backup current install to /usr/share/nextcloud_back" +# mkdir /usr/share/nextcloud_back +# rsync -ar /usr/share/nextcloud/ /usr/share/nextcloud_back exit 1 fi fi +%postun +# true if $1 is greater than or equal $2 +verlte() { + [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] +} + +verlt() { + [ "$1" = "$2" ] && return 1 || verlte $1 $2 +} + +if [ $1 == 1 ]]; then +# if there is already an installed version +if [ -f /usr/share/nextcloud/version.php ] +then +# echo "version.php found, already installed" + # get version number + installedver=`php -r 'require("/usr/share/nextcloud/version.php"); print "$OC_VersionString";'`; + majvers=`echo %{version} | cut -d. -f1` + majcurvers=`echo $installedver | cut -d. -f1` +# echo "and the version is $installedver" + # we should fail with exit 1 if + # installed version > rpm version + if ( verlte %{version} $installedver ) + then +# echo "reverting content" +# rsync -ar /usr/share/nextcloud_back/ /usr/share/nextcloud_back +# rm -rf /usr/share/nextcloud_back + exit 0 + elif [ $(($majvers-1)) -gt $majcurvers ] + then # installed version < rpm version -1 +# echo "reverting content" +# rsync -ar /usr/share/nextcloud_back/ /usr/share/nextcloud_back +# rm -rf /usr/share/nextcloud_back + exit 0 + fi +fi +fi %install rm -rf %{buildroot}