1 Star 0 Fork 7

Shiloong/ck-build

forked from src-anolis-sig/ck-build 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
build.sh 4.24 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
#
# Anolis Cloud Kernel rpm builder
#
[ -z $WORKSPACE ] && WORKSPACE=$(pwd)
[ -z $BUILD_NUMBER ] && BUILD_NUMBER=0
topdir="${WORKSPACE}"
srcdir="${topdir}/cloud-kernel"
rpmbuilddir="${topdir}/rpmbuild"
outputdir="${topdir}/outputs"
dist="an8"
kernel_spec="${topdir}/kernel.spec"
nproc=$(grep -c processor /proc/cpuinfo)
function do_prep() {
rm -rf ${rpmbuilddir}
mkdir -p ${rpmbuilddir}/{SOURCES,SPECS}
cp ${kernel_spec} ${rpmbuilddir}/SPECS/kernel.spec
pushd ${srcdir}/ > /dev/null
KVER=$(make kernelversion)
if [ -z "${KVER##*-*}" ]; then
RELEASE=${KVER##*-}
KVER=${KVER%%-*}
fi
if [ "_${RELEASE}" == "_" ]; then
commit_sha=$(git rev-parse --short HEAD)
KREL="${BUILD_NUMBER}.git.${commit_sha}"
else
KREL=${RELEASE}
fi
sed -i "s/!KREL:.*}/!KREL:${KREL}}/" ${rpmbuilddir}/SPECS/kernel.spec
pkgname="linux-${KVER}-${KREL}.${dist}"
git archive --format=tar --prefix="${pkgname}/" HEAD | xz -T${nproc} > "${rpmbuilddir}/SOURCES/${pkgname}.tar.xz"
if [ -f arch/x86/configs/anolis_defconfig ]
then
cp arch/x86/configs/anolis_defconfig ${rpmbuilddir}/SOURCES/kernel-${KVER}-x86_64.config
cp arch/x86/configs/anolis-debug_defconfig ${rpmbuilddir}/SOURCES/kernel-${KVER}-x86_64-debug.config
cp arch/arm64/configs/anolis_defconfig ${rpmbuilddir}/SOURCES/kernel-${KVER}-aarch64.config
cp arch/arm64/configs/anolis-debug_defconfig ${rpmbuilddir}/SOURCES/kernel-${KVER}-aarch64-debug.config
popd > /dev/null
else
popd > /dev/null
cp anolis_defconfig.x86 ${rpmbuilddir}/SOURCES/kernel-${KVER}-x86_64.config
cp anolis-debug_defconfig.x86 ${rpmbuilddir}/SOURCES/kernel-${KVER}-x86_64-debug.config
cp anolis_defconfig.arm64 ${rpmbuilddir}/SOURCES/kernel-${KVER}-aarch64.config
cp anolis-debug_defconfig.arm64 ${rpmbuilddir}/SOURCES/kernel-${KVER}-aarch64-debug.config
fi
cp cpupower* ${rpmbuilddir}/SOURCES/
cp filter-* ${rpmbuilddir}/SOURCES/
cp mod-* ${rpmbuilddir}/SOURCES/
cp generate_bls_conf.sh ${rpmbuilddir}/SOURCES/
}
function do_rpmbuild() {
if [ "_${RELEASE}" == "_" ]; then
CMD="-bb"
else
CMD="-ba"
fi
# Now we have:
# + variants: default, only-debug, with-debug
# + extras: base, with-debuginfo, full
# + modes: nightly, dev, pre-release
#TODO: add with-gcov
#
# Matrix
#
# | Extra\Var | Default | Only-debug | With-debug |
# |-----------|----------|------------|------------|
# | Base | +default | -default | +default |
# | | -debug | +debug | +debug |
# | | +headers |
# |-----------|------------------------------------|
# | debuginfo | +debuginfo |
# |-----------|------------------------------------|
# | full | +tools +doc +perf |
#
# Note: pre-release mode will always be "full" and "with-debug" by default
build_opts="--with headers --without bpftool --without signmodules"
if [ "_${BUILD_VARIANT}" == "_only-debug" ]; then
build_opts="$build_opts --without default --with debug"
elif [ "_${BUILD_VARIANT}" == "_with-debug" ]; then
build_opts="$build_opts --with default --with debug"
else # assume default
build_opts="$build_opts --with default --without debug"
fi
if [ "_${BUILD_EXTRA}" == "_debuginfo" ]; then
build_opts="$build_opts --with debuginfo --without tools --without doc --without perf"
elif [ "_${BUILD_EXTRA}" == "_base" ]; then
build_opts="$build_opts --without debuginfo --without tools --without doc --without perf"
else # assume full
build_opts="$build_opts --with debuginfo --with tools --with doc --with perf"
fi
rpmbuild \
--define "%_smp_mflags -j${nproc}" \
--define "%packager <alicloud-linux@alibaba-inc.com>" \
--define "%_topdir ${rpmbuilddir}" \
--define "%KVER ${KVER}" \
--define "%KREL ${KREL}" \
${build_opts} \
${CMD} ${rpmbuilddir}/SPECS/kernel.spec \
--target=$(uname -m) || exit 1
}
function output() {
if [ "_${RELEASE}" == "_" ]; then
targetdir=${BUILD_NUMBER}
else
targetdir=${RELEASE}
fi
mkdir -p ${outputdir}/${targetdir}
cp ${rpmbuilddir}/RPMS/$(uname -m)/*.rpm ${outputdir}/${targetdir}/
cp ${rpmbuilddir}/SRPMS/*.rpm ${outputdir}/${targetdir}
i=0
for p in ${outputdir}/${targetdir}/*.rpm; do
echo $p
((i++))
done
echo "$i rpm(s) copied."
}
do_prep
do_rpmbuild
output
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/shiloong/ck-build.git
git@gitee.com:shiloong/ck-build.git
shiloong
ck-build
ck-build
an8-ml

搜索帮助