mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
sysprep: New operation to remove RPM database files.
See: https://lists.fedoraproject.org/pipermail/devel/2013-June/184389.html
This commit is contained in:
@@ -32,6 +32,7 @@ sysprep/sysprep_operation_pam_data.ml
|
||||
sysprep/sysprep_operation_puppet_data_log.ml
|
||||
sysprep/sysprep_operation_random_seed.ml
|
||||
sysprep/sysprep_operation_rhn_systemid.ml
|
||||
sysprep/sysprep_operation_rpm_db.ml
|
||||
sysprep/sysprep_operation_samba_db_log.ml
|
||||
sysprep/sysprep_operation_script.ml
|
||||
sysprep/sysprep_operation_smolt_uuid.ml
|
||||
|
||||
@@ -55,6 +55,7 @@ operations = \
|
||||
puppet_data_log \
|
||||
random_seed \
|
||||
rhn_systemid \
|
||||
rpm_db \
|
||||
samba_db_log \
|
||||
script \
|
||||
smolt_uuid \
|
||||
|
||||
49
sysprep/sysprep_operation_rpm_db.ml
Normal file
49
sysprep/sysprep_operation_rpm_db.ml
Normal file
@@ -0,0 +1,49 @@
|
||||
(* virt-sysprep
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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 Sysprep_operation
|
||||
open Common_gettext.Gettext
|
||||
|
||||
module StringSet = Set.Make (String)
|
||||
module G = Guestfs
|
||||
|
||||
let rpm_db_perform g root =
|
||||
let pf = g#inspect_get_package_format root in
|
||||
if pf = "rpm" then (
|
||||
let paths = g#glob_expand "/var/lib/rpm/__db.*" in
|
||||
Array.iter (
|
||||
fun filename ->
|
||||
try g#rm filename with G.Error _ -> ()
|
||||
) paths;
|
||||
[]
|
||||
)
|
||||
else []
|
||||
|
||||
let rpm_db_op = {
|
||||
name = "rpm-db";
|
||||
enabled_by_default = true;
|
||||
heading = s_"Remove host-specific RPM database files";
|
||||
pod_description = Some (s_"\
|
||||
Remove host-specific RPM database files and locks. RPM will
|
||||
recreate these files automatically if needed.");
|
||||
extra_args = [];
|
||||
perform_on_filesystems = Some rpm_db_perform;
|
||||
perform_on_devices = None;
|
||||
}
|
||||
|
||||
let () = register_operation rpm_db_op
|
||||
Reference in New Issue
Block a user