22 August 2019

GSoC 2019: Week 12 updates

Finally, we're at the end! This last week of GSoC includes implementation of parts of the revised Package Manager model, namely the PackageDatabase and some methods for interacting with our Jenkins repository.


As per the revisions proposed last week, I've started implementing the PackageDatabase as one of the core units in this API. Inside $launcherDirectory/packages, there are three important items to note:

  • sources.json:
    This specifies all repositories to sync packages with. Details include its url, type and the names of packages to track.

  • packages.db:
    It's a serialized HashMap of repositories to lists of tracked packages that serves as our primary data store while querying for packages.

  • cache:
    This folder will cache all the downloaded ZIP packages to support faster and offline package installation. Like all good cache storages, this too can be cleared any time to clean up disk space.

For example, my sources.json looks like:

		"url" : "http://jenkins.terasology.org/",
		"type" : "Jenkins",
		"trackedPackages" : [

When we sync the PackageDatabase, it reads all the entries in the sources.json and tries to fetch package details from the repositories and updates a map-based datastore, which could later be serialized down to the packages.db file. Based on the repository type, it makes use of a RepositoryHandler to properly fetch the package details. It makes use of Gson for all the JSON related tasks.

RepositoryHandler and JenkinsHandler

The RepositoryHandler interface specifies one important abstract method and one static factory method:

interface RepositoryHandler {
	List<Package> getPackages(PackageDatabase.Repository source);

	static RepositoryHandler ofType(String type) {
		switch (type) {
			case "Jenkins": return new JenkinsHandler();
			case "Custom":  return new CustomRepositoryHandler();
			default: return null;

The getPackages method should be called to fetch all package information from a given source repository, and the ofType factory method will return the appropriate RepositoryHandler implementation for any type as specified in the sources.json file.

JenkinsHandler is a RepositoryHandler that takes care of fetching package details from our Jenkins server, but can possibly interact with any Jenkins repository following a similar URL pattern. It connects using the Jenkins JSON API with a tree parameter to filter out the right details. The end product is a list of Packages that include all necessary details like its name, version and download link that could be used later.

Be sure to check out this post on my weekly GSoC forum thread.

Tags: GSoC Terasology