Create a Fedora RPM Package (Hello World)

This is the Fedora/RPM equivalent of a minimal Debian package tutorial. You will build a real .rpm that installs one script.

1) Install RPM build tools

sudo dnf install -y rpm-build rpmdevtools
rpmdev-setuptree

This creates ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}.

2) Create the app source

mkdir -p ~/hello-rpm-1.0.0
cat > ~/hello-rpm-1.0.0/hello-rpm << 'EOF'
#!/bin/sh
echo "Hello from my Fedora RPM package"
EOF
chmod 755 ~/hello-rpm-1.0.0/hello-rpm

Create source tarball:

tar -czf ~/rpmbuild/SOURCES/hello-rpm-1.0.0.tar.gz -C ~ hello-rpm-1.0.0

3) Create spec file

Create ~/rpmbuild/SPECS/hello-rpm.spec:

Name:           hello-rpm
Version:        1.0.0
Release:        1%{?dist}
Summary:        Minimal hello world RPM example
License:        MIT
BuildArch:      noarch
Source0:        %{name}-%{version}.tar.gz

%description
Minimal hello world script packaged as an RPM.

%prep
%autosetup

%build
# Nothing to build

%install
mkdir -p %{buildroot}/usr/local/bin
install -m 0755 hello-rpm %{buildroot}/usr/local/bin/hello-rpm

%files
/usr/local/bin/hello-rpm

%changelog
* Thu Jul 23 2026 Your Name <you@example.com> - 1.0.0-1
- Initial package

4) Build the RPM

rpmbuild -ba ~/rpmbuild/SPECS/hello-rpm.spec

Output package is usually in:

~/rpmbuild/RPMS/noarch/hello-rpm-1.0.0-1.fc*.noarch.rpm

5) Install and test

sudo dnf install -y ~/rpmbuild/RPMS/noarch/hello-rpm-1.0.0-1*.noarch.rpm
hello-rpm

Expected output:

Hello from my Fedora RPM package

6) Remove package

sudo dnf remove -y hello-rpm

Quick notes

  • Bump Version and/or Release for every update.
  • Inspect contents with rpm -qlp package.rpm.
  • Check metadata with rpm -qip package.rpm.