Help!

How to get rid of 'cd' before %prep in spec file

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> PRM - Partner Relationship Management RSS
Next:  Kernel für_Suse_10.2_übersetzen  
Author Message
boardrider
External


Since: Mar 26, 2007
Posts: 1



PostPosted: Mon Mar 26, 2007 9:48 am    Post subject: How to get rid of 'cd' before %prep in spec file
Archived from groups: linux>redhat>rpm (more info?)

Hi All,

I have an RPM/spec related question.
The spec listing (and listing of /var/tmp/rpm-tmp.36085) is below.

When I try to build an RPM from this spec, I get the following:

[root@mddinstall SW_EMAIL_GW]# rpmbuild -ba /usr/src/redhat/SPECS/
test.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.36085
+ umask 022
+ cd /tmp/test-4.7.0.0.99/output/BUILD
/var/tmp/rpm-tmp.36085: line 21: cd: /tmp/test-4.7.0.0.99/output/
BUILD: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.36085 (%prep)

RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.36085 (%prep)
[root@mddinstall SW_EMAIL_GW]#

My question is:
How can I instruct the rpmbuild command not to do the cd /tmp/
test-4.7.0.0.99/output/BUILD before the execution of the %prep
stanza ?

Thanks,
Ron.

P.S.: /tmp/test-4.7.0.0.99/output/BUILD is my $RPM_BUILD_ROOT.

--------------------------------------------------------------------------------

[root@mddinstall SW_EMAIL_GW]# cat /usr/src/redhat/SPECS/test.spec
%define debug_package %{nil}
%define __spec_install_post /usr/lib/rpm/brp-compress

%define component_name test
%define rpm_name %{component_name}
%define RPMstf 99
%define RPMversion 4.7.0.0.99
%define topdir /tmp/test-4.7.0.0.99/output
%define _topdir %{topdir}
%define view aor-Infra-integ-4.7.0.3

Name: %{rpm_name}
Version: %{RPMversion}
Copyright: Commercial
Group: Applications/Communications
Packager: Ron Barak (ron.barak2@comverse.com)
BuildRoot: %{_builddir}/%{name}-%{version}
Summary: cdr configurations
BuildArch: i686
Release: STF%{RPMstf}.04
# Example 'Source' line:
# Source: http://metalab.unc.edu/pub/Linux/utils/disk-management/eject-2.0.2.tar.gz
Source0: %{name}-%{version}.tar.bz2
Source1: ${RPM_BUILD_ROOT}/data/comverse/scripts/cksum.pl
Source2: ${RPM_BUILD_ROOT}/data/comverse/scripts/gw.csv
Source3: ${RPM_BUILD_ROOT}/data/comverse/scripts/
build_rpms_devel_generic.pl


%description
explanation comes here
STF: 99

%prep

echo executing: %%prep
%__rm -rf $RPM_BUILD_ROOT
%__mkdir_p $RPM_BUILD_ROOT
pushd $RPM_BUILD_ROOT && /bin/tar -jxvf /tmp/test-4.7.0.0.99/output/
SOURCES/test-4.7.0.0.99.tar.bz2 && popd

%build

# Checksums calculation
if [ -f ${RPM_BUILD_ROOT} ]; then
%__mkdir -p ${RPM_BUILD_ROOT}
fi
cd $RPM_BUILD_ROOT && /tmp/test-4.7.0.0.99/output/CKSUM/cksum.pl
create . /tmp/test-4.7.0.0.99/output/CKSUM/test_cksum.list
if [ -f /tmp/test-4.7.0.0.99/output/CKSUM/test_cksum.list ]; then
%__mkdir -p ${RPM_BUILD_ROOT}/data/comverse/cksums
%__cp /tmp/test-4.7.0.0.99/output/CKSUM/test_cksum.list $
{RPM_BUILD_ROOT}/data/comverse/cksums
else
echo "Error: could not create checksums file /tmp/
test-4.7.0.0.99/output/CKSUM/test_cksum.list"
fi

%__mkdir -p ${RPM_BUILD_ROOT}/data/comverse/scripts
%__cp /users/robarak/data/generic/build_rpms_devel_generic.pl $
{RPM_BUILD_ROOT}/data/comverse/scripts/build_rpms_devel_generic.pl
%__cp /users/robarak/data/generic/cksum.pl ${RPM_BUILD_ROOT}/
data/comverse/scripts/cksum.pl
%__cp /users/robarak/data/generic/gw.csv ${RPM_BUILD_ROOT}/
data/comverse/scripts/gw.csv
%__cp /users/robarak/data/generic/build_rpms_devel_generic.pl /
tmp/test-4.7.0.0.99/output/SOURCES/build_rpms_devel_generic.pl
%__cp /users/robarak/data/generic/cksum.pl /tmp/
test-4.7.0.0.99/output/SOURCES/cksum.pl
%__cp /users/robarak/data/generic/gw.csv /tmp/test-4.7.0.0.99/
output/SOURCES/gw.csv

%install

%clean
%__rm -rf $RPM_BUILD_ROOT

%files -f /tmp/test-4.7.0.0.99/output/BUILD/files.tmp
%defattr(-,gw,gw)
/data/comverse/scripts/build_rpms_devel_generic.pl
/data/comverse/scripts/cksum.pl
/data/comverse/scripts/gw.csv
/data/comverse/cksums/test_cksum.list

# Example %files lines:
#%{homedir_base}/%{rpm_name}
#%files -f %{_topdir}/../kit/include_dest_files
#%attr (775, mal, mal) /home/mal/cksum/mal.cksum

%pre

%post

%postun

%changelog

* Wed Mar 21 2007 Ron Barak <ron.barak2 RemoveThis @comverse.com> -
- Changes mage to make script generic (with CSV).

* Mon Feb 12 2007 Ron Barak <ron.barak2 RemoveThis @comverse.com> 4.7.0.0.5_STF02-
- $user is set now in this script, and not manipulated
- based on input from command line.

* Wed Oct 25 2006 Ron Barak <ron.barak2 RemoveThis @comverse.com>
4.7.0.2.0_STF02-02
- Initial version

[root@mddinstall SW_EMAIL_GW]#

--------------------------------------------------------------------------------
[root@mddinstall SW_EMAIL_GW]# cat /var/tmp/rpm-tmp.36085
#!/bin/sh

RPM_SOURCE_DIR="/tmp/test-4.7.0.0.99/output/SOURCES"
RPM_BUILD_DIR="/tmp/test-4.7.0.0.99/output/BUILD"
RPM_OPT_FLAGS="-O2 -g -pipe -march=i386 -mcpu=i686"
RPM_ARCH="i386"
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="4.7.0.0.99"
RPM_PACKAGE_RELEASE="STF99.04"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
RPM_BUILD_ROOT="/tmp/test-4.7.0.0.99/output/BUILD/test-4.7.0.0.99"
export RPM_BUILD_ROOT


set -x
umask 022
cd /tmp/test-4.7.0.0.99/output/BUILD
LANG=C
export LANG
unset DISPLAY


echo executing: %prep
/bin/rm -rf $RPM_BUILD_ROOT
/bin/mkdir -p $RPM_BUILD_ROOT
pushd $RPM_BUILD_ROOT && /bin/tar -jxvf /tmp/test-4.7.0.0.99/output/
SOURCES/test-4.7.0.0.99.tar.bz2 && popd


exit 0[root@mddinstall SW_EMAIL_GW]#
Back to top
Michal Jaegermann
External


Since: Jun 06, 2004
Posts: 62



PostPosted: Mon Mar 26, 2007 8:55 pm    Post subject: Re: How to get rid of 'cd' before %prep in spec file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

boardrider <google-groups-rpm.comverse.DeleteThis@9ox.net> wrote:
> Hi All,
>
> I have an RPM/spec related question.
> The spec listing (and listing of /var/tmp/rpm-tmp.36085) is below.
>
> When I try to build an RPM from this spec, I get the following:
>
> [root@mddinstall SW_EMAIL_GW]# rpmbuild -ba /usr/src/redhat/SPECS/

First of all, especially if you trying to learn such things
and experiment (but stupid mistakes may happen any time), you are not
ever, ever, do such things as root. A single typo and you will
have a long restoration job ahead of you. Start from this on
your own account (assuming that /usr/src/redhat/ is reasonably clean
without tons of leftovers and BUILD and forget about it for the future
except as a template).

mkdir -p $HOME/src/rpmlearn
( cd $(rpm --eval %_topdir) && find . -type d | cpio -pmd $HOME/src/rpmlearn )

Now put into $HOME/.rpmmacros

%_topdir %(echo $HOME)/src/rpmlearn

and you are ready to go in much saner way. You can check results
looking at an output of 'rpm --showrc' but if
'rpm --eval %_specdir' expands now to your freshly minted private
location then everything is ok. Of course, now if you will "install"
any source rpm it will unpack below your own %_topdir (and locations
and names of that are entirely up to you).

>
> My question is:
> How can I instruct the rpmbuild command not to do the cd /tmp/
> test-4.7.0.0.99/output/BUILD before the execution of the %prep
> stanza ?

By not trying to fight spec file.

> Source1: ${RPM_BUILD_ROOT}/data/comverse/scripts/cksum.pl
> Source2: ${RPM_BUILD_ROOT}/data/comverse/scripts/gw.csv
> Source3: ${RPM_BUILD_ROOT}/data/comverse/scripts/build_rpms_devel_generic.pl

This does not make a shred of a sense. Just list names of files you
put into your SOURCES (more precisely, in %_sourcedir). Macros like
%{SOURCE1} expand to full path name of those.

>
> %prep
>
> echo executing: %%prep
> %__rm -rf $RPM_BUILD_ROOT
> %__mkdir_p $RPM_BUILD_ROOT
> pushd $RPM_BUILD_ROOT && /bin/tar -jxvf /tmp/test-4.7.0.0.99/output/
> SOURCES/test-4.7.0.0.99.tar.bz2 && popd

$RPM_BUILD_ROOT is a location in which you are building your complete
installation tree as it will be used later on when installing ready
binary rpm. So you do not touch that at all in any section but,
possibly, %install. So the above is just plain wrong. Even if you
would manage to force some work to be done there then the first
thing which %install should do will be
rm -rf ${RPM_BUILD_ROOT}
and everything will be gone.

You are definitely not doing a %build work there which operates
in %_builddir.

Take a few working spec files, and start with some very simple ones,
and try to see how things are executed where you are using those.
That will probably do much better that trying to explain things here.
Also a pretty detailed documentation can be found at
http://docs.fedoraproject.org/drafts/rpm-guide-en/

Michal
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> PRM - Partner Relationship Management All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum