Koozali.org: home of the SME Server
Contribs.org Forums => Development => Topic started by: Xavier.A on June 18, 2015, 04:00:47 PM
-
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 :
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 :
- BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) (https://github.com/evilensky/avalon-packaging/blob/master/SPECS/tomcat-native.spec)
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:
- BuildRoot: /var/tmp/%{name}-buildroot (http://wiki.contribs.org/Building_RPMs)
- BuildRoot: /var/tmp/%{name}-%{version} (http://wiki.contribs.org/Web_Application_RPM)
- BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot (http://wiki.contribs.org/.spec_file_notes#BuildRoot:_.2Fvar.2Ftmp.2F.25.7Bname.7D-.25.7Bversion.7D-.25.7Brelease.7D-buildroot)
- BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot (http://wiki.contribs.org/RPM_Macros)
- (RPM MAcro) %{buildroot} %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch} (http://wiki.contribs.org/Rpm_build_example_using_cvs/mock)
but RpmLint doesn't like it:
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
-
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
-
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.
-
FYI: https://en.wiktionary.org/wiki/TMTOWTDI ;-)
-
:lol:
-
You make me smile charlie ;)
-
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):
%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
-
This build root seems to be the standard :
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
XA