GNU bug report logs - #57031
[PATCH] scripts: Show a hint the first time some commands are run as root.

Previous Next

Package: guix-patches;

Reported by: "(" <paren <at> disroot.org>

Date: Sun, 7 Aug 2022 11:15:02 UTC

Severity: normal

Tags: patch

Full log


Message #20 received at 57031 <at> debbugs.gnu.org (full text, mbox):

From: "(" <paren <at> disroot.org>
To: 57031 <at> debbugs.gnu.org
Cc: "\(" <paren <at> disroot.org>
Subject: [PATCH v2 1/2] ui: Make one-time hint API public.
Date: Sun, 11 Sep 2022 20:59:40 +0100
* guix/scripts/shell.scm (hint-directory, hint-file, record-hint,
  hint-given?): Move these...
* guix/ui.scm (hint-directory, hint-file, record-hint, hint-given?):
  ...here.
---
 guix/scripts/shell.scm | 23 -----------------------
 guix/ui.scm            | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm
index c115a00320..3ac7d80eb0 100644
--- a/guix/scripts/shell.scm
+++ b/guix/scripts/shell.scm
@@ -489,29 +489,6 @@ (define (validated-spec spec)
       (exp
        (pretty-print exp port)))))
 
-
-;;;
-;;; One-time hints.
-;;;
-
-(define (hint-directory)
-  "Return the directory name where previously given hints are recorded."
-  (string-append (cache-directory #:ensure? #f) "/hints"))
-
-(define (hint-file hint)
-  "Return the name of the file that marks HINT as already printed."
-  (string-append (hint-directory) "/" (symbol->string hint)))
-
-(define (record-hint hint)
-  "Mark HINT as already given."
-  (let ((file (hint-file hint)))
-    (mkdir-p (dirname file))
-    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
-
-(define (hint-given? hint)
-  "Return true if HINT was already given."
-  (file-exists? (hint-file hint)))
-
 
 (define-command (guix-shell . args)
   (category development)
diff --git a/guix/ui.scm b/guix/ui.scm
index dad2b853ac..3512c761d2 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs <at> stevesprang.com>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi <at> taiju.info>
 ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
+;;; Copyright © 2022 ( <paren <at> disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -137,6 +138,11 @@ (define-module (guix ui)
             switch-to-generation*
             delete-generation*
 
+            hint-directory
+            hint-file
+            record-hint
+            hint-given?
+
             %default-message-language
             current-message-language
 
@@ -2057,6 +2063,29 @@ (define* (package-specification->name+version+output spec
                  (package-name->name+version name)))
     (values name version sub-drv)))
 
+
+;;;
+;;; One-time hints.
+;;;
+
+(define (hint-directory)
+  "Return the directory name where previously given hints are recorded."
+  (string-append (cache-directory #:ensure? #f) "/hints"))
+
+(define (hint-file hint)
+  "Return the name of the file that marks HINT as already printed."
+  (string-append (hint-directory) "/" (symbol->string hint)))
+
+(define (record-hint hint)
+  "Mark HINT as already given."
+  (let ((file (hint-file hint)))
+    (mkdir-p (dirname file))
+    (close-fdes (open-fdes file (logior O_CREAT O_WRONLY)))))
+
+(define (hint-given? hint)
+  "Return true if HINT was already given."
+  (file-exists? (hint-file hint)))
+
 
 ;;;
 ;;; Command-line option processing.
-- 
2.37.3





This bug report was last modified 2 years and 236 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.