|
|
|
@ -10,8 +10,12 @@ struct packages {
|
|
|
|
int _yon_packages_get_db(){
|
|
|
|
int _yon_packages_get_db(){
|
|
|
|
const char *root = "/";
|
|
|
|
const char *root = "/";
|
|
|
|
const char *dbpath = "/var/lib/pacman";
|
|
|
|
const char *dbpath = "/var/lib/pacman";
|
|
|
|
|
|
|
|
const char *dbpath_local = "/var/lib/pacman/local";
|
|
|
|
const char *config_path = "/etc/pacman.conf";
|
|
|
|
const char *config_path = "/etc/pacman.conf";
|
|
|
|
packages_struct.packages_handle = alpm_initialize(root,dbpath,NULL);
|
|
|
|
packages_struct.packages_handle = alpm_initialize(root,dbpath,NULL);
|
|
|
|
|
|
|
|
if (!packages_struct.packages_handle){
|
|
|
|
|
|
|
|
packages_struct.packages_handle = alpm_initialize(root,dbpath_local,NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!packages_struct.packages_handle){
|
|
|
|
if (!packages_struct.packages_handle){
|
|
|
|
packages_struct.init_status=0;
|
|
|
|
packages_struct.init_status=0;
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
@ -87,10 +91,11 @@ int yon_packages_init(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int yon_packages_check_exist(const char *package_name){
|
|
|
|
int yon_packages_check_exist(const char *package_name){
|
|
|
|
alpm_list_t *sync_db = alpm_get_syncdbs(packages_struct.packages_handle);
|
|
|
|
alpm_list_t *sync_db = _yon_packages_get_db_list(YON_PACKAGES_ALL);
|
|
|
|
for (alpm_list_t *iter=sync_db;iter;iter=alpm_list_next(iter)){
|
|
|
|
for (alpm_list_t *iter=sync_db;iter;iter=alpm_list_next(iter)){
|
|
|
|
alpm_db_t *database = iter->data;
|
|
|
|
alpm_db_t *database = iter->data;
|
|
|
|
alpm_pkg_t *package = alpm_db_get_pkg(database,package_name);
|
|
|
|
alpm_pkg_t *package = alpm_db_get_pkg(database,package_name);
|
|
|
|
|
|
|
|
|
|
|
|
if (package) return 1;
|
|
|
|
if (package) return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|