Linux 安装包结构 rpm 结构探索

发布于 2022-09-23 23:40:18 字数 15043 浏览 166 评论 0

问题

如何在 centos 上离线安装一个 openresty

方案

参照 OpenResty® Linux Packages 提供。

  1. 下载 openresty-1.15.8.2-6.el7.x86_64.rpm
  2. 下载 openresty-openssl-1.1.0k-3.el7.x86_64.rpm
  3. 下载 openresty-zlib-1.2.11-3.el7.centos.x86_64.rpm
  4. 下载 openresty-pcre-8.43-1.el7.x86_64.rpm
  5. 上述4个 rpm 包,上传至服务器,rpm -Uvh --force *.rpm 全部安装。
  6. 更新版本,可以在 openresty repository to your CentOS system 中查找。

什么是 rpm 包?

RPM originally stands for Red Hat Package Manager.
An RPM package is simply a header structure on top of a CPIO archive. The package itself is comprised of four sections: a header with a leading identifier (magic number) that identifies the file as an RPM package, a signature to verify the integrity of the package, the header or ‘tagged’ data containing package information, version numbers, and copyright messaging, and the archive containing the actual program files.

解压 rpm 包

RPM 包括是使用 cpio 格式打包的,因此可以先转成 cpio 然后解压,如下所示:

rpm2cpio xxx.rpm | cpio -div

rpm2cpio 命令用于将 rpm 软件包转换为 cpio 格式的文件。

[vagrant@bogon openresty.centos.el7]$ rpm2cpio openresty-pcre-8.42-1.el7.centos.x86_64.rpm | cpio -div
./usr/local/openresty/pcre/lib/libpcre.so
./usr/local/openresty/pcre/lib/libpcre.so.1
./usr/local/openresty/pcre/lib/libpcre.so.1.2.10
892 块
[vagrant@bogon openresty.centos.el7]$ rpm2cpio openresty-1.15.8.1-1.el7.x86_64.rpm | cpio -div
./etc/init.d/openresty
./usr/bin/openresty
./usr/local/openresty/COPYRIGHT
./usr/local/openresty/bin/openresty
./usr/local/openresty/luajit/bin
./usr/local/openresty/luajit/bin/luajit
./usr/local/openresty/luajit/bin/luajit-2.1.0-beta3
./usr/local/openresty/luajit/include
./usr/local/openresty/luajit/include/luajit-2.1
./usr/local/openresty/luajit/include/luajit-2.1/lauxlib.h
./usr/local/openresty/luajit/include/luajit-2.1/lua.h
./usr/local/openresty/luajit/include/luajit-2.1/lua.hpp
./usr/local/openresty/luajit/include/luajit-2.1/luaconf.h
./usr/local/openresty/luajit/include/luajit-2.1/luajit.h
./usr/local/openresty/luajit/include/luajit-2.1/lualib.h
./usr/local/openresty/luajit/lib
./usr/local/openresty/luajit/lib/libluajit-5.1.so
./usr/local/openresty/luajit/lib/libluajit-5.1.so.2
./usr/local/openresty/luajit/lib/libluajit-5.1.so.2.1.0
./usr/local/openresty/luajit/lib/lua
./usr/local/openresty/luajit/lib/lua/5.1
./usr/local/openresty/luajit/lib/pkgconfig
./usr/local/openresty/luajit/lib/pkgconfig/luajit.pc
./usr/local/openresty/luajit/share
./usr/local/openresty/luajit/share/lua
./usr/local/openresty/luajit/share/lua/5.1
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/bc.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/bcsave.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_arm.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_arm64.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_arm64be.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_mips.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_mips64.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_mips64el.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_mipsel.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_ppc.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_x64.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dis_x86.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/dump.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/p.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/v.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/vmdef.lua
./usr/local/openresty/luajit/share/luajit-2.1.0-beta3/jit/zone.lua
./usr/local/openresty/lualib/cjson.so
./usr/local/openresty/lualib/librestysignal.so
./usr/local/openresty/lualib/ngx
./usr/local/openresty/lualib/ngx/balancer.lua
./usr/local/openresty/lualib/ngx/base64.lua
./usr/local/openresty/lualib/ngx/errlog.lua
./usr/local/openresty/lualib/ngx/ocsp.lua
./usr/local/openresty/lualib/ngx/pipe.lua
./usr/local/openresty/lualib/ngx/process.lua
./usr/local/openresty/lualib/ngx/re.lua
./usr/local/openresty/lualib/ngx/resp.lua
./usr/local/openresty/lualib/ngx/semaphore.lua
./usr/local/openresty/lualib/ngx/ssl
./usr/local/openresty/lualib/ngx/ssl.lua
./usr/local/openresty/lualib/ngx/ssl/session.lua
./usr/local/openresty/lualib/redis
./usr/local/openresty/lualib/redis/parser.so
./usr/local/openresty/lualib/resty
./usr/local/openresty/lualib/resty/aes.lua
./usr/local/openresty/lualib/resty/core
./usr/local/openresty/lualib/resty/core.lua
./usr/local/openresty/lualib/resty/core/base.lua
./usr/local/openresty/lualib/resty/core/base64.lua
./usr/local/openresty/lualib/resty/core/ctx.lua
./usr/local/openresty/lualib/resty/core/exit.lua
./usr/local/openresty/lualib/resty/core/hash.lua
./usr/local/openresty/lualib/resty/core/misc.lua
./usr/local/openresty/lualib/resty/core/ndk.lua
./usr/local/openresty/lualib/resty/core/phase.lua
./usr/local/openresty/lualib/resty/core/regex.lua
./usr/local/openresty/lualib/resty/core/request.lua
./usr/local/openresty/lualib/resty/core/response.lua
./usr/local/openresty/lualib/resty/core/shdict.lua
./usr/local/openresty/lualib/resty/core/time.lua
./usr/local/openresty/lualib/resty/core/uri.lua
./usr/local/openresty/lualib/resty/core/utils.lua
./usr/local/openresty/lualib/resty/core/var.lua
./usr/local/openresty/lualib/resty/core/worker.lua
./usr/local/openresty/lualib/resty/dns
./usr/local/openresty/lualib/resty/dns/resolver.lua
./usr/local/openresty/lualib/resty/limit
./usr/local/openresty/lualib/resty/limit/conn.lua
./usr/local/openresty/lualib/resty/limit/count.lua
./usr/local/openresty/lualib/resty/limit/req.lua
./usr/local/openresty/lualib/resty/limit/traffic.lua
./usr/local/openresty/lualib/resty/lock.lua
./usr/local/openresty/lualib/resty/lrucache
./usr/local/openresty/lualib/resty/lrucache.lua
./usr/local/openresty/lualib/resty/lrucache/pureffi.lua
./usr/local/openresty/lualib/resty/md5.lua
./usr/local/openresty/lualib/resty/memcached.lua
./usr/local/openresty/lualib/resty/mysql.lua
./usr/local/openresty/lualib/resty/random.lua
./usr/local/openresty/lualib/resty/redis.lua
./usr/local/openresty/lualib/resty/sha.lua
./usr/local/openresty/lualib/resty/sha1.lua
./usr/local/openresty/lualib/resty/sha224.lua
./usr/local/openresty/lualib/resty/sha256.lua
./usr/local/openresty/lualib/resty/sha384.lua
./usr/local/openresty/lualib/resty/sha512.lua
./usr/local/openresty/lualib/resty/shell.lua
./usr/local/openresty/lualib/resty/signal.lua
./usr/local/openresty/lualib/resty/string.lua
./usr/local/openresty/lualib/resty/upload.lua
./usr/local/openresty/lualib/resty/upstream
./usr/local/openresty/lualib/resty/upstream/healthcheck.lua
./usr/local/openresty/lualib/resty/websocket
./usr/local/openresty/lualib/resty/websocket/client.lua
./usr/local/openresty/lualib/resty/websocket/protocol.lua
./usr/local/openresty/lualib/resty/websocket/server.lua
./usr/local/openresty/lualib/tablepool.lua
./usr/local/openresty/nginx/conf/fastcgi.conf
./usr/local/openresty/nginx/conf/fastcgi.conf.default
./usr/local/openresty/nginx/conf/fastcgi_params
./usr/local/openresty/nginx/conf/fastcgi_params.default
./usr/local/openresty/nginx/conf/koi-utf
./usr/local/openresty/nginx/conf/koi-win
./usr/local/openresty/nginx/conf/mime.types
./usr/local/openresty/nginx/conf/mime.types.default
./usr/local/openresty/nginx/conf/nginx.conf
./usr/local/openresty/nginx/conf/nginx.conf.default
./usr/local/openresty/nginx/conf/scgi_params
./usr/local/openresty/nginx/conf/scgi_params.default
./usr/local/openresty/nginx/conf/uwsgi_params
./usr/local/openresty/nginx/conf/uwsgi_params.default
./usr/local/openresty/nginx/conf/win-utf
./usr/local/openresty/nginx/html/50x.html
./usr/local/openresty/nginx/html/index.html
./usr/local/openresty/nginx/logs
./usr/local/openresty/nginx/sbin/nginx
./usr/local/openresty/nginx/sbin/stap-nginx
./usr/local/openresty/nginx/tapset/nginx.stp
./usr/local/openresty/nginx/tapset/ngx_lua.stp
./usr/local/openresty/site/lualib
7156 块
 cpio 参数说明:
    -t  列出的意思,和"--list"等同,注意,此时列出的是“相对路径”
    -i  抽取的意思,和"--extract"等同
    -d  建立目录,和"--make-directories"等同
    -v  冗余信息输出,和"--verbose"等同
     
rpm 参数说明:
    -q  --query 查询
    -l  --list 列出
    -f  --file 指定文件
    -p --package 指定rpm包

显式 rpm 包中的脚本

  • -q option : Query option
  • -p option : Query an (uninstalled) package PACKAGE_FILE. The PACKAGE_FILE may be specified as an ftp or http style URL, in which case the package header will be downloaded and querie).
[vagrant@bogon openresty.centos.el7]$ rpm -qp --scripts   openresty-1.15.8.1-1.el7.x86_64.rpm
postinstall scriptlet (using /bin/sh):
/sbin/chkconfig --add openresty
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
    /sbin/service openresty stop >/dev/null 2>&1
    /sbin/chkconfig --del openresty
fi

查询 rpm 包详细信息

[vagrant@bogon openresty.centos.el7]$ rpm -pqi   openresty-1.15.8.1-1.el7.x86_64.rpm
Name        : openresty
Version     : 1.15.8.1
Release     : 1.el7
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 3640924
License     : BSD
Signature   : RSA/SHA1, 2019年05月17日 星期五 01时39分29秒, Key ID 97db7443d5edeb74
Source RPM  : openresty-1.15.8.1-1.el7.src.rpm
Build Date  : 2019年05月17日 星期五 01时39分26秒
Build Host  : centos7
Relocations : (not relocatable)
URL         : https://openresty.org/
Summary     : OpenResty, scalable web platform by extending NGINX with Lua
Description :
This package contains the core server for OpenResty. Built for production
uses.

OpenResty is a full-fledged web platform by integrating the standard Nginx
core, LuaJIT, many carefully written Lua libraries, lots of high quality
3rd-party Nginx modules, and most of their external dependencies. It is
designed to help developers easily build scalable web applications, web
services, and dynamic web gateways.

By taking advantage of various well-designed Nginx modules (most of which
are developed by the OpenResty team themselves), OpenResty effectively
turns the nginx server into a powerful web app server, in which the web
developers can use the Lua programming language to script various existing
nginx C modules and Lua modules and construct extremely high-performance
web applications that are capable to handle 10K ~ 1000K+ connections in
a single box.

在非 linux 上解压

  1. 在线解压 extract.me
  2. Open/Extract RPM File with Freeware on Windows/Mac/Linux

Check RPM dependencies

In fact that's not a one but four different questions:

1、First you can quickly list a downloaded package's dependencies/requirements by using the following commands:

$ rpm -qp mypackage.rpm --provides
$ rpm -qp mypackage.rpm --requires

2、Second, you can use yum utility in order to satisfy these (somewhat cryptic) dependencies automatically (assuming that all your repositories are set up correctly, and all the dependencies are available):

$ sudo yum install mypackage.rpm

3、Third, there are several RPM search resources, some of them already suggested above. I'd like to list another one, just for the reference - pkgs.org.

4、Fourth, there is an additional popular repository for RHEL5 and RHEL6 distros - EPEL. Note that it's not supported by Red Hat.

常用命令

  1. Install RPM File : # rpm -ivh awstats.i386.rpm
  2. Upgrade RPM File : # rpm -Uvh awstats.i386.rpm
    1, Erase (Delete) RPM File (package): # rpm -ev packagename
  3. To find list of all install packages, enter:
    • # rpm -qa
    • # rpm -qa | less
    • # rpm -qa | grep something

rpm command cheat sheet for Linux

SyntaxDescriptionExample(s)
rpm -ivh {rpm-file}Install the packagerpm -ivh mozilla-mail-1.7.5-17.i586.rpm
rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm
rpm -Uvh {rpm-file}Upgrade packagerpm -Uvh mozilla-mail-1.7.6-12.i586.rpm
rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm
rpm -ev {package}Erase/remove/ an installed packagerpm -ev mozilla-mail
rpm -ev --nodeps {package}Erase/remove/ an installed package without checking for dependenciesrpm -ev --nodeps mozilla-mail
rpm -qaDisplay list all installed packagesrpm -qarpm -qa | less
rpm -qi {package}Display installed information along with package version and short descriptionrpm -qi mozilla-mail
rpm -qf {/path/to/file}Find out what package a file belongs to i.e. find what package owns the filerpm -qf /etc/passwdrpm -qf /bin/bash
rpm -qc {pacakge-name}Display list of configuration file(s) for a packagerpm -qc httpd
rpm -qcf {/path/to/file}Display list of configuration files for a commandrpm -qcf /usr/X11R6/bin/xeyes
rpm -qa --lastDisplay list of all recently installed RPMsrpm -qa --lastrpm -qa --last | less
rpm -qpR {.rpm-file}
rpm -qR {package}
Find out what dependencies a rpm file hasrpm -qpR mediawiki-1.4rc1-4.i586.rpm
rpm -qR bash

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

给我一枪

暂无简介

0 文章
0 评论
23 人气
更多

推荐作者

我们的影子

文章 0 评论 0

素年丶

文章 0 评论 0

南笙

文章 0 评论 0

18215568913

文章 0 评论 0

qq_xk7Ean

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文