This post is more than 4 years old. If this is a technical post, the post will most likely not working, but feel free to try it and see if it works.
TL;DR
This post goes over the creation of a rpm package containing only executives using the only the built-in commands and rpmbuild to build packages. I created this article since I have read several articles like this and this trying to simplify the process of packaging, but as I created my own script to create debian package, this inspired me to create one using this. The script posted belongs to my project wslu.
cat <<EOF >> ~/rpm_wslu/SPECS/wslu-$BUILD_VER.spec %define packager patrick330602 <wotingwu@live.com> %define _topdir $HOME/rpm_wslu %define _tmppath /var/tmp %define _rpmtopdir %{_topdir} %define _builddir %{_rpmtopdir}/BUILD %define _rpmdir %{_rpmtopdir}/RPMS %define _sourcedir %{_rpmtopdir}/SOURCES %define _specdir %{_rpmtopdir}/SPECS %define _srcrpmdir %{_rpmtopdir}/SRPMS Summary: Windows 10 Linux Subsystem Utilities Name: wslu Version: $BUILD_VER Release: 1 Source: wslu-$BUILD_VER.tar.gz Requires: bc lsb-release hostname wget unzip URL: https://github.com/patrick330602/wslu/ License: GPL %description This is a collection of utilities for Windows 10 Linux Subsystem, such as enabling sound in WSL or creating your favorite linux app shortcuts on Windows 10 Desktop. Requires Windows 10 Creators Update and higher. %prep %setup %build %install rm -rf \$RPM_BUILD_ROOT mkdir -p \${RPM_BUILD_ROOT}/usr/bin install -m 755 wsl* \${RPM_BUILD_ROOT}%{_bindir} %clean rm -rf \$RPM_BUILD_ROOT %files %defattr(-,root,root) %attr(755,root,root) %{_bindir}/wslu %attr(755,root,root) %{_bindir}/wslusc %attr(755,root,root) %{_bindir}/wslfetch %attr(755,root,root) %{_bindir}/wslpkg %attr(755,root,root) %{_bindir}/wslsys %attr(755,root,root) %{_bindir}/wslupath %changelog * Fri May 11 2018 patrick330602 <wotingwu@live.com> - First rpm build of wslu. EOF
This is actually a lot different from most of the .spec files online so be very careful in this part, as I combined several files into one.
This .spec file have two parts: definition and specification.
Definition is the %define part, as they are used for define the temp build folder location and the information of yours.
Specification is the real build part, and for this part I suggest you to read the Fedora Quick Docs. There is just one more thing to be specified: $ and \\$ is different. $ will pass the variable from the script to the .spec file, but if you want to use something like $RPM_BUILD_ROOT, please make sure you use \\$ instead.
Build and copy the rpm packages
1 2 3 4 5 6 7
cd ~/rpm_wslu/SPECS sudo rpmbuild -ba wslu-$BUILD_VER.spec
This is pretty obivious. you build and copy the rpm packages and copy them to the desired destination. Just one more thing to be noticed: there is two version of packages: binary packages under SRPMS and normal packages under RPMS.