|
|
083da8 |
From 2711e86de854290af855e2acfcab8ac7699cc560 Mon Sep 17 00:00:00 2001
|
|
|
083da8 |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
083da8 |
Date: Wed, 29 Jul 2015 13:36:23 +0200
|
|
|
083da8 |
Subject: [PATCH] sysprep: machine_id: simplify implementation
|
|
|
083da8 |
|
|
|
083da8 |
Instead of rm + touch, just truncate the file if existing.
|
|
|
083da8 |
In case there was no file previously, now nothing is created, as most
|
|
|
083da8 |
probably the system was fine even without it.
|
|
|
083da8 |
|
|
|
083da8 |
Also, turn the single path into a list, so more machine-id files can be
|
|
|
083da8 |
handled at once.
|
|
|
083da8 |
|
|
|
083da8 |
(cherry picked from commit bc598ff52af415d8acc923402bd6dcfd462f2e4d)
|
|
|
083da8 |
---
|
|
|
083da8 |
sysprep/sysprep_operation_machine_id.ml | 11 ++++-------
|
|
|
083da8 |
1 file changed, 4 insertions(+), 7 deletions(-)
|
|
|
083da8 |
|
|
|
083da8 |
diff --git a/sysprep/sysprep_operation_machine_id.ml b/sysprep/sysprep_operation_machine_id.ml
|
|
|
083da8 |
index acf8757..1409876 100644
|
|
|
083da8 |
--- a/sysprep/sysprep_operation_machine_id.ml
|
|
|
083da8 |
+++ b/sysprep/sysprep_operation_machine_id.ml
|
|
|
083da8 |
@@ -21,15 +21,12 @@ open Common_gettext.Gettext
|
|
|
083da8 |
|
|
|
083da8 |
module G = Guestfs
|
|
|
083da8 |
|
|
|
083da8 |
-let machine_id_perform ~verbose ~quiet g root side_effects =
|
|
|
083da8 |
+let machine_id_perform ~verbose ~quiet (g : Guestfs.guestfs) root side_effects =
|
|
|
083da8 |
let typ = g#inspect_get_type root in
|
|
|
083da8 |
if typ <> "windows" then (
|
|
|
083da8 |
- let path = "/etc/machine-id" in
|
|
|
083da8 |
- (try g#rm path with G.Error _ -> ());
|
|
|
083da8 |
- (try
|
|
|
083da8 |
- g#touch path;
|
|
|
083da8 |
- side_effects#created_file ()
|
|
|
083da8 |
- with G.Error _ -> ());
|
|
|
083da8 |
+ let paths = [ "/etc/machine-id"; ] in
|
|
|
083da8 |
+ let paths = List.filter g#is_file paths in
|
|
|
083da8 |
+ List.iter g#truncate paths
|
|
|
083da8 |
)
|
|
|
083da8 |
|
|
|
083da8 |
let op = {
|
|
|
083da8 |
--
|
|
|
083da8 |
1.8.3.1
|
|
|
083da8 |
|