From patchwork Mon Jul 17 10:40:58 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: 121205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1036336vqt; Mon, 17 Jul 2023 04:04:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlF/TRc3uXWOYar6LsBPcBjyZD1UtiAIKVGuxOUJvG5XqNzHJY+k1tbGv91yuW/+QA4lfYH8 X-Received: by 2002:a17:907:7602:b0:988:a837:327e with SMTP id jx2-20020a170907760200b00988a837327emr9866036ejc.71.1689591887624; Mon, 17 Jul 2023 04:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591887; cv=none; d=google.com; s=arc-20160816; b=jM/RJXOYiQgvQqNgS1mIyArL7s3XtGq7rQ+KQPpPq8dAstQhklDvNnyJFNiSDEYGT3 sf/Wcdw0Yl+1OFQBL8l/NQF5CAJMN2H4npiGHHPR6RTmRhUaVPTllL6NAkKiz3s0ga4+ gV2Ct4NYndUHcU2MofvpfljdxNzhHL4u1JDK5rrnibkiq1b4zjvL5xtHu/h/7vUbdgp8 hnzCG5E5B7+3udyoebE1p+yWhPHmz1NpZ5bscC80lhnpJXglgKy2cy2HIkLt0Zq6ETyh DpeXT5RLco2f8Bfb+X4wTAr2fmUYOn7lSs1fdSYe7/GoojGkIRKuhl59AIYNGAmvQ5Gx ZmbA== 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=S86dhMRLrCdTR5PKHVfEnd0pvbnS5R7FdSBuvy/YLY0=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=Vs2/FaM6ODiwAdT48wgBOjb2y8dXywvCqNyPYHOD9qLz38tXRS57Wq9tIdAd4LFnl3 p33FLsXtAmkCv4jqpEOCTVxaPeNZvrK7sB5dMHAs3ypheaZcXzlqPt531gyDImHzIxXY ZpE7Z8vrzIvFnz81c2pAIfA/NnyzyrB6nnwk7KXtyRQniIDIMD4argVFOU91TpuXlgN8 vsEndjui43co/rfq4I910Wa8F3svAEG4VqJAHe5OR8Ai1rFFFjd8fAvDDUPo0yPzSEV9 rgL/O4ealNT1nuZEwe2PhqGy+Z+mXwDuSFCWb+KWd7tEWiNHhbBHSaWf0tzdnGkm90tW Riww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=wc64ghXc; dkim=neutral (no key) header.i=@suse.de header.b=5SPYBpKV; 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 l18-20020a170906231200b0099304c10fd0si12665383eja.991.2023.07.17.04.04.23; Mon, 17 Jul 2023 04:04:47 -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=wc64ghXc; dkim=neutral (no key) header.i=@suse.de header.b=5SPYBpKV; 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 S230187AbjGQKle (ORCPT + 99 others); Mon, 17 Jul 2023 06:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbjGQKld (ORCPT ); Mon, 17 Jul 2023 06:41:33 -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 787DA173E; Mon, 17 Jul 2023 03:41:04 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0C0591FDA8; Mon, 17 Jul 2023 10:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689590463; 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=S86dhMRLrCdTR5PKHVfEnd0pvbnS5R7FdSBuvy/YLY0=; b=wc64ghXcNImcIgHyUewvvsxBCNFJdverpvQa3rHIX7eNuIh8m+b3FfVD6h8NVE7wjLMn14 Fh+niHB8T3C+iFN/G0Hx7gyOe1HFTjB3qxMs1Ghy1XTCGcSibWta20a781KRY6HBKbto1g Y1w9t3b8dVUqlXzCBg1J5C+zKcGcDcs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689590463; 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=S86dhMRLrCdTR5PKHVfEnd0pvbnS5R7FdSBuvy/YLY0=; b=5SPYBpKVIArtLLt5PcPA5Ga6AU2PTo9e1JSYDljiPfUNHbOJbLr8XPamD7vPWv0ryT4pZ2 1JWgW8IMinMUKgDQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 8CFD92C143; Mon, 17 Jul 2023 10:41:02 +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 v4] depmod: Handle installing modules under a prefix Date: Mon, 17 Jul 2023 12:40:58 +0200 Message-ID: <20230717104100.6146-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 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: 1771665502970871334 X-GMAIL-MSGID: 1771665502970871334 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 --- Documentation/process/changes.rst | 15 +++++++++++++++ Makefile | 4 +++- scripts/depmod.sh | 8 ++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 5561dae94f85..f96a867ab85f 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -41,6 +41,7 @@ bison 2.0 bison --version pahole 1.16 pahole --version util-linux 2.10o fdformat --version kmod 13 depmod -V +jq any jq --version e2fsprogs 1.41.4 e2fsck -V jfsutils 1.1.3 fsck.jfs -V reiserfsprogs 3.6.3 reiserfsck -V @@ -176,6 +177,15 @@ You will need openssl to build kernels 3.7 and higher if module signing is enabled. You will also need openssl development packages to build kernels 4.3 and higher. + +Kmod +---- + +``depmod`` is needed for building modular kernels. ``jq`` is additionally needed +when support for installing modules outside of the default location +``/lib/modules`` is required. Missing ``jq`` will result in an error message +during build even if the tool is not needed. + Tar --- @@ -463,6 +473,11 @@ Kmod - - +jq +-- + +- + Ksymoops -------- diff --git a/Makefile b/Makefile index 47690c28456a..5eb04baaac58 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 kmod config >/dev/null 2>&1 && kmod config | jq -r .module_directory || 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