|
ginnOS
The reference: libc, the libraries and the kernel
|
librat: the repository. More...
#include "internal.h"#include <dirent.h>#include <errno.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <unistd.h>Macros | |
| #define | REPOS_FILE "etc/rat/repos.conf" |
| #define | INDEX_FILE RAT_DB_DIR "/index.conf" |
| #define | SIG_FILE RAT_DB_DIR "/index.conf.sig" |
| #define | SEQUENCE_FILE RAT_DB_DIR "/sequence" |
| #define | CACHE_DIR RAT_DB_DIR "/cache" |
| #define | INDEX_MAX (8u * 1024 * 1024) |
| the largest index and signature that rat downloads | |
| #define | SIGNATURE_MAX 1024u |
Functions | |
| int | rat_index_load (rat_t *rat, rat_index_t *index, rat_error_t *err) |
| read the index that rat_update kept, and check its signature again. | |
| int | rat_update (rat_t *rat, rat_progress_t progress, void *context, rat_update_t *result_out, rat_error_t *err) |
| get the index of the repository (the url for this architecture in <root>/etc/rat/repos.conf) and its signature, check them, and keep them. | |
| int | rat_install_name (rat_t *rat, const char *name, unsigned flags, rat_note_t note, rat_progress_t progress, void *context, rat_error_t *err) |
| install or upgrade a package of the index: download it into the cache, check its size and SHA-256 against the index, then install it as rat_install_file does. | |
| int | rat_upgradable (rat_t *rat, const rat_index_t *index, rat_upgradable_t **items_out, int *count_out, rat_error_t *err) |
| the installed packages that the index has in a newer version, sorted by name. | |
| void | rat_upgradables_free (rat_upgradable_t *items, int count) |
| release an array from rat_upgradable. | |
| int | rat_clean (rat_t *rat, uint64_t *freed_out, rat_error_t *err) |
| remove the downloaded files of the cache. | |
librat: the repository.
update the index, install a package by name, and the download cache.
the repository of this architecture is the url in the section [i686] or [x86_64] of <root>/etc/rat/repos.conf. it has index.conf, index.conf.sig and the package files. rat keeps the last good index in var/lib/rat (index.conf, index.conf.sig) and checks its signature each time it reads it. var/lib/rat/sequence has the largest sequence that rat accepted, so an old index is refused even when the saved index is damaged.
| #define REPOS_FILE "etc/rat/repos.conf" |
| #define INDEX_FILE RAT_DB_DIR "/index.conf" |
| #define SIG_FILE RAT_DB_DIR "/index.conf.sig" |
| #define SEQUENCE_FILE RAT_DB_DIR "/sequence" |
| #define CACHE_DIR RAT_DB_DIR "/cache" |
| #define INDEX_MAX (8u * 1024 * 1024) |
the largest index and signature that rat downloads
| #define SIGNATURE_MAX 1024u |
| int rat_index_load | ( | rat_t * | rat, |
| rat_index_t * | index, | ||
| rat_error_t * | err ) |
read the index that rat_update kept, and check its signature again.
| index | gets the index; free it with rat_index_free. |
| int rat_update | ( | rat_t * | rat, |
| rat_progress_t | progress, | ||
| void * | context, | ||
| rat_update_t * | result_out, | ||
| rat_error_t * | err ) |
get the index of the repository (the url for this architecture in <root>/etc/rat/repos.conf) and its signature, check them, and keep them.
an index with a bad signature, or older than the one rat has, is refused and the old one stays.
| progress | gets the progress of the download (may be NULL). |
| int rat_install_name | ( | rat_t * | rat, |
| const char * | name, | ||
| unsigned | flags, | ||
| rat_note_t | note, | ||
| rat_progress_t | progress, | ||
| void * | context, | ||
| rat_error_t * | err ) |
install or upgrade a package of the index: download it into the cache, check its size and SHA-256 against the index, then install it as rat_install_file does.
the file leaves the cache after the install. a package that has the version of the index is refused before the download.
| flags | RAT_FORCE, RAT_DOWNGRADE, or 0. |
| note | gets the notes of the install (may be NULL). |
| progress | gets the progress of the download (may be NULL). |
| context | goes to note and to progress. |
| int rat_upgradable | ( | rat_t * | rat, |
| const rat_index_t * | index, | ||
| rat_upgradable_t ** | items_out, | ||
| int * | count_out, | ||
| rat_error_t * | err ) |
the installed packages that the index has in a newer version, sorted by name.
a package that is not in the index is not in the list.
| items_out | gets an array to free with rat_upgradables_free; its remote pointers point into the index, so free it first. |
| void rat_upgradables_free | ( | rat_upgradable_t * | items, |
| int | count ) |
release an array from rat_upgradable.
| int rat_clean | ( | rat_t * | rat, |
| uint64_t * | freed_out, | ||
| rat_error_t * | err ) |
remove the downloaded files of the cache.
| freed_out | gets the bytes that were freed. |