Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a Fedora 17 system (A) where I have installed some packages over the time. Now I want to install Fedora 19 on another computer (B) and I want to install the same packages on it.

In Debian terms I want to accomplish something like this:

$ dpkg --get-selections > pkg_sel_host_a  # on host_a
$ dpkg --set-selections < pkg_sel_host_a  # on host_b

But to be honest, I really want a better method to select the same packages on the new Fedora 19 system (B): I just want to install the packages from system A that were explicitly mentioned on a yum install command line - and not those that were installed as dependencies!

Why? Because perhaps dependencies have changed - and I don't want to install outdated dependencies on the new system. Plus, when I remove packages I want to remove the (possibly) then unneeded automatically installed dependencies (i.e. orphans) as well.

I've found yum list installed - but it does not display if a package was explicitly selected or just installed because of a dependency.

How do I get that information on Fedora?

What is the Fedora/yum way to replicate package selections?

share|improve this question
    
Good question. Thanks for asking it! –  slm Jul 13 '13 at 14:38
add comment

4 Answers

up vote 2 down vote accepted

I've remembered the command repoquery - using that I am now at:

$ repoquery --installed --qf '%{n} - %{yumdb_info.reason}' --all \
    | grep 'user$' | awk '{ print $1 }' > pkg_sel_host_a  # on host_a
# xargs yum install < pkg_sel_host_a                      # on host_b

Inspecting pkg_sel_host_a the selection seems to be pretty much plausible - but there are a few packages, e.g.

xorg-x11-drv-mga
xorg-x11-drv-nouveau
xorg-x11-drv-openchrome
xorg-x11-drv-qxl

where I am pretty sure that I did not explicitly install them.

The reason for those additional packages is: they were installed by the fedora installer.

To exclude them we have to extend the query format string:

$ repoquery --installed \
     --qf '%{n} | %{yumdb_info.reason} | %{yumdb_info.installed_by}' --all \
    | awk -F'|' ' $2 ~ /user/ && ($3 != 4294967295) { print $1 }'  \
    | sort -u > pkg_sel_host_a

(the installer's user-id was apparently stored as 4294967295 - alternatively you can write something like ($3 == 0 || $3 == your-user-id))

share|improve this answer
    
I'm not sure if this approach will get everything, I noticed these on my system when I ran repoquery ...: "Invalid yumdb querytag 'reason' for installed pkg: HandBrake-cli-0.9.5-1.fc14.x86_64" –  slm Jul 13 '13 at 15:41
    
@slm, hm, from what repository was handbrake installed? Perhaps the repository setup has something to do with it? –  maxschlepzig Jul 13 '13 at 16:24
    
I think it might have been a standalone RPM that I installed using yum localinstall .... I had a fair amount of packages that fell into that camp though. –  slm Jul 13 '13 at 16:35
    
repoquery --installed --qf '%{n} - %{yumdb_info.reason}' --all 2>&1|grep -v "user$"|grep -v "dep$" |wc -l returned 90 packages. –  slm Jul 13 '13 at 16:39
add comment

I have an older version of Fedora (14) so my yum includes a less feature rich version of yum, but you might want to take a look at the yum history feature. I believe you can get the info you're looking for from that command.

history list

$ sudo yum history list
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
ID     | Login user             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   862 | System <unset>         | 2013-07-12 18:00 | Install        |    1   
   861 | System <unset>         | 2013-07-09 03:11 | Install        |    1   
   860 | System <unset>         | 2013-07-01 13:40 | Install        |    1   
   859 | System <unset>         | 2013-06-29 22:07 | Install        |    1   
   858 | System <unset>         | 2013-06-25 22:33 | Install        |    1 P<
   857 | System <unset>         | 2013-06-23 22:28 | Update         |    1 >E
   856 | System <unset>         | 2013-06-23 21:33 | Install        |    1   
   ...

You can go back to the very first transaction by passing a list of numbers to yum history list:

$ sudo yum history list `seq 1 10`
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
ID     | Login user             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    10 | Sam M. (local) <saml>  | 2010-12-18 23:23 | Install        |    2   
     9 | Sam M. (local) <saml>  | 2010-12-18 23:15 | Install        |   38   
     8 | Sam M. (local) <saml>  | 2010-12-18 23:12 | Install        |    1   
     7 | Sam M. (local) <saml>  | 2010-12-18 23:09 | Install        |    1  <
     6 | Sam M. (local) <saml>  | 2010-12-18 22:37 | Install        |    1 > 
     5 | Sam M. (local) <saml>  | 2010-12-18 21:57 | Install        |    1   
     4 | System <unset>         | 2010-12-18 21:21 | Install        |    5   
     3 | System <unset>         | 2010-12-18 21:18 | Install        |    4   
     2 | System <unset>         | 2010-12-18 21:10 | Install        |    3   
     1 | System <unset>         | 2010-12-18 19:14 | Install        | 1189

history info

The following will show you what was installed as part of the 1st yum transaction:

$ sudo yum history info 1 | less
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Transaction ID : 1
Begin time     : Sat Dec 18 19:14:05 2010
Begin rpmdb    : 0:da39a3ee5e6b4b0d3255bfef95601890afd80709
End time       :            19:42:43 2010 (1718 seconds)
End rpmdb      : 1189:8c21e9e377c3ebdee936916208f74232d5d6235f
User           : System <unset>
Return-Code    : Success
Transaction performed with:
Packages Altered:
    Dep-Install ConsoleKit-0.4.2-3.fc14.x86_64
    Dep-Install ConsoleKit-libs-0.4.2-3.fc14.x86_64
    Dep-Install ConsoleKit-x11-0.4.2-3.fc14.x86_64
    Dep-Install GConf2-2.31.91-1.fc14.x86_64
    Dep-Install GConf2-gtk-2.31.91-1.fc14.x86_64
    Dep-Install ModemManager-0.4-4.git20100720.fc14.x86_64
    Install     NetworkManager-1:0.8.1-10.git20100831.fc14.x86_64
    Dep-Install NetworkManager-glib-1:0.8.1-10.git20100831.fc14.x86_64
    Install     NetworkManager-gnome-1:0.8.1-10.git20100831.fc14.x86_64
    Install     NetworkManager-openconnect-0.8.1-1.fc14.x86_64

Notice how yum reports whether a package was explicitly installed or installed because it was needed by a dependency. You could parse this info and get your list of packages that were explicitly installed.

share|improve this answer
    
I've added an answer based on your yum history idea, it also compares the results against the repoquery based method. As a side-effect I've extended my repoquery answer. –  maxschlepzig Jul 13 '13 at 19:20
add comment

Inspired by slm's answer I've come up with following yum history based solution:

Get all detailed history on all yum install transactions (i.e. no upgrades), excluding those execited as part of initial installer actions (transactions 1 and 2 on my system, attributed to user 'System'):

$ yum history list all | awk -F'|' \
                            '$4 ~ /Install/ && $2 !~ /System/ {print $1}' \
    | xargs yum history info > yum_history

Filter explicitly installed packages and cut off version prefixes.

$ < yum_history grep '[^-]\<Install\>' | \
  awk '{ print $2 }' \
  | sed 's/\(-[0-9]\+:\|-[0-9]\+\.[0-9]\|-[0-9]\+-\|-[0-9]\+git\).\+\(\.fc1[1-7]\.\|\.noarch\).*$//' \
  | sort > hist_pkg_list

The ugly regular expression is needed such that all kinds of version suffixes are matched.

The results look quite fine on my system.

A comparison against the repoquery ansatz (on my system):

method         # packages
―――――――――――――――――――――――――
repoquery      569
repoquery-2nd  216
yum history    214

(I piped the repoquery results through sort -u)

Why are there differences? Because repoquery includes all the packages from transactions 1 and 2, i.e. all packages which were installed by the Fedora installer. This explains why repoquery includes the mentioned packages xorg-x11- drv-mga and friends.

Comparing repoquery-2nd and yum-history shows that repoquery-2nd is more accurate - it does not include some already removed packages. In addition it includes a few (2 on my system) packages from 'yum update'-operations, it seems.

Warning

The above history-based method only lists all explicitly installed packages over the complete lifetime of the system. It does not balance out those packages which were removed in a later transaction. Thus, this method needs some manual curating of the results and should only be used on systems were repoquery is not available.

share|improve this answer
    
Nice way to take the best of both our answers! I'd give you more than a +1 if I could for the eventual solution + the nice comparison of the various ways to do it. –  slm Jul 13 '13 at 22:53
add comment

The easiest way, and it's worked for a long time is:

yum-debug-dump => gives file.

yum-debug-restore <file-from-debug-dump>

...which works much like the get/set selections dpkg command, AIUI. Also note that if you are replaying history you can use:

yum history addon-info last saved_tx => gives file
yum load-tx <file-from-addon-info>

...instead of having to parse it yourself.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.