Re: [pacman-dev] Database consistency checking
Well, I thought the following method (pseudocode) for (pkg in pkgcache) { pkgdup = alpm_pkg_dup(pkg); clean_requiredby(pkgdup); _alpm_pkg_update_requiredby(pkgdup); good = sort_then_compare_requiredby(pkg, pkgdup); alpm_pkg_free(pkgdup); } ------------- depend checking is similar, just use alpm_checkdeps for a list containing pkgdup only. ------------- Bye, ngaba PS: Sorry for replying your e-mail address earlier.
On Thu, Jul 19, 2007 at 09:28:42PM +0200, Nagy Gabor wrote:
Well, I thought the following method (pseudocode) for (pkg in pkgcache) { pkgdup = alpm_pkg_dup(pkg); clean_requiredby(pkgdup); _alpm_pkg_update_requiredby(pkgdup); good = sort_then_compare_requiredby(pkg, pkgdup); alpm_pkg_free(pkgdup); } ------------- depend checking is similar, just use alpm_checkdeps for a list containing pkgdup only. -------------
Indeed, I think it could be done that way, that would allow reusing the existing code, and so probably the cleanest code for what we want to do. The only thing that is worrying me is that ideally, depend and requiredby checking would be done in the same time. There is no need to do every check twice.
The only thing that is worrying me is that ideally, depend and requiredby checking would be done in the same time. There is no need to do every check twice. You are right, but since this is a rarely used function, IMHO speed is not so important here (in my opinion: this function should be as simple as possible). Bye, ngaba
On Thu, Jul 19, 2007 at 09:28:42PM +0200, Nagy Gabor wrote:
Well, I thought the following method (pseudocode) for (pkg in pkgcache) { pkgdup = alpm_pkg_dup(pkg); clean_requiredby(pkgdup); _alpm_pkg_update_requiredby(pkgdup); good = sort_then_compare_requiredby(pkg, pkgdup); alpm_pkg_free(pkgdup); } ------------- depend checking is similar, just use alpm_checkdeps for a list containing pkgdup only.
I noted this on my TODO list and stopped looking at it, but I just started to look at it again. I see you had to clean the requiredby of the package before calling _alpm_pkg_update_requiredby. That's because _alpm_pkg_update_requiredby only adds to the requiredby list, it doesn't reset it itself. But in my opinion, it should do it. Anyway, I refactored this function in a public alpm_pkg_compute_requiredby(pkg) which returns the list of requiredby. And for checkdeps, I just exported it to alpm_checkdeps, without modification. Compared to my implementation using hash table, it now has the same functionality (detects missing dependencies, missing or extra requiredby), the code is much shorter (189 vs 299 lines), but it's also much more inefficient (1.3s vs 0.3s). Anyway, alpm doesn't contain hash table, so it's not like I have the choice :)
participants (2)
-
Nagy Gabor
-
Xavier