4

what I'm trying to is to make a USB disk with local repository / directory for offline installation (or upgrade) of Linux servers. Why !? Simple, I’m working on maintenance of huge cluster of asterisk IP PBX-es, asterisk (and dahdi, and ...) is build against kernel sources, and if version of kernel is changed (different from one I'm used to build), then it is a disaster waiting to happen. Now, my idea is to place all rpm's / srpm's that are installed on one server (development) and install / upgrade all other servers to same version of rpm's. Easy way to do this is to force YUM to download all installed rpm's to some directory, then copy them to usb-flash_disk and do on all other servers "yum install ./*.rpm" !? So then I'm having all systems at same revision!

Question is : how to tell YUM to (only) download all rpm's that are installed ???

VuLe
  • 43
  • 1
  • 3
  • Is there any reason why you do not mirror the whole install/update server on your own server? – Nils Dec 11 '16 at 14:31

3 Answers3

4

There are 2 options

Either use rpm (Red Hat Package Manager) or yum (Yellowdog Updater/Modifier)

1) RPM

rpm -qa > to_be_installed; while read -r package; do yum -y install "$package"; done < to_be_installed

2) YUM

yum list installed | awk 'NR>1{print $1}' > to_be_installed; while read -r line; do yum -y install "$line"; done < to_be_installed

Hope this gives you some ideas how to do it.

Valentin Bajrami
  • 3,870
  • 1
  • 17
  • 25
  • Yes that is (first) part of my problem (TNX), but much more dubios problem is how to tel YUM to download rpm's with out installing/reinstalling them ??? – VuLe Nov 21 '12 at 12:40
  • You can use yumdownloader as follow `yum list installed | awk '{print $1}' > to_be_installed; while read -r line; do yumdownloader "$line"; done < to_be_installed` – Valentin Bajrami Nov 21 '12 at 12:43
  • 1
    Excelent !!! It is working as we "speek" download dir is filing up !!! Thanks a lot !!! :) – VuLe Nov 21 '12 at 12:48
2

You can get a list of installed packages with yum list installed, you may want to clean it up a bit with

yum list installed | awk 'NR >2 {print $1}' >installed.pkg

Once you have the list you can use the yumdownloader utility to download the packages

for file in $(cat installed.pkg)
do
    yumdownloader "$file"
done

this will download all of the rpms to the current directory.

user9517
  • 114,104
  • 20
  • 206
  • 289
0

I believe that the two answers above will yield different results:

Case A) [as shown above]

rpm -qa > to_be_installed; while read -r package; do yum -y install "$package"; done < to_be_installed

Case B) [as shown above]

yum list installed | awk '{print $1}' > to_be_installed; while read -r line; do yum -y install "$line"; done < to_be_installed

In Case A) rpm -qa will return the "complete" rpm name, including the version info.
In Case B) the package name (with architecture suffix) is in the first column, version in the second column.

So, in Case A) you will get all of the currently installed rpms downloaded.
In Case B), you will get all of the MOST RECENT versions of the packages (for your release) downloaded.

The other major issue for trying to get offline upgrades working is that the switch --resolve on yumdownloader does not work properly (it does not resolve all dependencies).

The procedure I am using is:

  1. get machine with my actual installed packages connected to the internet
  2. if I am intending to upgrade, then I yum upgrade this machine from the internet
  3. the act of actually upgrading using yum does two things

    i) gets all versions of my rpms updated AND

    ii) resolves all package dependencies

  4. Then

    yumdownloader rpm -qa --destdir=/path/rpm_updates

I can not create a local file based repo out of the directory /path/rpm_updates, put this on a USB and upgrade a machine (offline) from that list of rpms.

Slipeer
  • 3,255
  • 2
  • 18
  • 32