How does rpmbuild move the results to the target - linux

When I do
rpmbuild -bi ~/rpmbuild/SPECS/microemacs.spec
The result is
>g++ -g -I. -I../src basic.o bind.o buffer.o char.o crypt.o display.o eval.o exec.o file.o
> fileio.o input.o isearch.o line.o main.o malloc.o mouse.o msdir.o random.o region.o search.o
> sinc.o tag.o window.o word.o map.o unix.o terminal.o lock.o -o microemacs
>
>+ exit 0
> Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.dzYbvW
> + umask 022
> + cd /home/<redacted>/rpmbuild/BUILD
> + '[' /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64 '!=' / ']'
> + rm -rf /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64
> ++ dirname /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64
> + mkdir -p /home/<redacted>/rpmbuild/BUILDROOT
> + mkdir /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64
> + cd microemacs-2.9
> + echo /home/<redacted>/rpmbuild/BUILD/unix
> /home/<redacted>/rpmbuild/BUILD/unix
> + cd /home/<redacted>/rpmbuild/BUILD/microemacs-2.9
> + cd unix
> + cp microemacs /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64/
> + cp ../macros/.emacsrc /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64/
> + cp ../src/microemacs.md /home/<redacted>/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64/
> + /usr/lib/rpm/find-debuginfo.sh --strict-build-id -m --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 /home/smit_pet/rpmbuild/BUILD/microemacs-2.9
> extracting debug info from /home/smit_pet/rpmbuild/BUILDROOT/microemacs-2.9-0.x86_64/microemacs
> dwz: Too few files for multifile optimization
> /usr/lib/rpm/sepdebugcrcfix: Updated 1 CRC32s, 0 CRC32s did match.
> 1019 blocks
> + /usr/lib/rpm/check-buildroot
> + /usr/lib/rpm/redhat/brp-compress
> + /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
> + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
> + /usr/lib/rpm/redhat/brp-python-hardlink
> + /usr/lib/rpm/redhat/brp-java-repack-jars
> Processing files: microemacs-2.9-0.x86_64
> error: File must begin with "/": microemacs
> error: File must begin with "/": .emacsrc
> error: File must begin with "/": microemacs.md
>
> RPM build errors:
> File must begin with "/": microemacs
> File must begin with "/": .emacsrc
> File must begin with "/": microemacs.md
I do not understand how the distinction between BUILD BUILDROOT or how the results get to the target and how %file features in this.
Also why the /usr/lib action and why and how is this happening?
I want the results to end up in ~/bin/ and I can do this with a manual copy in %install but I think this is not the correct way.
Also nothing prints Hello.
The .spec file is
> SPECS/microemacs.spec
> Name: microemacs
> %define version 2.9
> Version: %{version}
> Release: 0
> Summary: Microemacs program code editor
> Group: Applications/Development
> License: GPL 3.0 License
> URL: .
> Vendor: .
> Source: microemacs-%{version}.tar.gz
> Prefix: %{_prefix}
> Packager: .
> BuildRoot: %{_tmppath}/%{name}-root
>
> %description
> A text editor suporting
> + Piping input into it.
> + Editting Directories and their contents.
> + Taking text from the buffer into the command line
>
> %prep
>
> %setup -q
>
> %build
> echo Hello
> pwd
> cd ./unix
> make
>
> %install
> echo %{_builddir}/unix
> cd %{_builddir}/microemacs-%{version}
> cd unix
> cp microemacs %{buildroot}/
> cp ../macros/.emacsrc %{buildroot}/
> cp ../src/microemacs.md %{buildroot}/
>
> %clean
> cd ${_builddir}/microemacs-%{version}/unix
> make clean
>
> %files
> %defattr(-,root,root)
> microemacs
> .emacsrc
> microemacs.md

The %buildroot during the %install phase is directory where you create the layout of target. I.e., how it will be stored in final rpm.
When you have:
%install
cp microemacs %{buildroot}/
then you have to have
%files
/microemacs
But you likely want to have:
%install
cp -a microemacs %{buildroot}%{_bindir}/microemacs
%files
%{_bindir}/microemacs
%doc microemacs.md
This will place the microemacs to /usr/bin and microemacs.md to /usr/share/doc - no need to cp microemacs.md there during %install as the %doc macro will take care of it.

Related

I am getting a strange error when running MPICH 4.0.3

I am getting an error when running mpirun:
will#will-MS-7D91:~/WRFHYDRO/Tests/Compatibility$ mpirun ./a.out |& tee comp_test2.txt
C function called by Fortran
Values are xx = 2.00 and ii = 1
Abort(2139535) on node 0 (rank 0 in comm 0): Fatal error in PMPI_Init: Other MPI error, error stack:
MPIR_Init_thread(176)........:
MPID_Init(1538)..............:
MPIDI_OFI_mpi_init_hook(1511):
open_fabric(2565)............:
find_provider(2683)..........: OFI fi_getinfo() failed (ofi_init.c:2683:find_provider:No data available)
I have tested the commands on another computer and it works fine. The commands are this:
echo "Test 2"
mpifort -c 02_fortran+c+netcdf+mpi_f.f
mpicc -c 02_fortran+c+netcdf+mpi_c.c
mpifort 02_fortran+c+netcdf+mpi_f.o \
02_fortran+c+netcdf+mpi_c.o \
-L${NETCDF}/lib -lnetcdff -lnetcdf
mpirun ./a.out |& tee comp_test2.txt
I recently built a new pc, with an MSI Z790 Tomahawk board, Intel-13900K cpu, and 64GB of DDR5 5600mhz RAM. Could this be this issue were one of those things are not compatibile with mpich? Mpich version is 4.0.3.
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install gcc gfortran g++ libtool automake autoconf make m4 default-jre default-jdk csh ksh git python3 python3-dev python2 python2-dev mlocate curl cmake libcurl4-openssl-dev
echo " "
##############################Directory Listing############################
export HOME=`cd;pwd`
mkdir $HOME/WRF
export WRF_FOLDER=$HOME/WRF
cd $WRF_FOLDER/
mkdir Downloads
mkdir WRFPLUS
mkdir WRFDA
mkdir Libs
export DIR=$WRF_FOLDER/Libs
mkdir Libs/grib2
mkdir Libs/NETCDF
mkdir Libs/MPICH
mkdir -p Tests/Environment
mkdir -p Tests/Compatibility
echo " "
#############################Core Management####################################
export CPU_CORE=$(nproc) # number of available threads on system
export CPU_6CORE="6"
export CPU_HALF=$(($CPU_CORE / 2)) #half of availble cores on system
export CPU_HALF_EVEN=$(( $CPU_HALF - ($CPU_HALF % 2) )) #Forces CPU cores to even number to avoid partial core export. ie 7 cores would be 3.5 cores.
if [ $CPU_CORE -le $CPU_6CORE ] #If statement for low core systems. Forces computers to only use 1 core if there are 4 cores or less on the system.
then
export CPU_HALF_EVEN="2"
else
export CPU_HALF_EVEN=$(( $CPU_HALF - ($CPU_HALF % 2) ))
fi
echo "##########################################"
echo "Number of Threads being used $CPU_HALF_EVEN"
echo "##########################################"
echo " "
##############################Downloading Libraries############################
#Force use of ipv4 with -4
cd Downloads
wget -c -4 https://github.com/madler/zlib/archive/refs/tags/v1.2.13.tar.gz
wget -c -4 https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_13_2.tar.gz
wget -c -4 https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.0.tar.gz
wget -c -4 https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.0.tar.gz
wget -c -4 https://github.com/pmodels/mpich/releases/download/v4.0.3/mpich-4.0.3.tar.gz
wget -c -4 https://download.sourceforge.net/libpng/libpng-1.6.39.tar.gz
wget -c -4 https://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.1.zip
wget -c -4 https://sourceforge.net/projects/opengrads/files/grads2/2.2.1.oga.1/Linux%20%2864%20Bits%29/opengrads-2.2.1.oga.1-bundle-x86_64-pc-linux-gnu-glibc_2.17.tar.gz
echo " "
####################################Compilers#####################################
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
export CFLAGS="-fPIC -fPIE -O3"
#IF statement for GNU compiler issue
export GCC_VERSION=$(/usr/bin/gcc -dumpfullversion | awk '{print$1}')
export GFORTRAN_VERSION=$(/usr/bin/gfortran -dumpfullversion | awk '{print$1}')
export GPLUSPLUS_VERSION=$(/usr/bin/g++ -dumpfullversion | awk '{print$1}')
export GCC_VERSION_MAJOR_VERSION=$(echo $GCC_VERSION | awk -F. '{print $1}')
export GFORTRAN_VERSION_MAJOR_VERSION=$(echo $GFORTRAN_VERSION | awk -F. '{print $1}')
export GPLUSPLUS_VERSION_MAJOR_VERSION=$(echo $GPLUSPLUS_VERSION | awk -F. '{print $1}')
export version_10="10"
if [ $GCC_VERSION_MAJOR_VERSION -ge $version_10 ] || [ $GFORTRAN_VERSION_MAJOR_VERSION -ge $version_10 ] || [ $GPLUSPLUS_VERSION_MAJOR_VERSION -ge $version_10 ]
then
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz
else
export fallow_argument=
export boz_argument=
fi
export FFLAGS=$fallow_argument
export FCFLAGS=$fallow_argument
echo "##########################################"
echo "FFLAGS = $FFLAGS"
echo "FCFLAGS = $FCFLAGS"
echo "##########################################"
echo " "
#############################zlib############################
#Uncalling compilers due to comfigure issue with zlib1.2.13
#With CC & CXX definied ./configure uses different compiler Flags
cd $WRF_FOLDER/Downloads
tar -xvzf v1.2.13.tar.gz
cd zlib-1.2.13/
./configure --prefix=$DIR/grib2
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
echo " "
##############################MPICH############################
#F90= due to compiler issues with mpich install
cd $WRF_FOLDER/Downloads
tar -xvzf mpich-4.0.3.tar.gz
cd mpich-4.0.3/
F90= ./configure --prefix=$DIR/MPICH --with-device=ch3 FFLAGS=$fallow_argument FCFLAGS=$fallow_argument
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
# make check
export PATH=$DIR/MPICH/bin:$PATH
export MPIFC=$DIR/MPICH/bin/mpifort
export MPIF77=$DIR/MPICH/bin/mpifort
export MPIF90=$DIR/MPICH/bin/mpifort
export MPICC=$DIR/MPICH/bin/mpicc
export MPICXX=$DIR/MPICH/bin/mpicxx
echo " "
#############################libpng############################
cd $WRF_FOLDER/Downloads
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include
tar -xvzf libpng-1.6.39.tar.gz
cd libpng-1.6.39/
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/grib2
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
echo " "
#############################JasPer############################
cd $WRF_FOLDER/Downloads
unzip jasper-1.900.1.zip
cd jasper-1.900.1/
./configure --prefix=$DIR/grib2
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/grib2
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
echo " "
#############################hdf5 library for netcdf4 functionality############################
cd $WRF_FOLDER/Downloads
tar -xvzf hdf5-1_13_2.tar.gz
cd hdf5-hdf5-1_13_2
CC=$MPICC FC=$MPIFC F77=$MPIF77 F90=$MPIF90 CXX=$MPICXX ./configure --prefix=$DIR/grib2 --with-zlib=$DIR/grib2 --enable-hl --enable-fortran
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
export HDF5=$DIR/grib2
export LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH
echo " "
##############################Install NETCDF C Library############################
cd $WRF_FOLDER/Downloads
tar -xzvf v4.9.0.tar.gz
cd netcdf-c-4.9.0/
export CPPFLAGS=-I$DIR/grib2/include
export LDFLAGS=-L$DIR/grib2/lib
export LIBS="-lhdf5_hl -lhdf5 -lz -lcurl -lgfortran -lgcc -lm -ldl"
CC=$MPICC FC=$MPIFC CXX=$MPICXX F90=$MPIF90 F77=$MPIF77 ./configure --prefix=$DIR/NETCDF --disable-dap --enable-netcdf-4 --enable-netcdf4 --enable-shared
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
export PATH=$DIR/NETCDF/bin:$PATH
export NETCDF=$DIR/NETCDF
echo " "
##############################NetCDF fortran library############################
cd $WRF_FOLDER/Downloads
tar -xvzf v4.6.0.tar.gz
cd netcdf-fortran-4.6.0/
export LD_LIBRARY_PATH=$DIR/NETCDF/lib:$LD_LIBRARY_PATH
export CPPFLAGS="-I$DIR/NETCDF/include -I$DIR/grib2/include"
export LDFLAGS="-L$DIR/NETCDF/lib -L$DIR/grib2/lib"
export LIBS="-lnetcdf -lhdf5_hl -lhdf5 -lz -ldl"
CC=$MPICC FC=$MPIFC CXX=$MPICXX F90=$MPIF90 F77=$MPIF77 ./configure --prefix=$DIR/NETCDF --enable-netcdf-4 --enable-netcdf4 --enable-shared
make -j $CPU_HALF_EVEN
make -j $CPU_HALF_EVEN install |& tee make.install.log
#make check
echo " "
#################################### System Environment Tests ##############
cd $WRF_FOLDER/Downloads
wget -c -4 https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_NETCDF_MPI_tests.tar
wget -c -4 https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_tests.tar
tar -xvf Fortran_C_tests.tar -C $WRF_FOLDER/Tests/Environment
tar -xvf Fortran_C_NETCDF_MPI_tests.tar -C $WRF_FOLDER/Tests/Compatibility
export one="1"
echo " "
############## Testing Environment #####
cd $WRF_FOLDER/Tests/Environment
echo " "
echo " "
echo "Environment Testing "
echo "Test 1"
gfortran TEST_1_fortran_only_fixed.f
./a.out |& tee env_test1.txt
export TEST_PASS=$(grep -w -o -c "SUCCESS" env_test1.txt | awk '{print$1}')
if [ $TEST_PASS -ge 1 ]
then
echo "Enviroment Test 1 Passed"
else
echo "Environment Compiler Test 1 Failed"
exit
fi
read -t 3 -p "I am going to wait for 3 seconds only ..."
echo " "
echo "Test 2"
gfortran TEST_2_fortran_only_free.f90
./a.out |& tee env_test2.txt
export TEST_PASS=$(grep -w -o -c "SUCCESS" env_test2.txt | awk '{print$1}')
if [ $TEST_PASS -ge 1 ]
then
echo "Enviroment Test 2 Passed"
else
echo "Environment Compiler Test 2 Failed"
exit
fi
echo " "
read -t 3 -p "I am going to wait for 3 seconds only ..."
echo " "
echo "Test 3"
gcc TEST_3_c_only.c
./a.out |& tee env_test3.txt
export TEST_PASS=$(grep -w -o -c "SUCCESS" env_test3.txt | awk '{print$1}')
if [ $TEST_PASS -ge 1 ]
then
echo "Enviroment Test 3 Passed"
else
echo "Environment Compiler Test 3 Failed"
exit
fi
echo " "
read -t 3 -p "I am going to wait for 3 seconds only ..."
echo " "
echo "Test 4"
gcc -c -m64 TEST_4_fortran+c_c.c
gfortran -c -m64 TEST_4_fortran+c_f.f90
gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o
./a.out |& tee env_test4.txt
export TEST_PASS=$(grep -w -o -c "SUCCESS" env_test4.txt | awk '{print$1}')
if [ $TEST_PASS -ge 1 ]
then
echo "Enviroment Test 4 Passed"
else
echo "Environment Compiler Test 4 Failed"
exit
fi
echo " "
read -t 3 -p "I am going to wait for 3 seconds only ..."
echo " "
############## Testing Environment #####
cd $WRF_FOLDER/Tests/Compatibility
cp ${NETCDF}/include/netcdf.inc .
echo " "
echo " "
echo "Library Compatibility Tests "
echo "Test 1"
gfortran -c 01_fortran+c+netcdf_f.f
gcc -c 01_fortran+c+netcdf_c.c
gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o \
-L${NETCDF}/lib -lnetcdff -lnetcdf
./a.out |& tee comp_test1.txt
export TEST_PASS=$(grep -w -o -c "SUCCESS" comp_test1.txt | awk '{print$1}')
if [ $TEST_PASS -ge 1 ]
then
echo "Compatibility Test 1 Passed"
else
echo "Compatibility Compiler Test 1 Failed"
exit
fi
echo " "
read -t 3 -p "I am going to wait for 3 seconds only ..."
echo " "
echo "Test 2"
mpifort -c 02_fortran+c+netcdf+mpi_f.f
mpicc -c 02_fortran+c+netcdf+mpi_c.c
mpifort 02_fortran+c+netcdf+mpi_f.o \
02_fortran+c+netcdf+mpi_c.o \
-L${NETCDF}/lib -lnetcdff -lnetcdf
mpirun ./a.out |& tee comp_test2.txt
So this issue was having the intel mpi program in the $PATH and $LD_LIBRARY_PATH
Once I removed the intel mpi program from the both of those places in .bashrc it fixed the issue.

How to delete directories where files within directories don't have a certain regex match?

Say I have the following directories:
dir > subdir1 > k.txt > "Keep please"
> subdir2 > l.txt > "Keep me"
> subdir3 > m.txt > "Delete me"
> subdir4 > n.txt > "remove"
I want to find an expression that will let me do a regex match on the contents within the file, and delete the subdirectories that do not have that string match. So in the example above, I would use something like grep -r "Keep.* for the files and them only rm subdir3. I want to end up with:
dir > subdir1 > k.txt > "Keep please"
> subdir2 > l.txt > "Keep me"
Here is a shell script approach:-
#!/bin/ksh
for dir in <your directory name here>/*
do
printf "Checking dir: ${dir}..."
if grep -q "Keep" ${dir}/*
then
print " [Keep]"
# do nothing
else
print " [Remove]"
# rm -rf ${dir}
fi
done
I commented rm statement, you can first run the script and carefully verify the print statement output to make sure it is picking the right directory names.

which utility produces "Poky (Yocto Project Reference Distro) 2.6.1 (none) /dev/console"

I am playing with Yocto Thud 2.6.1.
I want to know which utility / program / library is responsible for producing following line:
'Poky (Yocto Project Reference Distro) 2.6.1 (none) /dev/console'
Thanks
The lines before the login are from the /etc/issue and /etc/issue.net files.
You can modify them by creating a bbappend file with your own issue and issue.net files.
Note that Yocto will still append the Poky (Yocto Project Reference Distro) 2.6.1 lines.
Taking a look at the base_file_3.0.14.bb (my current version):
BASEFILESISSUEINSTALL ?= "do_install_basefilesissue"
[...]
do_install_basefilesissue () {
if [ "${hostname}" ]; then
echo ${hostname} > ${D}${sysconfdir}/hostname
fi
install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir}
if [ -n "${DISTRO_NAME}" ]; then
printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue
printf "${DISTRO_NAME} " >> ${D}${sysconfdir}/issue.net
if [ -n "${DISTRO_VERSION}" ]; then
distro_version_nodate=${#'${DISTRO_VERSION}'.replace('snapshot-${DATE}','snapshot').replace('${DATE}','')}
printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue
printf "%s " $distro_version_nodate >> ${D}${sysconfdir}/issue.net
fi
printf "\\\n \\\l\n" >> ${D}${sysconfdir}/issue
echo >> ${D}${sysconfdir}/issue
echo "%h" >> ${D}${sysconfdir}/issue.net
echo >> ${D}${sysconfdir}/issue.net
fi
}
Yo need to disable this do_install_basefileissue and set your own install instead:
base-file_%.bbappend:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI_prepend = " file://issue \
file://issue.net "
BASEFILESISSUEINSTALL = "do_install_basefilesissuecustom"
do_install_basefilesissuecustom () {
install -m 644 ${WORKDIR}/issue* ${D}${sysconfdir}
}

RPM spec patch application fails

I have a spec file, which compiles fine without the patch:
build#SLES11SP4-185:~/rpmbuild/SPECS> cat testSoftware.spec
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# norootforbuild
Name: testSoftware
Version: 1.0
Release: 2
Summary: Demo - patch
Group: Deployment
License: GPLv2
Url: www.dell.com
#PreReq:
#Provides:
#BuildRequires:
Source: testSoftware.tar.gz
patch0: test1.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: on
%description
Authors:
--------
Raj Kumar
%prep
%setup -q
%build
%install
mkdir -p $RPM_BUILD_ROOT/opt/testSoftware
install test1.sh $RPM_BUILD_ROOT/opt/testSoftware
install test2.sh $RPM_BUILD_ROOT/opt/testSoftware
%patch -P 0
%clean
rm -rf $RPM_BUILD_ROOT
%post
%postun
%files
/opt/testSoftware/test1.sh
/opt/testSoftware/test2.sh
%defattr(-,root,root,0755)
My SOURCES directory has the test1.patch and the *.tar.gz
build#SLES11SP4-185:~/rpmbuild/SOURCES> ls
testSoftware.tar.gz
test1.patch testSoftware-1.0
Here is the test1.patch
build#SLES11SP4-185:~/rpmbuild/SOURCES> cat test1.patch
--- testSoftware-1.0/test1.sh 2016-08-20 04:49:19.000000000 -0400
+++ test1.sh 2016-08-20 05:33:45.000000000 -0400
## -1 +1 ##
-Hello - Test1
+Test1 - Test1 - patch
When i run the spec file, it fails:
build#SLES11SP4-185:~/rpmbuild/SPECS> rpmbuild -bb testSoftware.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.10960
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd /home/build/rpmbuild/BUILD
+ rm -rf testSoftware-1.0
+ /usr/bin/gzip -dc /home/build/rpmbuild/SOURCES/testSoftware.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd testSoftware-1.0
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.10960
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ /bin/rm -rf /var/tmp/testSoftware-1.0-build
++ dirname /var/tmp/testSoftware-1.0-build
+ /bin/mkdir -p /var/tmp
+ /bin/mkdir /var/tmp/testSoftware-1.0-build
+ cd testSoftware-1.0
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.10960
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd testSoftware-1.0
+ mkdir -p /var/tmp/testSoftware-1.0-build/opt/testSoftware
+ install test1.sh /var/tmp/testSoftware-1.0-build/opt/testSoftware
+ install test2.sh /var/tmp/testSoftware-1.0-build/opt/testSoftware
+ %patch -P 0
/var/tmp/rpm-tmp.10960: line 28: fg: no job control
error: Bad exit status from /var/tmp/rpm-tmp.10960 (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.10960 (%install)
Can someone tell me what is the issue?
You can see it is not recognizing the %patch macro and sending that text exactly to the shell, which interprets the % as trying to refer to a background job-control process. That is because %patch is a %build step and is in the wrong section of the specfile (you have it in %install).
Move it to %build and you should be fine.
It works if we apply it after %setup -q.
Below is the modified spec file which works:
Name: testSoftware
Version: 1.0
Release: 2
Summary: Demo - patch
Group: Deployment
License: GPLv2
Url: www.dell.com
#PreReq:
#Provides:
#BuildRequires:
Source: testSoftware.tar.gz
Patch0: test1.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: on
%description
Authors:
--------
Raj Kumar
%prep
%setup -q
%patch -p0
%build
%install
mkdir -p $RPM_BUILD_ROOT/opt/testSoftware
install test1.sh $RPM_BUILD_ROOT/opt/testSoftware
install test2.sh $RPM_BUILD_ROOT/opt/testSoftware
%clean
rm -rf $RPM_BUILD_ROOT

Redirecting vcftools file in linux - tips

Here is the code that gets the VCF file from a specific region using tabix and then filters it for specific (european) population using 'keep' option from vcftools.
####select specific population
if [ "$POP_FILE" != "" ]; then
vcftools --vcf temp.vcf --keep $POP_FILE --recode --recode-INFO-all > temp2.vcf 2> /dev/null
else
cp -f temp.vcf temp2.vcf
fi
PROBLEM: it creates the recode.vcf file but then the redirection is not happening as the temp2 file is empty
I would avoid vcftools and use bcftools (https://github.com/samtools/bcftools) instead:
if [ "$POP_FILE" != "" ]; then
bcftools view temp.vcf -S $POP_FILE -o temp2.vcf
else
cp -f temp.vcf temp2.vcf
fi
To install bcftools:
git clone --branch=develop git://github.com/samtools/bcftools.git
git clone --branch=develop git://github.com/samtools/htslib.git
cd htslib && make && cd ..
cd bcftools && make && cd ..
sudo cp bcftools/bcftools /usr/local/bin/

Resources