Author Topic: High level help with my first package  (Read 1209 times)

Offline Artthou

  • Full Member
  • ***
  • Posts: 65
High level help with my first package
« on: October 18, 2009, 06:08:26 PM »
Hey all,

I am pretty close on my first attempt at making RPMs for tintin++ using the HOW-TO as my guide. 

When I run the
Code: [Select]
rpm -ba tintin.spec
It compiles okay, but tries to copy the executable to /usr/bin, and failing since I am not root, seems to exit without making any RPMs.

The man page for rpm doesn't describe -ba option, and on my redhat machines at work, it is rpmbuild for that step.

Why does it try to install it when all I want to do is create the RPMs?

What I expected was to have both RPMs made, and then test them for the install step.

I still have a patch to add, but wanted to get this much working first.

Here is my spec file:

Code: [Select]
%define name tintin
%define version 1.99.6
%define release %mkrel 1

Summary: tintin++ is a console based MUD client
Name: %name
Version: %version
Release: %release
License: GPL
Group: Applications
Source: %{name}-%{version}.tar.bz2
BuildRoot: %_tmppath/tt-buildroot
BuildRequires: glibc-headers-devel libpcre0-devel zlib1-devel
#Requires: tintin-update
URL: http://tintin.sourceforge.net/

%description
Cwallpaper is a GUI front end for wallpaper utilies such as xsetroot.

%prep
%setup -q -n tt/src

%build
%{configure} --prefix=%{_prefix}
%{__make} %{?_smp_mflags} %{?mflags}

%install
%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install

%clean
test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%files
%defattr(-, root, root)
%{_bindir}/tt
%{_datadir}/tt/*

%changelog
* Wed Oct 17 2009 Artthou <gregmilford at gmail.com> 1.99.6-1pclos
- rebuild for pclos2009

Thanks in advance for tips and lessons...this is new to me.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: High level help with my first package
« Reply #1 on: October 18, 2009, 10:00:00 PM »
You will find that there are differences in the way we do things from the way Red Hat does them. IMO, if they are not using -ba (build all), then they are missing something good.

Could you please post the exact error message you got? Knowing what it was will help us to help you to figure it out.

If you have a patch that needs to be added, go ahead and add it. Note that when you build all (-ba), you are building the SRPM (src.rpm) as well as the RPM(s) for the package. If your build is successful and the testing is a success, you will have the SRPM ready and will not need to go through the build process again.


Offline Artthou

  • Full Member
  • ***
  • Posts: 65
Re: High level help with my first package
« Reply #2 on: October 19, 2009, 05:20:43 AM »
Code: [Select]
gcc -Wall -Wno-trigraphs -I/usr/include -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fomit-frame-pointer -march=i586 -mtune=pentiumpro -fasynchronous-unwind-tables -D_GNU_SOURCE -DHAVE_CONFIG_H     -o tt++ action.o alias.o files.o help.o highlight.o strhash.o llist.o log.o main.o misc.o net.o parse.o path.o update.o history.o tab.o vt102.o terminal.o session.o function.o text.o substitute.o tick.o telopt.o math.o split.o debug.o tinexp.o mapper.o tables.o buffer.o prompt.o class.o  event.o utils.o chat.o macro.o  config.o gag.o variables.o array.o input.o cursor.o memory.o system.o line.o tokenize.o forkpty.o -L/usr/lib -lpcre -lutil -lnsl -lpthread -lz                                 
+ exit 0                                                                                                                                   
Executing(%install): /bin/sh -e /home/greg/src/tmp/rpm-tmp.77711                                                                           
+ umask 022                                                                                                                                 
+ cd /home/greg/src/rpm/BUILD                                                                                                               
+ cd tt/src                                                                                                                                 
+ '[' 1 -eq 1 ']'                                                                                                                           
+ /usr/bin/make DESTDIR=/home/greg/src/tmp/tt-buildroot install                                                                             
mkdir -p /usr/bin                                                                                                                           
cp tt++ /usr/bin                                                                                                                           
cp: cannot create regular file `/usr/bin/tt++': Permission denied                                                                           
make: *** [install] Error 1                                                                                                                 
error: Bad exit status from /home/greg/src/tmp/rpm-tmp.77711 (%install)                                                                     

Thanks for the reply.  It would seem with the 'build all' option if it includes installation, it would need to switch to root privs at some point.  The HOW-TO is pretty explicit about not becoming root for any of the steps.

I'll add the patch tonight after work...I wanted to pass along this output.

Regards,
Greg

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1318
Re: High level help with my first package
« Reply #3 on: October 19, 2009, 06:11:30 AM »
oh, no, the entire buildprocess is required to be run as normal user. Only in very (very) specific circumstances you need to be root.

I will recommend to use pkgutils for packaging - get it from synaptic. Right-click RPM's and SRPMS will then display buildoptions.

The build process that is happening when building all (ba) is the process:

1. Unpacks the file SOURCES to the BUILD directory that is in /home/yourlogin/src/rpm folder
2. Patch them if necessary
3. Compiles the sources in the BUILD folder. The program is then built in the BUILD folder
4. Installs the program. Not to your running filesystem, but to the safe BUILDROOT. It is normally in /home/yourlocin/src/tmp (you have permissions for this location)
5. Pack the files in BUILDROOT to RPM's. The RPM's will have the proper filelocations (ie. the buildprocess has removed your BUILDROOT part of the path)
6. Pack the files in SOURCES and the specfile to a SRPM file

What happens next is well known for the actual installation on a system: You just su to root and run apt-get install name-of-your-rpm.rpm and the package is installed

Test it thoroughly and ship it to contribs :-)


Well, the actual issue here, is that the install part of your build need a  patch to create the directory in BUILDROOT and not your actual running filesystem.

Code: [Select]
mkdir -p /usr/bin                                                                                                                          
cp tt++ /usr/bin                                                                                                                            
cp: cannot create regular file `/usr/bin/tt++': Permission denied                                                                          
make: *** [install] Error 1                                      

the mkdir need to create the folder in %buildroot/usr/bin

You have made the proper settings for installation in BUILDROOT, this is why I belive you need to create a patch for this (or google around a bit)

cheers,
MBantz
« Last Edit: October 19, 2009, 06:28:45 AM by MBantz »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15829
  • LXDE! Coffee, Bacon and Cheesecake!
Re: High level help with my first package
« Reply #4 on: October 19, 2009, 06:24:08 AM »
Quote from: Artthou
.....It would seem with the 'build all' option if it includes installation, it would need to switch to root privs at some point.  The HOW-TO is pretty explicit about not becoming root for any of the steps.

Build all does not include installation. That is not in the documentation nor was it said or implied here.
As MBantz said, there is no need to build as root. Installation must be done as root but not packaging.

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

Have a look in the app's configure and make files for more information on its build and check its install file, if there is one. Tar.bz2 / tar.gz can be viewed in konqueror.

« Last Edit: October 19, 2009, 06:30:50 AM by Neal »

Offline Artthou

  • Full Member
  • ***
  • Posts: 65
Re: High level help with my first package
« Reply #5 on: October 19, 2009, 07:32:48 AM »
Thanks for the replies.

There was no SRPM to start with for this software, so I started with the example spec from the HOW-TO.  I did install the pkgutils, which helped me get everything set up, but yes I need to get to know those options better.

When I unpack the source, change into the src directory, and do ./configure and then make, it builds and does not try to install.  So it seems like my spec file is having it do a 'make install' even when I am just doing 'rpm -ba <specfile>' (utilizing the %install section)

Code: [Select]
%install
%{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install

It looks like the DESTDIR is not being used by the makefile, so that is probably what I need to patch.

If I were to patch the makefile to have it install to %buildroot/usr/bin as MBantz suggests, then is %buildroot empty when the RPM is installed normally and as such the executable is installed to '/usr/bin'?

I'll try a few things out when I get home tonight.  Thanks for helping me understand the process.

Greg
« Last Edit: October 19, 2009, 07:45:11 AM by Artthou »

Offline MBantz

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1318
Re: High level help with my first package
« Reply #6 on: October 19, 2009, 10:07:27 AM »
Yes, the 'build-all' IS installing, but NOT to your running filesystem but to %buildroot. The -ba is the final command when building, it builds both rpm and srpm.

The "make install" command in your specfile is the line: %{__make} %{?mflags_install} DESTDIR=$RPM_BUILD_ROOT install

You are correct that the DESTDIR is not picked up in the install part.

Eventually try just:

make DESTDIR=$RPM_BUILD_ROOT install   

you could also try and build and install it manually in the BUILD folder - sometimes this give directions to where things go wrong - also inspecting the makefile of course,

to manually build it you just:
Code: [Select]
./configure
make
make install

cheers,
MBantz

Offline Artthou

  • Full Member
  • ***
  • Posts: 65
Re: High level help with my first package
« Reply #7 on: October 20, 2009, 05:59:36 AM »
Thanks for the help everyone.  I uploaded my first SRPM to the dropbox:

tintin-1.99.6-1pclos2010.src.rpm

All critique and feedback is welcome.  The spec file is pretty much from scratch (starting with an example from the howto)

Cheers,
Greg