+let debian_list_files_installed pkg =
+ debug "using installed package %s ..." pkg;
+ let cmd = sprintf "dpkg-query --listfiles %s" pkg in
+ let lines = run_command_get_lines cmd in
+ (* filter out lines not directly describing fs objects such as
+ "package diverts others to: /path/to/..." *)
+ let lines = List.filter (
+ fun l -> l.[0] = '/' && l.[1] != '.'
+ ) lines in
+ let files = List.map (
+ fun path ->
+ let statbuf = lstat path in
+ let is_dir = statbuf.st_kind = S_DIR in
+ let config = statbuf.st_kind = S_REG && string_prefix "/etc/" path in
+ let mode = statbuf.st_perm in
+ (path, { ft_dir = is_dir; ft_config = config; ft_mode = mode;
+ ft_ghost = false; ft_size = statbuf.st_size })
+ ) lines in
+ files
+
+let debian_list_files ?(use_installed=false) pkg =
+ if use_installed && List.exists ((=) pkg) installed_pkgs then
+ debian_list_files_installed pkg
+ else
+ debian_list_files_downloaded pkg
+