Koozali.org: home of the SME Server

RPM - What is the canonical BuildRroot for SME Server's RPM in spec file?

Offline Xavier.A

  • ***
  • 104
  • +0/-0
Hi all,

I try to find the best way or the more secure build root for making RPM.

For the moment, in my spec file, i'm using :
  • BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-XXXXXX)
  • BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

like in debian with dh_make for the debian/control file, we can use rpmdev-newspec to create the spec file and the resulting Buildroot is :
Code: [Select]
cd $HOME/home/workspace/RPM/tomcat-native/SPECS
rpmdev-newspec tomcat-native
clear ; more tomcat-native.spec
no Buildroot tag in the minimal template of rpmdev-newspec  :?

In online spec files :

In the SME Server spec files, often we can read
  • BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot

It Is coherent with what we can read in the wiki:

but RpmLint doesn't like it:
Code: [Select]
A path is hardcoded in your Buildroot tag. It should be replaced by something
like %{_tmppath}/%name-root.

then what is the best or the more secure BuildRoot tag definition?


XA
« Last Edit: June 18, 2015, 07:19:53 PM by Xavier.A »
“When the wise man points to the moon, the fool looks at the finger.”

Online ReetP

  • *
  • 3,722
  • +5/-0
From a sample spec file smeserver-geoip.spec I have

BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot

I assume mock makes its own decision where to put the built RPMs

I originally followed (and rewrote some of) this howto  and it is exactly how my build box is set up :

http://wiki.contribs.org/Setting_up_RPM_Building_for_SME_Server

I really haven't got much of a clue about what I am doing but can successfully build packages :-)

The first section explains straight forward builds and they end up in /var/lib/mock/$CONFIG/result

(Just added a note on creating your build directories.)

This should use the SME build environment to create your RPMs. An example is nagios which I built from source.

nagios.spec contained the following
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

I then did :
 rpmbuild --bs /home/john/rpmbuild/SPECS/nagios.spec
 mock -r /etc/mock/epel-6-x86_64.cfg rebuild /home/john/rpmbuild/SRPMS/nagios-4.1.0rc1-2.el6.src.rpm

(you can vary the build environment - that is just an example)

If you then use CVS and mock build they will lend up in in the cvs folders in the correct version

Just :

make prep
make clean
make mockbuild

HTH

B. Rgds
John
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
From a sample spec file smeserver-geoip.spec I have

BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot

I assume mock makes its own decision where to put the built RPMs

The BuildRoot has nothing to do with where built RPMs are put. It's a marshalling area used during the process of building RPMs.

Xavier's suggestiong of:

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

(from an on-line tomcat example), is a good one - including uid means that on a multi-user build machine, different users can build the same rpm at the same time without problems. None of this matters if mock is being used, as mock creates its own isolated namespace.

As to the Subject of this thread - I don't think there needs to be a canonical BuildRoot. TMTOWTDI.


Online ReetP

  • *
  • 3,722
  • +5/-0
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline stephdl

  • *
  • 1,519
  • +0/-0
    • Linux et Geekeries
You make me smile charlie ;)
See http://wiki.contribs.org/Koozali_Foundation
irc : Freenode #sme_server #sme-fr

!!! Please write your knowledge to the Wiki !!!

Offline Xavier.A

  • ***
  • 104
  • +0/-0
tomcat-native-1.1.33-1.el6.x86_64.rpm  and tomcat-native-devel-1.1.33-1.el6.x86_64.rpm are built  and the spec file contains (for the exemple):
Code: [Select]
%define tcnver 1

Name: tomcat-native
Version: 1.1.33
Release: 1%{?dist}.%{distsuffix}
Summary: Tomcat Native Java library
Packager: %{packager}
Vendor: %{vendor}
Distribution: %{distribution}

Group: System Environment/Libraries
License: Apache Software License
URL: http://apr.apache.org/
Source0: http://www.apache.org/dist/tomcat/tomcat-connectors/native/%{version}/source/%{name}-%{version}-src.tar.gz 

BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: x86_64

BuildRequires: apr-devel
BuildRequires: openssl-devel >= 1.0.1

Provides: tcnative = %{version}-%{release}
Provides: tomcat-native = %{version}-%{release}

%description
The mission of the Tomcat Native Library (TCN) is to provide a
free library of C data structures and routines.  This library
contains additional utility interfaces for Java.

%package devel
Group: Development/Libraries
Summary: Tomcat Native development kit
Requires: tcnative = %{version}-%{release}
Requires: apr-devel
Requires: openssl-devel >= 1.0.1

%description devel
The mission of the Tomcat Native Library (TCN) is to provide a
free library of C data structures and routines.  This library
contains additional utility interfaces for Java.

%prep
%setup -q -n %{name}-%{version}-src

%build
cd jni/native
%configure --with-apr=%{_bindir}/apr-1-config \
 --with-java-home=%{java_home} \
 --with-ssl=yes

make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
cd jni/native
make install DESTDIR=$RPM_BUILD_ROOT

# Unpackaged files
rm -f $RPM_BUILD_ROOT%{_libdir}/tcnative.exp


%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc CHANGELOG.txt LICENSE NOTICE README.txt TODO.txt
%{_libdir}/libtcnative-%{tcnver}.so.*

%files devel
%defattr(-,root,root,-)
%doc jni/docs
%{_libdir}/libtcnative-%{tcnver}.*a
%{_libdir}/libtcnative-%{tcnver}.so
%{_libdir}/pkgconfig/tcnative-%{tcnver}.pc

These RPM are not only for SME Server but they are necessary for the future contribs. They will be available soon ;-)

Thanks to all !

XA
“When the wise man points to the moon, the fool looks at the finger.”

Offline Xavier.A

  • ***
  • 104
  • +0/-0
This build root seems to be the standard :
Code: [Select]
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

XA
“When the wise man points to the moon, the fool looks at the finger.”