I am trying to create an RPM file for the wget utility. Both of my attempts (with sudo and without sudo) to use the rpmbuild comman fail to create an .rpm file.

I run a "sudo rpmbuild" command to use a spec file. But I get these errors:

error: File not found: /root/rpmbuild/BUILDROOT/wget-1.19-1.x86_64/usr/local/bin/wget error: File not found: /root/rpmbuild/BUILDROOT/wget-1.19-1.x86_64/usr/local/share/man/man1/wget.1

If I manually create the directory paths and manually copy the files, I run into other problems down the road. I think something is wrong if the rpmbuild command expects key files to be in the locations above.

I read it was recommended to not use sudo. When I do not use sudo, the rpmbuild command (rpmbuild -v -bb --clean SPECS/wget.spec) shows this:

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.NiuIFV + umask 022 + cd /home/ec2-user/mywget/BUILD + cd /home/ec2-user/mywget/BUILD + rm -rf wget-1.19 rm: cannot remove 'wget-1.19/po/[email protected]': Permission denied rm: cannot remove 'wget-1.19/po/zh_CN.po': Permission denied rm: cannot remove 'wget-1.19/po/id.gmo': Permission denied rm: cannot remove 'wget-1.19/po/gl.gmo': Permission denied ...

I see other "rm cannot remove ... Permission denied" lines. I expected the rpmbuild command to work. I have changed the permissions of the wget-1.19 folder to be 777 (via sudo chmod) with the owner and group being identical to the user running the rpmbuild command. I still had the problem.

What can I do to create an RPM package of the wget utility?

# This is a sample spec file for wget

%define _topdir     /home/ec2-user/mywget
%define name            wget 
%define release     1
%define version     1.19
%define buildroot %{_topdir}/%{name}-%{version}-root

BuildRoot:  %{buildroot}
Summary:        GNU wget
License:        GPL
Name:           %{name}
Version:        %{version}
Release:        %{release}
Source:         %{name}-%{version}.tar.gz
Prefix:         /usr
Group:          Development/Tools

The GNU wget program downloads files from the Internet using the command-line.

%setup -q


make install prefix=$RPM_BUILD_ROOT/usr


%doc %attr(0444,root,root) /usr/local/share/man/man1/wget.1

The above was modified but heavily based on the spec file example here: https://www.ibm.com/developerworks/library/l-rpm1/index.html

  • hard to say without seeing the contents of your wget.spec where did that file come from and how did you modify it?
    – thrig
    Commented Nov 29, 2017 at 2:00
  • As an aside, the reason you should never run rpmbuild as root / with sudo: If you do that, and the package goes rogue and installs something into /usr/ instead of $HOME/rpmbuild/BUILDROOT/$PKG/usr/ during the build, it'll succeed. Then not only do you have a rogue file on your system, completely outside of rpm's control, but that file also won't be included in the actual RPM.
    – FeRD
    Commented Jan 25 at 22:02
  • (Quite a few Autotools and CMake projects accidentally go rogue on certain files, because they query pkg-config or Python sysconfig for the install destination and get an absolute path back. There's no chroot when running the %install step in rpmbuild, it relies on packages respecting build parameters like PREFIX and DESTDIR to redirect install locations.)
    – FeRD
    Commented Jan 25 at 22:05

1 Answer 1


This error:

error: File not found: /root/rpmbuild/BUILDROOT/wget-1.19-1.x86_64/usr/local/bin/wget

means that you specified this file in %files section:


so rpmbuild is expecting this file in $RPM_BUILD_ROOT/usr/local/bin/wget path but it is not there. Therefore this error. Vice versa for the man page.

You can run rpmbuild -bi which will stop just after %install phase and you can check the content of /root/rpmbuild/BUILDROOT/wget-1.19-1.x86_64/ where the make install actually put the files.

I guess that either

make install prefix=$RPM_BUILD_ROOT/usr/local


%doc %attr(0444,root,root) /usr/share/man/man1/wget.1

will fix your error. (just one of those!)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .