Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15230 closed bug (fixed)

Unable to add / remove repositories

Reported by: kallisti5 Owned by: leavengood
Priority: critical Milestone: R1/beta2
Component: Kits/Package Kit Version: R1/Development
Keywords: pkgman Cc: ttcoder
Blocked By: Blocking:
Platform: All

Description (last modified by kallisti5)

After https://git.haiku-os.org/haiku/commit/src/kits/package?id=dfbf1c8a0ac59206efcf819b420fbbb5bcf55251, it's not possible to "add repositories" to Haiku.

Error: Failed to open repository file "/boot/system/cache/package-repositories/Haiku": No such file or directory

This is the responsible change:

diff --git a/src/kits/package/RefreshRepositoryRequest.cpp b/src/kits/package/RefreshRepositoryRequest.cpp
index 300c1e481e..da23156f9b 100644
--- a/src/kits/package/RefreshRepositoryRequest.cpp
+++ b/src/kits/package/RefreshRepositoryRequest.cpp
@@ -74,7 +74,11 @@ BRefreshRepositoryRequest::CreateInitialJobs()
 
 	BRepositoryCache repoCache;
 	BPackageRoster roster;
-	roster.GetRepositoryCache(fRepoConfig.Name(), &repoCache);
+	result = roster.GetRepositoryCache(fRepoConfig.Name(), &repoCache);
+	if (result != B_OK) {
+		delete fetchChecksumJob;
+		return result;
+	}
 
 	ValidateChecksumJob* validateChecksumJob
 		= new (std::nothrow) ValidateChecksumJob(fContext,

While the error checks in that commit are correct, it seems the functionality of creating repository caches depends on "erroring out loading the cache file"

The ReaderImpl won't create repositories if they are missing. I had a partial fix adding a WriterImpl if the Cache doesn't exist, but a KDL in the network stack killed my git tree and lost my stash data :-(

Change History (11)

comment:1 by kallisti5, 5 years ago

Until this is fixed, I would recommend *NOT* removing the "Haiku" repository. It creates a situation where you can't get future updates without a lot of manual hacking to the Repo caches.

comment:2 by kallisti5, 5 years ago

Description: modified (diff)

comment:3 by ttcoder, 5 years ago

Cc: ttcoder added

comment:4 by diver, 5 years ago

Milestone: UnscheduledR1/beta2

Repository files do not exist after installation. So installing Haiku from a recent anyboot image won't be able to update or install anything.

comment:5 by leavengood, 5 years ago

Owner: changed from nobody to leavengood
Status: newin-progress

I am pretty confident I see the problem in the code, I'll try to fix it tonight.

comment:6 by leavengood, 5 years ago

Resolution: fixed
Status: in-progressclosed

So I worked on this for a while and tried to fix it properly but it became too much of a rabbit hole. It totally works to just ignore the error as we did before. I at least added a comment explaining it.

Fixed in hrev53356.

When I have time I'll see about fixing it in a better way. But this has worked fine for years, and I have plenty of other things I want to work on.

comment:7 by leavengood, 5 years ago

Also to explain a bit further, BPackageRoster::GetRepositoryCache has a bug because in a new Haiku install ~/config/cache does not exist, so this will always fail with B_NOT_FOUND until that directory is created. GetRepositoryConfig does not fail in this way because it is looking for ~/config/settings which always exists.

Since RefreshRepositoryRequest is always called to update repos, it was always failing due to no ~/config/cache existing. So if that directory is created, updates will start working, but adding new repos still won't because of another bug.

Ignoring this error skirts around both of those bugs. I have a fix for GetRepositoryCache but it is kind of ugly. The other bug is harder which is why I just added back the ignoring of the error.

Version 0, edited 5 years ago by leavengood (next)

comment:8 by kallisti5, 5 years ago

Heh, my sentiments exactly. I found a path calling the Write implementation (instead of just the Read which fails when the cache is missing), but quickly fell into just how 'bare minimum' everything is.

comment:9 by loathe, 5 years ago

Hello! I just installed a nightly image of Haiku and I have this bug also. I've also searched for "RefreshRepositoryRequest.cpp" to make a change to make it work but I only found a header file with the exact name. I'm guessing that file is only needed before building or something like that? May I get help to fix this bug in my system or should I wait for another nightly image that contains this commit?

hrev53356

comment:10 by waddlesplash, 5 years ago

Yes, you need to wait for a nightly image that contains that commit.

comment:11 by leavengood, 5 years ago

Please follow my steps above to work around this bug. To be more clear:

  1. mkdir ~/config/cache/package-repositories
  2. cp /system/cache/package-repositories/* ~/config/cache/package-repositories

That will work around this bug enough for updates to work so you can get my fix.

You can then delete the contents of ~/config/cache/package-repositories but you can leave the directory.

Note: See TracTickets for help on using tickets.