How to make a RPM package

 











How to make a RPM package

RPM is a versatile Linux packaging originally meant for Red Hat Linux (now RHEL) but now ported to Fedora Linux, Clear linux, and many more distro's. In my opinion, it is more cleaner and refined than the .deb format, DPKG, and APT, (used by Debian Linux and it's derivatives.) 

NOTE: The package was made on a CentOS 7 Virtual machine and was tested on a Fedora Linux 33 virtual machine. 

Step one, dependencies:

yum install rpm-build rpm-devel rpmlint make diffutils patch rpmdevtools

Step two, setup build directory

mkdir $HOME/rpmmaker

Step three, create a specifications file:

Name:       test
Version:    1
Release:    1
Summary:    a test RPM package
License:    None

%description
This is my first RPM package, which does nothing.

%prep
# We have nothing to prepare.

%build
cat > hello-world <<EOF
#!/bin/sh
echo Hello world
EOF

%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world %{buildroot}/usr/bin/hello-world

%files
/usr/bin/hello-world

%changelog
#This is version 1.0!

Save it as helloworld.spec in the rpmmaker directory

Step four, make the rpm:

cd $HOME/rpmmaker
rpmdev-setuptree
rpmbuild -ba helloworld.spec

The directory /home/YourName/rpmbuild/RPMS/x86_64/ should hold your RPM file.

Step 5, testing the file:

cd into the directory where the rpm is

sudo rpm -i filename.rpm
hello-world

If it says "Hello World!" then the file works.
The RPM is now ready to be shared.




Comments

Popular Posts