1. 一键制作libfastcommon rpm脚本
#!/bin/bash
cat << EOF
+-------------------------------------------+
| this is a rpmbuild libfastcommon script |
| from Antony ....... |
+--------------------------------------------
EOF
# 制作源码文件 建议手动安装yum
#yum groupinstall "Development Tools" "Server platform Development" -y
cd /root/
git clone https://github.com/happyfish100/libfastcommon.git
if [ $? -ne 0 ];then
exit 1
fi
libversion=$(grep -i "^version" libfastcommon/libfastcommon.spec |awk -F':' '{print $2}'|awk '{print $1}')
mv libfastcommon/ libfastcommon-$libversion
tar zcf libfastcommon-${libversion}.tar.gz libfastcommon-$libversion
# 制作rpm包
cd /root
mkdir rpmbuild/{SOURCES,SPECS} -pv
cp libfastcommon-${libversion}.tar.gz rpmbuild/SOURCES/
cp libfastcommon-${libversion}/libfastcommon.spec rpmbuild/SPECS/
rpmbuild -ba /root/rpmbuild/SPECS/libfastcommon.spec &>/dev/null
libfastcommon rpm编译报错
RPM build errors:Symlink points to BuildRoot
RPM build errors:
Symlink points to BuildRoot: /usr/lib/libfastcommon.so -> /root/rpmbuild/BUILDROOT/libfastcommon-1.0.40-1.el7.centos.x86_64/usr/lib64/libfastcommon.so
[root@node-60 ~]# ln -sf /usr/lib/libfastcommon.so /root/rpmbuild/BUILDROOT/libfastcommon-1.0.40-1.el7.centos.x86_64/usr/lib64/libfastcommon.so
原因:spec文件使用绝对路径,修改软链接使用%{buildroot}相对路径。
修改libfastcommon.spec
#解决:在.spec中的%install构建部分添加:
ln -sf '目标文件' %{buildroot}/'软连接文件'
这个‘软连接’通常出现在%files部分中引用
#修改.spec
[root@node-60]# vim rpmbuild/SPECS/libfastcommon.spec
%install
rm -rf %{buildroot}
DESTDIR=$RPM_BUILD_ROOT ./make.sh install
ln -sf usr/lib64/libfastcommon.so* %{buildroot}/usr/lib/libfastcommon.so* #添加软连接
- 然后重新执行
rpmbuild -ba /root/rpmbuild/SPECS/libfastcommon.spec
2、一键制作libfastcommon rpm脚本
#!/bin/bash
# Author: Antony
# rpm build for fastdfs
# Mail: zhaoxin@altamob.com,go80800@163.com
# Desc: build fastdfs # 作fastdfs rpm
cat << EOF
+-------------------------------------------+
| this is a rpmbuild FastDFS script |
| from Antony ....... |
+--------------------------------------------
EOF
if rpm -q libfastcommon;then
cd /root/
git clone https://github.com/happyfish100/fastdfs.git
if [ $? -ne 0 ];then
exit 1
fi
sleep 3
fdfsv=$(grep -E "FDFSVersion[[:space:]]+" fastdfs/fastdfs.spec|awk '{print $3}')
mv fastdfs fastdfs-${fdfsv}
cd /root/
tar zcf fastdfs-${fdfsv}.tar.gz fastdfs-${fdfsv}/
mkdir rpmbuild/{SOURCES,SPECS} -pv
cp fastdfs-${fdfsv}.tar.gz rpmbuild/SOURCES/
cp fastdfs-${fdfsv}/fastdfs.spec rpmbuild/SPECS/
rpmbuild -ba /root/rpmbuild/SPECS/fastdfs.spec
fastdfs rpm编译报错1
RPM build errors:
Installed (but unpackaged) file(s) found:
/etc/fdfs/http.conf.sample
/etc/fdfs/mime.types.sample
原因:spec文件中,“%files”部分中未指定将要安装的文件列表。
#解决:
编译过程中删除这些文件
#修改
[root@node-60]# vim rpmbuild/SPECS/fastdfs.spec
%clean
rm -rf %{buildroot} #把这里的#号删除,启用此语句
fastdfs rpm编译报错2
RPM build errors:
Installed (but unpackaged) file(s) found:
/usr/bin/fdfs_regenerate_filename
这个意思是说发现了制作RPM包的spec脚本中没有包含但又被安装的文件,那么不用多说,把这个文件添加在%files段就可以了,如下。
- 最后在重新执行
rpmbuild -ba /root/rpmbuild/SPECS/fastdfs.spec
- rpm包就在/root/rpmbuild/RPMS/x86_64/
参考
- https://zhaox.xyz/posts/制作并安装fastdfs的rpm程序包/
- https://www.jianshu.com/p/74bb69967094
- https://github.com/happyfish100/fastdfs/wiki