sysprep: New operation to remove RPM database files.

See:
https://lists.fedoraproject.org/pipermail/devel/2013-June/184389.html
This commit is contained in:
Richard W.M. Jones
2013-06-24 21:06:58 +01:00
parent a7aa47f4de
commit dd21bec400
3 changed files with 51 additions and 0 deletions

View File

@@ -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

View File

@@ -55,6 +55,7 @@ operations = \
puppet_data_log \
random_seed \
rhn_systemid \
rpm_db \
samba_db_log \
script \
smolt_uuid \

View 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