Newbie rpmbuild error - rpmbuild

I'm trying to build my first RPM, but getting an error. My .rpmmarcos files looks like this:
%packager Your Name
%_topdir /home/snort/test
%_tmppath /home/snort/test/tmp
%_smp_mflags -j3
%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
When I run: "rpmbuild -v -bb SPECS/test.spec" I receive this error:
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd test-1
/home/snort/test/tmp/rpm-tmp.55712: line 36: cd: test-1: No such file or directory
error: Bad exit status from /home/snort/test/tmp/rpm-tmp.55712 (%prep)
File rpm-tmp.55712 ends with this:
cd '/home/snort/test/BUILD'
rm -rf 'test-1'
/bin/gzip -dc '/home/snort/test/SOURCES/test-1.c55.tar.gz' | tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
cd 'test-1'
I'm guessing rpmbuild does the "rm -rf 'test-1'" to remove any old/un-needed directories, then it untar's the test-1.c55.tar.gz file, then tries to "cd test-1" but the untar command doesn't make the directory so the scripts errors out. I'm not sure what to do now.
My spec file: more SPECS/test.spec
Name: test
Version: 1
Release: .c55
Summary: Just a Test
Group: MyJunk
License: GPL
URL: http://www.somesite.com
Source0: test-1.c55.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
This is just a test
<br>
%prep
%setup BUILD
%build<br>
%configure<br>
make %{?_smp_mflags}<br>
%install<br>
rm -rf $RPM_BUILD_ROOT<br>
make install DESTDIR=$RPM_BUILD_ROOT
<br>
%clean<br>
rm -rf $RPM_BUILD_ROOT<br>
%files
%defattr(-,root,root,-)
%doc
%changelog
Any ideas?
Thanks for the Help
Gary

RPM (or, to be exact, %setup macro) expects your source tarbal test-1.c55.... to contain the directory test-1.
If the directory there is different, you can fix that by using
%setup -n yourdir
See http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html for more details.

Related

RPM .spec with bash must changed but not know what wrong

Pls answer me and hope my question not so stupid but i first time put inside rpm bash skrip. May someone can sent link or tip what i must coorrect in my .spec
This rpm pakage must make just two thing - copy in linux folder /bin/ one file(inet.dbg) and next when cp make must start bash skrip for check library for this file.
This my bash skript
#!/bin/bash
ldd inet.dbg > t.t
ERR=`grep -i "not" t.t | wc -l`
if [[ $ERR -gt 0 ]]; then
grep -i "not" t.t > erg.e
echo "Die folgenden Bibliotheken wurden nicht gefunden:"
cat erg.e
rm t.t erg.e
else
ls -a ss.tar &> t.t
if [[ $? -eq 0 ]]; then
echo alles ok
else
echo no
fi
fi '
This .spec
# %_topdir and %_tmppath are defined in ~/.rpmmacros
%define name inetdbg
%define version 0.1
%define release 1
%define buildroot %{_tmppath}/%{name}-%{version}-%{release}
%define tarfile %{tarversion}.tar
%define installscript /home/adis/rpmbuild/SOURCES/skript.sh
Name: %{name}
Version: %{version}
Release: %{release}
BuildArch: noarch
Summary: adisc
License: -
Source1: %{installscript}
Source2: /home/adis/rpmbuild/SOURCES/inetdbg.tar.xz
BuildRoot: %{_builddir}/%{name}-root
%description
Tested RPM
%prep
%build
%install
mkdir -p %{buildroot}%{_bindir}
install -D -pm 755 %{SOURCE2} %{buildroot}/bin/inetdbg.tar.xz
cp -a %{installscript} %{buildroot}%{_bindir}/
chmod a+x %{buildroot}%{_bindir}/%{installscript}
%files
%{_bindir}/%{installscript}
%{SOURCE2}
%post
%{_bindir}%{installscript}
%clean
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
%changelog
* 25 Jan 2023 <user>
- Add script.sh
- Add definit

How to skip elf checks when packing AppImage?

I have an AppImage file and want to package it in an rpm package.
Here is my .spec file:
%prep
%clean
rm -rf $RPM_BUILD_ROOT
%install
mkdir -p $RPM_BUILD_ROOT/opt/Movavi/
cp ~/RPM/SOURCES/MyProduct.AppImage $RPM_BUILD_ROOT/opt/MyCompany/
%files
# %doc
/opt/MyCompany/MyProduct.AppImage
When i call rpmbuild -ba ~/RPM/SPECS/MyProduct.spec it throws an error on ELF validation step
Whole output:
Executing(%prep): /bin/sh -e /tmp/rpm-tmp.71228
+ umask 022
+ /bin/mkdir -p /home/user/RPM/BUILD
+ cd /home/user/RPM/BUILD
+ exit 0
Executing(%install): /bin/sh -e /tmp/rpm-tmp.95497
+ umask 022
+ /bin/mkdir -p /home/user/RPM/BUILD
+ cd /home/user/RPM/BUILD
+ /bin/chmod -Rf u+rwX -- /tmp/MyProduct-buildroot
+ /bin/rm -rf -- /tmp/MyProduct-buildroot
+ mkdir -p /tmp/MyProduct-buildroot/opt/MyCompany/
+ cp /home/user/RPM/SOURCES/MyProduct.AppImage /tmp/MyProduct-buildroot/opt/MyCompany/
+ /usr/lib/rpm/brp-alt
Cleaning files in /tmp/MyProduct-buildroot (auto)
Verifying and fixing files in /tmp/MyProduct-buildroot (binconfig,pkgconfig,libtool,desktop)
Checking contents of files in /tmp/MyProduct-buildroot/ (default)
Compressing files in /tmp/MyProduct-buildroot (auto)
056-debuginfo.brp: WARNING: You have 1 stripped ELF objects. Please compile with debugging information!
056-debuginfo.brp: WARNING: An excerpt from the list of affected files follows:
./opt/MyCompany/MyProduct.AppImage
Verifying ELF objects in /tmp/MyProduct-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal)
unsupported ABI version e_ident[8] == 65
e_ident[9] is not zero
e_ident[10] is not zero
verify-elf: WARNING: ./opt/MyCompany/MyProduct.AppImage: eu-elflint failed
ldd: ERROR: ./opt/MyCompany/MyProduct.AppImage: failed to find the program interpreter
verify-elf: ERROR: ./opt/MyCompany/MyProduct.AppImage: ldd failed
error: Bad exit status from /tmp/rpm-tmp.95497 (%install)
RPM build errors:
Bad exit status from /tmp/rpm-tmp.95497 (%install)
Fixed the problem adding %set_verify_elf_method skip at the bottom of the spec file

rpmbuild %install section removes buildroot code. How do I keep rpmbuild from doing this

I am creating a new rpm for a rails app. However the default behavior of the %install section removes the BUILDROOT directory. I assumed that the %install section would install the files from buildroot. I must be doing something wrong because the buildroot is getting removed in the %install section. What is the proper way to do this?
This is the spec file
Summary: Rails APP API (replaces railsapp rpm)
Name: railsapp-api
Version: 6.0.0
Release: 1
License: GPL
URL: http://www.both.org
Group: System
Packager: Tommie Jones
Requires: bash
BuildRoot: ~/rpmbuild/
%description
A rewrite of railsapp from the HTML version to a Http API version
%prep
echo "BUILDROOT = $RPM_BUILD_ROOT"
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/veex/railsapp
unzip /home/realworx/rpmbuild/SOURCES/rwx-master.zip -d $RPM_BUILD_ROOT/usr/local/veex/
pushd $RPM_BUILD_ROOT/usr/local/veex/
rm -rf railsapp
mv rwx-master railsapp
pushd $RPM_BUILD_ROOT/usr/local/veex/railsapp
rm Gemfile.lock
bundle install
PWD=`pwd`
cat > gemrc <<EOGEMRC
gemhome: $PWD/vendor/bundle/ruby/1.8
gempath:
- $PWD/vendor/bundle/ruby/1.8
EOGEMRC
gem --config-file ./gemrc install bundler
# Don't need the gemrc any more...
rm ./gemrc
%files
%attr(0744, root, root) /usr/local/veex/railsapp/*
%install
echo %{buildroot}
echo "HELLO"
%clean
echo NOOP
Below is the log where the %install removes the buildroot.
(%install): /bin/sh -e /var/tmp/rpm-tmp.aX3U0b
+ umask 022
+ cd /home/railsapp-api/rpmbuild/BUILD
+ '[' /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch '!=' / ']'
+ rm -rf /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
++ dirname /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ mkdir -p /home/railsapp-api/rpmbuild/BUILDROOT
+ mkdir /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ echo /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
/home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ echo HELLO
HELLO
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-ldconfig
/sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip /usr/bin/strip
+ /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile 1
+ /usr/lib/rpm/brp-python-hardlink
+ PYTHON3=/usr/libexec/platform-python
+ /usr/lib/rpm/redhat/brp-mangle-shebangs
Processing files: railsapp-api-6.0.0-1.noarch
error: File not found: /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch/usr/local/veex/railsapp/*
How do I keep %install from removing my buildroot?
you are misusing the %prep section. In very short how you should use those sections:
%prep: to extract your sources, apply patches etc.
%build: to compile or build your application (if you need to)
%install: to copy the files into $RPM_BUILD_ROOT
So it is logical that $RPM_BUILD_ROOT is emptied at the start of the %isntall section.
Change your code to extract your zip file in %prep, and use the %install section to put the files inside $RPM_BUILD_ROOT.

Using rpmbuild when source tar directory doesn't correspond to name-version

I'm trying to build an rpm from source-1.4.3-linux.tgz (that is downloaded so I don't control the name) and the file untars into the directory source-1.4.3-linux. In my source.spec file, I have
Name: source
Version: 1.4.3
So it is probably quite logical that I am getting an error:
cd: source-1.4.3: No such file or directory.
I tried tacking -linux onto the version, but rpmbuild wants only a number there. What do I have to do to tell rpmbuild that the source files are untarred into source-1.4.3-linux?
Just use the setup macro.
setup -n %{name}-%{version}.linux
Here is a simple.spec file that would help you understand the issue. Source tarball contains the following:
$ tar tzf simple-0.tar.gz
simple-0/
simple-0/simple.txt
Spec file:
Summary: Simple SPEC
Name: simple
Version: 0
Release: 1
License: NONE
Group: NONE
URL: NONE
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
" This is Simple "
%prep
%setup -q
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/tmp/
install -m 0644 simple.txt %{buildroot}/tmp/simple.txt
%clean
rm -rf $RPM_BUILD_ROOT
%post
echo "In the Post section of Simple"
%files
%defattr(-,root,root,-)
%doc
/tmp/simple.txt
%changelog
* Wed Sep 12 2018 <iamauser#localdomain> -
- Initial build.
ok I got this working. Maybe a hack but it is working. As per the question my tarball is unconventionally named.
$ tar tzf source-1.4.3-linux-amd64.tar.gz
source-1.4.3-linux-amd64/
source-1.4.3-linux-amd64/simple.txt
in the specfile %prep section instead of using %setup or %autosetup, I unpacked manually and renamed the untarred directory.
Name: source
Version: 1.4.3
Release: 0
Source0: https://example.com/%{name}-%{version}-linux-amd64.tar.bz2
%prep
rm -fr %{name}-%{version}
tar -xjf %{SOURCE0}
mv %{name}-%{version}-linux-amd64 %{name}-%{version}

How to write a spec file not to run ./configure in CentOS7

I have written spec file just copy some files to some directory on CentOS7.
...(snip)...
%prep
%setup -q
%build
%install
install -m 644 -p $RPM_SOURCE_DIR/some/file \
$RPM_BUILD_ROOT%{_sysconfdir}/file
%clean
rm -rf $RPM_BUILD_ROOT
%files
%doc
%config(noreplace) %{_sysconfdir}/some/file
--------
$ cd rpmbuild
$ rpmbuild SPECS/my.spec
...(snip)...
+ ./configure --build=x86_64 ...
/var/tmp/rpm-tmp.RidAmi: line41: ./configure: No such file or directory
I have not written ./configure ... anywhere.
I don't know why rpmbuild fails.
I found an answer here.
Looks like deleting %build line.
https://www.centos.org/forums/viewtopic.php?t=51254

Resources