unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#44130] [PATCH] Add a recursive version of mkdir-p
@ 2020-10-21 23:29 divoplade
  2020-10-23 13:12 ` Ludovic Courtès
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: divoplade @ 2020-10-21 23:29 UTC (permalink / raw)
  To: 44130

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

Dear guix,

I need this mkdir-p function in any non-trivial program I write. I had
3 bad choices:

1. Lobby guile to provide this function out of the box (this will take
time);
2. Copy that of guix, or gash, or any other: this does not seem
acceptable to me, because this function will surely evolve (for
instance, if guile gets suport for mingw and we start running guile
programs on windows) and I don't want to update more than one version
of this function;
3. Depend on guix, gash or another package: this would be too large a
dependency for my programs.

So I wrote it in its own package and I intend to depend on it for my
other projects. It would be best if you could accept this package in
guix proper.

What do you think?

Best regards,

divoplade

[-- Attachment #2: 0001-Add-guile-mkdir-p.patch --]
[-- Type: text/x-patch, Size: 2323 bytes --]

From 1a1798a99b09ef7df0f183d99ea9a4717b9406d7 Mon Sep 17 00:00:00 2001
From: divoplade <d@divoplade.fr>
Date: Thu, 22 Oct 2020 01:14:27 +0200
Subject: [PATCH] Add guile-mkdir-p

As there is no guile function to create directories recursively, a lot of
packages bundle their own. For instance, Guile as Shell or Guix. This also
happens to me, as I need this function in any substantial program.
---
 gnu/packages/guile-xyz.scm | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 88c0586dc9..2504deb3af 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -4007,3 +4007,42 @@ features not found in the standard read procedure such as a compatible mode
 with support for other RnRS standards and a tolerant mode that continues on
 errors.")
     (license license:expat)))
+
+(define-public guile-mkdir-p
+  (package
+    (name "guile-mkdir-p")
+    (version "1.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://code.divoplade.fr/mkdir-p.git")
+             (commit "83e955ba612369336a69fe50fe023ad14fbe5d7c")))
+       (sha256 (base32 "01k20rjcv6p0spmw8ls776aar6bfw0jxw46d2n12w0cb2p79xjv8"))
+       (snippet
+        `(begin
+           (with-output-to-file ".tarball-version"
+             (lambda _ (format #t "~a~%" "1.0.1")))
+           #t))))
+    (build-system gnu-build-system)
+    (arguments `())
+    (native-inputs
+     `(("guile" ,guile-3.0)
+       ("texinfo" ,texinfo)
+       ("autoconf" ,autoconf)
+       ("autoconf-archive" ,autoconf-archive)
+       ("automake" ,automake)
+       ("pkg-config" ,pkg-config)
+       ("gettext" ,gnu-gettext)))
+    (inputs `(("guile" ,guile-3.0)))
+    (propagated-inputs
+     `(("guile" ,guile-3.0)))
+    (synopsis "Implementation of a recursive mkdir for guile")
+    (description
+     "This package provides within the (mkdir-p) module the mkdir-p function
+that tries to create the chain of directories recursively.  It also provides
+new versions of open-output-file, call-with-output-file and
+with-output-to-file to create the directory of its argument if it does not
+exist.")
+    (home-page "https://mkdir-p.divoplade.fr")
+    (license license:asl2.0)))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-21 23:29 [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
@ 2020-10-23 13:12 ` Ludovic Courtès
  2020-10-23 14:14   ` divoplade
  2020-10-23 19:36 ` [bug#44130] " zimoun
  2020-10-23 20:01 ` Leo Prikler
  2 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2020-10-23 13:12 UTC (permalink / raw)
  To: divoplade; +Cc: 44130

Hi!

divoplade <d@divoplade.fr> skribis:

> I need this mkdir-p function in any non-trivial program I write. I had
> 3 bad choices:
>
> 1. Lobby guile to provide this function out of the box (this will take
> time);
> 2. Copy that of guix, or gash, or any other: this does not seem
> acceptable to me, because this function will surely evolve (for
> instance, if guile gets suport for mingw and we start running guile
> programs on windows) and I don't want to update more than one version
> of this function;
> 3. Depend on guix, gash or another package: this would be too large a
> dependency for my programs.
>
> So I wrote it in its own package and I intend to depend on it for my
> other projects. It would be best if you could accept this package in
> guix proper.
>
> What do you think?

I have nothing against adding this package to Guix, but…

Do you realize that the package definition is longer than the ‘mkdir-p’
procedure itself?  :-)

I think npm packages are too fine-grain; I don’t think this is the
approach to follow for Guile.

It’s likely that packages that need ‘mkdir-p’ also need other high-level
file system operations that Gash (say) provides.  In that case, I’d
encourage people to depend on Gash.  If Gash is too big a dependency for
the project, including its own copy of this 24-line procedure is
probably acceptable.

All that said, I do think that Guile itself should eventually include
some of the utilities found in (guix build utils) or Gash.  For
instance, it recently got a new ‘pipeline’ procedure, which comes from
Gash, and I think it’s a great addition.  This is the way to go in the
longer term.

Thoughts?

Ludo’.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-23 13:12 ` Ludovic Courtès
@ 2020-10-23 14:14   ` divoplade
  2020-10-23 16:37     ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: divoplade @ 2020-10-23 14:14 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 44130

Hi,

Le vendredi 23 octobre 2020 à 15:12 +0200, Ludovic Courtès a écrit :
> It’s likely that packages that need ‘mkdir-p’ also need other high-
> level
> file system operations that Gash (say) provides.  In that case, I’d
> encourage people to depend on Gash.  If Gash is too big a dependency
> for
> the project, including its own copy of this 24-line procedure is
> probably acceptable.

This function is needed for nearly all desktop applications. In the
freedesktop.org world of specifications, your application should store
data in different places in the home directory of the user. The
application data, such as your bookmarks, should be stored in
$XDG_DATA_HOME/<app>/, or $HOME/.local/share/<app>/ if XDG_DATA_HOME is
not set. So if that's a fresh system, or you want to have different
folders in your application data, you will need to make sure that an
arbitrary long chain of directories exist before writing your files.
You can't expect a static chain of directories, since you have to rely
on an environment variable. This is one example, but as a general rule,
whenever you want to write to a file, guile will create it if it does
not exist, because the intent is "do whatever it takes to have that
file and let me write to it".

As I explained, copying the function is not a good thing, because it
will need to adapt. If not a package, the solution could take the form
of a gnulib for guile (which makes little sense since the whole guile
is the standard library), or...

> All that said, I do think that Guile itself should eventually include
> some of the utilities found in (guix build utils) or Gash.

I really think that would be the ideal solution. I understand that you
don't want my package (to be fair, I'm not satisfied with one-package-
per-function either), but the need for that particular function exceeds
that of most other from guix build utils or gash.

Look, even guix itself does not care about mkdir! I get 481 instances
of '(mkdir ' in the source, for 1317 instances of '(mkdir-p '. That
should say something about having a mkdir function by default, but not 
mkdir-p. The only functions from guix build utils that have more than
100 calls (detected as '(fun ') are with-directory-excursion (616),
install-file (1018) (half of its job being mkdir-p), copy-recursively
(559), delete-file-recursively (470), find-files (1161), which (1423,
that's more than mkdir-p), modify-phases (4556, that's a lot more but
it's very specific to guix), substitute* (4240, same), wrap-program
(311, same), and invoke (2242). So I think if you want to import one
function from guix build utils into guile, start with mkdir-p!

Best regards,

divoplade





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-23 14:14   ` divoplade
@ 2020-10-23 16:37     ` Ludovic Courtès
  2020-10-23 17:12       ` divoplade
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2020-10-23 16:37 UTC (permalink / raw)
  To: divoplade; +Cc: 44130

Maybe I wasn’t clear enough but I don’t need to be convinced about the
usefulness of ‘mkdir-p’ and friends—I totally agree with you!

What I was questioning is the temptation to make one-function packages
as is common for instance in npm.

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-23 16:37     ` Ludovic Courtès
@ 2020-10-23 17:12       ` divoplade
  2020-10-26 16:57         ` bug#44130: " Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: divoplade @ 2020-10-23 17:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 44130

Le vendredi 23 octobre 2020 à 18:37 +0200, Ludovic Courtès a écrit :
> 
> What I was questioning is the temptation to make one-function
> packages
> as is common for instance in npm.

Ah, so I can summarize. My solutions are:

1. Guile provides mkdir-p: Perfect!
2. I put the function in a package: not great, but acceptable.
3. I depend on gash: not acceptable, there's only mkdir-p that's
interesting, the rest is for advanced system tools.
4. I copy that function around: not acceptable.

So, there's no temptation to make one-function packages.

Should I understand that you question the integration of one-function
packages into guix? If you don't want it in guix, then it's fine, I can
just use it only for myself, I have my own channel. In which case,
please just say so, so we can all move on to more interesting things.

Best regards,

divoplade





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-21 23:29 [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
  2020-10-23 13:12 ` Ludovic Courtès
@ 2020-10-23 19:36 ` zimoun
  2020-10-23 22:00   ` [bug#44130] Recursive mkdir divoplade
  2020-10-23 22:11   ` [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
  2020-10-23 20:01 ` Leo Prikler
  2 siblings, 2 replies; 10+ messages in thread
From: zimoun @ 2020-10-23 19:36 UTC (permalink / raw)
  To: divoplade; +Cc: 44130

salut,

On Thu, 22 Oct 2020 at 01:29, divoplade <d@divoplade.fr> wrote:

> 1. Lobby guile to provide this function out of the box (this will take
> time);

This path seems the one to go.  It will take less time than running
Guile on Windows. ;-)

The only issue is that your code will depend on Guile 3.0.x where x>4.  

Otherwise, why is it not possible to send a patch to Guile?


> 2. Copy that of guix, or gash, or any other: this does not seem
> acceptable to me, because this function will surely evolve (for
> instance, if guile gets suport for mingw and we start running guile
> programs on windows) and I don't want to update more than one version
> of this function;

The ’mkdir-p’ version in (guix build utils) is the same as 2012.  So I
am not convinced that you will need to update it really often.


> 3. Depend on guix, gash or another package: this would be too large a
> dependency for my programs.

Ok.


On Fri, 23 Oct 2020 at 19:12, divoplade <d@divoplade.fr> wrote:

> So, there's no temptation to make one-function packages.

One package making one-function package will call other one-function
packages. :-)


à tantôt,
simon




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-21 23:29 [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
  2020-10-23 13:12 ` Ludovic Courtès
  2020-10-23 19:36 ` [bug#44130] " zimoun
@ 2020-10-23 20:01 ` Leo Prikler
  2 siblings, 0 replies; 10+ messages in thread
From: Leo Prikler @ 2020-10-23 20:01 UTC (permalink / raw)
  To: d; +Cc: 44130

> Le vendredi 23 octobre 2020 à 18:37 +0200, Ludovic Courtès a écrit :
> > 
> > What I was questioning is the temptation to make one-function
> > packages
> > as is common for instance in npm.
> 
> Ah, so I can summarize. My solutions are:
> 
> 1. Guile provides mkdir-p: Perfect!
> 2. I put the function in a package: not great, but acceptable.
> 3. I depend on gash: not acceptable, there's only mkdir-p that's
> interesting, the rest is for advanced system tools.
> 4. I copy that function around: not acceptable.
5. You depend on any other package, that provides mkdir-p among other
utilities big enough to be packaged in Guix: Not acceptable.
6. You depend on any other package, that provides just mkdir-p with
maybe a few other utilities, that make Guix devs question whether this
will become the next npm.
7. You write a module, that evals untrusted code from the internet and
point it towards your implementation of mkdir-p.
8. You find existing implementations of mkdir-p insufficient and roll
yet another mkdir-p.
9. You write an accelerated mkdir-p in native code as a shared library.
10. You combine 7 and 9.
...

For what it's worth, I've been hacking on a slightly more complete set
of filesystem utilities over at [1] for the past few days.  It is not
yet complete to the point that I'd consider its inclusion into Guix
upstream, but you might want to try it out and perhaps contribute if
that fits your niche.

> So, there's no temptation to make one-function packages.
> 
> Should I understand that you question the integration of one-function
> packages into guix? If you don't want it in guix, then it's fine, I
> can
> just use it only for myself, I have my own channel. In which case,
> please just say so, so we can all move on to more interesting things.
In that case, you still recreate npm, just with an additional layer of
indirection.  Obviously Guix developers can not stop you from doing so,
only advise you not to.

Regards, Leo

[1] https://gitlab.com/leoprikler/guile-filesystem






^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#44130] Recursive mkdir
  2020-10-23 19:36 ` [bug#44130] " zimoun
@ 2020-10-23 22:00   ` divoplade
  2020-10-23 22:11   ` [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
  1 sibling, 0 replies; 10+ messages in thread
From: divoplade @ 2020-10-23 22:00 UTC (permalink / raw)
  To: bug-guile; +Cc: zimoun, 44130

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

Dear guile,

I have slightly modified the mkdir function so that it takes a third
argument to try to create the intermediate directories when calling
mkdir, in effect acting as "mkdir -p".

However, I could not make the test suite run the ports test, on which I
added the test for the new behavior. Is it expected? How do I run it?

In the mean time, here is the WIP version of the patch.

Best regards,

divoplade

Le vendredi 23 octobre 2020 à 21:36 +0200, zimoun a écrit :
> salut,
> 
> On Thu, 22 Oct 2020 at 01:29, divoplade <d@divoplade.fr> wrote:
> 
> > 1. Lobby guile to provide this function out of the box (this will
> > take
> > time);
> 
> This path seems the one to go.  It will take less time than running
> Guile on Windows. ;-)
> 
> The only issue is that your code will depend on Guile 3.0.x where
> x>4.  
> 
> Otherwise, why is it not possible to send a patch to Guile?

[-- Attachment #2: 0001-mkdir-Add-an-optional-argument-recursive-to-create-t.patch --]
[-- Type: text/x-patch, Size: 7683 bytes --]

From d69f24617290c4a875ff2356ca229bf1659feafe Mon Sep 17 00:00:00 2001
From: divoplade <d@divoplade.fr>
Date: Fri, 23 Oct 2020 22:44:36 +0200
Subject: [PATCH] mkdir: Add an optional argument, recursive, to create the
 intermediates

2020-10-23 divoplade <d@divoplade.fr>
	* libguile/filesys.c: include eq.h, so we can compare strings.
	* libguile/filesys.c (scm_mkdir): add an optional argument,
	recursive, to create the intermediate directories if they do not
	exist.
	* libguile/filesys.h (scm_mkdir): add the optional argument to
	the prototype.
	* doc/ref/posix.texi (mkdir): document the new optional
	argument.
	* NEWS: say there is a new argument.
	* test-suite/tests/ports.test: add a test suite to check
	recursive mkdir.
---
 NEWS                        |  5 +++++
 doc/ref/posix.texi          |  7 +++++--
 libguile/filesys.c          | 39 ++++++++++++++++++++++++++++++++++--
 libguile/filesys.h          |  2 +-
 test-suite/tests/ports.test | 40 +++++++++++++++++++++++++++++++++++++
 5 files changed, 88 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 694449202..765f3d2a3 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,11 @@ O(1) dispatch time, regardless of the length of the chain.  This
 optimization is also unlocked in many cases for `match' expressions with
 many similar clauses whose first differentiator are constants.
 
+** Additional optional argument in `mkdir' to create the directory recursively
+
+When the third argument to mkdir is true, the intermediate directories
+are created.
+
 * Incompatible changes
 
 ** `copy' read-option removed
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index f34c5222d..db0cdeae0 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -878,12 +878,15 @@ Create a symbolic link named @var{newpath} with the value (i.e., pointing to)
 @var{oldpath}.  The return value is unspecified.
 @end deffn
 
-@deffn {Scheme Procedure} mkdir path [mode]
-@deffnx {C Function} scm_mkdir (path, mode)
+@deffn {Scheme Procedure} mkdir path [mode [recursive]]
+@deffnx {C Function} scm_mkdir (path, mode, recursive)
 Create a new directory named by @var{path}.  If @var{mode} is omitted
 then the permissions of the directory are set to @code{#o777}
 masked with the current umask (@pxref{Processes, @code{umask}}).
 Otherwise they are set to the value specified with @var{mode}.
+If @var{recursive} is true, also try to create the intermediate missing
+directories. If an error happens, the created directories are left in
+place.
 The return value is unspecified.
 @end deffn
 
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 39bfd38cc..a3c26cfe0 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -82,6 +82,7 @@
 #include "async.h"
 #include "boolean.h"
 #include "dynwind.h"
+#include "eq.h"
 #include "fdes-finalizers.h"
 #include "feature.h"
 #include "fports.h"
@@ -1271,12 +1272,15 @@ SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, 0,
 #undef FUNC_NAME
 #endif /* HAVE_GETCWD */
 
-SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
-            (SCM path, SCM mode),
+SCM_DEFINE (scm_mkdir, "mkdir", 1, 2, 0,
+            (SCM path, SCM mode, SCM recursive),
 	    "Create a new directory named by @var{path}.  If @var{mode} is omitted\n"
 	    "then the permissions of the directory are set to @code{#o777}\n"
 	    "masked with the current umask (@pxref{Processes, @code{umask}}).\n"
 	    "Otherwise they are set to the value specified with @var{mode}.\n"
+            "If @var{recursive} is true, also try tocreate the intermediate missing\n"
+            "directories. If an error happens, the created directories are left\n"
+            "in place.\n"
 	    "The return value is unspecified.")
 #define FUNC_NAME s_scm_mkdir
 {
@@ -1285,6 +1289,37 @@ SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
 
   c_mode = SCM_UNBNDP (mode) ? 0777 : scm_to_uint (mode);
 
+  if (scm_is_true (recursive))
+    {
+      /* Record in paths all intermediate directory names up to the
+         root. The root is reached when the dirname of the current
+         directory is equal to the directory. */
+      SCM paths = SCM_EOL;
+      SCM current_name = path;
+      SCM parent_name = scm_dirname (current_name);
+      while (!scm_is_true (scm_equal_p (parent_name, current_name)))
+        {
+          paths = scm_cons (parent_name, paths);
+          current_name = parent_name;
+          parent_name = scm_dirname (current_name);
+        }
+      if (scm_is_true (scm_equal_p (current_name, scm_from_utf8_string ("."))))
+        {
+          /* If the root is '.', then also make the current working
+             directory the same way. */
+          scm_mkdir (scm_getcwd (), mode, recursive);
+        }
+      while (!scm_is_null (paths))
+        {
+          SCM dir = scm_car (paths);
+          /* Ignore the errors. If one mkdir fails, the final
+             STRING_SYSCALL at the end of this function will fail
+             too. */
+          STRING_SYSCALL (dir, c_dir, mkdir (c_dir, c_mode));
+          paths = scm_cdr (paths);
+        }
+    }
+
   STRING_SYSCALL (path, c_path, rv = mkdir (c_path, c_mode));
   if (rv != 0)
     SCM_SYSERROR;
diff --git a/libguile/filesys.h b/libguile/filesys.h
index f870ee434..011cc5d1d 100644
--- a/libguile/filesys.h
+++ b/libguile/filesys.h
@@ -49,7 +49,7 @@ SCM_API SCM scm_stat (SCM object, SCM exception_on_error);
 SCM_API SCM scm_link (SCM oldpath, SCM newpath);
 SCM_API SCM scm_rename (SCM oldname, SCM newname);
 SCM_API SCM scm_delete_file (SCM str);
-SCM_API SCM scm_mkdir (SCM path, SCM mode);
+SCM_API SCM scm_mkdir (SCM path, SCM mode, SCM recursive);
 SCM_API SCM scm_rmdir (SCM path);
 SCM_API SCM scm_directory_stream_p (SCM obj);
 SCM_API SCM scm_opendir (SCM dirname);
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 31fb2b0a8..c2b8b0596 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -2020,6 +2020,46 @@
           (not (string-index (%search-load-path (basename (test-file)))
                              #\\))))))
 
+(with-test-prefix "recursive mkdir"
+
+  (pass-if "Relative recursive mkdir creates the chain of directories"
+    (let ((dir "./nested/relative/subdirectory"))
+      (mkdir dir #o777 dir #t)
+      (let ((ok
+             (catch #t
+               (lambda ()
+                 (with-output-to-file "./nested/relative/subdirectory/file"
+                   (lambda ()
+                     (display "The directories have been created!")
+                     #t)))
+               (lambda (error . args)
+                 #f))))
+        (when ok
+          (delete-file "./nested/relative/subdirectory/file")
+          (rmdir "./nested/relative/subdirectory")
+          (rmdir "./nested/relative")
+          (rmdir "./nested"))
+        ok)))
+
+  (pass-if "Absolute recursive mkdir creates the chain of directories"
+    (let ((dir (string-append %temporary-directory "/nested/absolute/subdirectory")))
+      (mkdir dir #o777 dir #t)
+      (let ((ok
+             (catch #t
+               (lambda ()
+                 (with-output-to-file (string-append dir "/file")
+                   (lambda ()
+                     (display "The directories have been created!")
+                     #t)))
+               (lambda (error . args)
+                 #f))))
+        (when ok
+          (delete-file (string-append dir "/file"))
+          (rmdir (string-append %temporary-directory "/nested/absolute/subdirectory"))
+          (rmdir (string-append %temporary-directory "/nested/absolute"))
+          (rmdir (string-append %temporary-directory "/nested")))
+        ok))))
+
 (delete-file (test-file))
 
 ;;; Local Variables:
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#44130] [PATCH] Add a recursive version of mkdir-p
  2020-10-23 19:36 ` [bug#44130] " zimoun
  2020-10-23 22:00   ` [bug#44130] Recursive mkdir divoplade
@ 2020-10-23 22:11   ` divoplade
  1 sibling, 0 replies; 10+ messages in thread
From: divoplade @ 2020-10-23 22:11 UTC (permalink / raw)
  To: zimoun; +Cc: 44130

Le vendredi 23 octobre 2020 à 21:36 +0200, zimoun a écrit :
> salut,
> 
> On Thu, 22 Oct 2020 at 01:29, divoplade <d@divoplade.fr> wrote:
> 
> > 1. Lobby guile to provide this function out of the box (this will
> > take
> > time);
> 
> This path seems the one to go.  It will take less time than running
> Guile on Windows. ;-)
> 
> The only issue is that your code will depend on Guile 3.0.x where
> x>4.  
> 
> Otherwise, why is it not possible to send a patch to Guile?

The discussion continues here, in order to send the desired patch to
guile: 44186@debbugs.gnu.org





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44130: [PATCH] Add a recursive version of mkdir-p
  2020-10-23 17:12       ` divoplade
@ 2020-10-26 16:57         ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2020-10-26 16:57 UTC (permalink / raw)
  To: divoplade; +Cc: 44130-done

[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]

Hello!

divoplade <d@divoplade.fr> skribis:

> Le vendredi 23 octobre 2020 à 18:37 +0200, Ludovic Courtès a écrit :
>> 
>> What I was questioning is the temptation to make one-function
>> packages
>> as is common for instance in npm.
>
> Ah, so I can summarize. My solutions are:
>
> 1. Guile provides mkdir-p: Perfect!

Yes, we can work towards that goal.

> 2. I put the function in a package: not great, but acceptable.
> 3. I depend on gash: not acceptable, there's only mkdir-p that's
> interesting, the rest is for advanced system tools.
> 4. I copy that function around: not acceptable.

I agree that #4 is suboptimal, but I think you’re overstating it.

> So, there's no temptation to make one-function packages.

Well…  :-)

> Should I understand that you question the integration of one-function
> packages into guix? If you don't want it in guix, then it's fine, I can
> just use it only for myself, I have my own channel. In which case,
> please just say so, so we can all move on to more interesting things.

No no, like I wrote, I’m fine adding the ‘mkdir-p’ package, no problem;
the project currently has no guideline against one-function packages.

Anyway, I’ve applied the patch with the cosmetic changes below.

Thanks!

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2002 bytes --]

diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index e3f547412b..d09e8d9737 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -4016,12 +4016,14 @@ errors.")
        (method git-fetch)
        (uri (git-reference
              (url "https://code.divoplade.fr/mkdir-p.git")
-             (commit "83e955ba612369336a69fe50fe023ad14fbe5d7c")))
-       (sha256 (base32 "01k20rjcv6p0spmw8ls776aar6bfw0jxw46d2n12w0cb2p79xjv8"))
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "01k20rjcv6p0spmw8ls776aar6bfw0jxw46d2n12w0cb2p79xjv8"))
+       (file-name (git-file-name name version))
        (snippet
         `(begin
            (with-output-to-file ".tarball-version"
-             (lambda _ (format #t "~a~%" "1.0.1")))
+             (lambda _ (format #t "~a~%" ,version)))
            #t))))
     (build-system gnu-build-system)
     (arguments `())
@@ -4034,14 +4036,12 @@ errors.")
        ("pkg-config" ,pkg-config)
        ("gettext" ,gnu-gettext)))
     (inputs `(("guile" ,guile-3.0)))
-    (propagated-inputs
-     `(("guile" ,guile-3.0)))
-    (synopsis "Implementation of a recursive mkdir for guile")
+    (synopsis "Implementation of a recursive @code{mkdir} for Guile")
     (description
-     "This package provides within the (mkdir-p) module the mkdir-p function
-that tries to create the chain of directories recursively.  It also provides
-new versions of open-output-file, call-with-output-file and
-with-output-to-file to create the directory of its argument if it does not
-exist.")
+     "This package provides within the @code{(mkdir-p)} module the
+@code{mkdir-p} function that tries to create the chain of directories
+recursively.  It also provides new versions of @code{open-output-file},
+@code{call-with-output-file} and @code{with-output-to-file} to create the
+directory of its argument if it does not exist.")
     (home-page "https://mkdir-p.divoplade.fr")
     (license license:asl2.0)))

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-26 16:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 23:29 [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
2020-10-23 13:12 ` Ludovic Courtès
2020-10-23 14:14   ` divoplade
2020-10-23 16:37     ` Ludovic Courtès
2020-10-23 17:12       ` divoplade
2020-10-26 16:57         ` bug#44130: " Ludovic Courtès
2020-10-23 19:36 ` [bug#44130] " zimoun
2020-10-23 22:00   ` [bug#44130] Recursive mkdir divoplade
2020-10-23 22:11   ` [bug#44130] [PATCH] Add a recursive version of mkdir-p divoplade
2020-10-23 20:01 ` Leo Prikler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).