Skip to content

Commit

Permalink
RPM: set AllowedCPUs in quadlet file post install
Browse files Browse the repository at this point in the history
Fixes: containers#24

Signed-off-by: Lokesh Mandvekar <[email protected]>
  • Loading branch information
lsm5 committed Apr 27, 2023
1 parent 1c0282f commit cfbd564
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions qm.spec.rpkg
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ sed -i '/user_namespace/d' qm.if
%_format MODULES %{_datadir}/selinux/packages/$x.pp.bz2
%selinux_modules_install -s %{selinuxtype} $MODULES

# Set AllowedCPUs in quadlet file
NPROC=$(nproc)
if [[ $NPROC == 2 ]]; then
ALLOWED_CPUS=1
else
ALLOWED_CPUS=$(expr $NPROC / 2)"-"$(expr $NPROC - 1)
fi
sed -i "s/^AllowedCPUs=.*/AllowedCPUs=$ALLOWED_CPUS/" %{_datadir}/containers/systemd/qm.container


%postun
if [ $1 -eq 0 ]; then
%selinux_modules_uninstall -s %{selinuxtype} %{modulenames}
Expand Down

0 comments on commit cfbd564

Please sign in to comment.