From patchwork Tue Jul 18 12:03:47 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: 121975 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1697528vqt; Tue, 18 Jul 2023 05:15:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlER4Y7/3IRD6PESYu4hqLoyVOVjMSjTUDrniI0QDP1jafAzEMDaZ+SdhnjqxUdVk1m8K2fD X-Received: by 2002:a17:903:41d1:b0:1b8:9846:a3b2 with SMTP id u17-20020a17090341d100b001b89846a3b2mr16071623ple.14.1689682552879; Tue, 18 Jul 2023 05:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689682552; cv=none; d=google.com; s=arc-20160816; b=bEH8yCgJm/bcJ3Iud/ZSHJ3oB1JFZlug8GXSDu6v+w+T7g1yyMTEhLKhqF1Oll/Xod j6Ze0Xld6wQGujOcK6TSUb/Se3kvl2uw4jBDrnKljgiqseOdZihX6Ez1B8TCAU8yYoMY P4J5zBI/WUmRlDr9+SC3252KD9J0hGSc9S3RHsSYWYwhmRXfvm84bdC0od6vxngYJdd0 ttcWveO3btUw1U9kpZFTvv893OtdoL9RL8KCR7AmlP6V85t3npz6Z1bqSUwKzrpjsvyX ZgVGzmDCFbEPf8MMEGGDVW5mF9upZKYtCnCTmgtu4iKRAZL0VivElh0cwWc7qeWFyMut wI4g== 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=vcCkWnZUOHY/Sf1BWe3lgRRDTuoQCOqXBJxqBFvSUCI=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=xNSjk5Sye0FTPGPQxwmv32Eqh8ynlqs9fvRX93tjghVGN1JJa5zxQdMn6S1z2F4A2/ I/F1A4yuqS+VguMYNG4wOOBzD9o+AlmM1n6EIqKigK39DbiDuMR0Ma5q3h8W3Qktw7ew +BO1SXSiMAIvSWCAD3SGBaBMBvCnsP3fOpDBU1WrFcZOPzlhcIOAcWgs1laO+lyegQPw QzWu52COwby6mSCTp7QLtg7RLVzsP1T9YScN/8kyw9vLG6mf0QN5FQuVWOcYKfL7iZq4 VdO0jjWx6ro/QYav7FbDYbW/nYYczt+XBUCB4I7gYyincHdl+rjNPr5UOn/LcnXycVG1 c9Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=2YYugYC+; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170903120900b001b55070e154si1624050plh.96.2023.07.18.05.15.21; Tue, 18 Jul 2023 05:15:52 -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=2YYugYC+; 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 S231949AbjGRMEo (ORCPT + 99 others); Tue, 18 Jul 2023 08:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjGRMEn (ORCPT ); Tue, 18 Jul 2023 08:04:43 -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 CD8F619A0; Tue, 18 Jul 2023 05:04:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0EFC0218E8; Tue, 18 Jul 2023 12:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681832; 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=vcCkWnZUOHY/Sf1BWe3lgRRDTuoQCOqXBJxqBFvSUCI=; b=2YYugYC+Enel0PrgKJcncUJBkqbIDEOuHK7wgiHXmk2CX9K8zQEoed4m95jRTv/VjQj23N JphtDrJcqdJvH+svaQE3grLyf9x0kTdLCKvslKmENk2HcDxnDBsCRPuM2620D6ZvrDhv4f pNFN6Ppu2xTUJqwCpQdnf8XTjt0NPCs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681832; 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=vcCkWnZUOHY/Sf1BWe3lgRRDTuoQCOqXBJxqBFvSUCI=; b=PJoqenbvlmnXp9+Glk6cu66+zfOK29pIMidnd+UiFuBSAPNIlwIIVUfRxv3Y6b7Z2N3w/c BQ8fkgAKvwEwskAQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id BE74C2C142; Tue, 18 Jul 2023 12:03:51 +0000 (UTC) From: Michal Suchanek To: linux-modules@vger.kernel.org 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 v5] depmod: Handle installing modules under a prefix Date: Tue, 18 Jul 2023 14:03:47 +0200 Message-ID: <20230718120348.383-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771760572840547338 X-GMAIL-MSGID: 1771760572840547338 Some distributions aim at shipping all files in /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 path. With kmod that does not provide the config command /lib/modules 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 v4: - Document jq requirement - fix bashism - Update to getting full module path, not just additional prefix v5: switch to pkgconfig --- Makefile | 4 +++- scripts/depmod.sh | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 47690c28456a..1620d224ad9c 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_DIRECTORY := $(shell pkg-config --print-variables kmod 2>/dev/null | grep '^module_directory$$' >/dev/null && pkg-config --variable=module_directory kmod || echo /lib/modules) + +MODLIB = $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) export MODLIB PHONY += prepare0 diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 3643b4f896ed..06961f990fcb 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_DIRECTORY/$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_DIRECTORY/$KERNELRELEASE/modules.dep" -o \ + -e "$tmp_dir$KERNEL_MODULE_DIRECTORY/$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_DIRECTORY/99.98.$KERNELRELEASE" ln -s "$KERNELRELEASE" "$symlink" KERNELRELEASE=99.98.$KERNELRELEASE fi