Rpmbuildupdate

From Mandriva Community Wiki

Jump to: navigation, search
rpmbuildupdate

Contents


[edit] Description

rpmbuildupdate is a tool from the rpm-rebuilder package ( rpmbuildupdate for Mandriva 2007 and later) to automatically rebuild a new version of a package downloading automatically the source files.

[edit] Typical use

This command will download the 1.2.10 version of xmms, modify the spec file (new version, release 1mdk, changelog entry) and rebuild the new package.

$ rpmbuildupdate /SRPMS/main/xmms-1.2.9-5mdk.src.rpm 1.2.10
...

If the patch stage fails, the tool will only generate the src.rpm for manual correction. This way nothing is lost. rpmbuildupdate takes the value defined in your .rpmmacro file, with rpm --eval '%packager'. If this is not set, the $EMAIL shell variable is used. With cvs version 1.33, you can give a spec or an src.rpm without any argument.

[edit] Advanced use

The --execute 'command' option allows to execute an arbitrary perl command on each line of the spec file, as if using perl -pi -e 'command' rpm.spec. For example, just to make a pure-perl package depend on perl-devel only before mandrake 10.0, try:

$ rpmbuildupdate --execute 's/^BuildRequires:\s+perl-devel\n$/%if %{mdkversion} \
< 1010\nBuildrequires:\tperl-devel\n\%endif\n/i' --changelog '- fix buildrequires' perl-Acme-Cow

The bash completion allows to automatically complete on src packages found in configured directories:

$ rpmbuildupdate perl-<TAB>
Display all 526 possibilities? (y or n)

The --execafterbuild 'command' ( cvs 1.45 ) will run a shell command, passing the src.rpm as first parameter, followed by the binary rpm. You can use it to upload your package, or to copy it in a place for reviewing it. You can also place it in the config file.

[edit] Configuration file

Rpmbuildupdate ( since cvs 1.28 ) uses 2 configuration files: a user one ( ~/.rpmbuildupdaterc ) and a system one ( /etc/rpmbuildupdate.conf ). They have the same syntax :

option = "value"

The values are the same as the command line option.

One option that is interesting to set is srpm :

[misc@n1 misc] $ cat .rpmbuildupdate.conf
srpms = "/SRPMS/contrib/,/SRPMS/main/"

With it, you can simply give the name of the rpm to rebuild it :

[misc@n1 misc] $ rpmbuildupdate.cvs --log svk 0.21
Logs are in /home/misc/rpm/log/svk-0.23-1mdk.src.rpm.log
===> Building svk 0.21

[misc@n1 misc] $

[edit] Special cases

rpmbuildupdate knows some magic about some URLs:

  • if the URL starts with ftp.redhat.com, it looks for the source in an rpm package of the same name.
  • if the URL contains sourceforge.net, it will try some known sourceforge mirrors.
  • if the URL contains ftp.gnome.org, it will add the version number in the form X.Y at the end of the path (before the file name).
  • if the url starts with svn://, it will automagically take a subversion snapshot
  • if the source is not a valid URL, rpmbuildupdate will try to use the URL tag, and even do some magic with it if this is a known software repository ( sourceforge, berlios, at the moment )

If you need other special cases, just contact Frederic Lepied, or Michael Scherer.

And in all cases, it will try to download a .tar.bz2 file in this order until it succeeds:

  1. the original file
  2. the file ended with .tar.gz and then bzip it
  3. the file ended with .tgz and then bzip it
  4. the file ended with .zip and then bzip it

[edit] Subversion snapshot

In order to use a subversion snapshot, several conditions should be filled. First, you need to have the tools used to grab a subversion repository (Subversion)

Source should reflect the path to subversion :

Source0:    svn://svn.collab.net/repos/cvs2svn/trunk/%{name}-%{version}.tar.bz2

The last part is stripped, so the real path is svn.collab.net/repos/cvs2svn/trunk/. svn is replaced by http, and you may use svns for svn over https.

The versioning should be something like :

%define version 0.rev912

The revision part is important, since it is the version number that should be given to rpmbuildupdate. The rpm should be named %{name}-{version}-%{release} as usual, but it is mandatory that %{version} end by rev1234, for revision 1234 of the svn repository. Then you can invoke with

~/soft/rpm-rebuilder/rpmbuildupdate --src ../SRPMS/cvs2svn-0.rev914-1mdk.src.rpm 0.rev915

to grab the revision 915.

This feature is still experimental, please report bugs to misc@mandriva.org. See cvs2svn package for an example of usage.

[edit] Availability

rpmbuildupdate is available from mdk cvs

[edit] Integration with Distro Specific Release Tag

In order to use the %mkrel macro, you need to either use it like this :

%define release %mkrel   X
...
Release:  %release

or define %rel and use it as argument to mkrel :

%define rel X
%define release %mkrel  %rel
...
Release:  %release

Or even directly :

Release: %mkrel X 

rpmbuildupdate will  :

  • increment the value defined for %rel
  • increment a number following %mkrel

Other methods are too complex to be added. This was added in cvs version 1.48.

[edit] BuildRequires installation

Since version 1.60 of the cvs, rpmbuildupdate can use a script to install automatically the BuildRequires of a package.

You need first to write a script, something like this in ~/bin/install_rpm.sh :

#!/bin/bash
sudo /usr/bin/rurpmi --auto --no-remove $@

Then, add this to your config file ( ~/.rpmbuildupdaterc ) :

installbuildrequires = "~/bin/install_rpm.sh"

and now, rpmbuildupdate will run the script before the build with all rpms listed as BuildRequires as parameter .

[edit] Still to do

  • CVS and Arch integration
  • More url autodetection

[edit] Code snippet

[edit] %mkrel addition

add this to the config file :

execute = "$message .= "\n- use mkrel" if s/(%define\s+release)\s+(\d+)mdk/$1 %mkrel $2/ or s/(Release:)\s+(\d+)mdk/$1 %mkrel $2/"

This will add %mkrel on rebuild.

[edit] Perl empty dir removal

Perl create arch package even when empty. Use a line of code like this :

rpmbuildupdate --nodownload --changelog '- Do not ship empty dir' \
--execute 's|makeinstall_std|makeinstall_std\nrm -rf \$RPM_BUILD_ROOT/\%{perl_vendorarch}|' perl-Net-Rendezvous-Publish-Backend-Howl

[edit] Python new macro migration

In order to replace the old incorrect macro by the new one, this command was used (Note the use of "our" to declare the variable):

rpmbuildupdate.cvs --nodownload --changelog '- Use new python macro' \
--execute 'our $arch||="plat"; /^BuildArch.'':\s'''noarch.''$/ and $arch="pure"; s+%{?''libdir}?/\
python(%{?pyver}?|\''')/site-packages/+%py''${arch}sitedir/+'  python-gobject
Personal tools
Ad (via La Vignette)
Looking for a job?