@@ -42,7 +42,8 @@ usage(bool fail)
4242 " -c, --cachedir <dir> Path to cachedir\n"
4343 " -d, --debug Debug mode shown to stderr\n"
4444 " -h, --help Show usage\n"
45- " -i, --ignore-conf-repos Ignore repositories defined in xbps.d\n"
45+ " -F, --update-files Updates the files-database\n"
46+ " -i, --ignore-conf-repos Ignore repositories defined in xbps.d\n"
4647 " -M, --memory-sync Remote repository data is fetched and stored\n"
4748 " in memory, ignoring on-disk repodata archives\n"
4849 " -p, --property PROP[,...] Show properties for PKGNAME\n"
@@ -64,7 +65,9 @@ usage(bool fail)
6465 " -m, --list-manual-pkgs List packages installed explicitly\n"
6566 " -O, --list-orphans List package orphans\n"
6667 " -o, --ownedby FILE Search for package files by matching STRING or REGEX\n"
67- " -S, --show PKG Show information for PKG [default mode]\n"
68+ " --ownedhash FILE Search for package files by matching hash of FILE\n"
69+ " or treating FILE as hash if not present\n"
70+ " -S, --show PKG Show information for PKG [default mode]\n"
6871 " -s, --search PKG Search for packages by matching PKG, STRING or REGEX\n"
6972 " --cat=FILE PKG Print FILE from PKG binpkg to stdout\n"
7073 " -f, --files PKG Show package files for PKG\n"
@@ -77,13 +80,14 @@ usage(bool fail)
7780int
7881main (int argc , char * * argv )
7982{
80- const char * shortopts = "C:c:df :hHiLlMmOo:p:Rr:s:S:VvX:x:" ;
83+ const char * shortopts = "C:c:dFf :hHiLlMmOo:p:Rr:s:S:VvX:x:" ;
8184 const struct option longopts [] = {
8285 { "config" , required_argument , NULL , 'C' },
8386 { "cachedir" , required_argument , NULL , 'c' },
8487 { "debug" , no_argument , NULL , 'd' },
8588 { "help" , no_argument , NULL , 'h' },
8689 { "ignore-conf-repos" , no_argument , NULL , 'i' },
90+ { "update-files" , no_argument , NULL , 'F' },
8791 { "list-repos" , no_argument , NULL , 'L' },
8892 { "list-pkgs" , no_argument , NULL , 'l' },
8993 { "list-hold-pkgs" , no_argument , NULL , 'H' },
@@ -92,6 +96,7 @@ main(int argc, char **argv)
9296 { "list-manual-pkgs" , no_argument , NULL , 'm' },
9397 { "list-orphans" , no_argument , NULL , 'O' },
9498 { "ownedby" , required_argument , NULL , 'o' },
99+ { "ownedhash" , required_argument , NULL , 4 },
95100 { "property" , required_argument , NULL , 'p' },
96101 { "repository" , optional_argument , NULL , 'R' },
97102 { "rootdir" , required_argument , NULL , 'r' },
@@ -108,17 +113,18 @@ main(int argc, char **argv)
108113 { NULL , 0 , NULL , 0 },
109114 };
110115 struct xbps_handle xh ;
116+ struct xbps_fetch_cb_data xfer ;
111117 const char * pkg , * rootdir , * cachedir , * confdir , * props , * catfile ;
112118 int c , flags , rv ;
113- bool list_pkgs , list_repos , orphans , own , list_repolock ;
119+ bool list_pkgs , list_repos , orphans , own , ownhash , list_repolock ;
114120 bool list_manual , list_hold , show_prop , show_files , show_deps , show_rdeps ;
115- bool show , pkg_search , regex , repo_mode , opmode , fulldeptree ;
121+ bool show , pkg_search , regex , repo_mode , opmode , fulldeptree , update_files ;
116122
117123 rootdir = cachedir = confdir = props = pkg = catfile = NULL ;
118124 flags = rv = c = 0 ;
119- list_pkgs = list_repos = list_hold = orphans = pkg_search = own = false;
125+ list_pkgs = list_repos = list_hold = orphans = pkg_search = own = ownhash = false;
120126 list_manual = list_repolock = show_prop = show_files = false;
121- regex = show = show_deps = show_rdeps = fulldeptree = false;
127+ regex = show = show_deps = show_rdeps = fulldeptree = false, update_files = false ;
122128 repo_mode = opmode = false;
123129
124130 memset (& xh , 0 , sizeof (xh ));
@@ -138,6 +144,9 @@ main(int argc, char **argv)
138144 pkg = optarg ;
139145 show_files = opmode = true;
140146 break ;
147+ case 'F' :
148+ update_files = true;
149+ break ;
141150 case 'H' :
142151 list_hold = opmode = true;
143152 break ;
@@ -213,6 +222,10 @@ main(int argc, char **argv)
213222 case 3 :
214223 list_repolock = opmode = true;
215224 break ;
225+ case 4 :
226+ pkg = optarg ;
227+ ownhash = opmode = true;
228+ break ;
216229 case '?' :
217230 default :
218231 usage (true);
@@ -247,13 +260,18 @@ main(int argc, char **argv)
247260 xbps_strlcpy (xh .confdir , confdir , sizeof (xh .confdir ));
248261
249262 xh .flags = flags ;
263+ xh .fetch_cb = fetch_file_progress_cb ;
264+ xh .fetch_cb_data = & xfer ;
250265
251266 if ((rv = xbps_init (& xh )) != 0 ) {
252267 xbps_error_printf ("Failed to initialize libxbps: %s\n" ,
253268 strerror (rv ));
254269 exit (EXIT_FAILURE );
255270 }
256271
272+ if (update_files )
273+ xbps_rpool_sync_files (& xh );
274+
257275 if (list_repos ) {
258276 /* list repositories */
259277 rv = repo_list (& xh );
@@ -282,6 +300,10 @@ main(int argc, char **argv)
282300 /* ownedby mode */
283301 rv = ownedby (& xh , pkg , repo_mode , regex );
284302
303+ } else if (ownhash ) {
304+ /* ownedby mode */
305+ rv = ownedhash (& xh , pkg , repo_mode , regex );
306+
285307 } else if (pkg_search ) {
286308 /* search mode */
287309 rv = search (& xh , repo_mode , pkg , props , regex );
0 commit comments