images

# The DarwinPorts Registry

## About This Chapter

This chapter provides a detailed overview of the new DarwinPorts Registry package and its API. This package is queried by the DarwinPorts tools for information about installed ports for information related to dependencies, port images, and simple user information about what is installed.

The DarwinPorts Registry contains an abstraction layer which allows for alternative storage mechanisms for receipts. This chapter will also provide an overview of this, and how to write a receipt storage module.

## Introduction To The New Registry

The new DarwinPorts Registry solves many problems with the old registry:

- The old registry provided no mechanism for modifying a receipt after installation.

- The old registry kept no global database of all installed files and ports that could be queried by the port system to check for conflicts, or by the user to check which port installed a file.

- The old registry was tied to flat-file receipts, and provided no abstraction of open and close calls to receipt files.

The new registry allows for modification of receipts, to reflect and changes made to installed ports being maintained by DarwinPorts. It also provides global file and dependencies databases that can be queried to check if installed files conflict with each other, and to maintain dependency trees of installed ports. It also provides abstraction over a modular receipt storage layer, allowing for flat-file receipts, as well as receipts stored in a SQLite database.

## API For Accessing The Registry

The DarwinPorts Registry provides a public API in the `registry1.0` Tcl package. Using this API you can access the DarwinPorts Registry using the storage mechanism the DarwinPorts user has chosen for receipt storage.

`registry::new_entry {name version {revision 0} {variants ""}}`

  Begin the creation of a new registry entry for the given port.

  Returns a reference ID to the registry entry created.

`registry::open_entry {name {version 0} {revision 0} {variants ""}}`

  Opens an existing registry entry.

  Returns a reference ID to the registry entry that was opened.

`registry::entry_exists {name version {revision 0} {variants ""}}`

  Checks to see if a port exists in the registry.

  Returns 1 if the entry exists, 0 if not.

`registry::write_entry {ref}`

  Writes the receipt associated with the given reference.

`registry::delete_entry {ref}`

  Deletes the receipt associated with the given reference.

`registry::property_store {ref property value}`

  Store the given value with the property name in the receipt associated with the given reference.

`registry::property_retrieve {ref property}`

  Retrieve the property name from the receipt associated with the given reference.

  Returns the value of the property, if the property exists.

`registry::installed {{name ""} {version ""}}`

  Get all installed ports, optionally all installed ports matching the given name, or the given name and version.

  Returns a list of the installed ports.

`registry::location {portname portversion}`

  Returns the physical location the port is installed in on the disk. This is primarily useful for finding out where a port image is installed.

`registry::open_file_map {args}`

  Opens the file map that contains file-port relationships.

`registry::file_registered {file}`

  Returns the name of the port that owns the given file, if the file is registered as installed, and 0 otherwise.

`registry::port_registered {name}`

  Returns a list of all files associated with the given port if that port is installed, and 0 otherwise.

`registry::register_file {file port}`

  Registeres the given file in the file map as belonging to the given port.

`registry::unregister_file {file}`

  Removes the file from the file map.

`registry::write_file_map {args}`

  Write the changes to the file map.

`registry::open_dep_map {args}`

  Opens the dependency map that contains port dependency relationships.

`registry::fileinfo_for_file {fname}`

  Returns a list for the given file name representing all data currently known about the file. This is a 6-tuple in the form of:

  1. file path
  2. uid
  3. gid
  4. mode
  5. size
  6. md5 checksum
`registry::fileinfo_for_index {flist}`

  Returns a list of information concerning each file in the given file list, if that file exists in the registry. The information if obtained through `registry::fileinfo_for_file`

`registry::list_depends {name}`

  Returns a list of all the ports that given port name depends on.

`registry::list_dependents {name}`

  Returns a list of all the ports that depend on the given port name.

`registry::register_dep {dep type port}`

  Registers the given dependency as the given type of dependency with the given port.

`registry::unregister_dep {dep type port}`

  Unregisters the given dependency of the given type as a dependency of the given port.

`registry::write_dep_map {args}`

  Write changes to the dependency map.