From patchwork Wed Jul 12 13:45:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 119211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1182999vqm; Wed, 12 Jul 2023 07:17:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlErgfyp71d3e7d05onMFQGVyaiBWEG6KxXhp09RMEuC01wU2m7mVdzNwJJtks1cLLjCYkJG X-Received: by 2002:a17:902:ea05:b0:1b8:9b1b:ae7a with SMTP id s5-20020a170902ea0500b001b89b1bae7amr17347231plg.34.1689171440429; Wed, 12 Jul 2023 07:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689171440; cv=none; d=google.com; s=arc-20160816; b=Kd4zigANRXnrYV9fEzPI6z0DJWkZFAmLHn86ldWZURZOJAthgLfzV0dppkPk3ioN31 gltSYaWd8iAqLLxjq4fnKZZECeYudW70T9Th/Z1fWkz5M9wQWH3HLTpzHnIyBHK3cmf6 xg9R98JT+0lDnLK1ChdKwuqI3+zUd9hbN9OLcbYLmmPuqa0t777uoyuBST5s5lv3K460 woPuYNKMgrnhjefzDRaD/hCDVyUJGvNjY0hE361FVCF83lyko4l2s3DhyHYodRr8fTS8 zvXipc4wWboofxqBB3cGwc0cKtJeCcuJNT26XbRgIjYlha0BSUfictzecbvnPyccJxtd 3jqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature:dkim-signature; bh=G+kzlCw/SCEEe9a86Jj/6fxE8wGtEPp1cF0uqUxJXbY=; fh=0XnM2H6ejEEyg0g/ieWHbrD2GNHH6viteU1JtXW3WHI=; b=aEKHCFWz4/i4XhTd1sLT8v9aLK61Jsb9kAU1FkIyTiS5aw9fEnyplbfG93CpbH2prt DZwRlnUr+sHUyWS+96UFUYd4Fa5Oaxi72KJI3mGKzkLGDAkUWVjl/xJDfyEqmDMBKQda 13uuMASop6bn6H2c1lV8aPsLKn4TS07tdZqPnG2ydJGFHNna30VMhZKZcKVmHzOdV0ZW t5y8Gis1486TE3X0cAru0+E5rzdIptbAK8Hhpyy+NLJ7yfycQB6UIs2B+CiDJv+xCmmt OyHedRZuS8BR3RlL6JZ4Ki6mqY7qXDOsz5mQl59SWpp0vWkuasLMTATHuH1WGSAsZ9DF SLtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@suse.de header.s=susede2_rsa header.b=WIilWt8P; 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=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a17090311d200b001b5006b87c0si3575245plh.139.2023.07.12.07.17.08; Wed, 12 Jul 2023 07:17:20 -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=fail header.i=@suse.de header.s=susede2_rsa header.b=WIilWt8P; 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=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233128AbjGLNpm (ORCPT + 99 others); Wed, 12 Jul 2023 09:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232952AbjGLNpl (ORCPT ); Wed, 12 Jul 2023 09:45:41 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3D4E4D; Wed, 12 Jul 2023 06:45:40 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id F41E31F893; Wed, 12 Jul 2023 13:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689169539; 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=G+kzlCw/SCEEe9a86Jj/6fxE8wGtEPp1cF0uqUxJXbY=; b=WIilWt8PA4uZmrnmW+mk+UJaoE5N7LsZBv14GAXDJamGClORjV6AaedgU+81krZ/Dl6yXg 3JWG4czVlAyz5nyQTq7d95HQ5pbybQEVj+uj0SxbedPzkA/yfx0VwZm2S96J65PmkRkDF2 63FhZ77cJ0ffor6VgDjx3zaVTSWF6ho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689169539; 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=G+kzlCw/SCEEe9a86Jj/6fxE8wGtEPp1cF0uqUxJXbY=; b=umhHv+grXQ8dOfv81wH9k9xTDQjcnRVnp74XMx8ajHLPBEmlUJNyEbOTOR+WfgsG3umNc5 AUWEfD0cN2OK2aAg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 9BC152C142; Wed, 12 Jul 2023 13:45:38 +0000 (UTC) From: Michal Suchanek Cc: Michal Suchanek , Takashi Iwai , Lucas De Marchi , =?utf-8?q?Michal_Koutn=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 v2--to=linux-modules@vger.kernel.org] depmod: Handle installing modules under a prefix Date: Wed, 12 Jul 2023 15:45:31 +0200 Message-ID: <20230712134533.4419-1-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771141178799364395 X-GMAIL-MSGID: 1771224632286488845 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) 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