I am looking for a way to have yum install only dependencies for a given package, something like an --prepare-for-install option so I can take a snapshot of the prepared system and test the rpm setup with different options or rebuilds of the package itself on a clean system without having to rely on the rpm uninstall and without downloading the dependencies each time.
-
1You want to not install the package? That doesn't make a whole lot of sense. What are you really trying to do?– Michael HamptonSep 17, 2012 at 16:27
-
1Hi @Michael, the purpose of not installing the package seems clear to me from the text: preparing a system for package testing.– a1anSep 17, 2012 at 21:02
-
Right, that's why it doesn't make any sense.– Michael HamptonSep 17, 2012 at 21:34
-
1Letting aside the constructiveness of discussing what makes sense to whom, how do you test the rpm you develop then?– a1anSep 18, 2012 at 7:56
Add a comment
|
3 Answers
This might be really dumb but it should work.
PACKAGE=awstats
yum deplist $PACKAGE | grep provider | awk '{print $2}' | sort | uniq | grep -v $PACKAGE | sed ':a;N;$!ba;s/\n/ /g' | xargs yum -y install
-
Works like a charm, who said dumb isn't good :) Would you explain the :a;N;$!ba; part of the sed command for completeness? Thanks– a1anSep 18, 2012 at 10:30
-
I honestly don't know, but I pulled it from here, stackoverflow.com/a/1252191 Sep 18, 2012 at 17:35
-
1The
sed
expression joins the multiple lines returned byyum deplist
and the intervening pipeline, transforming it into a single line of space-separated dependencies. It's not actually necessary. You can simplify the above as:yum deplist $PACKAGE | awk '/provider/ {print $2}' | sort -u | xargs yum -y install
.– larsksApr 21, 2015 at 13:22 -
2Your solution has an error. Say, if we try to install dependencies for package "mysql" and it has "mysql-common" and "init-mysql" dependencies, we will not see them installed, because they both will be filtered by 'grep -v mysql'. Jan 27, 2016 at 13:18
-
1
yum install $(repoquery --requires <package>)
-
Note that this doesn't account for providers. For instance, I have
git18
which providesgit
; the above command attempts to installgit
as a dependency anyway. Nov 30, 2013 at 17:53 -
1I believe this answer addresses the valid concern raised by @AaronAdams, above.– floer32Jan 18, 2017 at 3:44
Best option I found until now for my packages is to put an "exit 1" into the %pre scriptlet the first time the package is built but I'm looking for cleaner options, not requiring modification of the package itself.