LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 6448|回复: 20

在Slackware中,关于软件的安装和卸载的

[复制链接]
发表于 2003-8-12 09:54:46 | 显示全部楼层 |阅读模式
链接: http://www.userlocal.com/articles/slackwaretools.php

Getting to know Slackware packaging tools

    There are two types of package tools; menu based tools and command line based tools. There is actually only one menu based tool and that's "pkgtool" all the rest are command line tools.

    You use pkgtool to get an overview of what's installed on your system. It provides menu options to view installed packages, the content of individual packages and you can also remove currently installed packages by using the menus and you can install new ones. If you use pkgtool to install packages, you can specify a directory containing one or more packages and you will be asked a 'yes' or 'no' question about if you want them installed. If you select to remove packages you will get a list of all currently installed packages and you can then select one or more to remove.

    All of the above functions can also be accomplished by using the command line tools. If, for example, you just need to install a single package, it may seem a bit tedious to have to go through a lot of menus. That's why we have the command line tools. Here's a description of each of them and how I mostly use them.

    installpkg

    Description:

    installpkg is used to install a prebuilt slackware package. Basically what it does is to unzip and untar the package in the "/" (root) directory of your filesystem, and subsequently it executes the script "install/doinst.sh" from the package if it's included (try to unpack a package from your slackware CD into a new directory and take a look at it).

    How I use installpkg:

    In almost all cases all I do is type a command like "installpkg packagename.tgz" (or "installpkg packagename.tar.gz"). In a few cases I may wish to review the content of a package before I install it, so I issue a command like "installpkg -warn packagename.tgz > package.log". That gives me a file called package.log with information about what files will be installed and where; and I can now judge if I wish to install the package (if you omit the "> package.log" part the report will be dumped to your console). I rarely use the "-r" an "-m" options, they can be used to generate and/or install a subdirectory as a package, but I prefer to use makepkg for that.

    [Notes on Installing more than one package. Let's say you have the kde1 dir and you want to install everything, you can cd into the kde1 dir and "installpkg *.tgz". Or you can "installpkg pack1.tgz pack2.tgz pack3.tgz"]

    explodepkg
    Description:

    explodepkg is used to extract a package into the current directory without running the "install/doinst.sh" script from the package and without updating the installed-packages database in "/var/adm/packages". [note that /var/adm is a sym link to /var/log, so /var/log/packages is also correct] It's a useful tool if you are maintaining/updating a package (probably one of your own) and want to change a few things. After using explodepkg and editing the package it is a simple matter to run makepkg to recreate the package with the new and/or updated content.

    How I use explodepkg:

    There is only one way to use this tool; cd to an empty directory and type "explodepkg packagename.tgz".

    removepkg
    Description:

    removepkg is used to remove a currently installed Slackware package. It will look in "/var/adm/packages" for information about what files to remove (the entry under /var/adm/packages was created when the package was installed).

    How I use removepkg:

    Normally I just type "removepkg packagename", but if I don't have the original package on disk or CD-ROM or if I'm not completely sure if the package is critical to normal systems operation I'll pass the "-preserve" option to removepkg (as in "removepkg -preserve packagename") to keep the entire tree of removed files under "/tmp/preserved_packages/packagename"). This allows me to reinstall the files if the system did indeed need them for something. Just as with installpkg you can pass the "-warn" option to get a dump of the files that would be removed by the operation. Read the man page for a description of the "-keep" and "-copy" options if you think you'll need them (I don't).

    makepkg
    Description:

    This is the tool you'll use to create a proper Slackware package. What it does is to tar and gzip the content of the current working directory and it's subdirs while converting symlinks to script code on the fly (the script code will be placed in a file called "doinst.sh" in a dir called install) so as to be able to recreate links at package installation.

    How I use makepkg:

    Let me give you an example. Let's say we want to create a package called "readme.tgz" that contains 3 files called "readme1", "readme2" and "readme3". When the package installs you want the files placed like this; "/usr/readme1", "/usr/sbin/readme2" and "/home/readme3". To do that you will need to create a new empty dir to create the package in, in this example I'll assume you create a new dir called "/home/pkgmanager/readme" and change to that directory ("cd /home/pkgmanager/readme"). You can now start building your package. First we create the needed directories, execute these commands:
    $ mkdir usr
    $ mkdir usr/sbin
    $ mkdir home

    Then copy the files to their right locations, like this:

    $ cp ~/readme1 usr
    $ cp ~/readme2 usr/sbin
    $ cp ~/readme3 home

    Now we need to build the package itself, execute the command "makepkg readme.tgz" to do just that. If there where any symlinks encountered (not in this example) you will find that an "install" directory has been created with the "doinst.sh" script to recreate them. This all goes into the package and if you feel you have some extra commands that should be run from doinst.sh you can explodepkg the package and add them to the script. You should now have a proper slackware package called "readme.tgz" that will install properly with "installpkg readme.tgz". Try it out and see if you can find the readme1, 2 and 3 files in their right locations. If you ever need to create a package of a program that you downloaded as source (or binary) you will have to create the correct directory structure for all the files in the package and follow the above procedure (remember to compile the source first ;-). If the program uses autoconf/automake, then life is a great deal simpler as you can usually just pass the "--prefix=" parameter to the configure script to have "make install" install it into some subdirectory of your choice. Then you can run makepkg in that directory afterwards and that's it. Here is a generic example of creating a package from a source based on autoconf/automake:

    $ ./configure --prefix=/home/pkgmanager/builddir
    $ make
    $ make install
    $ cd /home/pkgmanager/builddir
    $ makepkg packagename.tgz

    upgradepkg
    Description:

    This tool is used to upgrade an installed Slackware package with a new version. All it does is to install the new package on top of the old one and then remove all files from the old package that are not present in the new one.

    How I use upgradepkg: There are not that many ways to use it. Here's how it goes; If the old and new packages have the same name, the just type "upgradepkg packagename.tgz", if the names are different, then use a command like "upgradepkg oldpackage%newpackage.tgz". [You can also upgrade multiple packages with upgradepkg by doing "upgradepkg *.tgz", as long as the packages you want to upgrade have the same name as the Slackware packs in the dir.]

    Other notes:
    Both installpkg, removepkg and upgradepkg support an env. variable called "ROOT" that points to the root directory to use when installing or removing packages. This is not something you'll generally use, but it can be useful if you need to install packages to another harddrive/partition or stuff like that. There are two other types of scripts that you can place in a Slackware package apart from "doinst.sh" (the configuration and only-once scripts) but most people don't need to use them. Read the man page for makepkg if you feel you need to know. Remember to use ash script syntax in your package scripts if they are to be used by anyone but yourself, as that's the shell that will be used if the packages are installed from a Slackware rescue disk (and not all people have bash installed ;-)

    Jesper Juhl


    juhl@eisenstein.dk

    http://jesper.staff.groundcontrol.dk/
发表于 2003-8-12 11:59:30 | 显示全部楼层
最近把pkgtools安装到了mandrake上,^_^!
发表于 2003-10-1 18:29:40 | 显示全部楼层
朋友,能不能翻译成中文啊,看起来很累的~!
发表于 2003-12-22 20:30:44 | 显示全部楼层

在Slackware中,关于软件的安装和卸载的

1.我们如何安装单个软件包?

方面主要有以下几种:

我们可以通过installpkg来安装,但软件包的文件格式必须是tgz的,比如下面:


[root@sir beinan]#installpkg bmp-0.9.6-1.hamigua.i386.tgz

也可以用pkgtool工具,这个也是比较好的办法。是图形界面的,也能卸载Slackware中的软件包。

[root@sir beinan]#pkgtool

运行这个命令后,指定包的位置就可以来安装单个包,也可以卸掉某个包;

2.我怎么才能知道setup/pkgtool/installpkg安装软件包工具把软件都安装到什么地方了呢?

我们应该查看/var/adm/packages目录,所有的安装包信息都存放在这里,您可以用more来查看某个包安装在什么地方。比如我想知道gaim安装到什么地方了,用下面的办法就好


[root@sir beinan]#more /var/adm/packages/gaim-0.74-i686-1dl

我们还可以查看某个软件包安装的脚本,安装脚本存放在/var/adm/scripts,我们也可以用查看工具来查看某个包的安装脚本。

[beinan@sir beinan]$more /var/adm/scripts/gaim-0.74-i686-1dl

3.如何升级软件包呢?
[root@sir beinan]#upgradepkg 软件包文件名

比如我们升级gdm这个软件包,应该是这样的。

[root@sir beinan]#upgradepkg gdm-2.4.4.5-i486-1.tgz


4如何卸掉一个软件包

[root@sir beinan]#removepkg 软件包名

比如我们想卸掉gdm,应该如下做

[root@sir beinan]#removepkg gdm

5.最后要说的可能就是.tar.gz和tar.bz2这样格式的源码包了。这样的源码包,一般都有安装方法,比如解开一个包,里面有README和INSTALL

安装时,一般要先configure ,然后再来运行命令make和make install

在configure时,我们还能看帮助,如果不知道怎么做,直接cofigure就行。如果出现错误提示,可能是让我们指定相应的头文件和库文件所在的目录。用configure --help就能看到相应的办法。

步骤如下:
#./configure --help  注:这是看configure的帮助
举个例子:比如我们想把一个名为gaim的软件安装到/opt/gaim的目录,我们应该:
#./configure --prefix=/opt/gaim   

当然不指定这些也行,在./configure --help里也有说软件会默认安装到哪里。

#make
#make install

如果我们指定了目录,如果想删除这个软件,直接就把那个目录删除就行了。比如我们把gaim安装到了/opt/gaim,想卸掉这个软件,直接删除/opt/gaim就ok了。



6.我们是不是能利用别的发行版中的RPM包,然后安装到Slackware中?

可以,不过最好还是通过命令转换成tgz格式的,然后再来安装,转换命令是:
[root@sir beinan]#rpm2tgz [RPM包的名字]

比如我想安装bmp-0.9.6-1.hamigua.i386.rpm 这包rpm包到Slackware系统中,应该先做一下转换
[root@sir beinan]#rpm2tgz bmp-0.9.6-1.hamigua.i386.rpm

转换成了什么呢??
[root@sir beinan]#ls -la bmp-0.9.6-1.hamigua.i386.*
-rw------- 1 beinan users 1905568 2003-12-22 08:27 bmp-0.9.6-1.hamigua.i386.rpm
-rw-r--r-- 1 root root 1889866 2003-12-22 08:27 bmp-0.9.6-1.hamigua.i386.tgz

我们可以看到有个bmp-0.9.6-1.hamigua.i386.tgz的包

然后我们再用installpkg来安装这个包
[root@sir beinan]#installpkg bmp-0.9.6-1.hamigua.i386.tgz

发表于 2003-12-23 11:32:02 | 显示全部楼层
应该加上checkintall部分,两个帖子合并就基本上齐了。
发表于 2003-12-23 18:32:00 | 显示全部楼层
发表于 2003-12-23 21:37:25 | 显示全部楼层
收集一下
发表于 2003-12-24 09:09:26 | 显示全部楼层
补充一下,slackware下载软件包非常灵活,比如刚刚安装了一个gaim
#installpkg /home/yisha/gaim-0.64-1.i386.tgz
现在要卸载,可以用
#removepkg gaim
也可以用
#removepkg /home/yisha/gaim-0.64-1.i386.tgz
还可以用
#removepkg /var/log/packages/gaim-0.64-1.i386

#removepkg gaim-0.64-1.i386
非常灵活易用。
升级软件upgradepkg可以加上一个参数--install-new ,这样的话,如果原系统中没有这个软件,那么升级软件将自动变为安装软件。所以如果某个目录下有一大堆软件,有一部分系统中已经有了但我们要升级到更新版本,有一部分系统中没有我们要安装他们,就可以用
#upgradepkg --install-new *.tgz
升级+安装一条龙完成,十分方便。
发表于 2004-2-4 17:00:02 | 显示全部楼层

rpm文件装不到啊?

依楼主的方法安装不行:
出错如下:
rpm2cpio failed. (maybe ravlin8-8.1.4.rpm not an RPM?)
 楼主| 发表于 2004-2-5 08:53:36 | 显示全部楼层

回复: rpm文件装不到啊?

最初由 zhawuxi 发表
依楼主的方法安装不行:
出错如下:
rpm2cpio failed. (maybe ravlin8-8.1.4.rpm not an RPM?)


看看你的ravlin8这个文件是不是有错误。试试重新下载。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表