Pkgmgmt101

From openSUSE Community Wiki

Contents

Package Management in openSUSE for Newcomers


Lightning fast crash course for new openSUSE users on how to install packages in openSUSE! If you dont know about YaST, just came from other Linux distro, this is for you.

People often ask in IRC how to install packages in openSUSE, and it is sometimes hard to explain. There are lots of resources, but people can't find them because they are in different pages or people don't know about them or don't read the documentation, etc. So the purpose of this guide is to be an introduction to the topic, and give the minimum amount of information for a newcomer to get going.

Crash course into technical terms


Lets start, lean and mean, on what you need to know about it:

Packages

Packages actually contain the files that make up a piece of software (an application like MozillaFirefox, shared libraries such as libusb, development packages containing files needed to build software against a library such as kdelibs3-devel, ...).

A package is properly integrated into the distribution it has been built for, with regard to installation paths, dependencies (see below), desktop integration, proper startup scripts for servers, etc...

For the reasons above, you should always install packages that have been built for the distribution you are using, including the exact version of the distribution (e.g. openSUSE 10.2). As an example, do not install Fedora packages on openSUSE, and not even openSUSE 10.1 packages on openSUSE 10.2 (although the latter might work, occasionally).

Package Metadata

A package also contains further information (commonly referred to as "metadata"), such as

  • a summary,
  • a description,
  • a list of files contained in the package,
  • the version of the software it contains as well as the release number of the package,
  • when, where and by whom it has been built,
  • what architecture it has been built for,
  • checksums of the files contained in the package,
  • the license of the software it contains,
  • etc...

Package Dependencies

Packages also have dependencies on other packages, which means that (as an example) package A needs the packages B, C and D to be installed in order to work properly.

Dependencies are not there to annoy you, they are really needed to actually run the application. Note that dependencies on libraries (typically packages with a name that starts with "lib") are very common and pretty much every single application depends on a set of library packages.

Package dependencies are transitive, which means that when package A needs package B, and package B needs package C, package A also needs package C. Which is why you sometimes end up with lots of packages to install although you just wanted that one application.

Packages and Package Dependencies are very important aspects of Linux distributions (as well as other BSD and UNIX systems) because they provide a modular way to set up and manage an operating system and its applications. This is especially true for library packages: as an example, the package openssl contains cryptographic libraries that are used by many applications and other libraries (e.g. for SSL encryption). When a new, improved version of openssl is available, all the applications that use it will benefit from it just by upgrading that single package to the newer version.

It's also a very efficient way to maintain a stable and secure system: when a security hole, exploit or bug affects a library used by one or many applications, upgrading the single package will fix it for all of them.

Package Formats

Several package formats exist amongst Linux, *BSD and UNIX systems, most prominently "RPM" (RPM Package Manager) and "deb".

RPM was originally developed by Red Hat but adopted since then by other distributions such as openSUSE, Mandriva, Fedora or CentOS, to name just a very few.

The "deb" format has been developed by the developers of the Debian distribution and is used on Debian itself, as well as on its derivatives (such as Ubuntu).

Package Repository

A Repository is a collection of software packages on a media (usually a directory in a webserver, or a CD/DVD).

Repositories provide "metadata" about the packages they contain (package names, versions, dependencies, ...) -- typically, an aggregated form of the Package Metadata (see above) of the packages they contain.

Repositories are usually referred to using URLs (e.g. http://download.opensuse.org/distribution/11.0/repo/oss/)

Repository Formats

There are several different Repository Metadata formats: the most commonly encountered formats for openSUSE are "RPM-MD" (RPM MetaData, also known as "YUM") and YaST's own format (which is rather being deprecated in favour of RPM-MD, the latter being a standard across RPM-based distributions).

Package Manager

A Package Manager is an application that is able to install, update and remove packages.

rpm itself is usually not referred to as a Package Manager, as it only provides low-level operations on packages and is not able to resolve dependencies by downloading required additional packages.

Package Managers put an additional layer on top of the low-level tools such as rpm, typically providing the following additional capabilities:

  • download and refresh metadata from several repositories (see above), to know where to find what
  • resolve package dependencies by downloading and installing dependencies as well (if package A needs packages B and C but C is not installed, installing A will make a Package Manager first download and install C)
  • detect and display newer versions of packages that are available in repositories
  • search for packages in repositories

Note that unless you really know what you are doing, you should never install packages using low-level tools such as rpm (or dpkg on Debian based distributions) but always use a package manager instead.

Examples of Package Managers

How it works


This is very simple. It's going to be one phrase:

You add repositories to a package manager so it will be aware of the packages available in the repositories, then you tell it what packages you want to install and it will install them.

Neato! Yes, its that simple =)


Repositories?


So you need repositories, right? Wait, you don't know how to find openSUSE repositories?

Ok, its here: Repositories

PS: There is only one golden rule you should follow: ALWAYS use a source for your correct openSUSE version. Don't use repositories (or RPMs) made for other openSUSE version, and dont use RPMs built for other Linux distributions (or God will kill a kitten if you even think of doing it! And yes, I'm serious).

You can search for a program in here and find out if it is available in a repository close to you:


Working with packages in openSUSE


Ok, now you know the secret. The only part missing is telling you where to make that work in openSUSE.

The openSUSE package manager is called zypp, and you need to tell it 2 things:

  1. What are your repositories
  2. What you want to install

Note that you can only do (2) *after* doing (1). Ok? ok.

So we know zypp is responsible to handle all that data and doing the package management, but you still need to access it.

PS: Info on zypp: http://en.opensuse.org/Libzypp


Accessing zypp I - Specifying the repositories

Don't forget you need to be root to add repositories

There are 2 ways you can access zypp:

  1. Using YaST interface (can be graphical or ncurses)
  2. Using zypper interface (which is a command line interface)

So, for adding sources you can:

  1. Go to YaST -> installation sources, and add the URL in there (this is the most simple and error free method!)
  2. zypper ar -t rpm-md http://download.opensuse.org/distribution/10.3/repo/oss ossrepo
  3. installation_sources -a http://download.opensuse.org/distribution/10.3/repo/oss

Check this page on how to add sources: http://opensuse-community.org/AddSource

Accessing zypp II - seek and destroy (erm, search and install)

Now that you have added the repositories, you are good to go. Lets do it, lets install the packages.

Don't forget you need to be root to install packages!

  • zypper way

Let's search and install MPlayer (MPLayer is in the packman repository)

# zypper se MPlayer // Lets search for packman

<message saying it found it in a repository>

# zypper in MPlayer // tell zypper to install MPlayer

<message saying it installed MPlayer, hopefully>


  • YaST way

You need to open another YaST module, so open YaST -> Software Management

You will see a screen where you can search for packages, list the repositories, etc. It's much more comfortable to use it here, you just need to search and tick the packages you want to install.

When you are done, just click OK, and it will show a list of what you are installing and, if needed, solve some dependency handling you may need.

If you configured the sources correctly this will usually just list the stuff; you won't need to make a manual intervention, but if you need to, it's easy just select one of the options wisely. If you are in doubt, just ask for help.

To-do. add screeshots of yast UI in live action

External links


Retrieved from "http://kruemel/Pkgmgmt101"