Rpm spec copy post install

I’ve done this before. Successfully. And I can’t find where.

%if 0%{?sailfishos_version} > 40200
  cp %{buildroot}%{_datadir}/%{name}/qml/pages/WebView2.qml %{_datadir}/qml/pages/WebView.qml

Or should it be in # >> install post?

# >> install post
%if "%{sailfishos_version}" < "40000"
        cp %{buildroot}%{_datadir}/%{name}/qml/pages/FirstPage_3.qml \
           %{buildroot}%{_datadir}/%{name}/qml/pages/FirstPage.qml \

I think the last one if from @nephros

I’m trying to get old Webkit views ‘back’ for 3.4.x.x

Is the sailfishos_version macro even defned at package install time? If not you can’t use it in %post.

%install should work though.

%post I’ve used in one case for changing some values in a src file, but not depending on a conditional.

I’ll try it after the desktop-file-install in the %install section. Thanks!

Damn. This doesn’t work. Nor does it work with variations in %post. How in the hell did I do this before:
EDIT: WHERE did I do this. Too many repos. To many commits.

rm -rf %{buildroot}
# >> install pre
# << install pre

# >> install post
# << install post

%if "%{sailfishos_version}" > "40200"
        cp %{buildroot}%{_datadir}/%{name}/qml/pages/WebViewPage_4.qml \

Are you using a yaml&spec combination? If yes you need to put the custom stuff between the markers or the next specify run will remove it!

Now I’ve never used the SDK but is it possible that it will invoke spectacle if it sees a .yaml?

Also, not sure about quoting the ‘40200’ value makes a difference for the comparison.

Afaik %{sailfishos_version} is only available on OBS and you have to hack it yourself elsewhere, at least I did for quazip on 4.5. But you can always use rpm --eval to test macros and there is also an option to get the demacroed spec but I forgot its name.

Just .spec

Now that you mention, it was on OBS that I was using it (3.4 vs. 4.x python PIL) and have since abandoned it. Hmmm. I’ll see if I can come up with a clean method. Maybe read /etc/sailfish-release in %post

I would implement it in app, but it’s a problem that also applies to code that I’m helping package but don’t maintain.


Here’s what I did to support OBS not having /etc/os-release: harbour-contrac/harbour-contrac.spec at 4f594df60413c78b4a17dd0060ef827f614d5fda · llewelld/harbour-contrac · GitHub

Cool! I just started with but

export `grep VERSION_ID /etc/sailfish-release | sed -e 's/\.//g'`

Which gets me:


Thanks for the tips!

1 Like

Just be aware that OBS numbers work like I re-implemented it, they only use the major & minor numbers and replace . with 0.

Ah, so I’ll need two macros then. Or check vendor, then define? EDIT, ummm. You need this at BUILD time. What I’m doing supplies < 4.2 qml version and just swaps it post install so it should work since it’s only required on install?

This works from SDK or rpm/pkcon

# >> macros
%define sfos_version  `grep VERSION_ID /etc/sailfish-release | cut -d'=' -f2 | cut -d'.' -f1-2 | sed -e 's/\.//g'`
# << macros
# << files
%if "%{?sfos_version}" > "42"
        cp %{_datadir}/%{name}/qml/pages/WebViewPage_4.qml %{_datadir}/%{name}/qml/pages/WebViewPage.qml

I’ve named it differently just to avoid conflicts with other macros.

EDIT: This works for installs from 3.4 to 4.5 …

@slava it just occured to me that doing all this for the apps I want to support might be silly and it better to use your compat library?

I prefer doing it at run time e.g. like this or this. Both pieces of code use HarbourSystemInfo for OS/package version detection. That way rpm may remain Harbour compliant (rpm scripts are not allowed in Jolla Store).

1 Like

And another thing - if you have an rpm script that creates files during installation (not owned by any package) you better think how and when you’re going to delete those. My qrshare plugin was doing this, for example.

These days I think that perhaps it might be a better idea to install a dummy file and overwrite it during (after) the installation - that way it would remain owned by the package.

Of course it would be even better if the OS maintained compatibility between the releases, but that’s apparently is not an option😐

1 Like

In the case this began with, I simply supply both files. I’m just copying one over the other. For most of these WebViews, there’s not much content. I’m thinking of adding a SilicaWebView compatibility view. But I have to go through all the source I’ve already made backward incompatible (maybe 6/7 apps). I had looked at your library long ago and just got distracted by other tasks. Maybe I can take this as an opportunity to finally go there.

I would also have thought that maintaining SilicaWebView as a wrapper on WebView wouldn’t have been such a big deal. Ah, well.