Exploring the Yum Package Manager If You Are Removing Packages, It Pays to Be Careful; Automatically Removing Dependencies Can Have Unpleasant Side Effects
Total Page:16
File Type:pdf, Size:1020Kb
LINUXUSER A Taste of Yum Exploring the yum package manager If you are removing packages, it pays to be careful; automatically removing dependencies can have unpleasant side effects. By default, yum will install from the configured package sources (e.g., DVD, Internet repositories). You can also in- DELICIOUS stall individual RPM files with yum in- stead of rpm. Again, yum will check for Install and manage packages from the command line with the powerful dependencies and reference the reposito- yum package manager. BY DANIEL NIEDZIELSKI ries to add any missing packages auto- matically. The command line for this is: um (Yellow Dog Updater, Modi- same time. For example, to install the yum localinstall package_name fied) runs on Fedora and Yellow Pingus game, type yum install pingus. YDog Linux as an interface to the To check the dependencies, yum starts Yum also makes life easier if you need to underlying RPM system. You can think by loading the header files with the pack- remove a package by deleting any com- of yum as something like the apt pack- age metadata for the new package as a ponents you no longer need. With the age manager found on Debian-based background operation. After resolving example of the Pingus game installation, systems. If you favor a graphical ap- the dependencies, yum lists the addi- yum adds sdl and ClanLib. proach, yum graphical front-ends in- tional package requirements (Listing 1). If you want to remove these packages, clude pirut (Figure 1), gyum, yum ex- Then the tool asks you to confirm that you must explicitly tell the RPM com- tender (Figure 2), and kyum; however, if you want to start the installation; if so, mand to do this: you are familiar with a few basic yum type Y. If the installation is successful, commands, you might find that yum is yum will output a Complete! message to rpm -e pingus SDL Clanlib .... faster and easier without the GUI. In this confirm that the packages were installed article, I’ll help you get started with correctly. Because you typically learn the depen- command-line Yum. If you don’t like answering Yes/ No dencies for the packages you are remov- The yum package manager is really prompts, you can specify the -y option ing from RPM’s error messages, this ap- easy to use. To install a package, type to say yes automatically to all questions: proach can be time-consuming. In con- yum install package_name; you can trast, yum remove ClanLib will list the specify any number of packages at the yum -y install pingus packages to uninstall, including their de- Elena Elisseeva, Fotolia Elisseeva, Elena 78 ISSUE 103 JUNE 2009 A Taste of Yum LINUXUSER pendencies. Yum quickly prompts you to confirm that you want to uninstall all the listed packages and then does so if you say yes. Update Packages To update a package – or all packages – use the yum update package_name or yum update command. If you prefer a GUI, launch the Package Updater, pup, from a console through the desktop menu. Pup is part of the pirut package, which you set up via yum install pirut. The yum update daemon will even up- date the whole system. To allow this to happen, you need to set the do_update entry to yes in your /etc/yum/yum-up- datesd.conf configuration file (Listing 2). At boot time, chkconfig tells you whether or not the updatesd service is launched automatically: # chkconfig --list | grep -i yum Figure 2: If pirut is too spartan for your taste, try yum extender. The output shows the runlevel the ser- date. Typing run launches the batch se- vice is enabled in; you can type runlevel Yum Shell quence you entered previously. When to identify the current runlevel. To en- If you need to complete a couple of you are done, you can quit the shell by able automatic start-up when you boot, chores one after another, the yum shell typing quit. Another use for the yum type chkconfig yum-updatesd on. To start is the best place to do it. The shell lets shell is to invoke a pipe to install some- the daemon once only, type service you enter a number of actions in se- thing directly from a shell script: yum-updatesd start. quence without waiting for the previous Most often, you are likely to use the action to complete. A typical scenario is # echo -e “install pingus\n U command yum search keyword, com- a session in which you delete the cache, run\n quit” | yum -y shell mand searches the package names and install packages, and remove other details of all available packages for the packages. Here documents are often used for this keyword. To restrict the search to the To launch the shell, type yum shell. purpose. A here document is a special package names, you can type yum list | The prompt accepts all the normal com- approach to redirecting commands to grep keyword. mands, such as install, remove, or up- the stdin channel of a program (Listing 3). Unlike the normal echo command, this method keeps most indents and newlines. You might need to download a number of RPM packages that you will be install- ing later on, or that you need to install on several identical machines. The yum- downloader tool from the yum-utils pack- age is useful for this. To download the Pingus game, just type yumdownloader pingus. Yumdownloader will drop the specified package into the current work- ing directory. Then you can enter # yum localinstall pingus-U 0.7.2-3.fc10.i386.rpm to install and resolve the dependencies. If you want to resolve the dependencies at the download stage, call yuminstaller Figure 1: Fedora uses the pirut front-end as its default package manager. with the --resolve option. JUNE 2009 ISSUE 103 79 LINUXUSER A Taste of Yum Yum is also perfect for downloading To avoid legal issues, Fedora only pro- tion files below /etc/yum.repos.d/: fe- source packages that you will be build- vides software available under a free li- dora.repo, fedora-updates.repo, and ing manually. To do so, use the --source cense. The default Fedora repositories do livna.repo. Just set the top lines to en- option not include proprietary programs or, for abled=1 and the others to enabled = 0. licensing reasons, many other free appli- Alternatively, you can delete and dis- # yumdownloader U cations, such as mplayer. Fortunately, able all additional repository entries by --source pingus some of these programs are available typing: through third-party suppliers. to create an RPM file called pin- The most popular repositories include # rpm -e yum-priorities U gus-0.7.2-3.fc10.i386.rpm in the current Livna, RPMforge, Dribble, freshrpms, yum-fedorafaq livna-release directory. To install, type: and ATrpms. In Fedora 10, Dribble, freshrpms, and Livna combined to form The yum-priorities plugin mentioned # rpm -ihv pingus-0.7.2-3.U a single repository known as RPM Fu- earlier is used here. yum repolist gives fc10.i386.rpm sion [1]. The unofficial Fedora FAQ page you a list of all enabled repositories. [2] describes how to add Livna, or RPM This command drops the source archive Fusion, as package source; for Fedora 10, Upgrading with Yum into /usr/src/redhat/SOURCES/, where simply enter: Yum lets you upgrade a Fedora system to you can unpack and build the applica- the next version on the fly. Unfortu- tion yourself. # rpm -Uvh U nately, this option sometimes doesn’t http://rpm.livna.org/U work properly and typically requires Caching livna-release-10.rpm some manual attention. When launched, yum updates the If you do decide to rely on yum up- header files; it will always download the The configuration files for the various re- grading for you, start by flushing your headers, even if you are installing the positories are stored in /etc/ yum cache and updating the package package multiple times. To avoid redun- yum-repos.d/. In these configuration sources. Listing 4 gives a short overview dancy, you can enable header and pack- files, you can enable or disable individ- of the steps required for upgrading to Fe- age file caching. To do so, enable the ual repositories with the enabled=1 or dora 11. You’ll find a more detailed keepcache=1 option in the /etc/yum enabled=0 entries. Most repository files howto in the Fedora wiki [3]. .conf configuration file. If you then call include several entries, but typically you yum with the -C option, yum will access only need the top one. Package Groups the cache regardless of the /etc/yum.conf After completing a standard Fedora in- If you use Ubuntu and occasionally need settings. Of course, this will only work if stallation, including the RPM Fusion re- to compile something, you will be famil- you really do have the required re- pository, you will have three configura- iar with the build-essential package. sources in the cache. If resources are missing, yum will give you the message Listing 1: Installing with yum Caching enabled but no local cache of …. Dependencies Resolved Plugins and Repositories ============================================================================= Yum has many extensions that you can Package Arch Version Repository Size install easily from the repository. When ============================================================================= you download a file, for example, the Installing: Fastestmirror plugin performs a back- ground search for the fastest mirror pingus i386 0.7.0-0.4.20060721.fc6 fedora 18 M server. To install and enable the plugin, Installing for dependencies: type yum install yum-fastestmirror.