From patchwork Sat Oct 30 10:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34158 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 EFBC927BBE3; Sat, 30 Oct 2021 11:44:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BDAA427BBE1 for ; Sat, 30 Oct 2021 11:44:08 +0100 (BST) Received: from localhost ([::1]:53144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mglqJ-00025c-Ua for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 06:44:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mglqE-00025U-JH for guix-patches@gnu.org; Sat, 30 Oct 2021 06:44:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mglqE-00023Q-Ay for guix-patches@gnu.org; Sat, 30 Oct 2021 06:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mglqE-0002dd-9E for guix-patches@gnu.org; Sat, 30 Oct 2021 06:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50873] [PATCH v3 8/8] guix home: import: Call =?utf-8?b?4oCY?= =?utf-8?b?bG9jYWwtZmlsZeKAmQ==?= with =?utf-8?b?4oCYbmFtZeKAmQ==?= Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 10:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50873 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50873@debbugs.gnu.org, Oleg Pykhalov , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 50873-submit@debbugs.gnu.org id=B50873.163559061210088 (code B ref 50873); Sat, 30 Oct 2021 10:44:02 +0000 Received: (at 50873) by debbugs.gnu.org; 30 Oct 2021 10:43:32 +0000 Received: from localhost ([127.0.0.1]:56739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglpk-0002ce-4d for submit@debbugs.gnu.org; Sat, 30 Oct 2021 06:43:32 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:59378 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mglp4-0002a4-4g for 50873@debbugs.gnu.org; Sat, 30 Oct 2021 06:42:50 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635590564; bh=UfY9+sc2B8doB9Z7PPiKrSE05DUz+hLQryKoFe2kmWc=; h=From:To:Subject:In-Reply-To:References:Date; b=lipI8QytGuzGQ5MvkifBXAi9tSO6TbR2UQETHykOfPV9AZoKCxBCgfdfoRgA42r7Y 6Pado9K6ZvIrc8fCf16na9btlmm/7KX5ABXviJpcbPf+t+rpqCOl3vXkrUluQh6pr/ RV09E/LYxN1qxGswFvvja0hv3ulR5naVVVxrWj60= In-Reply-To: References: Message-Id: <19dd061d4f7a3aab24ecb660df01e3c6613d4ae7.1635590221.git.public@yoctocell.xyz> Date: Sat, 30 Oct 2021 12:42:44 +0200 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" X-getmail-retrieved-from-mailbox: Patches Set the name of the file to just the basename of the file passed to ‘local-file’. * guix/scripts/home/import.scm (basename+remove-dots): New procedure. (generate-bash-configuration+modules): Use it. * tests/home-import.scm (match-home-environment-bash-service): Adjust accordingly. --- guix/scripts/home/import.scm | 20 ++++++++++++++++---- tests/home-import.scm | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 6e3ed065d5..a0022458f6 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm @@ -39,7 +39,16 @@ (define-module (guix scripts home import) ;;; ;;; Code: - +(define (basename+remove-dots file-name) + "Remove the dot from the dotfile FILE-NAME; replace the other dots in +FILE-NAME with \"-\", and return the basename of it." + (string-map (match-lambda + (#\. #\-) + (c c)) + (let ((base (basename file-name))) + (if (string-prefix? "." base) + (string-drop base 1) + base)))) (define (generate-bash-configuration+modules destination-directory) (define (destination-append path) @@ -52,15 +61,18 @@ (define (destination-append path) (home-bash-configuration ,@(if (file-exists? rc) `((bashrc - (list (local-file ,rc)))) + (list (local-file ,rc + ,(basename+remove-dots rc))))) '()) ,@(if (file-exists? profile) `((bash-profile - (list (local-file ,profile)))) + (list (local-file ,profile + ,(basename+remove-dots profile))))) '()) ,@(if (file-exists? logout) `((bash-logout - (list (local-file ,logout)))) + (list (local-file ,logout + ,(basename+remove-dots logout))))) '()))) (guix gexp) (gnu home services shells)))) diff --git a/tests/home-import.scm b/tests/home-import.scm index a4e71fa698..d2f5728e3c 100644 --- a/tests/home-import.scm +++ b/tests/home-import.scm @@ -156,7 +156,8 @@ (define-home-environment-matcher match-home-environment-bash-service 'home-bash-service-type ('home-bash-configuration ('bashrc - ('list ('local-file "/tmp/guix-config/.bashrc")))))))))) + ('list ('local-file "/tmp/guix-config/.bashrc" + "bashrc")))))))))) (test-assert "manifest->code: No services" (eval-test-with-home-environment