0

I have a .spec file to install a rpm. I have the following snippet in post install (%post scriplet)

%post -n %{package_name}
# Enable the service at boot time
%if %{?suse_version:1}0
  /usr/lib/lsb/install_initd %{_initrddir}/%{package_name}
%else
  chkconfig --add %{package_name}
%endi

During zypper install package_name it fails at the post installation phase with the following error:

/var/tmp/rpm-tmp.Z5R29N: line 2: /usr/lib/1sb/install _initd: No such file or directory
warning: %post (package_name.sles15.x86_64) scriptlet failed, exit status 127

I am a novice in .spec files for rpm but this scriplet failed because /usr/lib/lsb/ directory doesn't exists in SLES 15 SP4

My Questions are:

  1. What is this scriplet exactly doing?
  2. Where to get this /lsb/ package from so that I can create this path in SLES 15 SP4? I check that SLES 15 SP4 pre-installed with lsb-xxx package but they are not working here ?
  3. Do I need to do case checks here for sles 15 SP4 inside this scriplet? like:
%if 0%{?sle_version} == 150400 && 0%{?is_opensuse}
// do somthing
%endif

1 Answer 1

1

That spec is extremely outdated

What is this scriplet exactly doing?

What that snippet does is to install scripts to init.d, which are used by sysv-init, to start services at boot

Since SLE 12, SUSE (and most other distros have switched too) has been using systemd, rendering init.d totally obsolete and warranting a switch to a service

Where to get this /lsb/ package from so that I can create this path in SLES 15 SP4? I check that SLES 15 SP4 pre-installed with lsb-xxx package but they are not working here ?

You can't, there are only a very limited support for those means of starting and managing services nowadays, one of those is systemd-sysv-generator, this is a solution, but I'd go for a native systemd solution if that's an important piece of software.

But the snippet, as it is, will never work on SLES 15, it will need to be completely rewritten as chkconfig will not also not work

Do I need to do case checks here for sles 15 SP4 inside this scriplet? like:

If you still support SLE < 12, and need to keep the older way to do it, yes you can do that


What you need to do, if you want to make it native :

  • Find what script it is trying to install
  • Using that script as a reference, build a Systemd service unit file
  • If you have the source, and you can modify it, add it to the source. If you don't have a modifiable source, you'll need to patch it in at buildtime.
  • Remove that snippet and follow that guide (from openSUSE but will work just fine on SLE) to build it into your code

%if 0%{?sle_version} == 150400 && 0%{?is_opensuse}

FYI, this is a conditional that will only match openSUSE Leap 15.4, and not SLE 15.4, this is not an issue as Leap and SLE are the same thing but can be surprising

1
  • Thanks for the elaborate response. I really appreciate it. Commented Jan 18, 2023 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .