Wanlong Gao
2013-Oct-22 08:17 UTC
[Libguestfs] [PATCH] sysprep: add feature of removing specified paths
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- po/POTFILES-ml | 1 + sysprep/Makefile.am | 1 + sysprep/sysprep_operation_remove_path.ml | 53 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 sysprep/sysprep_operation_remove_path.ml diff --git a/po/POTFILES-ml b/po/POTFILES-ml index 509e786..0e25e95 100644 --- a/po/POTFILES-ml +++ b/po/POTFILES-ml @@ -50,6 +50,7 @@ sysprep/sysprep_operation_pam_data.ml sysprep/sysprep_operation_password.ml sysprep/sysprep_operation_puppet_data_log.ml sysprep/sysprep_operation_random_seed.ml +sysprep/sysprep_operation_remove_path.ml sysprep/sysprep_operation_rhn_systemid.ml sysprep/sysprep_operation_rpm_db.ml sysprep/sysprep_operation_samba_db_log.ml diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index c5be5ba..cb95cea 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -57,6 +57,7 @@ operations = \ password \ puppet_data_log \ random_seed \ + remove_path \ rhn_systemid \ rpm_db \ samba_db_log \ diff --git a/sysprep/sysprep_operation_remove_path.ml b/sysprep/sysprep_operation_remove_path.ml new file mode 100644 index 0000000..d307373 --- /dev/null +++ b/sysprep/sysprep_operation_remove_path.ml @@ -0,0 +1,53 @@ +(* virt-sysprep + * Copyright (C) 2013 Fujitsu Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +open Common_utils +open Sysprep_operation +open Common_gettext.Gettext + +module G = Guestfs + +let paths= ref [] +let add_paths path= paths := path :: !paths + +let path_perform g root + let paths = List.rev !paths in + if paths <> [] then ( + List.iter (fun glob -> Array.iter g#rm_rf (g#glob_expand glob)) paths + ); + [] + +let op = { + defaults with + name = "remove-path"; + enabled_by_default = true; + heading = s_"Remove specified paths"; + pod_description = Some (s_"\ +Remove specified files or directories. + +Use the I<--remove-path> option to specify a path to remove."); + extra_args = [ + ("--remove-path", Arg.String add_paths, s_"path" ^ " " ^ s_"Files or directories to be removed on guest"), + s_"\ +Remove the specified path C<file> on guest."; + ]; + + perform_on_filesystems = Some path_perform; +} + +let () = register_operation op -- 1.8.4.474.g128a96c
Richard W.M. Jones
2013-Oct-22 09:34 UTC
Re: [Libguestfs] [PATCH] sysprep: add feature of removing specified paths
Preliminary ACK. I won't be able to apply this until next week because we're all at LinuxCon/KVM Forum this week. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Wanlong Gao
2013-Oct-22 10:11 UTC
Re: [Libguestfs] [PATCH] sysprep: add feature of removing specified paths
On 10/22/2013 05:34 PM, Richard W.M. Jones wrote:> > Preliminary ACK. I won't be able to apply this until next week > because we're all at LinuxCon/KVM Forum this week.Yeah, got it. ;) Thanks, Wanlong Gao> > Rich. >
Richard W.M. Jones
2013-Oct-29 12:57 UTC
Re: [Libguestfs] [PATCH] sysprep: add feature of removing specified paths
What do you think about this instead? It uses the --delete option which is compatible with virt-builder. It doesn't allow globs (whereas your version did). Not sure if you intended to allow globs. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Wanlong Gao
2013-Oct-30 01:43 UTC
Re: [Libguestfs] [PATCH] sysprep: add feature of removing specified paths
On 10/29/2013 08:57 PM, Richard W.M. Jones wrote:> What do you think about this instead? > > It uses the --delete option which is compatible with virt-builder. > > It doesn't allow globs (whereas your version did). Not sure if you > intended to allow globs.I think we'd better allow globs, but anyway we can add that when it is really needed in future. ;) Thanks, Wanlong Gao> > Rich.
Maybe Matching Threads
- [PATCH] sysprep: allow to specify globbing for --delete
- Re: [PATCH] sysprep: allow to specify globbing for --delete
- [PATCH] sysprep: mention globbing in help for --delete
- [PATCH] sysprep: mention globbing in help for --delete
- [PATCH 1/2] sysprep: Update comments.