rpmbuild exiting with error: File not found - makefile

I'm trying to build my first RPM package and struggling with the rpmbuild process.
This is my environment I have to deal with:
cat /home/rpmadm/.rpmmacros
%_topdir /export/standardbuild
%_tmppath /export/standardbuild/tmp
%_sourcedir /export/standardbuild/SOURCES
%_rpmdir /export/standardbuild/RPMS
%_srcrpmdir /export/standardbuild/SRPMS
%_builddir /export/standardbuild/COMP_BUILDS/%{name}
My Makefile looks like this:
packagename = metricconf
%_sourcedir = /export/standardbuild/SOURCES
# version number of package: make sure you also update the version
# number in the spec file
version = 1.0
all:
#echo "usage: make dist | package"
install:
if [ ! -d $(DESTDIR)/tmp/$(packagename) ]; \
then \
mkdir -p $(DESTDIR)/tmp/$(packagename); \
fi
cp mb_system_betrieb.yml $(DESTDIR)/tmp/$(packagename)/mb_system_betrieb.yml
cp metricbeat $(DESTDIR)/tmp/$(packagename)/metricbeat
cp metricbeat.yml $(DESTDIR)/tmp/$(packagename)/metricbeat.yml
dist:
tar cvf $(packagename)-$(version).tar ../$(packagename)-$(version)
gzip $(packagename)-$(version).tar
cp $(packagename)-$(version).tar.gz $(%_sourcedir) && rm $(packagename)-$(version).tar.gz
package: rpm
rpm:
rpmbuild -ba $(packagename).spec
rm -rf $(packagename)-$(version).tar
And this is my .spec file:
Summary: configures Metricbeat for AIX
Name: metricconf
Version: 1.0
Release: 0
Vendor: Comp
Source: metricconf-1.0.tar.gz
BuildRoot: %{_builddir}/%{name}-{version}
Requires: metricbeat
%description
metricconf prepares AIX for metricbeat
%prep
%setup -c
%build
%install
%files
%defattr(644,root,system)
/tmp/metricbeat.yml
/tmp/mb_system_betrieb.yml
/tmp/metricbeat
make dist works well and the .tar.gz file will be created correctly.
But the make rpm command fails every time with following error:
make rpm
rpmbuild -ba metricconf.spec
Executing(%prep): /bin/sh -e /export/standardbuild/tmp/rpm-tmp.cIlqQa
+ umask 022
+ cd /export/standardbuild/COMP_BUILDS/metricconf
+ cd /export/standardbuild/COMP_BUILDS/metricconf
+ rm -rf metricconf-1.0
+ /usr/bin/mkdir -p metricconf-1.0
+ cd metricconf-1.0
+ /bin/gzip -dc /export/standardbuild/SOURCES/metricconf-1.0.tar.gz
+ /bin/tar -xvvof -
x ../COOPmetricbeat-1.0
x ../COOPmetricbeat-1.0/metricconf.spec, 2289 bytes, 5 tape blocks
x ../COOPmetricbeat-1.0/ChangeLog, 135 bytes, 1 tape blocks
x ../COOPmetricbeat-1.0/Makefile, 885 bytes, 2 tape blocks
x ../COOPmetricbeat-1.0/README, 74 bytes, 1 tape blocks
x ../COOPmetricbeat-1.0/mb_system_betrieb.yml, 1161 bytes, 3 tape blocks
x ../COOPmetricbeat-1.0/metricbeat, 1552 bytes, 4 tape blocks
x ../COOPmetricbeat-1.0/metricbeat.yml, 1240 bytes, 3 tape blocks
+ STATUS=0
+ [ 0 -ne 0 ]
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /export/standardbuild/tmp/rpm-tmp.dalqQb
+ umask 022
+ cd /export/standardbuild/COMP_BUILDS/metricconf
+ cd COOPmetricbeat-1.0
+ exit 0
Executing(%install): /bin/sh -e /export/standardbuild/tmp/rpm-tmp.delqQc
+ umask 022
+ cd /export/standardbuild/COMP_BUILDS/metricconf
+ cd metricconf-1.0
+ exit 0
Processing files: metricconf-1.0-0.ppc
error: File not found: /export/standardbuild/tmp/metricconf-1.0-0.ppc/tmp/metricbeat.yml
error: File not found: /export/standardbuild/tmp/metricconf-1.0-0.ppc/tmp/mb_system_betrieb.yml
error: File not found: /export/standardbuild/tmp/metricconf-1.0-0.ppc/tmp/metricbeat
RPM build errors:
File not found: /export/standardbuild/tmp/metricconf-1.0-0.ppc/tmp/metricbeat.yml
File not found: /export/standardbuild/tmp/metricconf-1.0-0.ppc/tmp/mb_system_betrieb.yml
File not found: /export/standardbuild/tmp/metricconf-1.0-0.ppc/tmp/metricbeat
make: 1254-004 The error code from the last command is 1.## Heading ##
Please, can anyone explain to me why rpmbuild is looking in "/export/standardbuild/tmp/metricconf-1.0-0.ppc" for the files and not in "/export/standardbuild/COMP_BUILDS/metricconf/metricconf-1.0" ???
I read a lot about building rpms especially at Fedora's doc pages, but it doesn't matter what I change in the Makefile or .spec file, the error remains.

Your %build and %install phases are both empty, so it's not doing anything. All you have is %prep which is untarring it into a temporary staging area.
Look around for examples, e.g. if you are using autoconf you probably want %configure.
ETA: It also looks like you are trying to put your final files into /tmp on the target machine, which won't work because they will disappear after a reboot. %files should list the files to be installed on the target without any leading temporary paths.

Related

How do configure my `travis.yaml` `jobs.include` and `before_install` to install stack for macOS?

Though I've implemented the steps described in the instructions
before_install:
# Download and unpack the stack executable
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
in my travis.yaml these fail when I attempt to build on macOS using
jobs:
include:
...
- name: "LTS 9.6 (Haskell for macOS)"
os: osx
osx_image: xcode10
env: ...
...
with
tar: Option --wildcards is not supported
Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help
curl: (23) Failed writing body (0 != 597)
The command "curl -L https://www.stackage.org/stack/linux-x86_64" failed. Retrying, 2 of 3.
curl: (23) Failed writing body (0 != 597)
The command "curl -L https://www.stackage.org/stack/linux-x86_64" failed. Retrying, 3 of 3.
curl: (23) Failed writing body (0 != 597)
The command "curl -L https://www.stackage.org/stack/linux-x86_64" failed 3 times.
How do I modify my travis.yaml jobs.include and before_install to install stack for macOS?
A couple of things.
I wouldn't use travis_retry here, since curl has the --retry flag that works better.
macOS uses BSD tar, not GNU tar. You can either:
Find a common flag that works on both
Install gnu-tar, and use that instead. (This formula requires more than just brew install gnu-tar, if you want to execute it as tar, so be sure to set it up correctly.)

During cppunit make install error for task install-m4DATA appeared

I've been building freedesktop cppunit with mingw
https://www.freedesktop.org/wiki/Software/cppunit/
I've made some fixes to source files and makefiles and been able to
successfully execute commmands:
./autogen.sh
./configure
make
without any errors.
There was a need to set
m4_DATA = m4
instead of value "cppunit.m4" in Makefile.am(there was no such dir in build and it looks like such dir is "m4" dir).
After successful make execution doing
make --debug install
failed with error:
File install-m4DATA not found
from Makefile.am:
m4dir = $(datadir)/aclocal //what is datadir btw?
automake generated Makefile task:
install-m4DATA: $(m4_DATA)
#$(NORMAL_INSTALL) // fails at this line
test -z "$(m4dir)" || $(MKDIR_P) "$(DESTDIR)$(m4dir)"
#list='$(m4_DATA)'; test -n "$(m4dir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(m4dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(m4dir)" || exit $$?; \
done
before that task NORMAL_INSTALL is set to:
NORMAL_INSTALL = :
How to fix "make install" execution.
Will it work if i have only mingw envieronment on my PC?
Version is 1.13.2 fresh from git repo.
I also post lines from "make --debug install" output
File 'install-m4DATA' does not exist.
Must remake target 'install-m4DATA'.
test -z "/usr/local/share/aclocal" || /usr/bin/mkdir -p "/usr/local/share/aclocal"
/usr/bin/install -c -m 644 ./m4 '/usr/local/share/aclocal'
Makefile:432: recipe for target 'install-m4DATA' failed
make[2]: Leaving directory 'c:/Users/user/projects/cppunit'
Makefile:799: recipe for target 'install-am' failed
make[1]: Leaving directory 'c:/Users/user/projects/cppunit'
Makefile:479: recipe for target 'install-recursive' failed
It also prints that that script omits directory at line
/usr/bin/install -c -m 644 ./m4 '/usr/local/share/aclocal'
Possibly here must go files from directory but not directory itself.
How to fix it to do that(i'm not familiar with Makefiles and bash)?

Getting libcrypto ar error while compiling OpenSSL for Mac

I have been able to compile a specific version of OpenSSL for iOS devices, and I am now trying to compile for Mac OSX. However, when I run my bash script (provided below) I am getting the following error:
ar r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
ar: ../../libcrypto.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: ../../libcrypto.a: Inappropriate file type or format
When I run lipo -info libcrypto.a I get the following result:
Architectures in the fat file: libcrypto.a are: i386 x86_64
This does not make any sense, as my bash script is only configuring OpenSSL for i386 (I was looping to do both, but removed x86_64 once I started getting these problems).
I have tried following the answers for similar SO questions here and here. However, those yielded the same results. Additionally, the Mac installation instructions on the OpenSSL Wiki were of no help either.
My scripts:
Build.sh
projectDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCHS=("i386")
FIPS_VERSION="2.0.12"
OPENSSL_VERSION="1.0.2g"
rm -rf openssl* fips*
if [ -d "out" ]; then
rm -rf out
fi
mkdir out
source ./Build-FIPS.sh
cd $projectDir
source ./Build-OpenSSL.sh
Build-OpenSSL.sh
set -e
function main() {
verifyopenssl
for ((i=0; i < ${#ARCHS[#]}; i++))
do
makeopenssl "${ARCHS[i]}"
done
}
function verifyopenssl() {
gpg --verify $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz.asc
tar -zxf $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz
cd openssl-$OPENSSL_VERSION
}
function makeopenssl() {
BUILD_ARCH=$1
SDK_NAME="macosx"
GCC=$(xcrun -sdk ${SDK_NAME} -find gcc)
SDK_PATH=$(xcrun -sdk ${SDK_NAME} --show-sdk-path)
MACHINE="darwin-i386-cc"
# BSD_ARCH="BSD-generic32"
CONFIG_ARGS="$MACHINE \
$BSD_ARCH \
--openssldir=$projectDir/out/openssl_${BUILD_ARCH} \
fips \
--with-fipsdir=${projectDir}/out/fips_${BUILD_ARCH} \
no-idea \
no-cast \
no-seed \
no-md2 \
no-sha0 \
no-whirlpool \
-DL_ENDIAN"
export CC="${GCC} -arch ${BUILD_ARCH}"
export CFLAGS="-isysroot ${SDK_PATH} -I ${projectDir}/out/fips_${BUILD_ARCH}/include"
export LDFLAGS="-arch $BUILD_ARCH"
./Configure ${CONFIG_ARGS}
make depend
make
# make install
# make clean && make dclean
}
main $#
Following #jww's answer, I found that changing the following line (around line 69) in the main Makefile (the one in the root folder) solved the ar linking problem that #jww mentioned:
AR= ar $(ARFLAGS) r to AR= libtool -o
Making this change did get me further along in the process. However, I began having other problems. Further "research" led me to the OpenSSL FAQ page which had a question talking about OpenSSL failing to build on Mac. It pointed me to the PROBLEMS file in the root directory of the OpenSSL source code. That file said that there is a MAC ld problem:
This is really a misfeature in ld, which seems to look for .dylib
libraries along the whole library path before it bothers looking for
.a libraries. This means that -L switches won't matter unless OpenSSL
is built with shared library support.
The workaround may be to change the following lines in apps/Makefile
and test/Makefile:
LIBCRYPTO=-L.. -lcrypto
LIBSSL=-L.. -lssl
to:
LIBCRYPTO=../libcrypto.a
LIBSSL=../libssl.a
With this information, I created a patch file for the root Makefile and the Makefile in the apps folder. I also found that I had to comment out the instructions in the main Makefile and the apps/Makefile to build the openssl binary / executable. This should only be necessary if you want to run make install.
The patch files exists at the same level as the Build.sh script. And after fiddling around with my Build-OpenSSL.sh script I was finally able to get it to build for both i386 and x86_64.
For future reference, I am including the complete contents of the two patch files, and the original two script files below.
Build.sh
#!/bin/bash
#
projectDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ARCHS=("i386" "x86_64")
FIPS_VERSION="2.0.12"
OPENSSL_VERSION="1.0.2g"
rm -rf openssl*
if [ -d "out" ]; then
rm -rf out
fi
mkdir out
source ./Build-FIPS.sh
source ./Build-OpenSSL.sh
Build-OpenSSL.sh
#!/bin/bash
#
set -e
function main() {
verifyopenssl
for ((i=0; i < ${#ARCHS[#]}; i++))
do
makeopenssl "${ARCHS[i]}"
done
}
function verifyopenssl() {
gpg --verify $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz.asc
tar -zxf $projectDir/../Source/openssl-$OPENSSL_VERSION.tar.gz
cd openssl-$OPENSSL_VERSION
}
function makeopenssl() {
BUILD_ARCH=$1
SDK_NAME="macosx"
GCC=$(xcrun -sdk ${SDK_NAME} -find gcc)
SDK_PATH=$(xcrun -sdk ${SDK_NAME} --show-sdk-path)
if [[ $BUILD_ARCH = "i386" ]]; then
MACHINE="darwin-i386-cc"
NISTP=""
elif [[ $BUILD_ARCH = "x86_64" ]]; then
MACHINE="darwin64-x86_64-cc"
NISTP="enable-ec_nistp_64_gcc_128"
else
exit
fi
CONFIG_ARGS="$MACHINE \
$NISTP \
--openssldir=$projectDir/out/openssl_${BUILD_ARCH} \
fips \
--with-fipsdir=${projectDir}/out/fips_${BUILD_ARCH} \
no-idea \
no-cast \
no-seed \
no-md2 \
no-sha0 \
no-whirlpool \
-DL_ENDIAN"
./Configure ${CONFIG_ARGS}
patch Makefile < ../MainMake.patch
patch apps/Makefile < ../AppMake.patch
make depend
make build_libcrypto build_libssl
make install_sw
make clean && make dclean
patch -R Makefile < ../MainMake.patch
patch -R apps/Makefile < ../AppMake.patch
}
main $#
AppMake.patch
--- apps/Makefile 2016-03-01 06:36:53.000000000 -0700
+++ ../Makefile 2016-05-06 13:00:16.000000000 -0600
## -26,8 +26,8 ##
DLIBCRYPTO=../libcrypto.a
DLIBSSL=../libssl.a
-LIBCRYPTO=-L.. -lcrypto
-LIBSSL=-L.. -lssl
+LIBCRYPTO=../libcrypto.a
+LIBSSL=../libssl.a
PROGRAM= openssl
## -101,24 +101,24 ##
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
install:
- #[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
- #set -e; for i in $(EXE); \
- do \
- (echo installing $$i; \
- cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
- chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
- mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
- done;
- #set -e; for i in $(SCRIPTS); \
- do \
- (echo installing $$i; \
- cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
- chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
- mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \
- done
- #cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
- chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
- mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
+ # #[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
+ # #set -e; for i in $(EXE); \
+ # do \
+ # (echo installing $$i; \
+ # cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
+ # chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
+ # mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
+ # done;
+ # #set -e; for i in $(SCRIPTS); \
+ # do \
+ # (echo installing $$i; \
+ # cp $$i $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
+ # chmod 755 $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new; \
+ # mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i.new $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$i ); \
+ # done
+ # #cp openssl.cnf $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
+ # chmod 644 $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new; \
+ # mv -f $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf.new $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf
tags:
ctags $(SRC)
MainMake.patch
--- Makefile 2016-05-06 13:06:11.000000000 -0600
+++ ../Makefile 2016-05-06 13:06:44.000000000 -0600
## -602,8 +602,8 ##
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
- cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
- chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
+ # cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
+ # chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
install_html_docs:
here="`pwd`"; \
ar r ../../libcrypto.a o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
ar: ../../libcrypto.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: ../../libcrypto.a: Inappropriate file type or format
ar, libtool and -arch is the reason the answer says "... supplying -arch x86_64 -arch i386 will result in a build failure because of the way OpenSSL's build system forms commands" at Build Multiarch OpenSSL on OS X.
You need to use Apple's libtool, and stop using ar. Apple's libtool knows about architectures, ar does not.
Another small wrinkle is the makefile does something like this, if I recall correctly. It makes it difficult to simply use Apple's libtool, and stop using ar:
$(AR) $(ARFLAGS) $# ...
In many makefiles you can simply make AR="libtool -o", but this case is different because the command comes out libtool -o r libcrypto.a or similar. I also seem to recall something like make AR="libtool" ARFLAGS="r -o $#" does not work well either.
I used to patch the makefile after config to do it.

How to run and interact with a script from within an RPM?

I'm building an RPM which needs to run a bash script as root.
The %install stanza of the spec file is:
%install
cp %{SOURCE1} %{SOURCE2} %{_tmppath}/%{name}-%{version}-%{release}
cd %{_tmppath}/%{name}-%{version}-%{release}
chmod u+x %{installscript}
sudo ./%{installscript}
Where %{installscript} is the script that runs as root with sudo.
rpmbuild executes %{installscript} and creates the RPM (without problems).
However, when I install the RPM:
$ sudo rpm -Uvh $rpmpath
Preparing... ########################################### [100%]
1:tty-cap ########################################### [100%]
$
The %{installscript} script is not executed.
I tried to change the spec file by moving the script invocation to a %post stanza:
%install
cp %{SOURCE1} %{SOURCE2} %{_tmppath}/%{name}-%{version}-%{release}
cd %{_tmppath}/%{name}-%{version}-%{release}
%post
chmod u+x %{installscript}
sudo ./%{installscript}
But the %post doesn't seem to do anything.
How can I pack an RPM that will execute a script when installed?
Edit 1:
After reviewing the helpful comments below, here's a spec file with a %post stanza that actually gets executed during the RPM installation.
However, the script %{installscript} does not interact with the user (as it does when run from the shell), but seems to accept all its defaults without user interaction.
What should I change so that the script will interact with the rpm command user?
$ cat ~/RPMBUILD/SPECS/demo.spec
#
# %_topdir and %_tmppath are defined in ~/.rpmmacros
%define name tty-cap
%define version 5.2
%define release 1
%define buildroot %{_tmppath}/%{name}-%{version}-%{release}
%define tarversion tty-5.2.0-00-70270
%define tarfile %{tarversion}.tar
%define installscript tty.install.sh
Name: %{name}
Version: %{version}
Release: %{release}
BuildArch: noarch
Summary: Bla
License: Proprietary
Source1: %{installscript}
Source2: tty-5.2.0-00-70270.tar
Prefix: /opt/Intellinx/TTYCapture
BuildRoot: %{_builddir}/%{name}-root
%description
Demonstration RPM
%prep
%build
%install
cp %{SOURCE1} %{SOURCE2} %{_tmppath}/%{name}-%{version}-%{release}
cd %{_tmppath}/%{name}-%{version}-%{release}
%clean
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
%post
echo ">>> Inside post <<<"
chmod u+x %{installscript}
./%{installscript}
%files
%define tmp /
%{tmp}/%{tarfile}
%{tmp}/%{installscript}
$ rpmbuild -v -bb ~/RPMBUILD/SPECS/demo.spec
Executing(%prep): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.oEOM10
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%build): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.qQFuTA
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.8rTMLa
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ '[' /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1 '!=' / ']'
+ rm -rf /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
++ dirname /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
+ mkdir -p /home/ronbarak/RPMBUILD/tmp
+ mkdir /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cp /home/ronbarak/RPMBUILD/SOURCES/tty.install.sh /home/ronbarak/RPMBUILD/SOURCES/tty-5.2.0-00-70270.tar /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
+ cd /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: tty-cap-5.2-1.noarch
Requires(interp): /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
Wrote: /home/ronbarak/RPMBUILD/RPMS/noarch/tty-cap-5.2-1.noarch.rpm
Executing(%clean): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.Yag9bm
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ '[' /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1 '!=' / ']'
+ rm -rf /home/ronbarak/RPMBUILD/tmp/tty-cap-5.2-1
+ exit 0
$ sudo rpm -Uvh /home/ronbarak/RPMBUILD/RPMS/noarch/tty-cap-5.2-1.noarch.rpm
Preparing... ########################################### [100%]
1:tty-cap ########################################### [100%]
>>> Inside post <<<
###### Starting tty capturing installation ######
Specify installation directory full path [/opt/Intellinx/TTYCapture]:
/opt/Intellinx/TTYCapture already exists. continue installation? (y/n) [y]
Extracting archive tty-5*.* ...
Please specify TTY sensor owner user [ronbarak]:
TTY sensor will be accessible by user 'ronbarak' in group 'ronbarak'
Specify sensor working directory full path [/opt/Intellinx/TTYCapture/work]:
Specify sensor listening port [1024-65000] [8888]:
Do you want to register the sensor service? (y/n) [n]
Server gxttySensorService is not register as a daemon
Executing default user shell (y/n) [y]
TTY capturing has been installed successfully.
You are mixing several concepts here. So let make step back.
In %prep section you should unpack your %{SOURCE0} and apply patches if any. This usually do
%setup -q
However if you want you can extract it manually. For more info about this macro see http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html
In %build section you usually compile source into binaries. Likely empty if you use interpreted language or your tar contains already compiled binaries.
In %install section you should copy the files into %{buildroot} and create there structure which will land in package. E.g. %{buildroot}/etc/yourconfig, %{buildroot}/usr/bin/yourcommand etc. You can run there any script you want, but keep in mind that it is run only in build time. I.e. only on your machine (or build system). This is intended for creating files which are automatically generated (e.g. documentation of libraries from source code).
Then you have section %post which is run on user machine after the package was installed. And all files are installed in final path. Not in buildroot. At the beginning you are changed to / so you need to specify full path on that user machine.
So in your case it should be probably look like:
%install
mkdir -p %{buildroot}%{_bindir}
cp -a %{installscript} %{buildroot}%{_bindir}/
chmod a+x %{buildroot}%{_bindir}/%{installscript}
%files
%{_bindir}/%{installscript}
%post
%{_bindir}%{installscript}
Sever notes:
%post section is executed under root, so sudo is not needed.
Running interactive script is strongly discouraged. RPM was designed as non-interactive and every utility around assume no interaction during package installation (e.g. PackageKit, Spacewalk etc.). So sooner then later you will get some compains. It is much safer to say user to run some command after installation manually (or automate it using Ansible or Puppet).

RPM build errors:Bad exit status from /var/tmp/rpm-tmp.32XJLX (%install)

Im trying to create a simple rpm package on centos 6.5.. But i cannot finish it as its giving me errors.. I have already followed these two threads.. Bad exit status from /var/tmp/rpm-tmp.b1DgAt (%build) and Bad exit status from /var/tmp/rpm-tmp.ajKra4 (%prep) .. yet no luck...
I cannot figure out what i'm missing here.. please help me to fix this..
this is my
Name: test
Version: 1.0
Release: 1%{?dist}
Summary: A test package
Group: Testing
License: GPL
URL: http://www.yahoo.com
Source0: test-1.0.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: /bin/rm, /bin/mkdir, /bin/cp
Requires: /bin/bash, /bin/date
%description
this is the test package build for rhche
%prep
%setup -q
%build
./configure
%install
rm -rf $RPM_BUILD_ROOT
make -p $RPM_BUILD_ROOT/usr/local/bin
cp myscriptdate $RPM_BUILD_ROOT/usr/local/bin
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%attr(0755,root,root)/usr/local/bin/myscriptdate
%changelog
* Thu Dec 09 2010 Forrest <forrest#redhat.com> 1.0-1
-Initial RPM
-Added /usr/local/bin/myscript
Source directory is /test1
[ara#catshit test1]$ pwd
/test1
[ara#catshit test1]$ ls -ls
total 12
4 drwxrwxrwx. 2 ara ara 4096 Dec 7 00:02 test-1.0
4 -rw-rw-r--. 1 ara ara 210 Dec 7 00:09 test-1.0.tar.gz
4 -rwxrwxrwx. 1 ara ara 742 Dec 7 00:17 test.spec
[ara#catshit test1]$
test-1.0 is compressed as test-1.0.tar.gz.
Inside test-1.0 I have script called myscriptdate which is having following simple code..
'#!/bin/bash
date
when i try rpmbuild -ba test.spec it gives me
# Not a target:
.f:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# commands to execute (built-in):
$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $#
# Not a target:
.f.o:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# commands to execute (built-in):
$(COMPILE.f) $(OUTPUT_OPTION) $<
# files hash-table stats:
# Load=70/1024=7%, Rehash=0, Collisions=278/1660=17%
# VPATH Search Paths
# No `vpath' search paths.
# No general (`VPATH' variable) search path.
# # of strings in strcache: 0
# # of strcache buffers: 0
# strcache size: total = 0 / max = 0 / min = 4096 / avg = 0
# strcache free: total = 0 / max = 0 / min = 4096 / avg = 0
# Finished Make data base on Sun Dec 7 00:51:01 2014
error: Bad exit status from /var/tmp/rpm-tmp.ZFlmeu (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.ZFlmeu (%install)
/var/tmp/rpm-tmp.ZFlmeu content is below
#!/bin/sh
RPM_SOURCE_DIR="/home/ara/rpmbuild/SOURCES"
RPM_BUILD_DIR="/home/ara/rpmbuild/BUILD"
RPM_OPT_FLAGS="-O2 -g"
RPM_ARCH="x86_64"
RPM_OS="linux"
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
RPM_DOC_DIR="/usr/share/doc"
export RPM_DOC_DIR
RPM_PACKAGE_NAME="test"
RPM_PACKAGE_VERSION="1.0"
RPM_PACKAGE_RELEASE="1.el6"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
LANG=C
export LANG
unset CDPATH DISPLAY ||:
RPM_BUILD_ROOT="/home/ara/rpmbuild/BUILDROOT/test-1.0-1.el6.x86_64"
export RPM_BUILD_ROOT
PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/share/pkgconfig"
export PKG_CONFIG_PATH
set -x
umask 022
cd "/home/ara/rpmbuild/BUILD"
cd 'test-1.0'
rm -rf $RPM_BUILD_ROOT
make -p $RPM_BUILD_ROOT/usr/local/bin
cp myscriptdate $RPM_BUILD_ROOT/usr/local/bin
/usr/lib/rpm/brp-compress
/usr/lib/rpm/brp-strip
/usr/lib/rpm/brp-strip-static-archive
/usr/lib/rpm/brp-strip-comment-note
The make -p $RPM_BUILD_ROOT/usr/local/bin line is your problem.
While not the problem you almost certainly don't want -p on that line. As it doesn't do anything useful for you during compilation and your rpm build process has no need to see the make database of rules.
The real problem is that you are telling make that you would like it to build the $RPM_BUILD_ROOT/usr/local/bin target which it is incredibly unlikely that make actually knows how to build (thus causing make to fail to build it and giving you an error). Removing the -p will help you see the actual error that make is spitting out as it will not also spit out the rule database stuff.
I think you meant mkdir -p there instead. (Which should be available as the %{__mkdir_p} macro.)

Resources