ianw1974 Posted June 6, 2006 Report Share Posted June 6, 2006 I installed a system using a set of disks, whilst another updated set was being downloaded. Now, to save the reinstall, I'm wanting to upgrade the packages installed on the system. I can use the: rpm -qa command to give me the list of packages installed, but wanted to be able to pipe the results, in a way that I can then just use: rpm -Uvh list-of-packages to do the upgrade automatically, without me having to specify all the packages manually. Any ideas how I could do this? I've tried piping the results of the rpm -qa to a text file, but unsure of how to get the text file read back to the upgrade command. Quote Link to comment Share on other sites More sharing options...
jlc Posted June 7, 2006 Report Share Posted June 7, 2006 Use SED and CAT Example: The file: $ cat list-of-packages xmms-skins xmms-wma xmms-mp3 xmms-cdread videolan-client gaim\* We'll create a new file to include yum and end of line / $ echo '#!/bin/bash' > yumlist.sh $ echo 'yum --exclude=*\debug\* install \' >> yumlist.sh $ cat yumlist.sh #!/bin/bash yum --exclude=*\debug\* install \ Now we will add a space and / to the end of the file from your list of packages file: sed it: $ sed 's/$/ \\/' list-of-packages >> yumlist.sh Add something to the bottom so it doesn't end with / echo 'echo "done"' >> yumlist.sh Revised file: $ cat yumlist.sh #!/bin/bash yum --exclude=*\debug\* install \ xmms-skins \ xmms-wma \ xmms-mp3 \ xmms-cdread \ videolan-client \ gaim\* \ echo "done" Install the file # sh list-of-packages.yum<SNIP> Installing: gaim i386 1:1.5.0-16.fc5 updates 4.3 M gaim-encryption i386 2.38-2.fc5 freshrpms 93 k gaim-gaym i386 0.96-3.fc5 extras 97 k gaim-guifications i386 2.13-0.beta2.fc5.rf rpmforge 262 k gaim-irchelper i386 0.12-1.fc5.rf rpmforge 22 k gaim-meanwhile i386 1.2.8-2.fc5 extras 57 k gaim-otr i386 3.0.0-2.fc5.rf rpmforge 41 k gaim-plugin_pack i386 1.0-0.beta3.fc5.rf rpmforge 46 k videolan-client i386 0.8.5-1.fc5 freshrpms 6.2 M xmms-cdread i386 0.14-11.fc5 extras 37 k xmms-mp3 i386 1:1.2.10-16.fc5.rf rpmforge 87 k xmms-skins i386 1:1.2.10-13 extras 2.6 M xmms-wma i386 1.0.5-3.fc5.rf rpmforge 79 k Installing for dependencies: xmms i386 1:1.2.10-22.fc5 extras 1.9 M xmms-libs i386 1:1.2.10-23.fc5 extras 245 k Transaction Summary ============================================================================= Install 15 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 16 M Is this ok [y/N]: Is that what you wanted? Quote Link to comment Share on other sites More sharing options...
jlc Posted June 7, 2006 Report Share Posted June 7, 2006 If you made your list with rpm -qa you would want to do this first: rpm -qa xmms\* gaim\* videolan-client\* > new_list.txt cat new_list.txt gaim-gaym-0.96-3.fc5 xmms-libs-1.2.10-23.fc5 gaim-meanwhile-1.2.8-2.fc5 gaim-guifications-2.13-0.beta2.fc5.rf xmms-1.2.10-22.fc5 gaim-encryption-2.38-2.fc5 xmms-wma-1.0.5-3.fc5.rf xmms-cdread-0.14-11.fc5 gaim-1.5.0-16.fc5 xmms-mp3-1.2.10-16.fc5.rf gaim-otr-3.0.0-2.fc5.rf videolan-client-0.8.5-1.fc5 xmms-skins-1.2.10-13 gaim-irchelper-0.12-1.fc5.rf gaim-plugin_pack-1.0-0.beta3.fc5.rf Now remove the numbers and extra blobs: $ sed -i s/-[0-9].*// new_list.txt $ cat new_list.txt gaim-gaym xmms-libs gaim-meanwhile gaim-guifications xmms gaim-encryption xmms-wma xmms-cdread gaim xmms-mp3 gaim-otr videolan-client xmms-skins gaim-irchelper gaim-plugin_pack Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted June 8, 2006 Author Report Share Posted June 8, 2006 OK, I'll have a go at this when I'm back in the office in a couple of weeks. Not got yum installed, but I'm sure I can find it :P Quote Link to comment Share on other sites More sharing options...
jlc Posted June 8, 2006 Report Share Posted June 8, 2006 OK, I'll have a go at this when I'm back in the office in a couple of weeks. Not got yum installed, but I'm sure I can find it :P Oh, i was thinking fedora :) Are you on RH or CentOS? Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted June 8, 2006 Author Report Share Posted June 8, 2006 Red Hat, using EL4 Update 2. I couldn't wait to install whilst I had Update 3 ISO's downloading, and just wanted to save installing without reinstall :P Quote Link to comment Share on other sites More sharing options...
jlc Posted June 8, 2006 Report Share Posted June 8, 2006 Red Hat, using EL4 Update 2. I couldn't wait to install whilst I had Update 3 ISO's downloading, and just wanted to save installing without reinstall :P Ah, is this a company box that your using rhel 4 on but don't have it setup for RHN? If so, and these are just iso's you d/l that are freely avaible, no problem there, but i would suggest using centos, rebuild of rhel4 only has "yum" :) [justin@pillar ~]$ cat /etc/redhat-release CentOS release 4.3 (Final) Quote Link to comment Share on other sites More sharing options...
Gul Dukat Posted June 8, 2006 Report Share Posted June 8, 2006 Ah, is this a company box that your using rhel 4 on but don't have it setup for RHN? If so, and these are just iso's you d/l that are freely avaible, no problem there, but i would suggest using centos, rebuild of rhel4 only has "yum" :) Just a little offtopic. But would you advise CentOS as server? And can I install additional packages with yum? I´m still looking for a good server distro and I like the Fedora structure very much. Sorry, for going offtopic here. Quote Link to comment Share on other sites More sharing options...
jlc Posted June 9, 2006 Report Share Posted June 9, 2006 Just a little offtopic. But would you advise CentOS as server? And can I install additional packages with yum? I´m still looking for a good server distro and I like the Fedora structure very much. Very much, I do :) Very stable rock solid distro, its built from the same sources as Red Hat Enterprise. Quote Link to comment Share on other sites More sharing options...
Gul Dukat Posted June 9, 2006 Report Share Posted June 9, 2006 Thanks for the additional info jlc. Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted June 9, 2006 Author Report Share Posted June 9, 2006 Unfortunately, we're Red Hat only at work (even though I use Mandriva on my laptop ;) ). Would be nice to know how to get it working on RHEL though just purely as a learning exercise more than anything else. My main system runs RHEL AS with a subscription :P Quote Link to comment Share on other sites More sharing options...
jlc Posted June 17, 2006 Report Share Posted June 17, 2006 I knew there was an --aid, but never knew how to use it, now I do :) find /start/dir -name "*.rpm" \ -exec rpm -Uvh --aid {} \; more here: http://www.redhat.com/magazine/020jun06/de...ts/tips_tricks/ The first line of the command would get a list of the RPMs available in the directory (/start/dir, in the example). The second line would install each RPM in turn. Depending on the nature of the RPMs, it may be necessary to issue the command twice, though the --aid option should attempt to resolve dependencies. Quote Link to comment Share on other sites More sharing options...
bvc Posted June 17, 2006 Report Share Posted June 17, 2006 nice B) Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted June 18, 2006 Author Report Share Posted June 18, 2006 Hmm, not sure how that would work for me. The problem with rpm is that it requires the full name of the rpm to be able to install from the command line. What I tend to do, is copy the rpm's from the iso's into a directory - /redhat/rpms Of course, using the rpm -qa command gives me the names of the rpms, so I can't use this list natively, since the version numbers would be different from U2 to U3. Thus, I can remove using the previous suggestion so that I just have the filenames. The next problem comes is that to use the list with the names, I need the version numbers from U3, as with just the name of the rpm it won't work, because it requires the full name of the rpm. Of course, if I had something like yum installed, perhaps I could just issue the list of names, and it would pick them up from /redhat/rpms if it was configured to look here. The only other method I can think means sorting through all the rpms, and leaving just the ones I want to upgrade and then issue the command above. But this would take too long, and I might as well just reinstall anyhow. Makes me conclude that rpm is somewhat limited as a package manager compared to perhaps yum, urpmi and others. Quote Link to comment Share on other sites More sharing options...
jlc Posted June 18, 2006 Report Share Posted June 18, 2006 Thats actually cause you have the terminolgy mixed up. :P yum/urpmi are frontends to rpm apt-get/apptitude are frontednds to dpkg so on and so on . You could try something like this: $ mkdir test && cd test $ rpm -qa > rpmlist.txt $ sed -i s/-[0-9].*/*.rpm/ rpmlist.txt $ sed s/-[0-9].*/*.rpm/ rpmlist.txt > install_list.txt # cat install_list.txt | for X in *.rpm; do rpm -Uvh --aid $X; done In this example, I dropped in my fc5 dvd, went to the dir holding the rpms and then executed the command # pwd /media/disk/Fedora/RPMS # cat /home/justin/test/install_list.txt | for X in *.rpm; do rpm -Uvh --aid $X; done error: Failed dependencies: libc.so.6()(64bit) is needed by a2ps-4.13b-49.x86_64 libc.so.6(GLIBC_2.2.5)(64bit) is needed by a2ps-4.13b-49.x86_64 libc.so.6(GLIBC_2.3)(64bit) is needed by a2ps-4.13b-49.x86_64 libc.so.6(GLIBC_2.3.4)(64bit) is needed by a2ps-4.13b-49.x86_64 libc.so.6(GLIBC_2.4)(64bit) is needed by a2ps-4.13b-49.x86_64 libm.so.6()(64bit) is needed by a2ps-4.13b-49.x86_64 libm.so.6(GLIBC_2.2.5)(64bit) is needed by a2ps-4.13b-49.x86_64 error: Failed dependencies: libacl.so.1()(64bit) is needed by acl-2.2.34-1.2.x86_64 libacl.so.1(ACL_1.0)(64bit) is needed by acl-2.2.34-1.2.x86_64 libattr.so.1()(64bit) is needed by acl-2.2.34-1.2.x86_64 libc.so.6()(64bit) is needed by acl-2.2.34-1.2.x86_64 libc.so.6(GLIBC_2.2.5)(64bit) is needed by acl-2.2.34-1.2.x86_64 libc.so.6(GLIBC_2.3)(64bit) is needed by acl-2.2.34-1.2.x86_64 libc.so.6(GLIBC_2.3.3)(64bit) is needed by acl-2.2.34-1.2.x86_64 libc.so.6(GLIBC_2.3.4)(64bit) is needed by acl-2.2.34-1.2.x86_64 libc.so.6(GLIBC_2.4)(64bit) is needed by acl-2.2.34-1.2.x86_64 error: Failed dependencies: libc.so.6()(64bit) is needed by acpid-1.0.4-2.x86_64 libc.so.6(GLIBC_2.2.5)(64bit) is needed by acpid-1.0.4-2.x86_64 libc.so.6(GLIBC_2.3)(64bit) is needed by acpid-1.0.4-2.x86_64 libc.so.6(GLIBC_2.3.4)(64bit) is needed by acpid-1.0.4-2.x86_64 libc.so.6(GLIBC_2.4)(64bit) is needed by acpid-1.0.4-2.x86_64 Preparing... ########################################### [100%] 1:adaptx ########################################### [100%] Preparing... ########################################### [100%] 1:adaptx-doc ########################################### [100%] As you can see, it started to want to do it, however, ctrl+C out of it really quick because that was my x86_64 dvd and I'm on a i386 laptop so I figure I shouldn't let it keep going 8) How does that commercial go, "Ah the power of UNIX" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.