From patchwork Thu Apr 14 07:38:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: phodina X-Patchwork-Id: 38572 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id AE14127BBE9; Thu, 14 Apr 2022 08:39:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F18BF27BBED for ; Thu, 14 Apr 2022 08:39:18 +0100 (BST) Received: from localhost ([::1]:44100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neu4U-0003RM-3d for patchwork@mira.cbaines.net; Thu, 14 Apr 2022 03:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neu4E-0003Qa-Mw for guix-patches@gnu.org; Thu, 14 Apr 2022 03:39:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:32805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1neu4E-0006qX-EA for guix-patches@gnu.org; Thu, 14 Apr 2022 03:39:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1neu4E-0003cv-AK for guix-patches@gnu.org; Thu, 14 Apr 2022 03:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48314] [PATCH v3] Install guix system on Raspberry Pi References: <19E4796A-B0DB-444F-8773-2E8D3EF6132D@vodafonemail.de> In-Reply-To: <19E4796A-B0DB-444F-8773-2E8D3EF6132D@vodafonemail.de> Resent-From: phodina Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 14 Apr 2022 07:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48314 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "48314@debbugs.gnu.org" <48314@debbugs.gnu.org> Cc: Stefan , Vagrant Cascadian , Ludovic =?utf-8?q?Court=C3=A8s?= , "dannym@scratchpost.org" Received: via spool by 48314-submit@debbugs.gnu.org id=B48314.164992191913859 (code B ref 48314); Thu, 14 Apr 2022 07:39:02 +0000 Received: (at 48314) by debbugs.gnu.org; 14 Apr 2022 07:38:39 +0000 Received: from localhost ([127.0.0.1]:54925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neu3r-0003bT-3k for submit@debbugs.gnu.org; Thu, 14 Apr 2022 03:38:39 -0400 Received: from mail-40131.protonmail.ch ([185.70.40.131]:45775) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neu3p-0003b2-Qo for 48314@debbugs.gnu.org; Thu, 14 Apr 2022 03:38:38 -0400 Date: Thu, 14 Apr 2022 07:38:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1649921907; bh=qvhYsY7XyBJe6gBD2UNvsXfB6eU7kV1bcx2pjv5W+zs=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID; b=a2rLcdLw7DM7DAzFbvyT1EePO+0VhVljtUxWC901T4QJZjNJgYZ47gmXWXAq4rv6O 5FvDRTR7ZMtdxo101+1Hp81AGnhyka0EvGNXgPoXbHKndM3OedqDhPVjypqQpU1tVI U98K60+lLf0lsdKIBMS/Q1tGDOdH5loAOtw+u6tJvz+BQEoXKYnkSVOyagqEuqkV5x ZPhVQOshi/v72fMta25u/zv+BZCN0oFJ/fTUlY7bZG4r+1MnqDG95ivQKXnNvEOziM 7wpdKLZ+eKvIRXu78IllaICt7KV4KW3nTsaWWNYn//jXP7KfmsavYR/857BUlQPJHt Fe+ZazxHZCd4g== Message-ID: <1JV7YdNsB7LB0ij9pMN5ktIsdpU8g98Lpu0yOrl_r6wFvRjqRJ5XqOktugKlia2rSeyNVEwY0b8VJrFJr1TsWgOIo-JW6EmTpj6Bz4dNzxQ=@protonmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: phodina X-ACL-Warn: , phodina via Guix-patches X-Patchwork-Original-From: phodina via Guix-patches via From: phodina X-getmail-retrieved-from-mailbox: Patches Hi, I've rebased the patches to latest master and fixed some conflicts. However, I'm unable to build the system on my Pinebook (aarch64 for native build). ./pre-inst-env guix system build gnu/system/examples/raspberry-pi-64.tmpl substitute: updating substitutes from 'https://ci.guix.gnu.org'...substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0% substitute: updating substitutes from 'https://bordeaux.guix.gnu.osubstitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0% The following derivation will be built: /gnu/store/p50i4lk8ajcgrgz8m11vqifvh4ggin2w-linux-libre-arm64-generic-5.16.19.drv building /gnu/store/p50i4lk8ajcgrgz8m11vqifvh4ggin2w-linux-libre-arm64-generic-5.16.19.drv... ice-9/read.scm:126:4: In procedure read-expr*: /gnu/store/9gxgha6r0ab5g44mnb3rgyjkrhc709rq-linux-libre-arm64-generic-5.16.19-builder:1:3290: Unknown # object: "#<" builder for `/gnu/store/p50i4lk8ajcgrgz8m11vqifvh4ggin2w-linux-libre-arm64-generic-5.16.19.drv' failed with exit code 1 build of /gnu/store/p50i4lk8ajcgrgz8m11vqifvh4ggin2w-linux-libre-arm64-generic-5.16.19.drv failed View build log at '/var/log/guix/drvs/p5/0i4lk8ajcgrgz8m11vqifvh4ggin2w-linux-libre-arm64-generic-5.16.19.drv.gz'.guix system: error: build of `/gnu/store/p50i4lk8ajcgrgz8m11vqifvh4ggin2w-linux-libre-arm64-generic-5.16.19.drv' failed Unfortunately the build log is not helpful uncovering the cause (at least to me). I've also attempted to cross-compile the system (from x86_64) but there is at least one package that can't be build - guile-fibers-1.1.0. I've attached the build log as well. Kind regards, Petr From 1b05398ed9e7adb1fa8822c5d22ebff66bf4f8d8 Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Wed, 13 Apr 2022 21:18:37 +0200 Subject: [PATCH v3 4/8] gnu: linux: New function to modify the configuration of a Linux kernel. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Stefan * gnu/packages/linux.scm (system->linux-srcarch): New function to return the relevent folder name below arch/ in the Linux source code. (make-linux-libre*) ['set-environment]: Splitted this new phase out of and adding it before … ['configure]: … to allow a replacement and reuse from (modify-linux). (modify-linux): New function to make a customized Linux package inherited from another Linux package, which will be build with an own defconfig or configuration changes. (make-defconfig): Function to get a defconfig from an uri. diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index a405837bb1..48c7797095 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -59,7 +59,8 @@ ;;; Copyright © 2021 Josselin Poiret ;;; Copyright © 2021 Olivier Dion ;;; Copyright © 2021 Solene Rapenne -;;; Copyright © 2021 Petr Hodina +;;; Copyright © 2021, 2022 Petr Hodina +;;; Copyright © 2021 Stefan ;;; Copyright © 2022 Artyom V. Poptsov ;;; @@ -179,6 +180,7 @@ (define-module (gnu packages linux) #:use-module (srfi srfi-2) #:use-module (srfi srfi-26) #:use-module (ice-9 match) + #:use-module (ice-9 optargs) #:use-module (ice-9 regex)) (define-public (system->linux-architecture arch) @@ -195,6 +197,21 @@ (define-public (system->linux-architecture arch) ((string-prefix? "riscv" arch) "riscv") (else arch)))) +(define-public (system->linux-srcarch arch) + "Return for a Guix system ARCH name the SRCARCH name, which is set in the +toplevel Makefile of Linux and denotes the architecture specific directory name +below arch/ in its source code. Some few architectures share a common folder. +It resembles the definition of SRCARCH based on ARCH in the Makefile and may +be used to place a defconfig file in the proper path." + (let ((linux-arch (system->linux-architecture arch))) + (match linux-arch + ("i386" "x86") + ("x86_64" "x86") + ("sparc32" "sparc") + ("sparc64" "sparc") + ("sh64" "sh") + (_ linux-arch)))) + (define-public (system->defconfig system) "Some systems (notably powerpc-linux) require a special target for kernel defconfig. Return the appropriate make target if applicable, otherwise return @@ -852,7 +869,7 @@ (define* (make-linux-libre* version gnu-revision source supported-systems (lambda _ (substitute* (find-files "." "^Makefile(\\.include)?$") (("/bin/pwd") "pwd")))) - (replace 'configure + (add-before 'configure 'set-environment (lambda* (#:key inputs target #:allow-other-keys) ;; Avoid introducing timestamps. (setenv "KCONFIG_NOTIMESTAMP" "1") @@ -877,8 +894,10 @@ (define* (make-linux-libre* version gnu-revision source supported-systems (setenv "EXTRAVERSION" #$(and extra-version - (string-append "-" extra-version))) + (string-append "-" extra-version))))) + (replace 'configure + (lambda* (#:key inputs native-inputs #:allow-other-keys) (let ((build (assoc-ref %standard-phases 'build)) (config (assoc-ref inputs "kconfig"))) @@ -1210,6 +1229,111 @@ (define-public linux-libre-with-bpf (inputs (modify-inputs (package-inputs base-linux-libre) (prepend cpio)))))) + +;;; +;;; Linux kernel customization functions. +;;; + +(define*-public (modify-linux #:key name + (linux linux-libre) + source + defconfig + (configs "") + extra-version) + "Make a Linux package NAME as a modification of another LINUX package. + +If NAME is not given, then it defaults to the same name as the LINUX package. + +Unless SOURCE is given the source of LINUX is used. + +A DEFCONFIG file to be used can be given as a package, as a file like object +(file-append, local-file etc.), or as a string with the name of a defconfig file +available in the Linux sources. If DEFCONFIG is not given, then a defconfig +file will be saved from the LINUX package configuration. + +Additional CONFIGS will be used to modify the given or saved defconfig, which +will finally be used to build Linux. + +CONFIGS can be a list of strings, with one configuration per line. The usual +defconfig syntax has to be used, but there is a special extension to ease the +removal of configurations. Comment lines are supported as well. + +Here is an explaining usage example: + + '(;; This string defines the version tail in 'uname -r'. + \"CONFIG_LOCALVERSION=\\\"-handcrafted\\\" + ;; This '# CONFIG_… is not set' syntax has to match exactly! + \"# CONFIG_BOOT_CONFIG is not set\" + \"CONFIG_NFS_SWAP=y\" + ;; This is a multiline configuration: + \"CONFIG_E1000=y +# This is a comment, below follow two special removal extensions: +CONFIG_CMDLINE_EXTEND +CONFIG_CMDLINE_FORCE=\") + +A string of configurations instead of a list of configuration strings is also +possible. + +EXTRA-VERSION can be a string overwriting the EXTRAVERSION setting of the LINUX +package, after being prepended by a hyphen. It will be visible in the output +of 'uname -r' behind the Linux version numbers." + (package + (inherit linux) + (name (or name (package-name linux))) + (source (or source (package-source linux))) + (arguments + (substitute-keyword-arguments + (package-arguments linux) + ((#:imported-modules imported-modules %gnu-build-system-modules) + `((guix build kconfig) ,@imported-modules)) + ((#:modules modules) + `((guix build kconfig) ,@modules)) + ((#:phases phases) + `(modify-phases ,phases + (replace 'configure + (lambda* (#:key inputs #:allow-other-keys #:rest arguments) + (let* ((srcarch + ,(system->linux-srcarch (or (%current-target-system) + (%current-system)))) + (configs (string-append "arch/" srcarch "/configs/")) + (guix_defconfig (string-append configs "guix_defconfig"))) + ,(cond + ((not defconfig) + `(begin + ;; Call the original 'configure phase. + (apply (assoc-ref ,phases 'configure) arguments) + ;; Save a defconfig file. + (invoke "make" "savedefconfig") + ;; Move the saved defconfig to the proper location. + (rename-file "defconfig" + guix_defconfig))) + ((string? defconfig) + ;; Use another existing defconfig from the Linux sources. + `(rename-file (string-append configs ,defconfig) + guix_defconfig)) + (else + ;; Copy the defconfig input to the proper location. + '(copy-file (assoc-ref inputs "guix_defconfig") + guix_defconfig))) + (modify-defconfig guix_defconfig ',configs) + ,@(if extra-version + `((setenv "EXTRAVERSION" + ,(string-append "-" extra-version))) + '()) + (invoke "make" "guix_defconfig")) + #t)))))) + (native-inputs + (append (if (or (not defconfig) + (string? defconfig)) + '() + ;; The defconfig should be a package or file-like object. + `(("guix_defconfig" ,defconfig))) + (package-native-inputs linux))))) + +(define-public (make-defconfig uri sha256-as-base32) + (origin (method url-fetch) + (uri uri) + (sha256 (base32 sha256-as-base32)))) ;;; -- 2.35.1