rpm-software-management / tito

A tool for managing rpm based git projects.
GNU General Public License v2.0
377 stars 128 forks source link

tito build --rpm should offer auto-install for BuildRequires #31

Open mccun934 opened 12 years ago

mccun934 commented 12 years ago

Turn the below errors into a 'yum install' command would be very very handy

 # tito build --rpm --test
Building package [katello-0.1.150-1]
Wrote: /tmp/tito/katello-git-4.188b416.tar.gz

 ########## ERROR ############
Error running command: LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5"  --define "_binary_filedigest_algorithm md5"  --define "_sourcedir /tmp/tito/rpmbuild-katello-188b41664ed516b12c5d5c5068a6c2d2b131b384/SOURCES" --define "_builddir /tmp/tito/rpmbuild-katello-188b41664ed516b12c5d5c5068a6c2d2b131b384/BUILD" --define "_srcrpmdir /tmp/tito" --define "_rpmdir /tmp/tito"   --clean -ba /tmp/tito/rpmbuild-katello-188b41664ed516b12c5d5c5068a6c2d2b131b384/SOURCES/katello-git-4.188b416/katello.spec
Status code: 256
Command output: error: Failed build dependencies:
    rubygems is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem-rake is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem(gettext) is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem(jammit) is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem(chunky_png) is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem(fssm) >= 0.2.7 is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem(compass) >= 0.11.5 is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
    rubygem(compass-960-plugin) >= 0.10.4 is needed by katello-0.1.150-1.git.4.188b416.fc15.noarch
mccun934 commented 12 years ago

easy workaround for this is:

 # tito build --rpm --test 2>&1 | grep "is needed" | awk '{print $1}' | xargs yum install -y 
jmrodri commented 12 years ago

At the point that occurs rpmbuild is the one spitting out that dependencies are required. One thought is to look at the BuildRequires in the spec and see if they are already installed. But unsure if there are edge cases where this won't work, say if the BuildRequires is one of the packages that isn't really installed but PROVIDES a dependency. Maybe that might be the approach see what provides the BuildRequires and if something comes back as not providing it, we do the yum install of it? Though I'd like to make this driven by a CLI arg tito build --test --install-deps --rpm

jmrodri commented 12 years ago

Something like this:

$ rpm -q --whatprovides selinux-policy-doc
no package provides selinux-policy-doc
$ echo $?
1

$ rpm -q --whatprovides python
python-2.7.1-7.fc15.x86_64
$ echo $?
0
xsuchy commented 11 years ago

This will install missing dependencies:

yum-builddep $( LC_ALL=C tito build --srpm | awk '/Wrote:.*.src.rpm/ { print $2; }' )
xsuchy commented 11 years ago

Hmm it can be shorten even to: yum-builddep *.spec

jumanjiman commented 11 years ago

personally i like the idea of tito offering a hint to run yum-builddep <name>.spec, but i'm not so fond of tito automatically running a command that needs escalated privileges

jmrodri commented 11 years ago

How about we do the automatic install ONLY when the -i is passed into to the --rpm command? That option already requires escalated privileges. When the -i is absent we printout the command so user know what to do.

jumanjiman commented 11 years ago

:+1: (along with an updated comment at https://github.com/dgoodwin/tito/blob/master/src/tito/cli.py#L319-320)

xsuchy commented 11 years ago

See https://github.com/dgoodwin/tito/pull/69

jumanjiman commented 10 years ago

sadly, the yum-builddep command doesn't work on spec files in el5. see https://github.com/dgoodwin/tito/pull/135

ringerc commented 9 years ago

Doesn't mock take care of this anyway?

jflorian commented 9 years ago

I believe I'm running into this issue and am utterly confused by much of the comments here. I thought the whole point of having BuildRequires in your spec was so that the build system would automatically install those packages into your otherwise sterile build root. The mock tool has the --installdeps option, so why doesn't tito's MockBuilder use that option? Or am I overlooking some other point?

Err, wait. I'm getting this with tito.builder.Builder and perhaps not with MockBuilder. I think that explains my confusion.