1
0

refine scripts

This commit is contained in:
Konstantin Demin 2024-11-01 15:46:17 +03:00
parent a03db36fed
commit 352b17054d
3 changed files with 88 additions and 2 deletions

View File

@ -7,7 +7,7 @@ w=$(git rev-parse --path-format=absolute --show-toplevel) ; : "${w:?}" ; cd "$w"
dst='debian/patches/pf' dst='debian/patches/pf'
src='../linux-extras' src='../linux-extras'
branches='amd-pstate amd-rapl cpuidle crypto fixes ksm zstd' branches='amd-pstate amd-rapl cpu cpuidle crypto fixes ksm zstd'
[ -d "${dst}" ] [ -d "${dst}" ]

View File

@ -29,7 +29,7 @@ ver_path="v${major}.${minor}"
tarball_new="linux_${v}.orig.tar" tarball_new="linux_${v}.orig.tar"
tarball_new_comp="${tarball_new}.xz" tarball_new_comp="${tarball_new}.xz"
do_compress() { do_idle xz -1vv "$1" ; } do_compress() { do_idle xz -8vv "$1" ; }
while ! [ -s "../${tarball_new_comp}" ] ; do while ! [ -s "../${tarball_new_comp}" ] ; do

86
debian/bin/refine-configs vendored Executable file
View File

@ -0,0 +1,86 @@
#!/bin/sh
set -ef
prj_dir=$(readlink -f "$(dirname "$0")/../..")
cd "${prj_dir}"
[ -s debian/changelog ]
dpkg-parsechangelog --show-field Source | grep -Eq '^linux'
ch_ver=$(dpkg-parsechangelog --show-field Version)
v=$1
[ -n "$v" ] || v=$(echo "${ch_ver}" | sed -E 's/^\d+://;s/-[^-]+$//')
[ -n "$v" ]
## should be source tree with patches applied
src_dir=$2
[ -n "${src_dir}" ] || src_dir="/tmp/linux-$v"
[ -n "${src_dir}" ]
[ -d "${src_dir}" ]
src_dir=$(readlink -f "${src_dir}")
export PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
nproc=$(nproc || printf 2)
case "${nproc}" in
[0-1] ) nproc=2 ;;
[2-9] | 1[0-9] ) ;;
* ) nproc=20 ;;
esac
rm -rf debian/build/
make -f debian/rules debian/control
[ -f debian/rules.gen ]
configs=$(sed -En '\,debian/build/(config\.[^ :]+):$,{s,,\1,p}' debian/rules.gen | sort -uV | tr -s '[:space:]' ' ')
[ -n "${configs}" ]
## produce configs
make -f debian/rules.gen "-j${nproc}" $(printf ' debian/build/%s' ${configs})
## refresh configs
for c in ${configs} ; do
echo "# refreshing $c" >&2
f="debian/build/$c"
cp -f "$f" "${src_dir}/.config"
env -C "${src_dir}" make "-j${nproc}" olddefconfig
cp -f "${src_dir}/.config" "$f"
done
## remove BUILD_SALT
find debian/build/ -name 'config.*' -type f -exec sed -i -E '/CONFIG_BUILD_SALT/d' {} +
## prepare configs for splitting
find debian/build/ -name 'config.*' -type f -exec sed -i -En '/CONFIG_/p' {} +
(
cd debian/build
mkdir -p split-configs
cd split-configs
"${prj_dir}/../kconfigeditor2/split-common.py" $(printf ' ../%s' ${configs})
find ./ -mindepth 1 -maxdepth 1 -type f -exec sed -i -En '/CONFIG_/p' {} +
cp -f output-common "${prj_dir}/debian/config/config"
i=0
for c in ${configs} ; do
i=$((i+1))
## config.amd64_none_cloud -> amd64/config.cloud
## config.amd64_rt_desktop -> amd64/rt/config.desktop
read -r arch featureset flavour <<-EOF
$(printf '%s' "${c#config.}" | tr '_' ' ')
EOF
[ -n "${arch}" ] || continue
[ -n "${featureset}" ] || continue
[ -n "${flavour}" ] || continue
case "${featureset}" in
none ) o="${arch}/config.${flavour}" ;;
* ) o="${arch}/${featureset}/config.${flavour}" ;;
esac
cp -f "output-part-$i" "${prj_dir}/debian/config/$o"
done
)
"${prj_dir}/../kconfigeditor2/process.py" -s "${src_dir}" .