From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62581EB64DA for ; Wed, 12 Jul 2023 16:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232068AbjGLQPb (ORCPT ); Wed, 12 Jul 2023 12:15:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbjGLQPW (ORCPT ); Wed, 12 Jul 2023 12:15:22 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E292113; Wed, 12 Jul 2023 09:15:18 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A69BA21BF6; Wed, 12 Jul 2023 16:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689178516; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f+VBw2m9h9l7vvxNuxZsgOqUhypJ0WlLLP87GhZA5AE=; b=YSLsdtwZOTkfjqynfuSJKj0gvd2emXLtxf244R7bExDlFjBODop+V8pZdCoMtk800ot5y1 IGAvjy7xx0LDVfROul9MHc86uhCeGeOVSAjpJXts4n94xNKWkujab22FoWM4Ca8MYoluC9 Ef0qK/McyteLSd3OpzeyQQ3kNOnMbQ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689178516; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f+VBw2m9h9l7vvxNuxZsgOqUhypJ0WlLLP87GhZA5AE=; b=AcDoY21OwDC41DctUXzxwi968x4MBiI1tUbqoCeoJ+0xifX83UAemuQdYknb8NdNbQLf4n wR+GMtS7/uRYYCBw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 37BFD2C142; Wed, 12 Jul 2023 16:15:16 +0000 (UTC) Date: Wed, 12 Jul 2023 18:15:15 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Masahiro Yamada Cc: Takashi Iwai , Lucas De Marchi , Michal =?iso-8859-1?Q?Koutn=FD?= , Jiri Slaby , Jan Engelhardt , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2--to=linux-modules@vger.kernel.org] depmod: Handle installing modules under a prefix Message-ID: <20230712161515.GH9196@kitsune.suse.cz> References: <20230712134533.4419-1-msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 12, 2023 at 11:14:33PM +0900, Masahiro Yamada wrote: > On Wed, Jul 12, 2023 at 10:45 PM Michal Suchanek wrote: > > > > Some distributions aim at not shipping any files in / ustside of usr. > > > > The path under which kernel modules are instaleld is hardcoded to /lib > > which conflicts with this goal. > > > > When kmod provides the config command use it to determine the correct > > module installation prefix. > > > > On kmod that does not provide the command / is used as before. > > > > Signed-off-by: Michal Suchanek > > --- > > v2: Avoid error on systems with kmod that does not support config > > command > > --- > > Makefile | 4 +++- > > scripts/depmod.sh | 8 ++++---- > > 2 files changed, 7 insertions(+), 5 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index 47690c28456a..b1fea135bdec 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -1165,7 +1165,9 @@ export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) > > # makefile but the argument can be passed to make if needed. > > # > > > > -MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) > > +export KERNEL_MODULE_PREFIX := $(shell kmod config &> /dev/null && kmod config | jq -r .module_prefix) > > + > > +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_PREFIX)/lib/modules/$(KERNELRELEASE) > > You can do "make modules_install INSTALL_MOD_PATH=/usr/what/ever/prefix" > > This patch is unneeded. It's very much needed. INSTALL_MOD_PATH is temporary staging location, KERNEL_MODULE_PREFIX is permanent prefix under which modules are searched. Note that depmod.sh does not use INSTALL_MOD_PATH but uses KERNEL_MODULE_PREFIX. Support for this is added by the corresponding kmod patchset. Thanks Michal > > export MODLIB > > > > PHONY += prepare0 > > diff --git a/scripts/depmod.sh b/scripts/depmod.sh > > index 3643b4f896ed..88ac79056153 100755 > > --- a/scripts/depmod.sh > > +++ b/scripts/depmod.sh > > @@ -27,16 +27,16 @@ fi > > # numbers, so we cheat with a symlink here > > depmod_hack_needed=true > > tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX) > > -mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE" > > +mkdir -p "$tmp_dir$KERNEL_MODULE_PREFIX/lib/modules/$KERNELRELEASE" > > if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then > > - if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \ > > - -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then > > + if test -e "$tmp_dir$KERNEL_MODULE_PREFIX/lib/modules/$KERNELRELEASE/modules.dep" -o \ > > + -e "$tmp_dir$KERNEL_MODULE_PREFIX/lib/modules/$KERNELRELEASE/modules.dep.bin"; then > > depmod_hack_needed=false > > fi > > fi > > rm -rf "$tmp_dir" > > if $depmod_hack_needed; then > > - symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE" > > + symlink="$INSTALL_MOD_PATH$KERNEL_MODULE_PREFIX/lib/modules/99.98.$KERNELRELEASE" > > ln -s "$KERNELRELEASE" "$symlink" > > KERNELRELEASE=99.98.$KERNELRELEASE > > fi > > -- > > 2.41.0 > > > > > -- > Best Regards > Masahiro Yamada