1

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)
J-D
  • 13
  • 5

1 Answers1

0

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.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
  • This may be a silly question, but where in my spec file do I place it? I am using Docker to install and build out my environment, so I added the install of dos2unix there but then what do I add to my spec file? Should I, and COULD I just place it under my %install in my spec file and have it apply to all files? Example: dos2unix * – J-D Jan 05 '23 at 21:53
  • Run `dos2unix` _on_ the specfile itself; not adding it _to_ it. – Aaron D. Marasco Jan 06 '23 at 20:17