Understanding RPM (2009-02-08 classroom)

From FedoraProject

Jump to: navigation, search
---nirik has changed the topic to: Fedora IRC Classroom - Understanding RPM - The engine behind yum with your teacher Clint Savage (herlo) - See https://fedoraproject.org/wiki/Classroom for tonights schedule of classes. Feb 07 01:41
*jds2001 is here Feb 07 01:41
-->JonCruz (n=joncruz@adsl-76-246-93-218.dsl.lsan03.sbcglobal.net) has joined #fedora-classroom Feb 07 01:42
-->vaughan (n=vaughan@ppp121-44-227-60.lns1.per1.internode.on.net) has joined #fedora-classroom Feb 07 01:42
*nirik is here. Hopefull some of the other folks in channel are awake. Feb 07 01:42
herlo Hi all... My name is Clint Savage, I am a Fedora Ambassador in North America and am an experienced Linux Instructor... Feb 07 01:42
*mj0vy1 is ready.. Feb 07 01:42
-->VileGent (n=notfred@fedora/Southern-Gentleman) has joined #fedora-classroom Feb 07 01:42
herlo been teaching linux for 3 years now, have taught for RH (as a contractor) and other companies including IBM, HP, etc... Feb 07 01:42
*herlo is now down pimping his resume :) Feb 07 01:42
herlo So I'd like to start by talking about RPM, it's basic benefits and why it's important to the world. Feb 07 01:43
herlo RPM - Originally stood for Red Hat Package Manager, now dually named RPM Package Manager Feb 07 01:43
-->subfusc (n=sin@kri3-1x-dhcp147.studby.uio.no) has joined #fedora-classroom Feb 07 01:43
herlo is essentially to help manage loads of files, including binaries, configuration and documentations... Feb 07 01:43
herlo in one easy way. Feb 07 01:44
herlo of course, there are other package management systems. And many distributions use RPM as their package management system. Feb 07 01:44
herlo DPKG, that's the Debian way... Feb 07 01:44
herlo Ubuntu uses this as well Feb 07 01:44
<--Guest123 has quit (Connection timed out) Feb 07 01:44
herlo Ports, from the BSD family Feb 07 01:44
herlo Portage is part of the gentoo system Feb 07 01:45
herlo there's one called conary, which is pretty new, from the Foresight folks... Feb 07 01:45
herlo the benefits of packaging are quite large, but essentially, it makes it easy to contain all the files that belong to a particular application... Feb 07 01:45
herlo RPM has a small database (I still believe its berkeley db) Feb 07 01:46
herlo located in /var/lib/rpm Feb 07 01:46
herlo and each of the files in there are __db.00* which represent the RPM database... Feb 07 01:46
herlo which makes it easy for RPM to query and find out what has and hasn't been installed... Feb 07 01:47
-->fenris02 (n=dj@cpe-70-113-121-246.austin.res.rr.com) has joined #fedora-classroom Feb 07 01:47
herlo there is also the *rpm* command, which is the core functionality of how rpm works... Feb 07 01:47
herlo which is what we'll mainly talk about in this class... Feb 07 01:47
herlo rpm can install, verify and query existing packages as well as packages we wish to install. Feb 07 01:48
herlo rpm can also fix problems where yum can't and hopefully we'll get a chance to talk about these corner cases Feb 07 01:48
<--vaughan has quit ("A closed mouth gathers no feat") Feb 07 01:48
herlo another thing, one that most people don't realize, but rpm can do dependency resolution. Feb 07 01:48
herlo and that's a little tricky, but we'll talk about dependency resolution later on... Feb 07 01:49
herlo to start off with, I like to talk about rpm and how it can install packages, as well as upgrade and remove packages. Feb 07 01:49
herlo then we'll move to querying the database and packages... Feb 07 01:49
herlo the simplest way to install a package is to use rpm -i Feb 07 01:50
herlo something like this Feb 07 01:50
herlo rpm -i zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 01:50
<--Guest456 has quit (Read error: 110 (Connection timed out)) Feb 07 01:51
herlo assuming that the rpm database doesn't have zsh-html already installed, it will verify this package and then install all the files associated with this package Feb 07 01:51
herlo if you are interested in following along with this package, you can download it at Feb 07 01:52
herlo http://herlo.fedorapeople.org/rpms/zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 01:52
herlo it is the file that is also included in the current F10 base repository... Feb 07 01:52
herlo doing that install yields pretty much no output Feb 07 01:53
herlo and the package is in stalled Feb 07 01:54
herlo but the real question is what does that benefit us... Feb 07 01:54
-->Falstius (n=jeff@c-98-243-65-184.hsd1.mi.comcast.net) has joined #fedora-classroom Feb 07 01:54
herlo and it's really simple, we now have the documentation for the zshell installed. Feb 07 01:54
herlo how do we erase an rpm? Feb 07 01:55
herlo well, that's rpm -e Feb 07 01:55
herlo prety straightforward as well, but there is one catch, let's try that now... Feb 07 01:55
herlo # rpm -e zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 01:55
herlo error: package zsh-html-4.3.4-8.fc9.i386.rpm is not installed Feb 07 01:55
herlo hmm, I wonder why that happened :) Feb 07 01:55
herlo any thoughts? Feb 07 01:55
brunowolff .rpm Feb 07 01:56
herlo brunowolff: dig a little deeper there, you're right Feb 07 01:56
herlo the .rpm implies that we're trying to uninstall the rpm file, it's not what we ant Feb 07 01:56
herlo want Feb 07 01:56
herlo instead, what we want is Feb 07 01:56
herlo # rpm -e zsh-html-4.3.4-8.fc9.i386 Feb 07 01:57
herlo and that will erase the package Feb 07 01:57
herlo but this would also work Feb 07 01:57
herlo # rpm -e zsh-html-4.3.4-8.fc9 Feb 07 01:57
herlo and this Feb 07 01:57
herlo # rpm -e zsh-html-4.3.4-8 Feb 07 01:57
herlo and this Feb 07 01:57
herlo # rpm -e zsh-html Feb 07 01:57
herlo because the way that rpm works, versioning is based upon several things Feb 07 01:57
herlo the version 4.3.4-8 Feb 07 01:57
herlo the release fc9 Feb 07 01:57
herlo the architecture i386 Feb 07 01:58
herlo you'll find that there is only one zsh-html package and normally this is what you want... Feb 07 01:58
herlo I can also install or upgrade an rpm package... Feb 07 01:58
VileGent  ? cant we install with http as well Feb 07 01:58
herlo that's rpm -U Feb 07 01:58
herlo VileGent: indeed, we're getting there :) Feb 07 01:59
herlo VileGent: you can also install over ftp or http actually Feb 07 01:59
herlo so that http package I provided earlier would be a good way to go... Feb 07 01:59
herlo try this Feb 07 01:59
herlo rpm -U http://herlo.fedorapeople.org/rpms/zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 01:59
mj0vy1  ! Feb 07 01:59
-->nuonguy (n=john@c-24-6-174-132.hsd1.ca.comcast.net) has joined #fedora-classroom Feb 07 01:59
herlo mj0vy1: please go ahead :) Feb 07 01:59
mj0vy1 When I install, I am getting this error "Header V3 DSA signature: NOKEY, key ID 4ebfc273", but it installs eventually Feb 07 02:00
herlo mj0vy1: that's not an error, but we'll talk aobut that a little further on Feb 07 02:00
mj0vy1 ok Feb 07 02:00
herlo if I don't cover it, let me know and I'll answer it in the q&a section Feb 07 02:00
mj0vy1 alright.. Feb 07 02:00
herlo okay, so you've installed and removed a package, let me include one somewhat deprecated option Feb 07 02:00
herlo rpm -F Feb 07 02:01
herlo -F stands for freshen, or update only Feb 07 02:01
herlo it allowed administrators to run an rpm -F *rpm and *only* upgrade packages that are installed on the system Feb 07 02:01
brunowolff Deprecated? Feb 07 02:01
herlo no packages that were in that directory (glob) that weren't already installed would not get installed Feb 07 02:02
fenris02 (it should be mentioned that -F views .i386 and .i686 as "the same" so use sparingly) Feb 07 02:02
brunowolff Is there some better way to do what it does in rpm? Feb 07 02:02
herlo brunowolff: it's still fully functional, but it's been recommended against and isn't that useful Feb 07 02:02
herlo brunowolff: no, that's why it's still there Feb 07 02:02
herlo fenris02: as does all rpm unless you specify it (iirc) Feb 07 02:03
-->mdious (n=mmcallis@nat/redhat/x-6faa30e335933f88) has joined #fedora-classroom Feb 07 02:03
herlo okay, so for now, pretend that -F is something you use sparingly as fenris02 pointed out :) Feb 07 02:03
herlo a couple other switches that are handy, -v verbose -h hash marks Feb 07 02:03
herlo so try this Feb 07 02:03
herlo rpm -e zsh-html Feb 07 02:04
herlo rpm -Uvh http://herlo.fedorapeople.org/rpms/zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 02:04
herlo rpm -Uvh http://herlo.fedorapeople.org/rpms/zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 02:04
herlo Retrieving http://herlo.fedorapeople.org/rpms/zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 02:04
herlo Preparing... ########################################### [100%] 1:zsh-html ########################################### [100%] Feb 07 02:04
herlo as you do this install, you'll notice that there's a new percentage [50%] field and some new hash marks to show the progress Feb 07 02:05
herlo these are useful, especially when you are installing many packages at once... Feb 07 02:06
herlo I also wanted to mention that if you insall over ftp, it can use globbing, like * or ? in the url Feb 07 02:06
herlo so you could do something like this rpm -Uvh 'http://herlo.fedorapeople.org/rpms/zsh*' Feb 07 02:07
herlo and if there was zsh and zsh-html packages, it would install both (or upgrade) Feb 07 02:07
herlo questions? Feb 07 02:08
herlo okay, moving forward... Feb 07 02:08
brunowolff Is there a way to update and delete at the same time? Feb 07 02:08
herlo in what sense? Feb 07 02:08
herlo brunowolff: you want to update one package and remove another? Feb 07 02:08
brunowolff Sometimes you need to delete one package in order to install another one, but you can't delete it first because of dependencies. Feb 07 02:09
brunowolff Think of handling obsoletes. Feb 07 02:09
herlo brunowolff: well, that's a more advanced question, but we'll talk about --force and --nodeps near the end of this conversation... Feb 07 02:09
herlo however, there is one point I should make Feb 07 02:09
fenris02 if all the deps are provided on the same rpm line, it'll work. Feb 07 02:09
herlo right Feb 07 02:10
herlo but here's my other point... Feb 07 02:10
brunowolff But --force may not work correctly with scripts. It would be nice to do it in one transaction. Feb 07 02:10
<--rtnpro has quit (Read error: 110 (Connection timed out)) Feb 07 02:10
herlo brunowolff: let's address that in the q&a because I want to get to your specific request... Feb 07 02:10
herlo but there's something else here, when you upgrade a package, the old package is removed and the new installed. Feb 07 02:11
herlo okay, so I have two things I need to address at the end :) Feb 07 02:12
herlo moving to querying... Feb 07 02:12
herlo to start with, let's talk about querying the rpm database and asking for the list of all packages installed Feb 07 02:12
herlo rpm -qa Feb 07 02:12
herlo I liked to do Feb 07 02:12
herlo rpm -qa | wc -l Feb 07 02:13
herlo to see how many packages are installed on my machine Feb 07 02:13
herlo another thing you can do is Feb 07 02:13
herlo rpm -qa '*zsh*' Feb 07 02:14
herlo I love to use this to search for any rpms that might match that pattern Feb 07 02:14
herlo another thing to look at is just Feb 07 02:14
herlo rpm -q Feb 07 02:14
herlo # rpm -q zsh-html Feb 07 02:15
herlo zsh-html-4.3.4-8.fc9.i386 Feb 07 02:15
herlo another is Feb 07 02:15
herlo rpm -qi Feb 07 02:15
herlo Name  : zsh-html Relocations: (not relocatable) Feb 07 02:15
herlo Version  : 4.3.4 Vendor: Fedora Project Feb 07 02:15
herlo Release  : 8.fc9 Build Date: Thu 15 May 2008 10:17:38 PM MDT Feb 07 02:16
herlo Install Date: Sat 07 Feb 2009 07:03:01 PM MST Build Host: xenbuilder2.fedora.redhat.com Feb 07 02:16
herlo Group  : System Environment/Shells Source RPM: zsh-4.3.4-8.fc9.src.rpm Feb 07 02:16
herlo Size  : 2197128 License: BSD Feb 07 02:16
herlo Signature  : DSA/SHA1, Tue 28 Oct 2008 11:31:09 PM MDT, Key ID bf226fcc4ebfc273 Feb 07 02:16
herlo Packager  : Fedora Project Feb 07 02:16
herlo URL  : http://zsh.sunsite.dk/ Feb 07 02:16
herlo Summary  : Zsh shell manual in html format Feb 07 02:16
herlo Description : Feb 07 02:16
herlo The zsh shell is a command interpreter usable as an interactive login Feb 07 02:16
herlo shell and as a shell script command processor. Zsh resembles the ksh Feb 07 02:16
herlo shell (the Korn shell), but includes many enhancements. Zsh supports Feb 07 02:16
herlo command line editing, built-in spelling correction, programmable Feb 07 02:16
herlo command completion, shell functions (with autoloading), a history Feb 07 02:16
herlo mechanism, and more. Feb 07 02:16
herlo This package contains the Zsh manual in html format. Feb 07 02:16
herlo which provides the package information Feb 07 02:16
herlo and rpm -ql Feb 07 02:16
herlo rpm -ql zsh-html Feb 07 02:17
herlo /usr/share/doc/zsh-html-4.3.4 Feb 07 02:17
herlo /usr/share/doc/zsh-html-4.3.4/zsh.html Feb 07 02:17
herlo /usr/share/doc/zsh-html-4.3.4/zsh_1.html Feb 07 02:17
herlo ... snip ... Feb 07 02:17
herlo there's a lot of files listed here... Feb 07 02:17
herlo but there's a really cool one I like Feb 07 02:17
herlo rpm -qf Feb 07 02:17
herlo rpm -qf /bin/bash Feb 07 02:18
herlo bash-3.2-30.fc10.i386 Feb 07 02:18
herlo so you can do this for any rpm that's installed Feb 07 02:18
herlo so try this one.... Feb 07 02:18
herlo rpm -qf /bin/ls Feb 07 02:18
herlo and you'll find out that it's not in the ls package Feb 07 02:18
herlo coreutils-6.12-18.fc10.i386 Feb 07 02:19
herlo also, you can check packages that aren't installed Feb 07 02:20
herlo rpm -qp Feb 07 02:20
herlo rpm -qlp Feb 07 02:20
herlo rpm -qip Feb 07 02:20
herlo will query the rpm file itself Feb 07 02:20
herlo and give similar results to -q, -ql, -qi Feb 07 02:20
herlo but for packages Feb 07 02:21
herlo moving to answer mj0vy1's question Feb 07 02:21
herlo verification... Feb 07 02:21
herlo mj0vy1: when you installed your package you got the Header missing error right? Feb 07 02:21
herlo that is because you don't have the RPM GPG keys installed... Feb 07 02:22
herlo to install your RPM GPG keys, they are automatically provided by Fedora in /etc/pki/rpm-gpg Feb 07 02:23
-->quaid (n=quaid@fedora/quaid) has joined #fedora-classroom Feb 07 02:23
herlo now, you can also get these from the CD media or right on the actual installed system... Feb 07 02:23
herlo to fix that issue, you may wish to run the following Feb 07 02:24
herlo rpm --import RPM-GPG-KEY /etc/pki/tls/RPM-GPG-KEY-fedora Feb 07 02:24
herlo and any others you'd like to install Feb 07 02:25
herlo this will then allow you to verify the packages upon install Feb 07 02:25
herlo and you can do that prior to installing the package with Feb 07 02:26
herlo rpm -K zsh-html-4.3.4-8.fc9.i386.rpm Feb 07 02:27
herlo zsh-html-4.3.4-8.fc9.i386.rpm: (sha1) dsa sha1 md5 gpg OK Feb 07 02:27
herlo noting the gpg md5 and everything there is okay Feb 07 02:27
herlo you can do this with other rpm gpg keys and import things from other repos too... Feb 07 02:28
jds2001 also, note that we're moving to sha256 digests likely in F12. Feb 07 02:28
herlo cool Feb 07 02:29
herlo jds2001: thanks for that Feb 07 02:29
herlo moving to the final stuffs with verification Feb 07 02:29
herlo you can use rpm -V to verify a particular package Feb 07 02:29
herlo after it's installed Feb 07 02:29
herlo if it returns an empty result, it's successful Feb 07 02:30
herlo if you get an error, then something is wrong Feb 07 02:30
brunowolff Not always. Feb 07 02:30
nirik unless it's a config file change. ;) Feb 07 02:30
brunowolff Some packages have scripts that modify what they install. Feb 07 02:31
herlo good point Feb 07 02:31
jds2001 brunowolff: such packages are broken by design :) Feb 07 02:31
jds2001 unless it's a config file, obviosuly Feb 07 02:31
herlo nirik: pam is a good example of the a config file changing Feb 07 02:31
brunowolff Well there are a number of them. I have filed bug reports on some in the past. Feb 07 02:31
herlo you can also verify package files, but I have never found a use for this Feb 07 02:32
herlo that's done with Feb 07 02:32
herlo rpm -Vp Feb 07 02:32
---Guest453 is now known as SM0TVI Feb 07 02:32
herlo so a couple points to wrap it up then q&a Feb 07 02:32
herlo first off, when installing a kernel, never use -U with rpm Feb 07 02:32
herlo always use rpm -i or use *yum* Feb 07 02:33
*herlo points to nirik's presentation Feb 07 02:33
<--ningbojoe_ has quit ("Ex-Chat") Feb 07 02:33
herlo another thing to talk about, I mentioned that rpm can do dependency resolutoin Feb 07 02:33
herlo I read people mentioning that you have to put all the dependencies on one line of an rpm command, this is not true Feb 07 02:33
herlo though it's the most common way Feb 07 02:33
herlo if you wish to use rpm and do resolution, you'll need to do two basic things... Feb 07 02:34
*herlo doesn't know what happened to the rpmdb package, but recalls it was merged into rpm or soemthing, jds2001 ?? Feb 07 02:34
herlo and you'll have to create a .rpmmacros file in your home directory Feb 07 02:34
jds2001 i dont think so, i think it's gone. Feb 07 02:35
jds2001 --aid never worked well anyways :) Feb 07 02:35
herlo yeah, it worked fine for me in RHEL4 Feb 07 02:35
herlo hmm, well anyway Feb 07 02:35
herlo there's the .rpmmacros file Feb 07 02:35
herlo  %_solve_pkgsdir /path/to/installtree/RedHat/RPMS/ Feb 07 02:35
herlo  %_solve_name_fmt  %{?_solve_pkgsdir}%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm Feb 07 02:35
jds2001 yeah, in rhel it's still there i think. Feb 07 02:35
herlo add these lines and you can point to the rpm dir and resolve it all Feb 07 02:36
fenris02 rpmdb function was replaced by 'yum provides' iirc Feb 07 02:36
*nirik just thinks it's better to use yum now. ;) Feb 07 02:36
herlo yes, I agree Feb 07 02:36
-->skorcher (n=SK@122.172.21.115) has joined #fedora-classroom Feb 07 02:36
herlo well, that's good to know about rpmdb Feb 07 02:36
herlo so to address the --script question from brunowolff Feb 07 02:37
herlo brunowolff: wanna bring that back up again... Feb 07 02:37
brunowolff Yes Feb 07 02:38
brunowolff The case I am talking about is where you want to replace a package with a different one, such as with obsoletes in yum. Feb 07 02:39
<--viking-ice has quit ("Ex-Chat") Feb 07 02:39
brunowolff If there is a dependency on the package being removed and it conflicts with the one being added it blocks doing the update one step at a time. Feb 07 02:39
herlo could you give an example Feb 07 02:39
herlo brunowolff: one choice might be --nodeps in that situation?? Feb 07 02:40
fenris02 --nodeps and --force are last-resort options that frequently do more harm than good. Feb 07 02:40
brunowolff I know I can force it, but if scripts are being run there could be problems. Feb 07 02:40
*nirik nods at fenris02's comment. Feb 07 02:40
fenris02 --noscripts exists too if that's the issue. Feb 07 02:41
herlo fenris02: --nodeps is somethign I use regularly to solve those problems. I'm a big fan of it when it comes to mono packages from OBS Feb 07 02:41
herlo fenris02: good catch! Feb 07 02:41
brunowolff lately I only do this if something is too broken for yum to handle, so it doesn't come up a lot. Feb 07 02:41
fenris02 herlo, they have their use, but are frequently misused ime. Feb 07 02:41
herlo fenris02: true, which is why it's discouraged Feb 07 02:42
brunowolff No scripts doesn't run the scripts. That is usually even worse. Feb 07 02:42
herlo and should be used with great caution Feb 07 02:42
herlo any other questions? Feb 07 02:43
brunowolff I would have expected to be able to do something like rpm -U packagenew.rpm -e packageold Feb 07 02:43
herlo hmm, I don't think that's a good idea either, but I can see your desire... Feb 07 02:44
fenris02 brunowolff, if the new package properly has an 'obsoletes: ' tag, that is not necessary Feb 07 02:44
brunowolff Really? rpm will automatically remove an obsoleted package? Feb 07 02:45
fenris02 brunowolff, yes. Feb 07 02:45
brunowolff I thought I'd seen cases in the past when it didn't. Feb 07 02:45
Falstius brunowolff: a package can specify packages it replaces even if they don't have the same name. Feb 07 02:45
fenris02 brunowolff, if they did not use an obsoletes: tag, it wont Feb 07 02:45
jds2001 /win 34 Feb 07 02:45
herlo lol Feb 07 02:45
*herlo has to head, thanks all Feb 07 02:45
brunowolff Maybe what I saw where cases that were missing proper obsoletes definitions and would have broken yum as well. Feb 07 02:45
nirik well, I see we are at end of time here... shall we wrap things up? Feb 07 02:46
herlo enjoy the discussions... Feb 07 02:46
nirik the next class starts in 15min or so... Using Yum - Tricks and tips - Kevin Fenzi (nirik) Feb 07 02:46
fenris02 thanks herlo. nicely done. Feb 07 02:46
nirik thanks herlo ! Feb 07 02:46
subfusc yeah, thanks! it has been interesting to watch! Feb 07 02:47

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!