Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2398915rwp; Fri, 14 Jul 2023 05:46:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHegTdiHUsxcnyaaHU5XKb5lm67fH9BOelGx33kjkUqKnPWPvTqOoa47McS15go3EDITuQM X-Received: by 2002:a05:6a20:100c:b0:12d:208c:acaa with SMTP id gs12-20020a056a20100c00b0012d208cacaamr3237764pzc.26.1689338771908; Fri, 14 Jul 2023 05:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689338771; cv=none; d=google.com; s=arc-20160816; b=uQCkjno/lg6M4QV6WHEMYs9LaWQMAUCkc8GYdX2WgRxLZOqo1wxTpZMerW8eZ30Xqk vFFl5y3bGKHDrShAMGpo88UaRVkd2JvMTkn0YBX/6t2rPuyjFlW9PBtSJ+gsTZwsyBc6 ngO3oZs9j56s6SevkBVXLSr4IbXKH8gm9lOeoYpOoqJyjONm/jIW1r7ZDm6P7Onr6OY4 hlyaIK37DnN3NzxSGjocIEm84V8gUysn56ku5ACAaK46Bai2uixAXpvTd/VgqldJCfcy tz7a6tJtgg1P4J0DAtY8Y7dOAjBUdO6G/lkrImaFbcw7y4leMdYS9eORRoDvtiYrEWal iO1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=lNe8idGh8AhD5+hHQZpsPL59psm6FR8/RCbKm61pH2E=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=FQnpa+RVucJHeYKtXWzk9IustmuYKUqetsghs8Ik+T9WbMX4SUkh78VFCs0pAe1icp jActiTh2N64E26hMfPZC5Elp4OqFnkkoT3NtVBGYGXHJmjQEms+KGZSO3CzwyqA1tjvm 6AkR7vn3V3fCztxR8HSAYIVsf7y6eKhVAb+5iJ46ZLpMhemdBIPdq5YGpOfHRPjPI9IZ IPlvrmTvDczPiFeO+dAtrBuS+CjpHiU8TCreNxySL+mSkGUiMUOaaCcnDIft8u+h169r XuRBTQEllMORHOhW2r86jNKyhnLS+6D1LQu433kTTL8npO4TzR34udV2SYAzvyLoOoni k1EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vXsRp0tc; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s186-20020a6377c3000000b0055c71125c22si4361182pgc.230.2023.07.14.05.45.59; Fri, 14 Jul 2023 05:46:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vXsRp0tc; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235777AbjGNMVc (ORCPT + 99 others); Fri, 14 Jul 2023 08:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235408AbjGNMVb (ORCPT ); Fri, 14 Jul 2023 08:21:31 -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 45ED11FD6; Fri, 14 Jul 2023 05:21:29 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id EE2E522103; Fri, 14 Jul 2023 12:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689337287; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lNe8idGh8AhD5+hHQZpsPL59psm6FR8/RCbKm61pH2E=; b=vXsRp0tcRJfFimJyLjP1QbJiQYuZM44d0JGuYNbqmsTbljBQfa8L/PCC9IsL9jmQrY2Q7/ WHdQfKyuREK5Ip3zI2vJrQUYX79dx1PVCtMeNkL/lznHyrVp9GKIgLfl7dokv6HZmPM7os bP/dWnmewq+L0YEO2NsOz45co+RXEIc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689337287; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lNe8idGh8AhD5+hHQZpsPL59psm6FR8/RCbKm61pH2E=; b=CjXy6UpXkH0Qcw/+xNiDCQzr5EuOWwWs5h20kXpoN74P429a0cZptMvcu/5Zc265vTdbNo 7CW9sEC7RpW9iPAQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 91DC02C142; Fri, 14 Jul 2023 12:21:27 +0000 (UTC) From: Michal Suchanek To: linux-modules@vger.kernel.org Cc: Michal Suchanek , Takashi Iwai , Lucas De Marchi , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Jiri Slaby , Jan Engelhardt , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] depmod: Handle installing modules under a prefix Date: Fri, 14 Jul 2023 14:21:08 +0200 Message-ID: <20230714122111.7528-1-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <30d8c675-e769-e567-a81f-c1b59c66ad67@suse.com> References: <30d8c675-e769-e567-a81f-c1b59c66ad67@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some distributions aim at not shipping any files in / outside of usr. The path under which kernel modules are installed is hardcoded to /lib which conflicts with this goal. When kmod provides the config command, use it to determine the correct module installation prefix. This is a prefix under which the modules are searched by kmod on the system, and is separate from the temporary staging location already supported by INSTALL_MOD_PATH. With kmod that does not provide the config command empty prefix is used as before. Signed-off-by: Michal Suchanek --- v2: Avoid error on systems with kmod that does not support config command v3: More verbose commit message --- 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) 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