linuxcentosrpmrpmbuildrpm-spec

"/var/tmp/rpm-tmp.6K3TRj: line 33: $'\r': command not found" Can't get past this error when building my RPM


I'm trying to build my first RPM, and I keep getting this error:

/var/tmp/rpm-tmp.6K3TRj: line 33: $'\r': command not found error: Bad exit status from /var/tmp/rpm-tmp.6K3TRj (%prep)

I have seen a few people ask about this error, but I cant find a solution that I haven't already tried.

My spec file looks like this:

Name:           test
Version:        0.0.2
Release:        1%{?dist}
Summary:        test
BuildArch:      noarch

License:        GPL
Source0:        %{name}-%{version}.tar.gz


Requires:       bash


%description
test

%prep
%setup -q


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
cp %{name}.sh $RPM_BUILD_ROOT/%{_bindir}

%clean
rm -rf $RPM_BUILD_ROOT

%files

%{_bindir}/%{name}.sh

I get this error after running the command

rpmbuild -bb ~/rpmbuild/SPECS/test.spec

I'm really new to this, so if anyone could help figure out what I need to change to get this to run, I'd be so grateful.

the complete output I get is:

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.6K3TRj
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf api-controller-0.0.2
+ /usr/bin/tar -xf /root/rpmbuild/SOURCES/test-0.0.2.tar.gz
+ cd test-0.0.2
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ $'\r'
/var/tmp/rpm-tmp.6K3TRj: line 33: $'\r': command not found
error: Bad exit status from /var/tmp/rpm-tmp.6K3TRj (%prep)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.6K3TRj (%prep)

Solution

  • Any time you see random \r complaints in Linux/Unix, it means you have a Windows-formatted file. Run dos2unix on your specfile.

    See Wikipedia.