LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Mandriva (https://www.linuxquestions.org/questions/mandriva-30/)
-   -   anyone making rpm's from source (.src and .tar.gz/bz2) (https://www.linuxquestions.org/questions/mandriva-30/anyone-making-rpms-from-source-src-and-tar-gz-bz2-777646/)

GlennsPref 12-23-2009 04:38 AM

anyone making rpm's from source (.src and .tar.gz/bz2)
 
Hi, the moniker says it all really, does anyone here build rpm packages from it's source.

If so, I'd be interested in reading more about it.

There are somany programs out there in the OSS world, but rather difficult to keep track of through the various package managers.

Any thoughts welcome, any news on the kde4 mandriva packger.
I mean the dev/person who builds rpms from the kde4 source for x86_64 as well as i586

I'm mostly interested in x86_64.

thanks, happy holidays everyone!

Regards Glenn

kbp 12-23-2009 04:02 PM

Hey Glenn,

I do a bit of packaging, did you have any specific questions or just looking for a general intro/howto ?

cheers

GlennsPref 12-23-2009 05:34 PM

Hi, thanks for the reply.

Yes, I'm interested in a howto, but the rpm-build tutes I have read are old or incomplete.

I've been using GNU/Linux for a while now(since 2001) and I want to sort out some things

Like avoiding "dependency-hell" and the bloat associated with gtk+ vs Qt (cute), and i586 vs x86_64.

If you know of a starting point, please share it with me. I intend to contribute to OSS by way of packaging.

I have done (barely passed) 3 programming courses (Pascal, java, c+, and objC), but I am by no means a programmer.

The last time I checked was a few years ago, about building rpm's from source.

I am interested in getting to a point where I may contribute to the repos, but that may take a while.

Thank you, regards Glenn

kbp 12-23-2009 06:36 PM

The shortest method to getting started :-

Code:

$ sudo yum install rpm-build rpmdevtools rpmlint
...
$ rpmdev-setuptree

This will create the directory ~/rpmbuild with several subdirs:
- SPECS ( spec files go here )
- SOURCES ( tar.gz etc go here )
- BUILD ( temp dir for unpacking/patching sources )
- RPMS ( finished packages will be under here in arch specific subdirs )
- SRPMS ( if you opt to build src.rpm's they will be under here )

The rpmdevtools package provides several spec file templates:
/etc/rpmdevtools/spectemplate-R.spec
/etc/rpmdevtools/spectemplate-dummy.spec
/etc/rpmdevtools/spectemplate-lib.spec
/etc/rpmdevtools/spectemplate-minimal.spec
/etc/rpmdevtools/spectemplate-ocaml.spec
/etc/rpmdevtools/spectemplate-perl.spec
/etc/rpmdevtools/spectemplate-php-pear.spec
/etc/rpmdevtools/spectemplate-python.spec
/etc/rpmdevtools/spectemplate-ruby.spec

The minimal template is ideal for generating an rpm from a 'configure/make/make install' type tarball, on Fedora this is the default.

Code:

cd ~/rpmbuild
cp /path/to/myapp-1.0.0.tar.gz SOURCES/
vi SPECS/myapp.spec

.. should open a new file based on the minimal template. Simply supply the missing details.

Name, Version and Summary - pretty straight forward
Group - find a matching category in /usr/share/doc/rpm-xxx/GROUPS
License, URL - pretty straight forward
Source0 - I usually use %{name}-%{version}.tar.gz, make sure that myapp-1.0.0.tar.gz is named accordingly

BuildRequires - what the package needs to compile, comma separated ( gcc, make, ... )
Requires - what the package depends on to function, comma separated
Description - pretty straight forward

skip down to the %files section, you will need to add all the files that the package will provide, you can specify a directory to include all files under it

eg.
Code:

%files
%defattr(-,root,root,-)
/opt/myapp
/etc/rc.d/init.d/myapp

The %defattr macro determines the default permissions and ownership for all files. When building an rpm where the source has a makefile, the file permissions are most likely already correct. If you need to override them just modify like so:

Code:

%files
%defattr(-,root,root,-)
/opt/myapp
%attr(755,root,root) /etc/rc.d/init.d/myapp

The %doc directive works well when your source has documentation in it's root dir, it will place the files under /usr/share/doc/myapp-1.0.0/.

eg.
Code:

%doc CHANGES
%doc INSTALL

Add an entry to the %changelog section like so: (taken from initscripts.spec)
Code:

* Fri Feb 07 1997 Erik Troan <ewt@redhat.com>
- Added usernetctl wrapper for user mode ifup and ifdown's and man page
- Rewrote ppp and slip kill and retry code
- Added doexec and man page

Save your spec file and exit vi.

First build attempt:
Code:

rpmbuild -ba SPECS/myapp.spec
If all goes well, it should tell you that it has written 2 files, a src.rpm and an .rpm

You can run 'rpmbuild -b?' to only perform specific sections ( helps when troubleshooting), please see the man page.

Once you have a successful build try running rpmlint:

Code:

rpmlint SPECS/myapp.spec
Take the output with a grain of salt, but sometimes it helps.

If you're having trouble it can also help to download someone else's src.rpm, install it and take a look at their spec file


Hope this helps, my fingers are worn out

cheers

GlennsPref 12-23-2009 07:20 PM

Thanks heaps for the effort! ;)

I shall begin, but first I'll have to deal with my family (that time of year)

But I'll post back in a day or so with feedback and questions, if I have any.

Thanks heaps.

Regards Glenn

jkerr82508 12-23-2009 09:06 PM

This may help (it includes information that may be specific to Mandriva):

http://wiki.mandriva.com/en/Mandriva_RPM_HOWTO

Jim

GlennsPref 12-24-2009 06:12 AM

Thank you sir.

Happy holidays!

kind regards Glenn

knudfl 12-25-2009 06:48 AM

rpmbuild
 
1 Attachment(s)
A couple of good links ( I think.)

http://docs.fedoraproject.org/drafts...specfiles.html
http://docs.fedoraproject.org/drafts...n/ch09s05.html
http://docs.fedoraproject.org/drafts...html#id2972829
.....

http://www.rpm.org/max-rpm-snapshot/index.html
http://www.rpm.org/max-rpm/s1-rpm-bu...spec-file.html
http://www.rpm.org/max-rpm-snapshot/...b-command.html
.....

A "beginners" example spec file is attached .. .. and it works OK ..
.....

GlennsPref 12-25-2009 06:39 PM

Thank you, I have some (quite a bit of...) reading to do, Thanks for the .txt, I does help.

please excuse me for not responding (yet).

I appreciate your support.

cheers, Glenn

GlennsPref 12-26-2009 08:21 PM

Hi kbp, I'm working through the example above,

this spec part,
Quote:

Code:

cd ~/rpmbuild
cp /path/to/myapp-1.0.0.tar.gz SOURCES/
vi SPECS/myapp.spec

do I need to unpack the .tar.bz2, first?

The point I'm at is that the spec file is created, empty. Have I missed linking the templates?
Quote:

should open a new file based on the minimal template. Simply supply the missing details.
Code:

cd ~/rpmbuild

glenn@GamesBox:~/rpmbuild$ vi /home/glenn/rpmbuild/SPECS/kdelibs.spec

The install of the packages for setup seem to have worked.
Code:

glenn@GamesBox:~/rpmbuild$ ls /etc/rpmdevtools/
newspec.conf            spectemplate-minimal.spec  spectemplate-python.spec
rmdevelrpms.conf        spectemplate-ocaml.spec    spectemplate-ruby.spec
spectemplate-fonts.spec  spectemplate-perl.spec
spectemplate-lib.spec    spectemplate-php-pear.spec

I have copied the sources to ...
Code:

glenn@GamesBox:~/rpmbuild$ ls /home/glenn/rpmbuild/SOURCES                      (27-12 12:16)
kdeaccessibility-4.3.4.tar.bz2  kdelibs-experimental-4.3.4.tar.bz2
kdeadmin-4.3.4.tar.bz2          kdemultimedia-4.3.4.tar.bz2
kdeartwork-4.3.4.tar.bz2        kdenetwork-4.3.4.tar.bz2
kdebase-4.3.4.tar.bz2            kdepim-4.3.4.tar.bz2
kdebase-runtime-4.3.4.tar.bz2    kdepimlibs-4.3.4.tar.bz2
kdebase-workspace-4.3.4.tar.bz2  kdepim-runtime-4.3.4.tar.bz2
kdebindings-4.3.4.tar.bz2        kdeplasma-addons-4.3.4.tar.bz2
kdeedu-4.3.4.tar.bz2            kdesdk-4.3.4.tar.bz2
kdegames-4.3.4.tar.bz2          kdetoys-4.3.4.tar.bz2
kdegraphics-4.3.4.tar.bz2        kdeutils-4.3.4.tar.bz2
kde-l10n-en_GB-4.3.4.tar.bz2    kdewebdev-4.3.4.tar.bz2
kdelibs-4.3.4.tar.bz2            oxygen-icons-4.3.4.tar.bz2

I feel I have missed a step, and no, I have not read all the links here yet.

Your assistance is appreciated.

Regards Glenn

kbp 12-27-2009 01:30 AM

Hey mate,

No, you don't need to unpack the tarball, rpmbuild will do that for you.

Maybe there's a difference between the Fedora rpmdevtools package and the Mandriva one, as a workaround just copy the minimal template into the SPECS dir and rename it.
I'll do a bit of digging and see if I can work out what the difference is...

Other than that you're on track

cheers

GlennsPref 12-27-2009 02:47 AM

OK, I see. that should work.

cheers, Glenn

DrLove73 12-27-2009 03:12 AM

Best practice to learn how to compile and create is to unpack packages with similar structure or same package from another distribution, unpack it and check it's spec file. That is how I started a year ago. Since then I recompiled about 30 package packs from Fedora to CentOS and created several mine own based on the source. use http://rpm.pbone.net to search for what you need. Look for a binary package you want and on it's page should be a link to src package.

GlennsPref 12-27-2009 04:18 AM

Hi DrLove73, That is what I am doing, I realise where the lists are, but for this version of kde (4.3.4), there is no ref on pbone for this version (only 4.3.85).

and the list is quite long.

urpmi gives me some details, but for older versions. (4.3.2, the version I have installed.)

Bit of a guessing game, but this is not severe, or crucial, It's just time, and I don't mind.

Plenty of disk-space and time.

Thank you for the tips.

Much appreciated, regards Glenn

ps, it's just setting up the spec file atm, I've compiled from source many, many times.

GlennsPref 12-27-2009 04:31 AM

To be sure, here is what the default minimal-spec file gives me before edit.
/etc/rpmdevtools/spectemplate-minimal.spec
Code:

Name:         
Version:       
Release:        1%{?dist}
Summary:       

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

BuildRequires: 
Requires:     

%description


%prep
%setup -q


%build
%configure
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc



%changelog



All times are GMT -5. The time now is 04:44 AM.