Skip to content

repo #

repo

This module manages the contents of the various repositories stored within a Vieter instance.

Terminology

  • Arch-repository (arch-repo): specific architecture of a given repository. This is what Pacman actually uses as a repository, and contains its own .db & .files files.
  • Repository (repo): a collection of arch-repositories. A single repository can contain packages of different architectures, with each package being stored in that specific architecture' arch-repository.
  • Repository group (repo-group): a collection of repositories. Each Vieter instance consists of a single repository group, which manages all underlying repositories & arch-repositories.

Arch-repository layout

An arch-repository (aka a regular Pacman repository) consists of a directory with the following files ({repo} should be replaced with the name of the repository):

  • One or more package directories. These directories follow the naming scheme ${pkgname}-${pkgver}-${pkgrel}. Each of these directories contains two files, desc & files. The desc file is a list of the package's metadata, while files contains a list of all files that the package contains. The latter is used when using pacman -F.
  • {repo}.db & {repo}.db.tar.gz: the database file of the repository. This is just a compressed tarball of all package directories, but only their desc files. Both these files should have the same content (repo-add creates a symlink, but Vieter just serves the same file for both routes)
  • {repo}.files & {repo}.files.tar.gz: the same as the .db file, but this also contains the files files, instead of just the desc files.

Filesystem layout

The repository part of Vieter consists of two directories. One is the repos directory inside the configured data_dir, while the other is the configured pkg_dir. repos contains only the repository group, while pkg_dir contains the actual package archives. pkg_dir is the directory that can take up a significant amount of memory, while repos solely consists of small text files.

fn archive_add_entry #

fn archive_add_entry(archive &C.archive, entry &C.archive_entry, file_path &string, inner_path &string)

archive_add_entry writes a file to an archive, given its path & inner path inside the archive.

fn new #

pub fn new(repos_dir string, pkg_dir string, default_arch string) !RepoGroupManager

new creates a new RepoGroupManager & creates the directories as needed

struct RepoAddResult #

pub struct RepoAddResult {
pub:
	name    string
	version string
	archs   []string
}

struct RepoGroupManager #

pub struct RepoGroupManager {
mut:
	mutex shared util.Dummy
pub:
// Where to store repositories' files
	repos_dir string [required]
// Where packages are stored; each arch-repository gets its own
// subdirectory
	pkg_dir string [required]
// The default architecture to use for a repository. Whenever a package of
// arch "any" is added to a repo, it will also be added to this
// architecture.
	default_arch string [required]
}

Manages a group of repositories. Each repository contains one or more arch-repositories, each of which represent a specific architecture.

fn (RepoGroupManager) add_pkg_from_path #

pub fn (r &RepoGroupManager) add_pkg_from_path(repo string, pkg_path string) !RepoAddResult

add_pkg_from_path adds a package to a given repo, given the file path to the pkg archive. It's a wrapper around add_pkg_in_repo that parses the archive file, passes the result to add_pkg_in_repo, and hard links the archive to the right subdirectories in r.pkg_dir if it was successfully added.

fn (RepoGroupManager) add_pkg_in_arch_repo #

fn (r &RepoGroupManager) add_pkg_in_arch_repo(repo string, arch string, pkg &package.Pkg) !

add_pkg_in_arch_repo is the function that actually adds a package to a given arch-repo. It records the package's data in the arch-repo's desc & files files, and afterwards updates the db & files archives to reflect these changes.

fn (RepoGroupManager) add_pkg_in_repo #

fn (r &RepoGroupManager) add_pkg_in_repo(repo string, pkg &package.Pkg) ![]string

add_pkg_in_repo adds a package to a given repo. This function is responsible for inspecting the package architecture. If said architecture is 'any', the package is added to each arch-repository within the given repo. A package of architecture 'any' is always added to the arch-repo defined by r.default_arch. If this arch-repo doesn't exist yet, it is created. If the architecture isn't 'any', the package is only added to the specific architecture.

fn (RepoGroupManager) remove_arch_repo #

pub fn (r &RepoGroupManager) remove_arch_repo(repo string, arch string) !bool

remove_arch_repo removes an arch-repo & its packages.

fn (RepoGroupManager) remove_pkg_from_arch_repo #

pub fn (r &RepoGroupManager) remove_pkg_from_arch_repo(repo string, arch string, pkg_name string, perform_sync bool) !bool

remove_pkg_from_arch_repo removes a package from an arch-repo's database. It returns false if the package wasn't present in the database. It also optionally re-syncs the repo archives.

fn (RepoGroupManager) remove_repo #

pub fn (r &RepoGroupManager) remove_repo(repo string) !bool

remove_repo removes a repo & its packages.

fn (RepoGroupManager) sync #

fn (r &RepoGroupManager) sync(repo string, arch string) !

sync regenerates the repository archive files.