-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path102-5-use-RPM-and-YUM-package-management
342 lines (280 loc) · 15.1 KB
/
102-5-use-RPM-and-YUM-package-management
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
############################################
102.5 Use RPM and YUM package management
############################################
Candidates should be able to perform package management using RPM and YUM tools.
Goals
& Install, re-install, upgrade and remove packages using RPM and YUM.
& Obtain information on RPM packages such as version, status, dependencies, integrity and signatures.
& Determine what files a package provides, as well as find which package a specific file comes from.
& rpm
& rpm2cpio
& /etc/yum.conf
& /etc/yum.repos.d/
& yum
& yumdownloader
######################################
Introduction
######################################
RedHat Package Manager (RPM) and Yellowdog Updater Modified (YUM) are fedora / redhat / rhel / centos / .. tools to manage packages. There are also gui tools for installing and updating. As you saw on 102.4, all package managers can do standard functions like installing, updating and removing packages.
YUM adds extra features likes automatic updates, dependency management and works with repositories (collection on packages accessed over network or on a CD).
######################################
Installing
######################################
Say you want to install "bzr" and you don't have it:
bzr:[root@localhost ~]$ bzr
bash: bzr: command not found
[jroot@localhost ~]$ which bzr
/usr/bin/which: no bzr in (/usr/libexec/lightdm:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/jadi/.local/bin:/home/jadi/bin)
[root@localhost ~]$ whatis bzr
bzr: nothing appropriate.
[root@localhost ~]$ whereis bzr
bzr:[root@localhost ~]$
we can obtain the bzr RPM package and try to install it:
[root@localhost ~]# rpm -i bzr-2.6.0-2.fc20.x86_64.rpm
error: Failed dependencies:
python-paramiko is needed by bzr-2.6.0-2.fc20.x86_64
Failed because of dependencies. RPM understands the dependencies but does not installs it itself. We need YUM:
[root@localhost ~]# yum install bzr
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package bzr.x86_64 0:2.6.0-2.fc20 will be installed
--> Processing Dependency: python-paramiko for package: bzr-2.6.0-2.fc20.x86_64
--> Running transaction check
---> Package python-paramiko.noarch 0:1.15.1-1.fc20 will be installed
--> Processing Dependency: python-crypto >= 2.1 for package: python-paramiko-1.15.1-1.fc20.noarch
--> Running transaction check
---> Package python-crypto.x86_64 0:2.6.1-1.fc20 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================
Installing:
bzr x86_64 2.6.0-2.fc20 fedora 6.3 M
Installing for dependencies:
python-crypto x86_64 2.6.1-1.fc20 fedora 470 k
python-paramiko noarch 1.15.1-1.fc20 updates 998 k
Transaction Summary
=========================================================================================================================
Install 1 Package (+2 Dependent packages)
Total size: 7.7 M
Total download size: 998 k
Installed size: 36 M
Is this ok [y/d/N]: y
Downloading packages:
Not downloading Presto metadata for updates
python-paramiko-1.15.1-1.fc20.noarch.rpm | 998 kB 00:00:32
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-crypto-2.6.1-1.fc20.x86_64 1/3
Installing : python-paramiko-1.15.1-1.fc20.noarch 2/3
Installing : bzr-2.6.0-2.fc20.x86_64 3/3
Verifying : python-crypto-2.6.1-1.fc20.x86_64 1/3
Verifying : python-paramiko-1.15.1-1.fc20.noarch 2/3
Verifying : bzr-2.6.0-2.fc20.x86_64 3/3
Installed:
bzr.x86_64 0:2.6.0-2.fc20
Dependency Installed:
python-crypto.x86_64 0:2.6.1-1.fc20 python-paramiko.noarch 0:1.15.1-1.fc20
Complete!
it is possible to use -y switch to prevent yum from asking Is this ok [y/d/N]
but where does YUM find these dependencies to install? it starts from /etc/yum.repos.d/
$ cat /etc/yum.repos.d/fedora-updates.repo
[updates]
name=Fedora $releasever - $basearch - Updates
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$releasever&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
[updates-debuginfo]
name=Fedora $releasever - $basearch - Updates - Debug
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/$basearch/debug/
metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-debug-f$releasever&arch=$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
[updates-source]
name=Fedora $releasever - Updates Source
failovermethod=priority
#baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever/SRPMS/
metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-source-f$releasever&arch=$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
######################################
Removing
######################################
For removing a package we have to use -e option of rpm (e for erase) or use the remove option of yum.
[root@localhost ~]# rpm -e bzr
[root@localhost ~]# bzr
bash: bzr: command not found
notes:
& rpm does not have a database of automatic package installation so it can not remove dependencies which are installed automatically.
& rpm removes package without asking!
& rpm wont remove a package which is needed by another package
but if you remove with yum, it will tell what other packages should be removed because of dependencies:
# yum install bzr
# rpm -e python-crypto
error: Failed dependencies:
python-crypto >= 2.1 is needed by (installed) python-paramiko-1.15.1-1.fc20.noarch
######################################
Upgrading
######################################
the most common command is yum update. This will update the repository data and then will ask user to confirm and then will upgrade the system. It is also possible to give a single package name or use a wildcard (*) to upgrade specific packages.
# yum upgrade 'cal*'
will upgrade all packages starting with cal (sal calendarj, calibre, ...).
if using RPM, you can upgrade a system using -U or -F instead of -i. This is the difference:
-i is for install, -U is upgrade or install, -F is upgrade if installed. Note that -F wont install / upgrade the package if it is not already installed.
please note that in many cases, we also us -v (verbose = print a lot of info) and -h (show a progress bar with hash signs (#) ).
Last thing you should now is if installing or updating using rpm and you have many files which are dependent to each other, you can copy all your rpm files into one directory and do a rpm -Uvh *.rpm and rpm will install/upgrade all the packages based on their dependencies to each other.
######################################
Querying info
######################################
You saw that rpm needed a full file name and yum needed only the package name. How can we find these info?
[root@localhost ~]# yum list bzr
Loaded plugins: langpacks
Installed Packages
bzr.x86_64 2.6.0-2.fc20 @fedora
[root@localhost ~]# yum list emacs
Loaded plugins: langpacks
Available Packages
emacs.x86_64 1:24.3-25.fc20 updates
[root@localhost ~]# rpm -q bzr
bzr-2.6.0-2.fc20.x86_64
[root@localhost ~]# rpm -q emacs
package emacs is not installed
[root@localhost ~]# yum info bzr
Loaded plugins: langpacks
Installed Packages
Name : bzr
Arch : x86_64
Version : 2.6.0
Release : 2.fc20
Size : 29 M
Repo : installed
From repo : fedora
Summary : Friendly distributed version control system
URL : http://www.bazaar-vcs.org/
License : GPLv2+
Description : Bazaar is a distributed revision control system that is powerful, friendly,
: and scalable. It is the successor of Baz-1.x which, in turn, was
: a user-friendly reimplementation of GNU Arch.
[root@localhost ~]# yum info emacs
Loaded plugins: langpacks
Available Packages
Name : emacs
Arch : x86_64
Epoch : 1
Version : 24.3
Release : 25.fc20
Size : 2.9 M
Repo : updates/20/x86_64
Summary : GNU Emacs text editor
URL : http://www.gnu.org/software/emacs/
License : GPLv3+
Description : Emacs is a powerful, customizable, self-documenting, modeless text
: editor. Emacs contains special code editing features, a scripting
: language (elisp), and the capability to read mail, news, and more
: without leaving the editor.
:
: This package provides an emacs binary with support for X windows.
It is also possible to search for packages:
[root@localhost ~]# yum search hack
Loaded plugins: langpacks
=================================================== N/S matched: hack ===================================================
nethack-vultures.x86_64 : NetHack - Vulture's Eye and Vulture's Claw
python-hacking.noarch : OpenStack Hacking Guideline Enforcement
...
...
wmMatrix.x86_64 : DockApp version of Jamie Zawinski's xmatrix screensaver hack
Name and summary matches only, use "search all" for everything.
it is also possible to find all installed packages with rpm -qa (query all). In most cases we pipe this with sort or grep and `less:
[root@localhost ~]# rpm -qa | grep vim
vim-minimal-7.4.027-2.fc20.x86_64
If you need to find files in a installed package:
[root@localhost ~]# rpm -ql bzr | head
/etc/bash_completion.d
/etc/bash_completion.d/bzr
/usr/bin/bzr
/usr/lib64/python2.7/site-packages/bzr-2.6.0-py2.7.egg-info
/usr/lib64/python2.7/site-packages/bzrlib
...
...
It is easy, query list.
if you need same info for a downloaded package, just add the -p switch to your rpm command.
Another important task is checking which package, own a specific file. Lets see what package gave us the cal command:
[root@localhost ~]$ which cal
/usr/bin/cal
[root@localhost ~]$ rpm -qf /usr/bin/cal
util-linux-2.24-2.fc20.x86_64
######################################
Dependencies
######################################
if you need to check what a packages is dependent on, use the --requires or -R switch:
[root@localhost ~]# rpm -qR bzr
/usr/bin/python
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
...
...
or use yum deplist bzr instead.
Poof.. I know this part was long so here comes the last important RPM querying command: whatprovides.
If you need to use bzr, you need to check what provides it! if installed you can go with rpm -q --whatprovides bzr and if not :
yum whatprovides bzr
Loaded plugins: langpacks
bzr-2.6.0-2.fc20.x86_64 : Friendly distributed version control system
Repo : fedora
######################################
File Integrity
######################################
Security is important! So RPM can check the MD5 or SHA1 of files. The option is --checksig (-K) and it is a good idea to use it with -v option (verbose):
[root@localhost ~]# rpm -vK bzr-2.6.0-2.fc20.x86_64.rpm
bzr-2.6.0-2.fc20.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID 246110c1: OK
Header SHA1 digest: OK (171c91fbd14416ac44c0f6d396826d583c3840ce)
V3 RSA/SHA256 Signature, key ID 246110c1: OK
MD5 digest: OK (c4478d64f009d07cb17d018b377677ab)
The above output shows that this file is a valid file.
it is also possible to check if the installed FILES by a packages is OK:
[root@localhost ~]# rpm -V bzr
[root@localhost ~]# rm /etc/bash_completion.d/bzr
rm: remove regular file ‘/etc/bash_completion.d/bzr’? y
[root@localhost ~]# rpm -V bzr
missing /etc/bash_completion.d/bzr
if anything goes wrong, we can always reinstall a package:
yum reinstall bzr
######################################
yumdownloader
######################################
this tool will download rpms from repositories but wont install them. If you need to download all the dependencies too, use the --resolve switch:
yumdownloader --resolve bzr
######################################
rpm2cpio
######################################
The cpio is kind of an archive, just like zip or rar or tar. the rpm2cpio can convert rpm files to cpio archives so you can open them using cpio command.
# rpm2cpio bzr-2.6.0-2.fc20.x86_64.rpm | cpio -idv
./etc/bash_completion.d
./etc/bash_completion.d/bzr
./usr/bin/bzr
./usr/lib64/python2.7/site-packages/bzr-2.6.0-py2.7.egg-info
./usr/lib64/python2.7/site-packages/bzrlib
./usr/lib64/python2.7/site-packages/bzrlib/__init__.py
./usr/lib64/python2.7/site-packages/bzrlib/_annotator_py.py
./usr/lib64/python2.7/site-packages/bzrlib/_annotator_pyx.so
...
...
######################################
Other tools
######################################
YUM and RPM are the main package manager tools on Fedora, RHEL & Centos. but other system are available. The SUSE uses YaST and many modern desktops (KDE & Gnome) use PackageKit. Package Kit installs and updates packages on graphical interfaces on most linux systems (Debian, Fedora, Arch, ...). +