Fedora

git clone https://src.fedoraproject.org/rpms/...
 
sudo dnf install fedpkg
sudo usermod -a -G mock <current user> # use admin user only
 
# Pick mock config
ls /etc/mock
 
# Build packages for Fedora 39 (AArch64)
# Avoid `build` which requests build on Fedora's Koji server.
fedpkg mockbuild --root fedora-39-aarch64

Generic

sudo dnf install rpmdevtools
rpmdev-setuptree
 
cd ~/rpmbuild/SPECS
vim pkg.spec # and save
 
# Prepare build dependencies and sources
sudo dnf builddep pkg.spec
spectool -gR pkg.spec
 
# Build the package
rpmbuild -bb pkg.spec
 
cd ~/rpmbuild/RPMS/<arch> # replace <arch> with the corresponding architecture
sudo dnf install ./pkg-xxx.rpm