RPM- How to create


 * Install rpm-build on centos 7
 * Create folder RPMBUILD
 * mkdir -p SPECS
 * vim my-first-rpm.spec

Name:           my-first-rpm

Version:        5.0

Release:        1%{?dist}

Summary:        This is my first ever RPM

Vendor:         Kamil Pietras

Group:          Documentation

License:        GPLv2

%description

This is my first RPM package. I can describe it more thorougly here. It is normal to format these sections as 80 columns wide, so that it can easily be read on any screen

%clean

echo " Not cleaning up in this case"

%pre

echo "In the %pre preinstall script now($1)"

/usr/bin/useradd -c "Apache" -u 48 -s /sbin/nologin -r -d /usr/share/httpd apache 2> /dev/null || true

%post

echo "In the %post postinstall script now($1)   "


 * 1) /sbin/chkconfig --add httpd

%preun

echo "In the %preun pre-unistall script now($1) "


 * 1) /sbin/service httpd stop


 * 1) /sbin/chkconfig -del httpd

%postun

echo "In the %postun post-uninstall script now ($1)"

if [ $1 -eq 0 ]; then


 * 1) /usr/sbin/update-alternatives -- remove antlr /usr/bin/antlr-java

fi

%files

%defattr(0755,root,root)

/usr/bin/my-first-program

%attr(0644,root,root) %config  /etc/my-first-program.conf

%doc %name-%version/README

%doc %name-%version/COPYING

%doc %name-%version/LICENSE

%changelog

Fri Mar 25 2016 Kamil Pietras

- Bug fixes and improvments

Tue Mar 24 2016 Kamil Pietras

- Initial release.


 * mkdir -p BUILD/my-first-rpm-5.0 and copy LICENSE, COPYING AND README
 * mkdir -p BUILDROOT/my-first-rpm-5.0-1.el7.centos.x86_64/
 * and copy files with all path, like in spec file - /usr/bin/my-first-program etc.
 * rpmbuild -bb my-first-rpm-5.0-1.spec