sudo dnf install rpm-build rpmdevtools
cd to a directory within your home folder e.g.:
cd ~/packages
and then run 'rpmdev-setuptree':
rpmdev-setuptree
The above will generate the folder tree structure for our rpm creation.
Proceed by checking the .rpmmacros file is correct:
cat ~/.rpmmacros
*Note* The "_topdir" variable in the '.rpmmacros' file defines the root path - e.g. if you wanted to deploy the nano utility we might put it in $_topdir/usr/bin.
We should bundle our sources up:
tar czvf myscript_0.1.tar.gz myscript/
and place it in the 'SOURCES' folder:
mv myscript_0.1.tar.gz /home/limited/packages/myscript/SOURCES
We should now create our 'spec' file - which contains the meet of the configuration, defining dependencies, build instructions and so on:
vi ~/packages/myscript/SPECS/myscript.spec
An example .spec file is as follows:
Name: pywinusb
Version: 1
Release: 0
Summary: Allows you to install Windows on a USB drive.
Source0: pywinusb_0.1.tar.gz
License: GPL
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-buildroot
%description
Allows you to install Windows on a USB drive.
%prep
%setup -q
%build
%install
mkdir -p $RPM_BUILD_ROOT/usr/share/pywinusb/bin
install -m 0755 pywinusb.py $RPM_BUILD_ROOT/usr/share/pywinusb/bin/pywinusb
%clean
rm -rf $RPM_BUILD_ROOT
%post
ln -sf /usr/share/pywinusb/bin/pywinusb /usr/bin/pywinusb
echo pywinusb has been installed successfully!
%files
%dir /usr/share/pywinusb/bin
/usr/share/pywinusb/bin/pywinusb
Finally we can build the rpm with:
cd ~/rpmbuild
rpmbuild -ba SPECS/myscript.spec
No comments:
Post a Comment