[administrator] rpmbuild
rpmbuild
1. rpm是什么
RPM = RPM Package Manager = Redhat Package Manager
https://en.wikipedia.org/wiki/Rpm_(software)
2. two forks
1. RPM.org redhat 维护的,
This version is used by distributions such as Fedora, Red Hat Enterprise Linux and derivatives, openSUSE, SUSE Linux Enterprise, Unity Linux, Mageia[], OpenEmbedded, Tizen and OpenMandriva Lx(formerly Mandriva).
2. RPM V5 红帽前雇员维护
This version is used by distributions such as Wind River Linux (until Wind River Linux ), Rosa Linux, and OpenMandriva Lx (former Mandriva Linux which switched to rpm5 in []) and also by the
OpenPKG project which provides packages for other common UNIX-platforms. OpenMandriva Lx is going to switch back to rpm.org[] for 4.0 release. OpenEmbedded switched back to rpm.org due to issues in RPM5.[]
3. 官网
http://rpm.org/
4. rpm packaging文档
https://rpm-packaging-guide.github.io/
高级用法:https://rpm-packaging-guide.github.io/#triggers-and-scriptlets
5. spec file 是 rpmbuild 的配置文件,配置rpmbuild的行为,以及定制rpm包的内容。
A SPEC file can be thought of as the "recipe" that the rpmbuild utility uses to actually build an RPM. It tells the build system what to do by defining instructions in a series of sections.
The sections are defined in the Preamble and the Body. The Preamble contains a series of metadata items that are used in the Body. The Body contains the main part of the instructions.
6。 查看各种默认宏的值
[root@D129 j-dpdk]# rpm --eval %{buildroot}
/root/rpmbuild/BUILDROOT/%{name}-%{version}-%{release}.x86_64
[root@D129 j-dpdk]# rpm --eval %{_bindir}
/usr/bin
查看设置和环境变量。
[root@test ~]# rpm --showrc
ARCHITECTURE AND OS:
build arch : x86_64
compatible build archs: x86_64 noarch
build os : Linux
... ...
7. 安装rpmdev tools。
其实不装也是可以的。这个工具包主要帮助编写spec文件。和配置等?
[root@D129 j]# yum install rpmdevtools
77. rpm包需要与systemd serivce联动。见 https://fedoraproject.org/wiki/Packaging:Systemd
8. quick start
8.1 用rpmdev-newspec工具生成一个空 spec 模板,或者到什么地方去随便考一个过来。
[root@D129 copyright]# man rpmdev-newspec
[root@D129 j]# rpmdev-newspec
newpackage.spec created; type minimal, rpm version >= 4.11.
8.2 改 spec文件
写法可以读前边提到的文档,或者靠天分自己推理。
8.3 拷贝源代码的 gz tar包 到 $ROOT/rpmbuild/SOURCES
要求包名与解压后的文件夹名相同,且格式为 $NAME-$VERSION
rpmbuild在解压,找目录的时候,根据:定义在spec文件的Source变量:Source: http://dpdk.org/browse/dpdk/snapshot/%{name}-%{version}.tar.gz
如果不喜欢,也可以自己定义这个过程:https://rpm-packaging-guide.github.io/#setup
8.4 使用命令开始做包:
[root@D129 pkg]# rpmbuild -ba dpdk.spec
成功之后,生成的包,在这里:
[root@D129 pkg]# ll /root/rpmbuild/RPMS/x86_64/
total
-rw-r--r-- root root Jul : dpdk-16.07-.x86_64.rpm
-rw-r--r-- root root Jul : dpdk-debuginfo-16.07-.x86_64.rpm
-rw-r--r-- root root Jul : dpdk-devel-16.07-.x86_64.rpm
[root@D129 pkg]# ll /root/rpmbuild/SRPMS/
total
-rw-r--r-- root root Jul : dpdk-16.07-.src.rpm
9. 最终,我是为dpdk打了个轻量的rpm包,做了些裁剪定制。修改过的内容如下:
dpdk.spec
Name: xxxx-dpdk
Version: 16.07
Release:
Packager: packaging@6wind.com
URL: http://dpdk.org
Source: http://dpdk.org/browse/dpdk/snapshot/%{name}-%{version}.tar.gz Summary: Data Plane Development Kit core
Group: System Environment/Libraries
License: BSD and LGPLv2 and GPLv2 ExclusiveArch: x86_64
%global target %{_arch}-native-linuxapp-gcc
%global config %{target} BuildRequires: kernel-devel, kernel-headers %description
DPDK core includes kernel modules, core libraries and tools.
testpmd application allows to test fast packet processing environments
on x86 platforms. For instance, it can be used to check that environment
can support fast path applications such as 6WINDGate, pktgen, rumptcpip, etc.
More libraries are available as extensions in other packages. %package devel
Summary: Data Plane Development Kit for development
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
DPDK devel is a set of makefiles, headers and examples
for fast packet processing on x86 platforms. %prep
%setup -q %build
make O=%{target} T=%{config} config
sed -ri 's,(RTE_APP_TEST=).*,\1n,' %{target}/.config
sed -ri 's,(RTE_BUILD_SHARED_LIB=).*,\1y,' %{target}/.config
sed -ri 's,(RTE_NEXT_ABI=).*,\1n,' %{target}/.config
sed -ri 's,(LIBRTE_VHOST=).*,\1y,' %{target}/.config
make O=%{target} %{?_smp_mflags} %install
rm -rf %{buildroot}
make install O=%{target} DESTDIR=%{buildroot} \
prefix=%{_prefix} bindir=%{_bindir} sbindir=%{_sbindir} \
includedir=%{_includedir}/dpdk libdir=%{_libdir} \
datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk %files
%dir %{_datadir}/dpdk
%{_datadir}/dpdk/tools
/lib/modules/%(uname -r)/extra/*
%{_sbindir}/*
%{_bindir}/*
%{_libdir}/* %files devel
%{_includedir}/dpdk
%{_datadir}/dpdk/mk
%{_datadir}/dpdk/scripts
%{_datadir}/dpdk/%{target}
%{_datadir}/dpdk/examples %post
/sbin/ldconfig
/sbin/depmod %postun
/sbin/ldconfig
/sbin/depmod
strip.sh
#! /bin/bash
#
# Descriptions:
# strap rpmbuild of xxxx-dpdk
#
# created @ --
# PACKAGE_NAME="xxxx-dpdk"
DPDK_VERSION="16.07" cd ..
TOPDIR=`rpmbuild --eval '%_topdir' >/dev/null`
git archive --format=tar.gz \
--prefix=$PACKAGE_NAME-$DPDK_VERSION/ \
-o $TOPDIR/SOURCES/$PACKAGE_NAME-$DPDK_VERSION.tar.gz HEAD
cd ./pkg rpmbuild -ba dpdk.spec
所以,如果你已经读到这里了。那么你至少应该,像我一样理解了以上两个脚本中的每一行。同时能够应付日常的rpmbuild工作,或者懂了更多。
10. QA
10.1
error: Bad owner/group
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
error: Bad owner/group: /root/Src/copyright/j/dpdk/pkg/dpdk.spec RPM build errors:
Bad owner/group: /root/Src/copyright/j/dpdk/pkg/dpdk.spec
[root@D129 pkg]# ll
因为我的环境是nfs,改了dpdk.spec的owner。
10.2 在编译dpdk的app程序时,由于以下错误,导致只能出正常bin包,不能出debug包。
+ /usr/lib/rpm/find-debuginfo.sh --strict-build-id -m --run-dwz --dwz-low-mem-die-limit --dwz-max-die-limit /root/rpmbuild/BUILD/jer
extracting debug info from /root/rpmbuild/BUILDROOT/jb-1.0.-.el7.x86_64/usr/bin/jb
/usr/lib/rpm/debugedit -b "$RPM_BUILD_DIR" -d /usr/src/debug -i -l "$SOURCEFILE" $f"
/root/rpmbuild/BUILD
/root/rpmbuild/BUILD/jr/debugsources.list
/usr/lib/rpm/debugedit: canonicalization unexpectedly shrank by one character
error: Bad exit status from /var/tmp/rpm-tmp.f7o4DC (%install)
debug一下工具 debugedit
编译rpm工具的源码:
clone rpm的代码:https://github.com/rpm-software-management/rpm
[root@D129 rpm.git]# yum search nss-devel nspr-devel file-devel popt-devel
编译:
./autogen.sh CPPFLAGS="-I/usr/include/nspr4 -I/usr/include/nss3" --without-lua
很遗憾没有编译出debugedit的可执行文件,研究半天,也不知道怎么编。
第二招,通过rpm安装 debuginfo
[root@D129 rpm.git]# yum install rpm-debuginfo
步骤:
1. 执行脚本/usr/lib/rpm/find-debuginfo.sh, 在debugedit 调用前,sleep 特别特别长的时间。
2. 到另一个konsole,用gdb执行debugedi程序。
3. 设立断点,到错误的行。
结论:定位到了错误,但是不理解逻辑,所以也很难定位原因。觉得理解一下debugedit的逻辑:
参数说明:
static struct poptOption optionsTable[] = {
{ "base-dir", 'b', POPT_ARG_STRING, &base_dir, ,
"base build directory of objects", NULL },
{ "dest-dir", 'd', POPT_ARG_STRING, &dest_dir, ,
"directory to rewrite base-dir into", NULL },
{ "list-file", 'l', POPT_ARG_STRING, &list_file, ,
"file where to put list of source and header file names", NULL },
{ "build-id", 'i', POPT_ARG_NONE, &do_build_id, ,
"recompute build ID note and print ID on stdout", NULL },
POPT_AUTOHELP
{ NULL, , , NULL, , NULL, NULL }
};
也就是说,debugedit工具利用 list-file中的信息,将dest obj中的debug信息(源文件的绝对路径)修改。将其内容从base-dir修改为dest-dir。
大概意思是这样的。所以,可以将上边提到的obj文件copy出来,每次复现。因为obj文件每次执行都会被修改,所以。第二次执行相同的文件是,结果会与第一次不同(我这里的现象是,第二次不复现错误。)
第三招
读源码,熟悉代码逻辑,继续深入debug。
通过yum安装源码:
yumdownloader --source rpm
不行。。。。 down下来的是patch。还是要用git代码。
/usr/lib/rpm/debugedit -b "/root/rpmbuild/BUILD" -d /usr/src/debug -i -l newdebug.list vrouter
至此,通过阅读代码,已经可以确定,是二进制程序的问题。debugedit在二进制程序的.debuginfo区检查目录名的时候,发现了它认为非法的目录名。
详见debugedit的代码:~/Src/thirdparty/rpm.git/tools/debugedit.c
if (shrank > )
{
if (--shrank == )
error (EXIT_FAILURE, ,
"canonicalization unexpectedly shrank by one character");
else
{
memset (ptr, 'X', shrank);
ptr += shrank;
*ptr++ = '\0';
}
}
。。。 10个小时之后 。。。
最终。。。。 是我的spec里,在make前,设置了环境变量,环境变量的值是一个path,结尾有个 ’ / ‘, 如下图:
然后把path结尾的 ‘ / ’, 去掉就好了。
[root@D129 j-vrouter]# ldd build/vrouter
linux-vdso.so. => (0x00007fffff9ed000)
libm.so. => /lib64/libm.so. (0x00007f4a54d6c000)
libthrift-0.9..so => /lib64/libthrift-0.9..so (0x00007f4a54ac5000)
libstdc++.so. => /lib64/libstdc++.so. (0x00007f4a547bd000)
libevent-2.0.so. => /lib64/libevent-2.0.so. (0x00007f4a54575000)
libjemalloc.so. => /lib64/libjemalloc.so. (0x00007f4a540f0000)
librte_kni.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_kni.so.2 (0x00007f4a53eeb000)
librte_pipeline.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_pipeline.so.3 (0x00007f4a53ce5000)
librte_table.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_table.so.2 (0x00007f4a53ac5000)
librte_port.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_port.so.3 (0x00007f4a538a8000)
librte_pdump.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_pdump.so.1 (0x00007f4a5349e000)
librte_distributor.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_distributor.so.1 (0x00007f4a5329a000)
librte_reorder.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_reorder.so.1 (0x00007f4a53096000)
librte_ip_frag.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_ip_frag.so.1 (0x00007f4a52e8d000)
librte_meter.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_meter.so.1 (0x00007f4a52c8a000)
librte_sched.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_sched.so.1 (0x00007f4a52a82000)
librte_lpm.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_lpm.so.2 (0x00007f4a5287b000)
librte_acl.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_acl.so.2 (0x00007f4a52665000)
librte_jobstats.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_jobstats.so.1 (0x00007f4a52462000)
librte_power.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_power.so.1 (0x00007f4a52251000)
librte_timer.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_timer.so.1 (0x00007f4a52046000)
librte_hash.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_hash.so.2 (0x00007f4a51e36000)
librte_vhost.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_vhost.so.3 (0x00007f4a51c19000)
librte_kvargs.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_kvargs.so.1 (0x00007f4a51a15000)
librte_mbuf.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_mbuf.so.2 (0x00007f4a51812000)
libethdev.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/libethdev.so.4 (0x00007f4a51585000)
librte_cryptodev.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_cryptodev.so.1 (0x00007f4a5137b000)
librte_mempool.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_mempool.so.2 (0x00007f4a51174000)
librte_ring.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_ring.so.1 (0x00007f4a50f71000)
librte_eal.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_eal.so.2 (0x00007f4a50d12000)
librte_cmdline.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_cmdline.so.2 (0x00007f4a50b08000)
librte_cfgfile.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_cfgfile.so.2 (0x00007f4a50904000)
librte_pmd_bond.so. => /root/Src/copyright/j/dpdk//x86_64-native-linuxapp-gcc/lib/librte_pmd_bond.so.1 (0x00007f4a506ef000)
libgcc_s.so. => /lib64/libgcc_s.so. (0x00007f4a504d9000)
libdl.so. => /lib64/libdl.so. (0x00007f4a502d5000)
libprotobuf-c.so. => /lib64/libprotobuf-c.so. (0x00007f4a500cb000)
libjansson.so. => /lib64/libjansson.so. (0x00007f4a4febe000)
libpthread.so. => /lib64/libpthread.so. (0x00007f4a4fca2000)
libc.so. => /lib64/libc.so. (0x00007f4a4f8de000)
/lib64/ld-linux-x86-.so. (0x00007f4a55078000)
libssl.so. => /lib64/libssl.so. (0x00007f4a4f671000)
libcrypto.so. => /lib64/libcrypto.so. (0x00007f4a4f28a000)
librt.so. => /lib64/librt.so. (0x00007f4a4f081000)
libgssapi_krb5.so. => /lib64/libgssapi_krb5.so. (0x00007f4a4ee33000)
libkrb5.so. => /lib64/libkrb5.so. (0x00007f4a4eb4b000)
libcom_err.so. => /lib64/libcom_err.so. (0x00007f4a4e947000)
libk5crypto.so. => /lib64/libk5crypto.so. (0x00007f4a4e713000)
libz.so. => /lib64/libz.so. (0x00007f4a4e4fd000)
libkrb5support.so. => /lib64/libkrb5support.so. (0x00007f4a4e2ef000)
libkeyutils.so. => /lib64/libkeyutils.so. (0x00007f4a4e0ea000)
libresolv.so. => /lib64/libresolv.so. (0x00007f4a4ded0000)
libselinux.so. => /lib64/libselinux.so. (0x00007f4a4dca8000)
libpcre.so. => /lib64/libpcre.so. (0x00007f4a4da46000)
[administrator] rpmbuild的更多相关文章
- win10用户文件夹重命名,启用administrator账户,删除文件夹时提示找不到该项目
这一切都源自楼主洁癖一般的强迫症. 楼主在重置win10后的安装过程中用microsoft账户登录的电脑,发现用户文件夹名称怪怪的,于是想重命名一下.楼主发现重命名用户文件夹并不能简单地用F2搞定,于 ...
- 以libfuse为例介绍rpm打包工具rpmbuild的使用和SPEC文件的编写
一.rpmbuild命令的安装 yum install rpm-build 二.用法 rpmbuild -bb XXXX.spec或者rpmbuild -ba XXX.tar.gz 三.目录概述 rp ...
- 比管理员(administrator)更高权限的TrustedInstaller
http://www.gezila.com/tutorials/9664.html 什么是TrustedInstaller管理权限 ?好多朋友都在使用Windows7系统.在使用过程中,有些朋友在删除 ...
- [求助] win7 x64 封装 出现 Administrator.xxxxx 的问题
[求助] win7 x64 封装 出现 Administrator.xxxxx 的问题 jacky_qu 发表于 2014-9-3 23:34:37 https://www.itsk.com/thre ...
- 开启Win7系统管理员Administrator账户
Win7系统凭借酷炫的界面以及简单.易用.快速.安全等特点,迅速成为全球最受用户喜爱的操作系统,如今Win7已经成为身边很多朋友生活学习工作的好伙伴.在我们使用Win7的时候,有一些软件的正常运行需要 ...
- Access denied for user 'Administrator'@'localhost' (using password: YES)
Access denied for user 'Administrator'@'localhost' (using password: YES) 配置文件中明明是用的root <entry ke ...
- Win7如何显示/隐藏Administrator账号
为了保证安全,windows7的administrator账户默认在登录时是不显示的. 在登录页面显示administrator账户的方法: 1. 选择"开始"菜单->&qu ...
- pe创建激活administrator后消除问题,删除用户问题
启动pe进入电脑,打开清楚密码,然后选择administrator,点击激活.然后就可以用administrator登陆电脑. 使用完毕后,想要注销administrator. 方法1. 在cmd中输 ...
- SharePoint Error - The current user is not an SharePoint Server farm administrator
错误截图 错误日志 位置:C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\LOGS 主要错误 The c ...
随机推荐
- GitHub网站操作
1.建立新的仓库 2.添加文件 3.新建一个分支 4.删除仓库
- 2. Attention Is All You Need(Transformer)算法原理解析
1. 语言模型 2. Attention Is All You Need(Transformer)算法原理解析 3. ELMo算法原理解析 4. OpenAI GPT算法原理解析 5. BERT算法原 ...
- Linux SD/MMC/SDIO驱动分析_转
转自:Linux SD/MMC/SDIO驱动分析 https://www.cnblogs.com/cslunatic/p/3678045.html#3053341 一.SD/MMC/SDIO概念 ...
- 【转】在Win7的IIS上搭建FTP服务及用户授权
[转]在Win7的IIS上搭建FTP服务及用户授权 [转]在Win7的IIS上搭建FTP服务及用户授权 FTP服务 FTP是文件传输协议(File Transfer Protocol)的简称,该协议属 ...
- 转载 :配置ssh密钥认证自动登录
原文地址 :https://segmentfault.com/a/1190000000481249 在客户端来看,SSH提供两种级别的安全验证.[摘自wikipedia] 第一种级别(基于密码的安全验 ...
- Java如何验证电子邮件地址格式?
在Java编程中,如何验证电子邮件地址格式? 以下示例演示如何使用String类的matches()方法来验证电子邮件地址. package com.yiibai; public class Vali ...
- 修改git用户密码
第一步:登录git服务器: 第二步:切换到git用户 su git 第三步:登录GitLab的Rails控制台(GitLab使用RoR语言开发), gitlab-rails console produ ...
- 设计模式-行为型模式,python访问者模式
访问者模式 在访问者模式(Visitor Pattern)中,我们使用了一个访问者类,它改变了元素类的执行算法.通过这种方式,元素的执行算法可以随着访问者改变而改变.这种类型的设计模式属于行为型模式. ...
- java.security.ProviderException: java.security.KeyException
本机部署没问题,部署到linux服务器报错: javax.net.ssl.SSLException: java.security.ProviderException: java.security.Ke ...
- IntelliJ IDE破解
1.购买正版用户 2.激活码 一:下载以下jar,放到 bin 破解补丁无需使用注册码,下载地址 idea14 keygen下载地址 二:在下面两个文件中加入-javaagent:E:\IDEA\In ...