CentOS 7 aarch64上制作kernel rpm二进制包 —— 筑梦之路

发布于:2025-03-06 ⋅ 阅读:(17) ⋅ 点赞:(0)

环境说明

centos 7  aarch64

gcc 8.3.1

kernel 5.4.290

准备编译制作

# 安装必要的工具和包
 
yum install rpm-devel rpmdevtools
yum groupinstall "Development Tools"
 
yum install ncurses-devel  bc elfutils-libelf-devel openssl-devel 


# 安装gcc 8.3.1

# 修改repo文件

cd /etc/yum.repos.d/
cat > CentOS-SCLo-scl-rh.repo << 'EOF'
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
EOF

yum clean all
yum makecache fast
sudo yum install devtoolset-8-gcc devtoolset-8-gcc-c++

#临时启用gcc8
source /opt/rh/devtoolset-8/enable

#长期使用
echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile

# 下载源码包
wget http://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v5.x/linux-5.4.290.tar.xz

tar -Jxf linux-5.4.290.tar.xz

开始编译制作rpm

cd linux-5.4.290

# 生成配置文件

make menuconfig
 
# 编译制作rpm包

make rpm-pkg  

# 更多参数说明参考
Kernel packaging:
  rpm-pkg             - Build both source and binary RPM kernel packages
  binrpm-pkg          - Build only the binary kernel RPM package
  deb-pkg             - Build both source and binary deb kernel packages
  bindeb-pkg          - Build only the binary kernel deb package
  snap-pkg            - Build only the binary kernel snap package
                        (will connect to external hosts)
  dir-pkg             - Build the kernel as a plain directory structure
  tar-pkg             - Build the kernel as an uncompressed tarball
  targz-pkg           - Build the kernel as a gzip compressed tarball
  tarbz2-pkg          - Build the kernel as a bzip2 compressed tarball
  tarxz-pkg           - Build the kernel as a xz compressed tarball
  perf-tar-src-pkg    - Build perf-5.7.1.tar source tarball
  perf-targz-src-pkg  - Build perf-5.7.1.tar.gz source tarball
  perf-tarbz2-src-pkg - Build perf-5.7.1.tar.bz2 source tarball
  perf-tarxz-src-pkg  - Build perf-5.7.1.tar.xz source tarball

成果展示

FAQ

1. No rule to make target 'certs/rhel.pem', needed by 'certs/x509_certificat

解决:

修改.config文件

CONFIG_SYSTEM_TRUSTED_KEYS=""

2. BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1

解决:

修改.config文件

CONFIG_DEBUG_INFO_BTF=n


网站公告

今日签到

点亮在社区的每一天
去签到