本文共 10335 字,大约阅读时间需要 34 分钟。
程序包管理器:RPM-redhat package manager, c语言编写。将编译好的应用程序的各组成文件打包成一个或几个程序包文件,从而更方便地实现程序的安装、升级、卸载和查询等管理操作;
获取程序包的方法:
1.系统发行的光盘ISO镜像、镜像站点、系统发行官方网站2.项目的官方站点,如Apache下的众多项目3.第三方组织:epel...4.下载源码包自己编译rpm命令使用:
[docker-ce-stable]name=Docker CE Stable - $basearchbaseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable enabled=1gpgcheck=1gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg文件中可用的变量:$releasever: 当前OS的发行版的主版本号; 6 7$arch: 平台架构;$basearch:基础平台;
构建私有仓库
createrepo-0.9.9-28.el7.noarch ,创建仓库元数据repodata用法:createrepo [options]选项: -o --outputdir 指定元数据输出位置 -v:详细信息 -q:静默模式 -g ,--groupfile #指定本地软件仓库的组划分 ,组文件和包需放在一起 # createrepo -g comps.xml ./
1.创建元数据
[root@xt data]# ls rpm/crmsh-3.0.0-6.2.noarch.rpm ldirectord-3.9.6-0rc1.1.2.x86_64.rpm repodata[root@xt data]# man createrepo[root@xt data]# createrepo -v ./rpm/ -o ./Spawning worker 0 with 1 pkgsSpawning worker 1 with 1 pkgsSpawning worker 2 with 0 pkgsSpawning worker 3 with 0 pkgsWorker 0: reading crmsh-3.0.0-6.2.noarch.rpmWorker 1: reading ldirectord-3.9.6-0rc1.1.2.x86_64.rpmWorkers FinishedSaving Primary metadataSaving file lists metadataSaving other metadataGenerating sqlite DBsStarting other db creation: Thu Jan 10 14:59:06 2019Ending other db creation: Thu Jan 10 14:59:06 2019Starting filelists db creation: Thu Jan 10 14:59:06 2019Ending filelists db creation: Thu Jan 10 14:59:06 2019Starting primary db creation: Thu Jan 10 14:59:06 2019Ending primary db creation: Thu Jan 10 14:59:06 2019Sqlite DBs complete[root@xt data]# lsrepodata rpm
2.配置yum源文件
baseurl需要指定到repodata目录即可
yum命令使用:
用法:yum [options] [command] [package ...]command is one of: * install package1 [package2] [...] * update [package1] [package2] [...] * update-to [package1] [package2] [...] * update-minimal [package1] [package2] [...] * check-update * upgrade [package1] [package2] [...] * upgrade-to [package1] [package2] [...] * distribution-synchronization [package1] [package2] [...] * remove | erase package1 [package2] [...] * autoremove [package1] [...] * list [...] * info [...] * provides | whatprovides feature1 [feature2] [...] * clean [ packages | metadata | expire-cache | rpmdb | plugins | all ] * makecache [fast] * groups [...] * search string1 [string2] [...] * shell [filename] * resolvedep dep1 [dep2] [...] (maintained for legacy reasons only - use repoquery or yum provides) * localinstall rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only - use install) * localupdate rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only - use update) * reinstall package1 [package2] [...] * downgrade package1 [package2] [...] * deplist package1 [package2] [...] * repolist [all|enabled|disabled] * repoinfo [all|enabled|disabled] * repository-packages[package2] [...] * version [ all | installed | available | group-* | nogroups* | grouplist | groupinfo ] * history [info|list|packages-list|packages-info|summary|addon-info|redo|undo|rollback|new|sync|stats] * load-transaction [txfile] * updateinfo [summary | list | info | remove-pkgs-ts | exclude-updates | exclude-all | check-running- kernel] * fssnapshot [summary | list | have-space | create | delete] * fs [filters | refilter | refilter-cleanup | du] * check * help [command]
构建缓存
yum makecache fast拆卸
yum remove | erase package1 [package2] [...]注:卸载也会把依赖的包删除,需要看清楚,否则可能删除与系统相关的包[root@xt ~]# yum provides "*/gdisk"Loaded plugins: fastestmirrorRepository base is listed more than once in the configurationLoading mirror speeds from cached hostfilebase: mirrors.aliyun.comextras: mirrors.tuna.tsinghua.edu.cnupdates: mirrors.163.comepel/7/x86_64/filelists | 10 MB 00:00:01 gdisk-0.8.10-2.el7.x86_64 : An fdisk-like partitioning tool for GPT disksRepo : baseMatched from:Filename : /usr/sbin/gdiskgdisk-0.8.10-2.el7.x86_64 : An fdisk-like partitioning tool for GPT disksRepo : @baseMatched from:Filename : /usr/sbin/gdisk
./configure:(1) 通过选项传递参数,指定启用特性、安装路径等;执行时会参考用户的指定以及Makefile.in文件生成makefile;(2) 检查依赖到的外部环境;make [-j #]:根据makefile文件编译,构建应用程序,启用cpu多线程任务make install:安装
[root@xt ntfs-3g_ntfsprogs-2017.3.23]# ./configure --prefix=/root/data #指定默认安装位置,默认为/usr/local/checking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for a thread-safe mkdir -p... /usr/bin/mkdir -pchecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether to enable maintainer-specific portions of Makefiles... nochecking for style of include used by make... GNUchecking for gcc... no #gcc等开发工具没有,需要先安装,通常提供Development Tools即可(需要看安装版本)checking for cc... nochecking for cl.exe... noconfigure: error: in `/root/data/ntfs-3g_ntfsprogs-2017.3.23':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details=============================yum groups install Development\ Tools =============================./configure --prefix=/root/data重新检查..................../usr/bin/rm: cannot remove 'libtoolT': No such file or directory#个别警告或者错误可以忽略You can type now 'make' to build ntfs-3g.#进行下一步操作编译=============================# make -j 4......................libtool: link: gcc -DFUSE_USE_VERSION=26 -I../include/fuse-lite -I../include/ntfs-3g -DPLUGIN_DIR=\"/root/data/lib/ntfs-3g\" -g -O2 -Wall -o .libs/lowntfs-3g lowntfs_3g-lowntfs-3g.o lowntfs_3g-ntfs-3g_common.o -ldl ../libfuse-lite/.libs/libfuse-lite.a -lpthread ../libntfs-3g/.libs/libntfs-3g.so -Wl,-rpath -Wl,/root/data/libmake[2]: Leaving directory `/root/data/ntfs-3g_ntfsprogs-2017.3.23/src'make[2]: Entering directory `/root/data/ntfs-3g_ntfsprogs-2017.3.23'make[2]: Leaving directory `/root/data/ntfs-3g_ntfsprogs-2017.3.23'make[1]: Leaving directory `/root/data/ntfs-3g_ntfsprogs-2017.3.23'=============================编译完成即可安装make install[root@xt data]# lsbin include lib sbin share
(1) 导出二进制程序目录至PATH环境变量中;不导出执行命令需要用绝对路径! 编辑文件/etc/profile.d/NAME.sh export PATH=/PATH/TO/BIN:/root/data/ntfs-3g(2) 导出库文件路径 编辑/etc/ld.so.conf.d/ntfs-3g.conf, 添加/root/data/ntfs-3g/lib 到文件中; 让系统重新生成缓存: ldconfig [-v](3) 导出头文件 基于链接的方式实现:一般用于二进制包名称比较长 ln -sv (4) 导出帮助手册 编辑/etc/man_db.config文件,添加一个MANPATH #MANPATH /root/data/ntfs-3g/share/man
[root@xt rpm]# rpm2cpio ldirectord-3.9.6-0rc1.1.2.x86_64.rpm | cpio -id #注意展开的目录会覆盖原有的目录382 blocks[root@xt rpm]# lscrmsh-3.0.0-6.2.noarch.rpm etc ldirectord-3.9.6-0rc1.1.2.x86_64.rpm repodata test usr[root@xt rpm]# ls etc/ha.d/ logrotate.d/ [root@xt rpm]# ls etc/ha.d/resource.d/ldirectord crmsh-3.0.0-6.2.noarch.rpm ldirectord-3.9.6-0rc1.1.2.x86_64.rpm test/etc/ repodata/ usr/
转载于:https://blog.51cto.com/12580678/2341013