From patchwork Fri Dec 1 20:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: reza X-Patchwork-Id: 57181 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 A97F227BBE2; Fri, 1 Dec 2023 20:22:21 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,PDS_BAD_THREAD_QP_64,SPF_HELO_PASS, URIBL_BLOCKED autolearn=no 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 1608D27BBED for ; Fri, 1 Dec 2023 20:22:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r9A1O-0004W8-6d; Fri, 01 Dec 2023 15:21:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r9A1K-0004UN-Hn for guix-patches@gnu.org; Fri, 01 Dec 2023 15:21:54 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r9A1K-00059x-9R for guix-patches@gnu.org; Fri, 01 Dec 2023 15:21:54 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r9A1T-0000Zr-4e for guix-patches@gnu.org; Fri, 01 Dec 2023 15:22:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#66262] [PATCH v7 3/7] gnu: openfoam-org: Improve internal path handling. Resent-From: reza Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 01 Dec 2023 20:22:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66262 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66262@debbugs.gnu.org <66262@debbugs.gnu.org> Cc: reza Received: via spool by 66262-submit@debbugs.gnu.org id=B66262.17014621142156 (code B ref 66262); Fri, 01 Dec 2023 20:22:03 +0000 Received: (at 66262) by debbugs.gnu.org; 1 Dec 2023 20:21:54 +0000 Received: from localhost ([127.0.0.1]:56144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r9A1J-0000Yg-Kr for submit@debbugs.gnu.org; Fri, 01 Dec 2023 15:21:54 -0500 Received: from a6-238.smtp-out.eu-west-1.amazonses.com ([54.240.6.238]:48785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <0102018c270b27c4-0d31f22d-4f5d-46d5-91a1-03cc727da837-000000@mail.housseini.me>) id 1r9A1H-0000Y7-W6 for 66262@debbugs.gnu.org; Fri, 01 Dec 2023 15:21:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=solmzk3ljecfoypi3q6x2mqs3bucnhjw; d=housseini.me; t=1701462091; h=Subject:From:To:Cc:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Message-Id; bh=m2AT8XjEcCsN4AmP6DQqzR6IdqVJFZiIFxK7MUBQi+s=; b=XunZB2N8SbJfFuxdhJI2wUdwX5zK4I6+Ls3HoGD/T6qJwtVrsTwWdJ35XHET5PDH hDuRtsWCOG2f80aiw/JOrskk2P0OrAVd+ppVCuKV+fUAAeht6bT8qpu9XloXqQX7KZ7 5npyxzka/WGYf45YfA2mYtIBitZt8ZvJCa+NjTvY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=shh3fegwg5fppqsuzphvschd53n6ihuv; d=amazonses.com; t=1701462091; h=Subject:From:To:Cc:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Message-Id:Feedback-ID; bh=m2AT8XjEcCsN4AmP6DQqzR6IdqVJFZiIFxK7MUBQi+s=; b=hlFLHEU0cmhGiGAUlqkaW1fCeM6IgZJxus03mTbXPYUm7uS1xI3tiPBE/luXtBqs /OCTEiFe4IVjrFEAPiR62w2jN/4LckDgTYgm+lS58CQsKVYSOdnyOsKE0O4ZI3zWVU6 tY7YvaBquOqEknaAGQedu421+ukLr5er4ATP9Zp0= Date: Fri, 1 Dec 2023 20:21:31 +0000 Mime-Version: 1.0 In-Reply-To: <5a90ca452eac7f8947a241bf0900ca928acc311f.1701462064.git.reza@housseini.me> References: <5a90ca452eac7f8947a241bf0900ca928acc311f.1701462064.git.reza@housseini.me> X-Mailer: Amazon WorkMail Thread-Index: AQHaJJPzxeoHSzDjRfGKH1PaN4MhNQAAAUom Thread-Topic: [PATCH v7 3/7] gnu: openfoam-org: Improve internal path handling. X-Wm-Sent-Timestamp: 1701462090 X-Original-Mailer: git-send-email 2.41.0 Message-ID: <0102018c270b27c4-0d31f22d-4f5d-46d5-91a1-03cc727da837-000000@eu-west-1.amazonses.com> Feedback-ID: 1.eu-west-1.b24dn6frgCi6dh20skzbuMRr7UL8M6Soir/3ogtEjHQ=:AmazonSES X-SES-Outgoing: 2023.12.01-54.240.6.238 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: , Reply-to: reza X-ACL-Warn: , reza via Guix-patches X-Patchwork-Original-From: reza via Guix-patches via From: reza Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/simulation.scm (openfoam-org): Improve handling of internal path WM_PROJECT_DIR. Change-Id: I43de76fb009f955294686a0b45bf3dc0217e7dc7 --- gnu/packages/simulation.scm | 57 ++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 14 deletions(-) -- 2.41.0 diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm index 73e53fe35f..75eb070f64 100644 --- a/gnu/packages/simulation.scm +++ b/gnu/packages/simulation.scm @@ -197,8 +197,10 @@ (define-public openfoam-org ;; Executable files and shared libraries are located in the 'platforms' ;; subdirectory. #:strip-directories - #~(list "share/OpenFOAM/platforms/linux64GccDPInt32Opt/bin" - "share/OpenFOAM/platforms/linux64GccDPInt32Opt/lib") + #~(list (string-append "OpenFOAM-" #$(package-version this-package) + "/platforms/linux64GccDPInt32Opt/bin") + (string-append "OpenFOAM-" #$(package-version this-package) + "/platforms/linux64GccDPInt32Opt/lib")) #:modules '((ice-9 ftw) @@ -278,7 +280,9 @@ (define-public openfoam-org "/lib,")) "" libraries)) (openfoam-lib (string-append #$output - "/share/OpenFOAM/platforms/linux64GccDPInt32Opt/lib")) + "/share/OpenFOAM-" + #$(package-version this-package) + "/platforms/linux64GccDPInt32Opt/lib")) (ldflags (string-append "-Wl," rpaths @@ -338,19 +342,32 @@ (define-public openfoam-org ;; (with-directory-excursion "tutorials" ;; (invoke "bash" "-c" "source ../etc/bashrc && ./Alltest")) ) #t)) + (add-before 'install 'set-paths + (lambda _ + (let ((install-path (string-append #$output + "/share/OpenFOAM-" + #$(package-version this-package)))) + (substitute* "etc/bashrc" + (("^\\[ \"\\$BASH\".*$") "") + (("^export FOAM_INST_DIR=\\$\\(cd.*$") + (string-append "export FOAM_INST_DIR=" install-path "\n")) + (("^export FOAM_INST_DIR=\\$HOME.*$") ""))) #t)) (replace 'install (lambda _ - (let ((install-dir (string-append #$output - "/share/OpenFOAM"))) - (mkdir-p install-dir) ;create install directory + (let ((install-path (string-append #$output + "/share/OpenFOAM-" + #$(package-version this-package)))) + (mkdir-p install-path) ;create install directory ;; move contents of build directory to install directory - (copy-recursively "." install-dir)))) + (copy-recursively "." install-path)))) (add-after 'install 'add-symbolic-link (lambda _ (let* ((bin (string-append #$output "/bin")) (lib (string-append #$output "/lib")) + (etc (string-append #$output "/etc")) (openfoam (string-append #$output - "/share/OpenFOAM")) + "/share/OpenFOAM-" + #$(package-version this-package))) (build-bin (string-append openfoam "/platforms/linux64GccDPInt32Opt/bin")) (build-lib (string-append openfoam @@ -373,12 +390,24 @@ (define-public openfoam-org (string-append bin "/" file)))) (scandir foam-bin)) ;; add symbolic link for standard 'lib' directory - (symlink build-lib lib)) #t))))) - (native-search-paths - (list (search-path-specification - (variable "WM_PROJECT_DIR") - (separator #f) - (files '("share/OpenFOAM"))))) + (symlink build-lib lib) + ;; add symbolic link for bashrc file + (mkdir-p etc) + (symlink (string-append openfoam "/etc/bashrc") + (string-append etc "/bashrc"))) #t)) + (add-after 'add-symbolic-link 'wrap + (lambda* (#:key python inputs outputs #:allow-other-keys) + (let* ((bin (string-append #$output "/bin")) + (openfoam (string-append #$output + "/share/OpenFOAM-" + #$(package-version this-package)))) + (for-each + (lambda (program) + (unless (member program + '("." "..")) + (wrap-program (string-append bin "/" program) + `("WM_PROJECT_DIR" ":" prefix (,openfoam))))) + (scandir bin)))))))) ;; Note: ;; Tutorial files are installed read-only in /gnu/store. ;; To allow write permissions on files copied from the store a