2

I built for the first time a RPM package. This RPM is a packaged front-end app, and the install only needs to move the app files and do a nginx restart. This is my spec file:

Name:           my-portal-app

Version:        2.1

Release:        1%{?dist}

Summary:        Descripcion

License:        No-license

URL:            nourl

Source0:        my-portal-app-2.1.tar.gz

%description
My app install

%prep
%setup -q


%build
#%configure
#make %{?_smp_mflags}

%install
#rm -rf $RPM_BUILD_ROOT
cp -r ./* /var/www/myapp
service nginx restart

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc

%changelog

All it's ok when i run rpmbuild -ba, exit 0, and the %install sequence is computed (copy files and restart nginx). Ok, rpmbuild generates the RPM (in rpmbuild/RPMS) and the SRPM in (rpmbuild/SRPMS).

But, if i understand well, when i install my SRPM with rpm -ivh name.rpm the %install sequence must be executed, am i right? If i am, sequence is not being executed (not copy files to /var/www/myapp and not restarting nginx). Executing the RPM the same.

The contain of the SRPM is correct, all files are in. And the RPM is empty.

2

As you said, %install section is for configure initial RPM build sentences you will need to set up.

To accomplish your goal you must use %post section, in that, you can define the execution of your own .sh (for example) or you can set one by one the sentences that you need, for example:

sudo service restart nginx

For the issue of the empty RPM, it's because %files section did not properly filled, the binaries moved to RPM are related with the content of that section (%files)

1

Ok, I was wrong... as this doc says:

The %install section is not run when the binary RPM package is installed by the end-user, but is only run when creating a package.

  • The correct section to accomplish my goal is %post – Kalamarico Aug 30 '17 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.