As the title says, we'll start by loading the sources from a manifest in the Resources instead of them being fully hardcoded. Eventually this will allow moving to loading from a file that can be easily modified by the user and accessible to other winget front-ends that decide to use it.
This sources file can be something like,
source
# Source ID used to differentiate between
# sources. Will be used in place of the "-display-name:"
# field if that one's not available.
id: "winget"
# Specify whether this source should be updated and loaded.
-active-source: "True"
# What's shown in the "refresh cache"
# window. Maybe it would be a good idea to also
# display whether we're updating the database or
# the manifests at the current time. This could
# also be used in a sources manager program.
-display-name: "Microsoft/winget-pkgs"
# URLs that the manifest archive and database
# are downloaded from.
-manifest-archive-url: "https://github.com/Microsoft/winget-pkgs"
-database-url: "(insert database URL here)"
# Can't use the display name to determine the
# cache root directories, so we'll specify them.
# Getting this from the URL automatically
# would be a good idea.
-manifest-archive-cache-dir-root: "winget-pkgs"
-database-cache-dir-root: "winget-db"
# While unlikely, it's possible that other
# databases could have a different filename
# for itself, so this is just in case.
-database-file-name: "Index.db"
# Some repos have all the manifests in the
# root rather than a subfolder, such as the
# mirror repo on GitHub. By default, we'll look
# under the "manifests" subfolder, though.
-manifests-in-root: "False"
-manifest-path-subfolder: "\manifests\"
source
id: "msstore"
# Etc.
Additionally, this will have to have a field to determine whether manifests are discovered based on package ID and version from the database (default for winget-pkgs/winget-db), or whether it has to grab the manifests from the Internet based on a path from the pathparts
table (which would have to be used for the Store source). The Store database has pathparts all in one string, so that should be easy as long as it stays that way. Update: the Store source is now REST-based, rather than using a database.
Edit: The default winget source also has pathparts all in one string now too (actually, I don't think it does, and I was just confused and looking at the wrong thing), so I can just add support for using pathparts manifests from the Internet instead of having to download and extract the full repo all at once. For this to work, I'll have to save each manifest in the cache so that we don't use up the user's bandwidth too much. Not sure about how to get all the manifests with this, though.
Maybe this won't work, as I still need to figure out how to get the parent values to put the paths together properly. For example, this is the manifest for the Yukino package as shown in the top of the ids
table: https://winget.azureedge.net/cache/manifests/z/ZYROUGE/Yukino/1.0.9-beta.0/9f4b-ZYROUGE.Yukino.yaml
Edit again: I think I figured it out. You get the manifest filename from the manifests
table's pathpart
column, then you look at the pathparts
table. Look at the manifest filename row's parent
column value, and go to that rowid
column number. Prepend a forward-slash (/
) before the manifest filename, then put in the value in that row's pathpart
column. Keep looking at the parent
column value and going to that rowid
number and prepending the slash and the pathpart
column's value until you get to the parent
value saying a rowid
value of 1
. Then you'll go to rowid
column value 1
, which is just "manifests", and that's actually the subfolder in the /cache/
directory on Microsoft's server, or the "manifests" folder in the GitHub repo. That row has a parent of NULL
, but I don't currently know how to deal with a null value, but once that's hit, we have the path to that specific manifest and can move on after appending it to the source URL.