Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1362219
  • 博文数量: 343
  • 博客积分: 13098
  • 博客等级: 上将
  • 技术积分: 2862
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-06 00:35
文章存档

2012年(131)

2011年(31)

2010年(53)

2009年(23)

2008年(62)

2007年(2)

2006年(36)

2005年(5)

分类: LINUX

2008-12-17 20:20:24

Introduction

Smart is a package manager that works on most major distros (APT, APT-RPM, YUM, URPMI, etc), and offers "better package management for these distributions, even when working with their own packages".

http://wiki.suselinuxsupport.de/wikka.php?wakka=HowtoSmartPackageManager/images.xml&action=download&file=HowtoSmartPackageManager_smart1tn.jpg

Features

  • Modular

Smart has been developed with modularity and flexibility in mind. It's completely backend-based, and package-manager-agnostic. Support is currently implemented for RPM, DPKG, and Slackware package management systems, and porting it to new systems should be very easy.

  • Smart Transactions

That's one of the most interesting aspects of Smart Package Manager, and the one who has motivated calling it smart: Computing transactions respecting the relations involved in the package management world may become an unpleasant task when thousands of packages and relations are being considered, or even when just a few complex relations turn the most obvious choice into the unwanted one.

While other software applications try to find a possible solution to satisfy the relations involved in some user-requested operation, and sometimes even fail to do so, Smart goes beyond it. In the kernel of Smart Package Manager lives an algorithm that will not only find a solution, if one is available, but will find the best solution. This is done by quickly weighting every possible solution with a pluggable policy, which redefines the term "best" depending on the operation goal (install, remove, upgrade, etc).

This behavior has many interesting consequences. In upgrades, for instance, while precedence is given to newer versions, intermediate versions may get selected if they bring a better global result for the system. Packages may even be reinstalled, if different packages with the same name-version pair have different relations, and the one not installed is considered a better option.

Another important goal achieved with the transaction algorithm is that, even though it is able to check and fix relations in the whole system, it will work even when there are broken relations in installed packages. Only relations related to the operation being made are checked for correctness.

{i} Check case studies for real cases where the algorithm works better than what is implemented in other softwares.

*Priority Handling

Priorities are a powerful way to easily handle integration of multiple channels and explicit user setups regarding preferred package versions.

Basically, packages with higher priorities are considered a better option to be installed in the system, even when package versions state otherwise. Priorities may be individually assigned to all packages in given channels, to all packages with given names, and to packages with given names inside given channels.

With custom priority setups, it becomes possible to avoid unwanted upgrades, force downgrades, select packages in given channels as preferential, and other kinds of interesting setups.

  • Autobalancing Mirror System

Smart offers a very flexible mirror support. Mirrors are URLs that supposedly provide the same contents as are available in other URLs, named origins. There is no internal restriction on the kind of information which is mirrored. Once an origin URL is provided, and one or more mirror URLs are provided, these mirrors will be considered for any file which is going to be fetched from an URL starting with the origin URL.

Mirror precedence is dynamically computed based on the history of downloads of all mirrors available for a given origin URL (including the origin site itself). The fastest mirrors and with less errors are chosen. When errors occur, the next mirror in the queue is tried.

For instance, if a mirror is provided for the origin , and a file in is going to be fetched, the mirror will be considered for being used, and the URL will be used if the mirror is chosen. Notice that strings are compared and replaced without any pre-processing, so that it's possible to use different schemes (ftp, http, etc) in mirror entries, and even URLs ending in prefixes of directory entries.

  • Downloading Mechanism

Smart has a fast parallel downloading mechanism, allowing multiple connections to be used for one or more sites. The mechanism supports:

  • Resuming
  • Timestamp checking
  • Parallel uncompression
  • Autodetection of FTP user limit
  • Cached file validation

and more.

At that moment, the following schemes are nativelly supported:

  • file
  • ftp
  • http
  • https
  • scp

Additionally, the following schemes are supported when pycurl is available:

  • ftps
  • telnet
  • dict
  • ldap
  • Removable Media Support

Smart Package Manager implements builtin support for removable media (CDROMs, DVDs, etc) in most of the supported channel types. The following features are currently implemented:

  • Mountpoint autodetection
  • Support for multiple simultaneous media drives
  • Media may be inserted in any order
  • Installed system is guaranted to maintain correct relations between media changes
  • Remote removable media support using any of the supported schemes (ftp, http, scp, etc)

Available Interfaces

Smart has multiple native and completely integrated interfaces:

  • Command line interface, with several useful subcommands: update, install, reinstall, upgrade, remove, check, fix, download, search, and more.
  • Shell interface, with command and argument completion, making it easy to perform multiple operations quickly using a local or remote terminal.
  • Graphic interface, offering the friendliness of visual user interaction.
  • Command line interface with graphic feedback, allowing one to integrate the power of command line with graphic environments.

Besides these interfaces, ksmarttray is also included in the Smart package. It notifies users about available updates using a KDE tray icon.

Installation


Distribution

Download

Mandriva

ftp://ftp.ciril.fr/pub/linux/mandrakelinux/devel/cooker/cooker/media/main/ Cooker, Also check your Mandriva Contrib

Fedora/ Enterprise Linux

RPMforge ATrpms Guilherme Manika Fedora Core 5

Debian

Michael Vogt

CCux Linux

http://packages.ccux-linux.de/index.php?pdetail=706 CCux Linux

SUSE Linux

SUSE

Mac OS

Jeff Johnson

Fox Linux

Fox Linux

PCLinuxOS

PCLinuxOS

You can find smart at one of the above links for your distribution. Simply download it and install it from the command line or use a package manager like YaST, yum, or apt:

#rpm -Uvh smart-x.xx-x

#yum install smart-x.xx-x

#apt-get install smartpm-x.xx-x

#slapt-get --install smart

#swaret --install smart

To install from source, unpack package and cd into smart directory and execute as root:

python setup.py build
  • (where x is the version number). You don't have to install ksmarttray unless you want it in the tray.

Prerequisites


Mandriva/PCLinuxOS

Fedora/ Enterprise Linux

Debian/Ubuntu

SUSE

GLIBC

GLIBC

GLIBC

GLIBC

rpmlib

rpmlib

debhelper

rpm

python-rpm

python-abi

python2.4

rpm-pytho

python-base

usermode

python2.4-curl

python

gtk2

python

python2.4-gtk2

zlib

python-psyco

rpm

dpatch

popt

usermode-console-only

pygtk

python2.4-dev

gtk2

python

lsb-release


python-gtk


pygtk2.0


bzip2

  • Make sure you have these packages before installing smart. If you want the smart gui to run, then make sure that you have a current gtk2 and python-gtk/pygtk.

Most of these packages are part of a basic rpm distribution installation. GLIBC is standard in all distributions. To find out what you have installed on your RPM based distribution, simply run:

rpm -q --whatprovides 

For example,

rpm -q --whatprovides rpm-python

You can install smart via a package managers such as apt, YaST, or yum. Make sure you have your sources set. Please consult your distribution documentation if you have questions about how to set up your sources.

Supported Sources

Smart supports a variety of sources. Here is a list of what Smart supports:

  • RPM repositories
    • RPM System Database (locally installed packages)
    • APT repositories for .rpm
    • YaST repositories (SuSE 9.3 and below (this is in testing))
    • RPM-MD (used by YUM)
    • Red Carpet (used by Ximian/Novell)
    • RPM Header List (used by and Conectiva installation CDs, probably others)

    • RPM Directory (a directory with a bunch of RPMs in it, no indexing required)
    • URPMI (used by Mandriva)
  • DEB repositories
    • DEB System Database (locally installed packages)
    • [ APT repositories for .deb]

    • DEB Directory (a directory with a bunch of DEBs in it, no indexing required)
  • Slackware
    • Slackware installed packages database
    • [ Slackware repositories]

  • Mirrors
    • up2date (used by RedHat/Fedora)
    • Conectiva-style mirror description formats

From the Smart --help File

Smart Action Commands

        update
install
reinstall
upgrade
remove
check
fix
download
clean

Smart Update

This command will update the known information about the
given channels. If no channels are given, all channels
which are not disabled or setup for manual updates will
be updated.

Options:
-h, --help Show this help message and exit
--after=MIN Only update if the last successful update happened before the
given delay

Examples:
smart update
smart update mychannel
smart update mychannel1 mychannel2

As you can see, you can control when smart updates, and specify what channels.

Smart Install/Reinstall

Usage: smart install [options] package ...

This command will install one or more packages in the
system. If a new version of an already installed package
is available, the new version will be selected for installation.

Options:
-h, --help Show this help message and exit
--stepped Split operation in steps
--urls Dump needed urls and don't commit operation
--download Download packages and don't commit operation
--explain Include additional information about changes, when possible
-y, --yes Do not ask for confirmation

Examples:
smart install pkgname
smart install '*kgna*'
smart install pkgname-1.0
smart install pkgname-1.0-1
smart install pkgname1 pkgname2
smart install ./somepackage.file
smart install

Smart install --stepped is a option that will confirm each step. Say you wanted to install foobar and it required some dependencies; before installing/upgrading those dependencies, it ask for confirmation with each package.

Smart install --explain can be a useful option for figuring out why smart wants to downgrade, remove, upgrade or consider certain packages. Basically, it's good for explaining the dependencies and its decisions.

Smart Upgrade

Usage: smart upgrade [options] [package] ...

This command will upgrade one or more packages which
are currently installed in the system. If no packages
are given, all installed packages will be checked.

Options:
-h, --help Show this help message and exit
--stepped Split operation in steps
--urls Dump needed urls and don't commit operation
--download Download packages and don't commit operation
--update Update channel information before trying to upgrade
--check Just check if there are upgrades to be done
--check-update Check if there are upgrades to be done, and update the known
upgrades
--explain Include additional information about changes,when possible
-y, --yes Do not ask for confirmation

Examples:
smart upgrade
smart upgrade pkgname
smart upgrade '*kgnam*'
smart upgrade pkgname-1.0
smart upgrade pkgname-1.0-1
smart upgrade pkgname1 pkgname2

As mentioned before, the stepped option would work the same here, confirming each action before proceeding.

Smart Remove

Usage: smart remove [options] package ...

This command will remove one or more packages which
are currently installed in the system.

Options:
-h, --help Show this help message and exit
--stepped Split operation in steps
--urls Dump needed urls and don't commit operation
--download Download packages and don't commit operation
--explain Include additional information about changes,when possible
-y, --yes Do not ask for confirmation

Examples:
smart remove pkgname
smart remove '*kgnam*'
smart remove pkgname-1.0
smart remove pkgname-1.0-1
smart remove pkgname1 pkgname2

Smart Check

Usage: smart check [options] [package] ...

This command will check relations between packages. If no
packages are explicitly given, all packages in the selected
channels will be checked. Relations of the checked packages
will only match packages inside the selected channels.

Use the 'fix' command to fix broken relations of
installed packages.

Options:
-h, --help Show this help message and exit
--all Check packages in all channels
--installed Check packages which are in at least one installed
channel (default)
--available Check packages which are in at least one non-installed
channel
--channels=ALIASES Check packages which are inside the given channels (comma
separated aliases)

Examples:
smart check
smart check pkgname
smart check '*kgna*'
smart check pkgname-1.0
smart check pkgname-1.0-1
smart check pkgname1 pkgname2

Smart Fix

Usage: smart fix [options] [package] ...

This command will try to fix dependencies of installed packages
which are related to the given packages. Notice that the given
packages may be currently installed or not. If no packages are
given, all installed packages will be checked.

Options:
-h, --help Show this help message and exit
--stepped Split operation in steps
--urls Dump needed urls and don't commit operation
--download Download packages and don't commit operation
--explain Include additional information about changes,when possible
-y, --yes Do not ask for confirmation

Examples:
smart fix
smart fix pkgname
smart fix '*kgna*'
smart fix pkgname-1.0
smart fix pkgname-1.0-1
smart fix pkgname1 pkgname2

Smart Download

Usage: smart download [options] package ...

This command allows downloading one or more given packages.

Options:
-h, --help Show this help message and exit
--target=DIR Packages will be saved in given directory
--urls Dump needed urls and don't download packages
--from-urls Download files from the given urls and/or from the given files
with lists of urls

Examples:
smart download pkgname
smart download '*kgna*'
smart download pkgname-1.0
smart download pkgname-1.0-1
smart download pkgname1 pkgname2
smart download pkgname --urls 2> pkgname-url.txt
smart download --from-urls pkgname-url.txt
smart download --from-urls

Smart Clean

smart clean

The smart clean command cleans the cache. You may use it to delete old files/packages in order to save space.

Smart Query and Information Commands

Query commands:
search
query
info
stats

Smart Search

This command allows searching for the given expressions
in the name, summary, and description of known packages.

Examples:
smart search ldap
smart search kernel module
smart search rpm 'package manager'
smart search pkgname
smart search 'pkgn*e'

Smart Query

This command allows querying the known packages in many
different ways. Check also the 'search' command.

Options:
-h, --help Show this help message and exit
--installed Consider only installed packages
--provides=DEP Show only packages providing the given dependency
--requires=DEP Show only packages requiring the given dependency
--conflicts=DEP Show only packages conflicting with the given dependency
--upgrades=DEP Show only packages upgrading the given dependency
--name=STR Show only packages which match given name
--summary=STR Show only packages which match given summary
--description=STR Show only packages which match given description
--path=STR Show only packages which include the given path in the
available meta information
--url=STR Show only packages which include the given reference url
in the available meta information
--hide-version Hide package version
--show-summary Show package summaries
--show-provides Show provides for the given packages
--show-requires Show requires for the given packages
--show-prerequires Show requires selecting only pre-dependencies
--show-upgrades Show upgrades for the given packages
--show-conflicts Show conflicts for the given packages
--show-providedby Show packages providing dependencies
--show-requiredby Show packages requiring provided information
--show-upgradedby Show packages upgrading provided information
--show-conflictedby Show packages conflicting with provided information
--show-priority Show package priority
--show-channels Show channels that include this package
--show-all Enable all --show-* options
--format=FMT Change output format
--output=FILE Redirect output to given filename

Examples:
smart query pkgname
smart query '*kgnam*'
smart query pkgname-1.0
smart query pkgname --show-requires
smart query --requires libpkg.so --show-providedby
smart query --installed
smart query --summary ldap

Smart Info

This command will show information about the given packages.

Options:
-h, --help Show this help message and exit
--urls Show urls
--paths Show path list

Examples:
smart info pkgname
smart info pkgname-1.0
smart info pkgname --urls --paths

Smart Stats

This command will show some statistics.

Examples:
smart stats

Smart Setup Commands

Setup commands:
channel
priority
mirror
flag

Smart Channel

Usage: smart channel [options]

This command allows one to manipulate channels. Channels are
used as sources of information about installed and available
packages. Depending on the channel type, a different backend
is used to handle interactions with the operating system and
extraction of information from the given channel.

The following channel types are available:

apt-deb - APT-DEB Repository
apt-rpm - APT-RPM Repository
deb-dir - DEB Directory
deb-sys - DPKG Installed Packages
mirrors - Mirror Information
red-carpet - Red Carpet Channel
rpm-dir - RPM Directory
rpm-hdl - RPM Header List
rpm-md - RPM MetaData
rpm-sys - RPM Installed Packages
slack-site - Slackware Repository
slack-sys - Slackware Installed Packages
up2date-mirrors - Mirror Information (up2date format)
urpmi - URPMI Repository
yast2 - YaST2 Repository

Use --help-type for more information.

Options:
-h, --help Show this help message and exit
--add Argument is an alias and one or more key=value pairs
defining a channel, or a filename/url pointing to a channel
description in the same format used by --show, or a
directory path where autodetection will be tried
--set Argument is an alias, and one or more key=value pairs
modifying a channel
--remove Arguments are channel aliases to be removed
--remove-all Remove all existent channels
--show Show channels with given aliases, or all channels if no
arguments were given
--edit Edit channels in editor set by $editor
--enable Enable channels with given aliases
--disable Disable channels with given aliases
-y, --yes Execute without asking
--help-type=TYPE Show further information about given type

Examples:
smart channel --help-type apt-rpm
smart channel --add mydb type=rpm-sys name="RPM Database"
smart channel --add mychannel type=apt-rpm name="Some repository" \
baseurl= components=extra
smart channel --set mychannel priority=-100
smart channel --disable mychannel
smart channel --remove mychannel
smart channel --show
smart channel --show mychannel > mychannel.txt
smart channel --add ./mychannel.txt
smart channel --add
smart channel --add /mnt/cdrom

Smart Priority

Usage: smart priority [options]

This command allows changing the priority of given packages.
Packages with higher priorities are considered a better option
even when package versions state otherwise. Using priorities
one may avoid unwanted upgrades, force downgrades, select
packages in given channels as preferential, and other kinds
of interesting setups. When a package has no explicit priority,
the channel priority is used. The channel priority may be
changed using the 'channel' command, and defaults to 0 when
not set.

Notice that negatives priorities must be preceded by '--' in
the command line, otherwise they'll be interpreted as command
line options.

Options:
-h, --help Show this help message and exit
--set Set priority
--remove Unset priority
--show Show priorities
--force Ignore problems

Examples:
smart priority --set pkgname 100
smart priority --set pkgname mychannel -- -200
smart priority --remove pkgname
smart priority --remove pkgname mychannel
smart priority --show
smart priority --show pkgname

Smart Mirror

Usage: smart mirror [options]

This command allows one to manipulate mirrors. Mirrors are URLs
that supposedly provide the same contents as are available in
other URLs, also called origins in this help text. There is no internal
restriction on the kind of information which is mirrored. Once
an origin URL is provided, and one or more mirror URLs are
provided, these mirrors will be considered for any file which
is going to be fetched from an URL starting with the origin URL.
Whether the mirror will be chosen or not will depend on the
history of downloads from this mirror and from other mirrors for
the same URL, since mirrors are automatically balanced so that
the fastest mirror and with less errors is chosen. When errors
occur, the next mirror is tried.

For instance, if a mirror "" is provided
for the origin "ftp://origin.url/other/path/", and a file in
"ftp://origin.url/other/path/subpath/somefile" is going to be
fetched, the mirror will be considered for being used, and the
URL "subpath/somefile" will be used if
the mirror is chosen. Notice that strings are compared and
replaced without any pre-processing, so that it's possible to
use URLs ending in prefixes of directory entries.

Options:
-h, --help Show this help message and exit
--show Show current mirrors
--add Add to the given origin url the given mirror url, provided
either in pairs, or in a given file/url in the format used
by --show
--remove Remove from the given origin url the given mirror url,
provided either in pairs, or in a given file/url in the
format used by --show
--remove-all Remove all mirrors for the given origin urls
--sync=FILE Synchronize mirrors from the given file/url, so that
origins in the given file will have exactly the specified
mirrors
--edit Edit mirrors in editor set by $editor
--clear-history Clear history for the given origins/mirrors, or for all
mirrors
--show-penalities Show current penalities for origins/mirrors, based on the
history information

Examples:
smart mirror --show
smart mirror --add ftp://origin.url/some/path/
smart mirror --remove ftp://origin.url/some/path/
smart mirror --add
smart mirror --sync
smart mirror --clear-history ftp://origin.url/some/path/
smart mirror --clear-history ftp://mirror.url/path/
smart mirror --clear-history
  • Why use mirrors?

Smart automatically detects and uses the best mirror. Whichever mirror is better, smart will use. It also allows you to continue to download a package if one mirror fails, since smart will automatically switch over to a working mirror.

Smart Flag

Usage: smart flag [options]

This command allows one to set, remove, and show package flags.
Package flags are used to tune the behavior of some algorithms
when dealing with the given packages.

Currently known flags are:

lock - Flagged packages will not be removed, if they
are currently installed, nor installed, if they
are currently available.
new - Flagged packages were considered new packages
in the repository when the last update was done.
This flag is automatically manipulated by the
system.
multi-version - Flagged packages may have more than one version
installed in the system at the same time
(backend dependent).

Options:
-h, --help Show this help message and exit
--set Set flags given in pairs of flag name/target, where targets may
use just the package name, or the package name, relation, and
version, such as: lock 'python > 1.0'
--remove Remove flags given in pairs of flag name/target, where targets
may use just the package name, or the package name, relation, and
version, such as: lock 'python > 1.0'
--show Show packages with the flags given as arguments or all flags if
no argument was given
--force Ignore problems

Examples:
smart flag --show
smart flag --show new
smart flag --set lock pkgname
smart flag --remove lock pkgname
smart flag --set lock 'pkgname >= 1.0'
smart flag --remove lock 'pkgname >= 1.0'

Working with channels

Channels are the dictories on the server of repositories that your distribution uses. There are a few ways in which to add channels. The command line way is covered in the above section [ Smart Channel].

Working with mirrors

Mirrors are different sites or servers that carry the exact same information as the original site. Mirrors can be benificial for obtaining faster download speeds. Not to mention when one server goes down, you have another as a back up. By utilizing mirrors in smart, you give smart the ability to choose which server is best, and to automatically switch when one goes down or performs poorly. The more mirrors you add, the greater the chance of optimizing smart's download capacity.

smart mirror --add

Example: smart mirror --add

smart mirror --add

smart mirror --add

Working with proxies

Proxies require authentication to access a server. To set up smart to access a proxy you must make sure pyhton-curl (pycurl) is installed. Then you must set the option in smart's configuration.

smart config --set ftp-proxy=

smart config --set http-proxy=

Working with priorities

With smart priorities you can control the prioritization, or ranking, of a channel or package. Priorities are ranked from -200 being the highest priority to 100 being the lowest. A priority with a negative value must be preceeded by a double negative (--). You may want to set priorities to keep packages from being downgraded, or to have desired packages upgraded more readily. The same is true of channels. You may wants a particular channel to be upgraded more readily than the others.

Example 1: smart priority --set packgename 100

Example 2: smart priority --set channelname 100

Example 3: smart priority --set packgename channelname 100

To remove priorities, just use --remove instead of --set.

Working with flags

Flags are a way in which to fine tune smart's algorithm. Flags have three options: lock, new, and multi-version. With lock, it locks the package, so that no changes will be made to that package. With a package that is locked, it will not upgrade or remove that package. New is the system default. Multi-version is when you have more than one version installed in the system at the same time.

Example 1: smart flag --set lock packgename

Example 2: smart flag --set multi-version packagename

To remove a flag, just use --remove instead of --set.

Working with removable media

Smart Package Manager has builtin support for removable media (CDROMs, DVDs, etc) in most of the supported channel types. Smart currently offers the following features regarding removable media:

  • Mountpoint autodetection
  • Support for multiple simultaneous media drives
  • Media may be inserted in any order
  • Installed system will maintain correct relations between media changes
  • Remote removable media support using any of the supported schemes (ftp, http, scp, etc)

Local removable media

Local removable media are CDROMs, DVDs, etc. In most Linux distributions you will typically find your removable media under /mnt. In SUSE, however, it's under /media. Directories that contain media (/mnt or /media) are actually links that come from /dev and must be registered in /etc/fstab or [ sysfs], and then sysfs must be in /etc/fstab. Please check your distributions documentation for specific information.

Using multiple media

With smart, you can have more than one type of media. You can have local removable media (CD-ROM/DVD-ROM) and ftp/http source, as well as local media (some directory on your hard drive), or any of the other types of media covered in this howto.

Remote removable media

Remote removable media, is media such as DVD-ROM's or CD-ROM's that are on some url (example: some.host.com). Smart see's this primarily as a URL, but recognizes that it is removable and will ask to change the media when required.

Example:

smart install

smart upgrade

Downloading at work to upgrade at home

Scripts to Convert Sources

  • NOTE: These scripts are experimental and are not supported by the smart development team. Use at your own risk.

aptosmart

aptosmart is a script that converts, or imports, your apt sources.list to smart channels. aptosmart can be found here] This is an executable script. Download this, and make sure you either delete the channels in /etc/smart/channels or rename the channels. Then

chmod a+x aptosmart.sh

Then as root, run the script like this;

./aptosmart.sh /etc/smart/channels

The aptosmart options are as follows

aptosmart.sh [ - v ] [ - f ] [ - s SOURCE cunning ] listing

Listing: A goal for the Channelfiles

Optionally:

v verbose, f overwrite channelfiles s selects another SOURCE than /etc/apt/sources.list
阅读(1476) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~