Linux软件包管理

软件包管理

软件包概述

  • 软件包:就是软件的安装程序
  • linux与windows软件包不兼容

分类

源码包
  • 源码包就是一大堆源代码程序,是由程序员按照特定的格式和语法编写出来的。计算机只能识别机器语言,也就是二进制语言,所以源码包安装之前需要编译

  • 一般可以在任何的计算机上安装使用

  • 编译过程耗时较长

  • 大多数用户不懂开发,编译过程中可能会有各种错误,用户无力解决。

源码安装 :下载软件的源代码 => 编译 => 安装(最麻烦,但也最稳定)

二进制包
  • 二进制包,也就是源码包经过成功编译之后产生的包,直接安装即可

  • 二进制包是 Linux 下默认的软件安装包,目前主要有以下 2 大主流的二进制包管理系统:

    • RPM 包管理系统:功能强大,安装、升级、査询和卸载非常简单方便,因此很多 Linux 发行版都默认使用此机制作为软件安装的管理方式,例如 Fedora、CentOS、RedHat、SUSE 等
      • rpm:先下载软件,本地安装
      • yum:在线安装,自动解决依赖关系
    • DEB 包管理系统:由 Debian Linux 所开发的包管理机制,通过 DPKG 包,Debian Linux 就可以进行软件包管理,主要应用在 Debian 和 Ubuntu 中。
      • dkpg
      • apt:在线安装,自动解决依赖关系
二进制源码包(.src.rpm)
  • 二进制源码包,是一个半成品,安装后不能直接使用

  • 需要使用rpmbuild工具重建成真正的rpm包或者重建成源码包才可安装使用

  • 命名方式一般为:

    • 软件包名.src.rpm

不管是源码包,还是二进制包,安装时都可能会有依赖关系

源码包管理

命名方式

  • 软件包名.tar.gz(多数为这个)
  • 软件包名.tar.bz2
  • 软件包名.tar.xz
  • 软件包名.zip

源码包获取

  • 可以去该软件的官网寻找,如Nginx、MySQL等

安装

步骤:软件配置./configure -->编译make–>安装make install

  • 软件配置./configure

    • 指定安装路径, --prefix=/usr/local/
    • 指定命令的目录,–bindir=/bin/
    • 指定配置文件的目录, --etcdir=/etc /
    • 启用或禁用某些功能,如 --enable-ssl 、 --disable-filter
    • 和其他软件关联,如 --with-pcre
    • 检查安装环境,例如是否有编译器gcc,是否满足软件的依赖需求
  • 编译make

    • make主要功能就是将其他语言的源代码打包成Linux可以识别安装的程序。编译过程需要gcc(gcc-c++)编译器
  • 实例1:代码雨安装

使用lrzsz工具,讲软件从windows导入linux
[root@server2 ~]# yum install -y  lrzsz
[root@server2 ~]# rz
#选择cmatrix-1.2a.tar.gz软件包
[root@server2 ~]# ll
总用量 80
-rw-------. 1 root root  1243 7月  24 17:35 anaconda-ks.cfg
-rw-r--r--. 1 root root 74376 8月  17 2021 cmatrix-1.2a.tar.gz

软件包解压
[root@server2 ~]# tar -zxf cmatrix-1.2a.tar.gz 
[root@server2 ~]# cd cmatrix-1.2a/
[root@server2 cmatrix-1.2a]# ls
acconfig.h  cmatrix.1        config.guess  configure.in  Makefile.am    missing        README
aclocal.m4  cmatrix.c        config.h.in   COPYING       Makefile.in    mkinstalldirs  stamp-h.in
AUTHORS     cmatrix.spec     config.sub    INSTALL       matrix.fnt     mtx.pcf        TODO
ChangeLog   cmatrix.spec.in  configure     install-sh    matrix.psf.gz  NEWS

软件配置(设置软件默认安装的位置等信息)
[root@server2 cmatrix-1.2a]# ./configure 
loading cache ./config.cache
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${
   
   MAKE}... yes
checking for tgetent in -ltermcap... no
configure: warning: 
*** No termcap lib available, consider getting the official ncurses
*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get
*** errors compiling nano.
checking for use_default_colors in -l... no
checking for /usr/X11R6/lib/X11/fonts/misc... no
configure: warning:  

*** You do not appear to have an X window fonts directory in the standard
*** locations (/usr/lib/X11/fonts/misc or /usr/X11R6/lib/X11/fonts/misc). The
*** mtx.pcf font will not be installed.  This means you will probably not
*** be able to use the mtx fonts in your x terminals, and hence be unable
*** to use the -x command line switch.  Sorry about that...

updating cache ./config.cache
creating ./config.status
creating Makefile
creating cmatrix.spec
creating config.h

准备编译环境
[root@server2 cmatrix-1.2a]# yum install -y gcc make

编译
[root@server2 cmatrix-1.2a]# make
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -Wall -Wno-comment -c cmatrix.c
cmatrix.c:37:20: 致命错误:curses.h:没有那个文件或目录
 #include <curses.h>
                    ^
编译中断。
make: *** [cmatrix.o] 错误 1

报错:致命错误:curses.h:没有那个文件或目录

原因:主要因为系统中没有找到ncurses-devel软件包

解决:yum install -y ncurses-devel

[root@server2 cmatrix-1.2a]# yum install -y ncurses-devel
[root@server2 cmatrix-1.2a]# make
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -Wall -Wno-comment -c cmatrix.c
gcc  -g -O2 -Wall -Wno-comment  -o cmatrix  cmatrix.o  
cmatrix.o:在函数‘finish’中:
/root/cmatrix-1.2a/cmatrix.c:86:对‘curs_set’未定义的引用
/root/cmatrix-1.2a/cmatrix
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值