libalpm
Arch Linux Package Manager Library
sync.c File Reference
#include <sys/types.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <limits.h>
#include "sync.h"
#include "alpm_list.h"
#include "log.h"
#include "package.h"
#include "db.h"
#include "deps.h"
#include "conflict.h"
#include "trans.h"
#include "add.h"
#include "util.h"
#include "handle.h"
#include "alpm.h"
#include "dload.h"
#include "remove.h"
#include "diskspace.h"
#include "signing.h"
Include dependency graph for sync.c:

Data Structures

struct  keyinfo_t
 

Macros

#define CHECK_FIELD(STR, FIELD, CMP)
 

Functions

alpm_pkg_t * alpm_sync_get_new_version (alpm_pkg_t *pkg, alpm_list_t *dbs_sync)
 Check for new version of pkg in syncdbs.
 
static int check_literal (alpm_handle_t *handle, alpm_pkg_t *lpkg, alpm_pkg_t *spkg, int enable_downgrade)
 
static alpm_list_tcheck_replacers (alpm_handle_t *handle, alpm_pkg_t *lpkg, alpm_db_t *sdb)
 
int alpm_sync_sysupgrade (alpm_handle_t *handle, int enable_downgrade)
 Search for packages to upgrade and add them to the transaction.
 
alpm_list_talpm_find_group_pkgs (alpm_list_t *dbs, const char *name)
 Find group members across a list of databases.
 
static int compute_download_size (alpm_pkg_t *newpkg)
 Compute the size of the files that will be downloaded to install a package.
 
off_t alpm_pkg_download_size (alpm_pkg_t *newpkg)
 Returns the size of the files that will be downloaded to install a package.
 
static int prompt_to_delete (alpm_handle_t *handle, const char *filepath, alpm_errno_t reason)
 Prompts to delete the file now that we know it is invalid.
 
static int find_dl_candidates (alpm_handle_t *handle, alpm_list_t **files)
 
static int download_files (alpm_handle_t *handle)
 
static int key_cmp (const void *k1, const void *k2)
 
static int check_keyring (alpm_handle_t *handle)
 
static int check_validity (alpm_handle_t *handle, size_t total, uint64_t total_bytes)
 
static int dep_not_equal (const alpm_depend_t *left, const alpm_depend_t *right)
 
static int check_pkg_field_matches_db (alpm_handle_t *handle, const char *field, alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp cmp)
 
static int check_pkg_matches_db (alpm_pkg_t *spkg, alpm_pkg_t *pkgfile)
 
static int load_packages (alpm_handle_t *handle, alpm_list_t **data, size_t total, size_t total_bytes)
 

Data Structure Documentation

◆ keyinfo_t

struct keyinfo_t
Data Fields
char * keyid
char * uid

Macro Definition Documentation

◆ CHECK_FIELD

#define CHECK_FIELD ( STR,
FIELD,
CMP )
Value:
do { \
int ok = check_pkg_field_matches_db(handle, STR, spkg->FIELD, pkgfile->FIELD, (alpm_list_fn_cmp)CMP); \
if(ok == -1) { \
return 1; \
} else if(ok != 0) { \
error = 1; \
} \
} while(0)
int(* alpm_list_fn_cmp)(const void *, const void *)
item comparison callback
Definition alpm_list.h:69
#define error(...)
static int check_pkg_field_matches_db(alpm_handle_t *handle, const char *field, alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp cmp)
Definition sync.c:1097

Referenced by check_pkg_matches_db().

Function Documentation

◆ check_keyring()

◆ check_literal()

static int check_literal ( alpm_handle_t * handle,
alpm_pkg_t * lpkg,
alpm_pkg_t * spkg,
int enable_downgrade )
static

◆ check_pkg_field_matches_db()

static int check_pkg_field_matches_db ( alpm_handle_t * handle,
const char * field,
alpm_list_t * left,
alpm_list_t * right,
alpm_list_fn_cmp cmp )
static

◆ check_pkg_matches_db()

static int check_pkg_matches_db ( alpm_pkg_t * spkg,
alpm_pkg_t * pkgfile )
static

References ALPM_LOG_DEBUG, CHECK_FIELD, dep_not_equal(), and error.

Referenced by load_packages().

◆ check_replacers()

◆ check_validity()

◆ compute_download_size()

static int compute_download_size ( alpm_pkg_t * newpkg)
static

Compute the size of the files that will be downloaded to install a package.

Parameters
newpkgthe new package to upgrade to

References ALPM_ERR_PKG_INVALID_NAME, ALPM_LOG_DEBUG, ALPM_PKG_FROM_SYNCDB, ASSERT, CALLOC, FREE, INFRQ_DSIZE, and RET_ERR.

Referenced by alpm_pkg_download_size().

◆ dep_not_equal()

static int dep_not_equal ( const alpm_depend_t * left,
const alpm_depend_t * right )
static

◆ download_files()

◆ find_dl_candidates()

◆ key_cmp()

static int key_cmp ( const void * k1,
const void * k2 )
static

References keyinfo_t::keyid.

Referenced by check_keyring().

◆ load_packages()

◆ prompt_to_delete()

static int prompt_to_delete ( alpm_handle_t * handle,
const char * filepath,
alpm_errno_t reason )
static

Prompts to delete the file now that we know it is invalid.

Parameters
handlethe context handle
filenamethe absolute path of the file to test
reasonan error code indicating the reason for package invalidity
Returns
1 if file was removed, 0 otherwise

References ALPM_QUESTION_CORRUPTED_PKG, FREE, QUESTION, alpm_question_corrupted_t::remove, and alpm_question_conflict_t::type.

Referenced by check_validity(), and load_packages().