APT: An Alternative To yum

 < Day Day Up > 

APT: An Alternative To yum

The Apt (Advanced Package Tool) utility can help with the issue of dependencies: Apt tries to resolve package dependencies automatically by looking for the packages that the package you are installing is dependent on. Since starting life as part of the Debian Linux distribution using Debian's .deb package format, Apt has been ported to rpm-based distributions. For more information go to apt.freshrpms.net.

The Apt utility uses repositories of rpm files as the basis for its actions. To make things quicker, Apt keeps locally a list of packages that are held in each of the repositories it uses. Any software you want to install or update must reside in a repository.

When you give Apt a command to install a package, Apt looks for the package in its local package list. If the package appears in the list, Apt fetches both that package and any packages that the package you are installing is dependent on and calls rpm to install the packages. Because Apt uses rpm, it maintains the rpm database.

Using Apt

This section describes how to configure Apt.

INSTALLING AND SETTING UP APT

Once you have downloaded the apt*.rpm file, you must install it (your Apt version number will be different):

 # rpm -Uvh apt-0.5.15cnc6-1.1.fc3.fr.i386.rpm Preparing...           ###########################################[100%]    1:apt               ###########################################[100%] 

Update the local package list

The primary Apt command is apt-get; its arguments determine what the command does. After you install Apt, give the command apt-get update to update the local package list:

 # apt-get update Get:1 http://ayo.freshrpms.net fedora/linux/3/i386 release [1991B] Fetched 1991B in 0s (4922B/s) Get:1 http://ayo.freshrpms.net fedora/linux/3/i386/core pkglist [1445kB] Get:2 http://ayo.freshrpms.net fedora/linux/3/i386/core release [151B] Get:3 http://ayo.freshrpms.net fedora/linux/3/i386/updates pkglist [251kB] Get:4 http://ayo.freshrpms.net fedora/linux/3/i386/updates release [157B] Get:5 http://ayo.freshrpms.net fedora/linux/3/i386/freshrpms pkglist [98kB] Get:6 http://ayo.freshrpms.net fedora/linux/3/i386/freshrpms release [161B] Fetched 1847kB in 28s (64.7kB/s) Reading Package Lists... Done Building Dependency Tree... Done 

Because the available packages change frequently, it is a good idea to create a cron job to update the local package list automatically. Create the following file to perform this task daily:

 $ cat /etc/cron.daily/apt-update apt-get update 

Check the dependency tree

The Apt utility does not tolerate a broken rpm dependency tree. To check the status of the local dependency tree, run apt-get check:

 # apt-get check Reading Package Lists... Done Building Dependency Tree... Done 

The easiest way to fix errors that apt-get reveals is to erase the offending packages and then reinstall them using Apt.

At the time this book was written, Apt was incompatible with the Ximian Desktop.

Update the system

Two arguments to apt-get cause it upgrade all packages on the system: upgrade upgrades all packages on the system that do not require new packages to be installed and dist-upgrade upgrades all packages on the system, installing new packages as needed.

The following command updates all rpm-based packages on the system that depend only on packages that are already installed:

 # apt-get upgrade Reading Package Lists... Done Building Dependency Tree... Done The following packages will be upgraded   bash binutils dia ethereal foomatic gaim gdm ghostscript gimp-print ...   rhn-applet rsync sed slocate strace vnc-server yum The following packages have been kept back   gstreamer-plugins gthumb rhythmbox 57 upgraded, 0 newly installed, 0 removed and 3 not upgraded. Need to get 59.7MB/87.9MB of archives. After unpacking 11.8MB of additional disk space will be used. Do you want to continue? [Y/n] 

Enter Y to upgrade the listed packages; otherwise, enter N. Packages that are not upgraded because they depend on packages that are not already installed are listed as kept back.

Use dist-upgrade to upgrade all packages, including packages that are dependent on packages that are not installed. This command also installs dependencies.

 # apt-get dist-upgrade Reading Package Lists... Done Building Dependency Tree... Done Calculating Upgrade... Done The following packages will be upgraded   gstreamer-plugins gthumb rhythmbox The following NEW packages will be installed:   Hermes flac libexif libid3tag 3 upgraded, 4 newly installed, 0 removed and 0 not upgraded. Need to get 4510kB of archives. After unpacking 6527kB of additional disk space will be used. Do you want to continue? [Y/n] 

Adding And Removing Individual Packages

The format of a command to install a specific software package and the packages it is dependent on is

 apt-get install package 

where package is the name of the package, such as zsh, and not the name of the rpm, which usually includes version and architecture information (for example, zsh-1.2.i386.rpm).

 # apt-get install zsh Reading Package Lists... Done Building Dependency Tree... Done The following NEW packages will be installed:   zsh 0 upgraded, 1 newly installed, 0 removed and 0 not upgraded. Need to get 1435kB of archives. After unpacking 2831kB of additional disk space will be used. Get:1 http://ayo.freshrpms.net fedora/linux/3/i386/core zsh 4.2.0-3 [1435kB] Fetched 1435kB in 21s (66.0kB/s) Committing changes... Preparing...               ########################################### [100%]    1:zsh                   ########################################### [100%] Done. 

Remove a package the same way you install a package, substituting remove for install:

 # apt-get remove zsh Reading Package Lists... Done Building Dependency Tree... Done The following packages will be REMOVED:   zsh 0 upgraded, 0 newly installed, 1 removed and 0 not upgraded. Need to get 0B of archives. After unpacking 2831kB disk space will be freed. Do you want to continue? [Y/n] y Committing changes... Preparing...               ########################################### [100%] Done. 

To ensure that you can later reinstall a package with the same configuration, the apt-get remove command does not remove configuration files from the /etc directory hierarchy. Although it is not recommended, you can use the purge option to remove all of these files, including configuration files. Alternatively, you can move these files to an archive so you can restore them later if necessary.

apt.conf: Configuring Apt

The /etc/apt/apt.conf file contains Apt configuration information and is split into three sections: APT, which contains global settings for the Apt tools; Acquire, which describes settings related to the package-fetching mechanism; and RPM, which contains rpm-specific settings. In this file semicolons (;) separate statements and double forward slashes (//) introduce comments.

APT section

The APT section is shown following:

 $ cat /etc/apt/apt.conf APT {     Clean-Installed "false";     Get {         Assume-Yes "false";         Download-Only "false";         Show-Upgraded "true";         Fix-Broken "false";         Ignore-Missing "false";         Compile "false";     }; }; ... 

When you set Clean-Installed to TRUE, Apt removes packages that are no longer in the repository.

The options in the Get subsection listed here apply to the apt-get utility (the apt-get utility has command line arguments with the same names as these options):

Assume-Yes

TRUE runs apt-get in batch mode, automatically answering YES whenever it would otherwise prompt you for input.

Download-Only

TRUE retrieves packages from the repository but does not install them. FALSE retrieves and installs the packages.

Show-Upgraded

TRUE displays a list of upgraded packages.

Fix-Broken

TRUE attempts to fix dependency tree problems with varying degrees of success. FALSE quits if it finds a dependency tree problem.

Ignore-Missing

TRUE holds back missing or corrupt packages and continues to install other packages. FALSE aborts the entire install or upgrade upon finding a missing or corrupt package.

Compile

TRUE compiles and installs source rpm (SRPM) packages that you ask apt-get to retrieve. FALSE downloads these files without compiling or installing them.

Acquire section

The Acquire section controls options related to fetching packages.


 $ cat /etc/apt/apt.conf ... Acquire { Retries "0"; Http { Proxy ""; // http://user:pass@host:port/ } }; ... 

The Retries option specifies the number of times Apt attempts to fetch a package when an attempt fails. The Http Proxy setting specifies the proxy to use when fetching packages using HTTP. The argument to this option is blank by default, indicating that Apt should not use a proxy. An example proxy is shown as a comment.

RPM section

Following is the RPM section of apt.conf:

 $ cat /etc/apt/apt.conf ... RPM {     Ignore { };     Hold { };     Allow-Duplicated { "^kernel$"; "^kernel-"; "^kmodule-"; "^gpg-pukey$" };     Options { };     Install-Options "";     Erase-Options "";     Source {         Build-Command "rpmbuild --rebuild";     }; }; 

The Ignore and Hold options perform similar functions and contain lists of packages that Apt ignores or holds (does not upgrade). They are usually blank.

The Allow-Duplicated section lists packages that can have more than one version on the system at one time. In general you do not want to have multiple versions of the same package on a system. The kernel is an exception: It is good practice to leave the old kernel installed when you install a new kernel in case you are unable to boot the new one.

The Options section contains options that are passed to rpm. The Install-Options and Erase-Options sections contain options that are passed to rpm whenever it is used to install or erase a package.

The Source Build-Command option specifies the command that Apt uses to build a source rpm file.

     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net