From patchwork Wed Jan 3 22:29:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 10143583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C97A60594 for ; Wed, 3 Jan 2018 22:29:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE0B529240 for ; Wed, 3 Jan 2018 22:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2CAA293C6; Wed, 3 Jan 2018 22:29:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, URIBL_BLACK autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7491A29240 for ; Wed, 3 Jan 2018 22:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751233AbeACW3f (ORCPT ); Wed, 3 Jan 2018 17:29:35 -0500 Received: from mga06.intel.com ([134.134.136.31]:63083 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeACW3e (ORCPT ); Wed, 3 Jan 2018 17:29:34 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 14:29:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,504,1508828400"; d="scan'208";a="192170648" Received: from ldmartin-desk.jf.intel.com ([10.24.10.79]) by fmsmga006.fm.intel.com with ESMTP; 03 Jan 2018 14:29:33 -0800 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: Yauheni Kaliuta Subject: [PATCH 3/6] testsuite: generalize mkosi support for other distros Date: Wed, 3 Jan 2018 14:29:21 -0800 Message-Id: <20180103222924.26347-4-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180103222924.26347-1-lucas.demarchi@intel.com> References: <20180103222924.26347-1-lucas.demarchi@intel.com> Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Instead of using the mkosi.default symlink, use an env var passed from the build system. We would need to pass the --default switch nonetheless or change the symlink, making the git tree dirty. Also, search for installed kernel headers in a way that's compatible with more distros. On Fedora, for example, the /usr/lib/modules//build symlink is only available if there's a kernel installed. We don't care about a kernel installed since we don't need to boot it on a real machine: the only thing we need is the kernel-devel package. --- Makefile.am | 4 +++- testsuite/mkosi/.gitignore | 3 +-- testsuite/mkosi/mkosi.arch | 3 +++ testsuite/mkosi/mkosi.build | 29 ++++++++++++++++++++++------- testsuite/mkosi/mkosi.default | 1 - 5 files changed, 29 insertions(+), 11 deletions(-) delete mode 120000 testsuite/mkosi/mkosi.default diff --git a/Makefile.am b/Makefile.am index 3ea4274..7b01201 100644 --- a/Makefile.am +++ b/Makefile.am @@ -503,6 +503,8 @@ tar-sync: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign # mkosi # ------------------------------------------------------------------------------ +DISTRO ?= "arch" + mkosi: -$(MKDIR_P) $(top_srcdir)/testsuite/mkosi/mkosi.cache - $(MKOSI) -C $(top_srcdir)/testsuite/mkosi --build-sources ../../ -fi + $(MKOSI) -C $(top_srcdir)/testsuite/mkosi --build-sources ../../ --default mkosi.${DISTRO} -fi diff --git a/testsuite/mkosi/.gitignore b/testsuite/mkosi/.gitignore index 024d05b..0e0981a 100644 --- a/testsuite/mkosi/.gitignore +++ b/testsuite/mkosi/.gitignore @@ -1,4 +1,3 @@ -/image.raw* +/*-image.raw* /.mkosi-* /mkosi.cache -/rootfs diff --git a/testsuite/mkosi/mkosi.arch b/testsuite/mkosi/mkosi.arch index 308dcdb..5ac0a45 100644 --- a/testsuite/mkosi/mkosi.arch +++ b/testsuite/mkosi/mkosi.arch @@ -2,6 +2,9 @@ Distribution=arch Release=(rolling) +[Output] +Output = arch-image.raw + [Packages] Packages = valgrind BuildPackages = diff --git a/testsuite/mkosi/mkosi.build b/testsuite/mkosi/mkosi.build index a6b325f..53fc797 100755 --- a/testsuite/mkosi/mkosi.build +++ b/testsuite/mkosi/mkosi.build @@ -1,5 +1,26 @@ #!/bin/bash -ex +function find_kdir() { + local kdirs=(/usr/lib/modules/*/build/Makefile /usr/src/kernels/*/Makefile) + local kdir="" + + for f in "${kdirs[@]}"; do + if [ -f "$f" ]; then + kdir=$f + break + fi + done + + if [ -z "$kdir" ]; then + printf '==> Unable to find kernel headers to build modules for tests\n' >&2 + exit 1 + fi + + kdir=${kdir%/Makefile} + + echo $kdir +} + if [ -f configure ]; then make distclean fi @@ -8,13 +29,7 @@ rm -rf build mkdir build cd build -kdirs=(/usr/lib/modules/*/build/Makefile) -if [[ ! -f ${kdirs[0]} ]]; then - printf '==> Unable to find kernel headers to build modules for tests\n' >&2 - return 1 -fi - -kdir=${kdirs[0]%/Makefile} +kdir=$(find_kdir) IFS=/ read _ _ _ kver _ <<<"$kdir" ../autogen.sh c diff --git a/testsuite/mkosi/mkosi.default b/testsuite/mkosi/mkosi.default deleted file mode 120000 index 695b71a..0000000 --- a/testsuite/mkosi/mkosi.default +++ /dev/null @@ -1 +0,0 @@ -mkosi.arch \ No newline at end of file