[Pkg-libvirt-commits] [libguestfs] 84/156: customize: Use Common_utils.error function instead of failwith.
Hilko Bengen
bengen at moszumanska.debian.org
Sat Aug 30 08:26:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch master
in repository libguestfs.
commit 51197106c7643d0fdd1e036e88343c1fafe3d269
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Tue Jul 8 20:51:22 2014 +0100
customize: Use Common_utils.error function instead of failwith.
This is just code refactoring.
(cherry picked from commit f913ca5ebcaacbd94a31ed8fac935833447cc0a7)
---
customize/customize_run.ml | 6 +++---
customize/firstboot.ml | 17 +++++++----------
customize/firstboot.mli | 7 ++++---
3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index a697100..3777531 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -190,20 +190,20 @@ exec >>%s 2>&1
| `FirstbootCommand cmd ->
incr i;
msg (f_"Installing firstboot command: [%d] %s") !i cmd;
- Firstboot.add_firstboot_script g root !i cmd
+ Firstboot.add_firstboot_script ~prog g root !i cmd
| `FirstbootPackages pkgs ->
incr i;
msg (f_"Installing firstboot packages: [%d] %s") !i
(String.concat " " pkgs);
let cmd = guest_install_command pkgs in
- Firstboot.add_firstboot_script g root !i cmd
+ Firstboot.add_firstboot_script ~prog g root !i cmd
| `FirstbootScript script ->
incr i;
msg (f_"Installing firstboot script: [%d] %s") !i script;
let cmd = read_whole_file script in
- Firstboot.add_firstboot_script g root !i cmd
+ Firstboot.add_firstboot_script ~prog g root !i cmd
| `Hostname hostname ->
msg (f_"Setting the hostname: %s") hostname;
diff --git a/customize/firstboot.ml b/customize/firstboot.ml
index 2116637..3b9929b 100644
--- a/customize/firstboot.ml
+++ b/customize/firstboot.ml
@@ -78,10 +78,7 @@ StandardError=inherit
WantedBy=default.target
" firstboot_dir
-let failed fs =
- ksprintf (fun msg -> failwith (s_"firstboot: failed: " ^ msg)) fs
-
-let rec install_service (g : Guestfs.guestfs) distro =
+let rec install_service ~prog (g : Guestfs.guestfs) distro =
g#mkdir_p firstboot_dir;
g#mkdir_p (sprintf "%s/scripts" firstboot_dir);
g#write (sprintf "%s/firstboot.sh" firstboot_dir) firstboot_sh;
@@ -97,7 +94,7 @@ let rec install_service (g : Guestfs.guestfs) distro =
if g#is_dir "/etc/systemd/system" then
install_systemd_service g;
if g#is_dir "/etc/rc.d" || g#is_dir "/etc/init.d" then
- install_sysvinit_service g distro
+ install_sysvinit_service ~prog g distro
(* Install the systemd firstboot service, if not installed already. *)
and install_systemd_service g =
@@ -106,7 +103,7 @@ and install_systemd_service g =
g#ln_sf (sprintf "%s/firstboot.service" firstboot_dir)
"/etc/systemd/system/default.target.wants"
-and install_sysvinit_service g = function
+and install_sysvinit_service ~prog g = function
| "fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based" ->
install_sysvinit_redhat g
| "opensuse"|"sles"|"suse-based" ->
@@ -114,7 +111,7 @@ and install_sysvinit_service g = function
| "debian"|"ubuntu" ->
install_sysvinit_debian g
| distro ->
- failed "guest type %s is not supported" distro
+ error ~prog (f_"guest type %s is not supported") distro
and install_sysvinit_redhat g =
g#mkdir_p "/etc/rc.d/rc2.d";
@@ -155,12 +152,12 @@ and install_sysvinit_debian g =
g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
"/etc/rc5.d/S99virt-sysprep-firstboot"
-let add_firstboot_script (g : Guestfs.guestfs) root i content =
+let add_firstboot_script ~prog (g : Guestfs.guestfs) root i content =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
| "linux", _ ->
- install_service g distro;
+ install_service ~prog g distro;
let t = Int64.of_float (Unix.time ()) in
let r = string_random8 () in
let filename = sprintf "%s/scripts/%04d-%Ld-%s" firstboot_dir i t r in
@@ -168,4 +165,4 @@ let add_firstboot_script (g : Guestfs.guestfs) root i content =
g#chmod 0o755 filename
| _ ->
- failed "guest type %s/%s is not supported" typ distro
+ error ~prog (f_"guest type %s/%s is not supported") typ distro
diff --git a/customize/firstboot.mli b/customize/firstboot.mli
index b8d9608..2aa8eff 100644
--- a/customize/firstboot.mli
+++ b/customize/firstboot.mli
@@ -16,12 +16,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
-val add_firstboot_script : Guestfs.guestfs -> string -> int -> string -> unit
- (** [add_firstboot_script g root idx content] adds a firstboot
+val add_firstboot_script : prog:string -> Guestfs.guestfs -> string -> int -> string -> unit
+ (** [add_firstboot_script ~prog g root idx content] adds a firstboot
script called [shortname] containing [content].
NB. [content] is the contents of the script, {b not} a filename.
The scripts run in index ([idx]) order.
- You should make sure the filesystem is relabelled after calling this. *)
+ For Linux guests using SELinux you should make sure the
+ filesystem is relabelled after calling this. *)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list