- The initial error messages you posted where not complete. Sure the line you posted contains the error, but in troubleshooting it is often "better" (easier, more efficient) to provide any lines before and after the error line for troubleshooting purposes.
- Building as root?
Quote:
Originally Posted by ukbhan
RPM_BUILD_DIR="/usr/src/redhat/BUILD"
(..)cd /usr/src/redhat/BUILD
|
The /usr/src/redhat tree is only used by the root account user to build RPMs. You should not use the root account for testing and building RPMs but an unprivileged user account.
- Conventions
Quote:
Originally Posted by ukbhan
install ./test
|
In the %install section of the .spec file a Makefile is expected when handling a "default" packaging process. If there is no Makefile then you can use 'cp', but it is better (easier, more efficient) to use 'install'.
- Conventions
A RPM should not execute processes trivially during install. Running 'test', when not explicitly advertised, is unexpcted behaviour that could compromise the trust we put in RPM. Besides that the name 'test' could lead to unexpected results since on default installation there already is a 'test' binary (see '[', ']', 'test').
- Spec file. Unless you cut off your file contents, your .spec file is not complete (and please use BB code next time).
Your .spec file could look like this, note I used RPM-style %{formatting}:
Code:
Name: test
Version: 1
Release: 1
Summary: %{name} prints hello world
Group: Utilities/System # See /usr/share/docs/rpm-*/GROUPS
License: GPL
Source: $RPM_SOURCE_DIR/%{name}.c
BuildRoot: %{_tmppath}/%{name}-%{version}
Provides: %{name}
%description
This package contains a "hello world" example binary.
# or %setup if a tarball
%prep # This preps dir $RPM_BUILD_DIR/%{name}-%{version}.%{release}/.
# We're in the BuildRoot now. Make certain:
cd $RPM_BUILD_DIR/%{name}-%{version}.%{release}/
# Copy files in that aren't packaged:
cp $RPM_SOURCE_DIR/%{name}.c .
%build
gcc -o %{name} %{name}.c
%install
# Create dirs leading up to if necessary:
[ -d /usr/local/bin ] || mkdir -p /usr/local/bin
install -m 0755 ./test $RPM_BUILD_ROOT/usr/local/bin
%clean
[ "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}-%{version}" ] && rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%attr(755,root,root) /usr/local/bin/%{name}
%changelog
* Wed June 10 2008 %{packager}
- Initialise .spec file for %{name}-%{ver}.
Before you use your unprivileged user account to build RPMs perform the next three steps to set up the environment:
0. Create a file "/home/uday_koganti/.rpmmacros" with minimally the following contents:
Code:
%_topdir /home/uday_koganti/redhat
%_tmppath %{_topdir}/tmp
%fname %{name}-%{version}.%{release}
%_builddir %{_topdir}/BUILD
%_rpmdir %{_topdir}/RPMS
%_sourcedir %{_topdir}/SOURCES
%_specdir %{_topdir}/SPECS
%_srcrpmdir %{_topdir}/SRPMS
%distribution none
%vendor none
1. Then create the necessary directories with: 'mkdir -p /home/uday_koganti/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}'
2. Place your "test.c" in /home/uday_koganti/redhat/SOURCES and your "test.spec" in /home/uday_koganti/redhat/SPECS.