Saturday, March 28, 2009

Class 12 Installing Packages in gnu/Linux.!

Redhat Package Manager - RPM
---------------------------------------------------------
* Can install, remove, query, and verify the software on your system
* Can run as root only, since it can change the underlying system.
* Used in other distro's like SuSe and Mandrake too
* have a local database and related files at /var/lib/rpm
* have four common elements : Name , Version (major.minor.patchlevel), Revision and Architecture.
* has frontends like Yum and up2date
* has Five basic modes of operation :
Installing - rpm -i
Uninstalling - rpm -e
Upgrading - rpm -U
Querying - rpm -q
Verifying - rpm -V

Querying:- 

Examples :

(1) rpm -qa | more -> what software you have installed on your system.

-q -> Query option
-a -> List all the packages

(2) rpm -qf /etc/sysctl.conf

-f -> Display the package that contains a particular file.

(3) rpm -qpl package_2.0.2-i386.rpm

-p -> Query a (uninstalled package file).
-l -> List the files in packages.

(4) rpm -qilsdc quota

-i -> displays package information including name, description, release, size, build date, install date, vendor, and other miscellaneous information.
-s -> displays the state of all the files in the package.
-d -> displays a list of files marked as documentation (man pages, info pages, READMEs, etc.).
-c -> displays the configuration files.

(5) rpm -q whatrequires package

print the other packages that depends on the package, installed

(6) rpm -qpR package_2.0.2-i386.rpm

to get the list of packages and programs that are required for instalation of the package_2.0.2-i386.rpm

Installing:- 

1. rpm -ivh package_2.0.2-i386.rpm

-v -> verbose
-h -> print hashes

Other options:- 

--test # simulate what will be done when executing "rpm -ivh package.rpm"
--nodeps # Don't perform a dependency check when installing or upgrading a package
--replacefiles # Install package even if it overwrites existing files
--replacepkgs # Install package even if it's already installed
--force # Combination of --replacefiles, --replacepkgs, and --oldpackage

Upgrading or Freshening:- 

Upgrading to a New package can be done in 2 ways, by freshening the package and by executing:

rpm -Uvh new-package.rpm

"-U" Upgrading option simple removes the old and installed package, then install the new one. The "-Uvh" can be used to install a package too, while freshening can upgrade only installed packages.

For downgrading also the same -U has to be used, but with an extra option though.

rpm -Uvh --oldpackage package_1.0.1-i386.rpm

Freshening --> rpm -Fvh package_2.0.2-i386.rpm <-- will upgrade only if old version of package exists. Erasing or Removing- rpm -e package rpm -e --test package - Don't actually remove package. Just show what will be removed. rpm -e --repackage package - A backup copy is made. The Old RPM will be generated on "_repackage_dir" RPM macro, usually /var/spool/repackage. _repackage_dir can be confirmed by the command, "rpm --showrc" rpm -q --whatrequires package - See a list of packages that requires the RPM package you're trying to erase Verification rpm -V package - Verify installed package rpm -Vp package_VVV-RRR.i386.rpm -- Verify package file, before installing rpm -Va -- Verify all packages Verify the packages downloaded using the GPG-Key rpm --import RPM-GPG-KEY (need to download the key first)
Debian Package Management
:-

.deb is the extension

Installation:-
 
apt-get install packagename

for installing from the repository.


Examples for package installation:-

dpkg --status package - To determine exactly which files are preserved during an upgrade.
dpkg -i package_2.0.2-1_i386.deb - Install package file
dpkg -R /usr/local/src - Install all packages recursively
dpkg --unpack package_2.0.2-1_i386.deb - Unpack the package, but don't configure it.
dpkg --configure package - Configure the unpackaged package
dpkg -r package - Remove an installed package, but leave the config file intact
dpkg -P package - Purge an installed package, including the config files.
dpkg -C package - Searches for packages that have been installed only partially on your system
dpkg -c package_2.0.2-1_i386.deb / dpkg --contents - List contents of package_2.0.2-1_i386.deb
dpkg -l mp3 - List packages matching the word mp3
dpkg -l - List all installed packages, along with package version and short description
dpkg -L package - List files installed to your system from package
dpkg -S 'search pattern' - Search for a filename from installed packages.
dpkg -p package - Display details about package.
dpkg --fsys-tarfile package_2.0.1-i86.deb | tar -xf - config.conf - Extract a single file named config.conf from the package.

Building binary packages from a source debian package:-

You will need all of package_*.dsc, package_*.tar.gz and package_*.diff.gz to compile the source. If there is no, package_*.diff.gz, don't panic. It's "OK".

Make sure dpkg-dev and fakeroot package is installed and dpkg-source command is available. After that,

dpkg-source -x package_version-revision.dsc

will extract the package into a directory called package-version.

If you want just to compile the package, you may cd into package-version directory and issue the command

dpkg-buildpackage -rfakeroot -b

Conversion b/w rpm and deb formats:-
Redhat Package Manager - http://labix.org/smart
Alien - http://kitenet.net/~joey/code/alien/

Package Managers:-

Yum, Apt, Slap-get, Emerge, pkgadd and so on are the package management tool or s/w that act as a automatic updater and package installer/remover for rpm, deb and tar.gz based systems.

Yum (Yellow dog Updater, Modified) is mainly used in the rpm based distros, like redhat, fedora, centos and so on.
Apt (Advanced Package Tool) is for debian based systems. Slap-get, slackpkg is for Slackware, Portage, Emerge for Gentoo and pkgadd for root linux, urpmi for Mandriva and Yast is used by SuSe

These are client server architecture for a software.

Some Yum Options:-

Escape the wild characters using the \.

yum install package
yum groupinstall "MySQL Database"
yum localinstall package.rpm

yum update package
yum groupupdate ""MySQL Database"

yum remove package
yum groupremove "MySQL Database"

yum list package - Search for specific package by name
yum grouplist - List all groups.
yum search mp3 - Searches the names, descriptions, summaries and listed package maintainers of all of the available packages to find those that match
yum provides libc.so - search for all packages that include files called libc.so

yum clean headers , yum clean packages , yum clean metadata , yum clean all - to redownload the indexes and cached files.

yum check update
yum upgrade

tell2humanlinux@gmail.com

1 comment: