Accepting request 330886 from home:cbosdonnat:branches:Virtualization

- Create the .cache folder if it doesn't exist already.
  bsc#939097.

OBS-URL: https://build.opensuse.org/request/show/330886
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=347
This commit is contained in:
Olaf Hering 2015-09-14 12:43:07 +00:00 committed by Git OBS Bridge
parent 7a9cb2da14
commit 8e5ba8d20f
2 changed files with 49 additions and 0 deletions

View File

@ -154,3 +154,46 @@ Index: libguestfs-1.26.10/customize/password.ml
| _, _ ->
warning ~prog (f_"password: using insecure md5 password encryption for
guest of type %s version %d.\nIf this is incorrect, use --password-crypto option and file a bug.") distro major;
Index: libguestfs-1.26.10/builder/builder.ml
===================================================================
--- libguestfs-1.26.10.orig/builder/builder.ml
+++ libguestfs-1.26.10/builder/builder.ml
@@ -159,7 +159,7 @@ let main () =
(* Try to make the directory. If that fails, warn and continue
* without any cache.
*)
- try mkdir dir 0o755; Some dir
+ try mkdir_p dir 0o755; Some dir
with exn ->
warning ~prog (f_"cache %s: %s") dir (Printexc.to_string exn);
warning ~prog (f_"disabling the cache");
Index: libguestfs-1.26.10/mllib/common_utils.ml
===================================================================
--- libguestfs-1.26.10.orig/mllib/common_utils.ml
+++ libguestfs-1.26.10/mllib/common_utils.ml
@@ -508,3 +508,14 @@ let is_char_device file =
let is_directory path =
try Sys.is_directory path
with Sys_error _ -> false
+
+let rec mkdir_p path permissions =
+ try Unix.mkdir path permissions
+ with
+ | Unix.Unix_error (Unix.EEXIST, _, _) -> ()
+ | Unix.Unix_error (Unix.ENOENT, _, _) ->
+ (* A component in the path does not exist, so first try
+ * creating the parent directory, and then again the requested
+ * directory. *)
+ mkdir_p (Filename.dirname path) permissions;
+ Unix.mkdir path permissions
Index: libguestfs-1.26.10/mllib/common_utils.mli
===================================================================
--- libguestfs-1.26.10.orig/mllib/common_utils.mli
+++ libguestfs-1.26.10/mllib/common_utils.mli
@@ -117,3 +117,6 @@ val is_block_device : string -> bool
val is_char_device : string -> bool
val is_directory : string -> bool
(** These don't throw exceptions, unlike the [Sys] functions. *)
+
+val mkdir_p : string -> int -> unit
+(** Creates a directory, and its parents if missing. *)

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Sep 14 11:27:19 UTC 2015 - cbosdonnat@suse.com
- Create the .cache folder if it doesn't exist already.
bsc#939097.
-------------------------------------------------------------------
Wed Sep 9 12:50:11 UTC 2015 - cbosdonnat@suse.com