|
|
|
|
@ -92,7 +92,8 @@ int yon_packages_init(){
|
|
|
|
|
|
|
|
|
|
int yon_packages_check_exist(const char *package_name){
|
|
|
|
|
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)){
|
|
|
|
|
alpm_list_t *iter;
|
|
|
|
|
for (iter=sync_db;iter;iter=alpm_list_next(iter)){
|
|
|
|
|
alpm_db_t *database = iter->data;
|
|
|
|
|
alpm_pkg_t *package = alpm_db_get_pkg(database,package_name);
|
|
|
|
|
|
|
|
|
|
@ -184,6 +185,157 @@ char *yon_packages_get_description(enum YON_PACKAGES_DB_TYPE type, const char *p
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* yon_alpm_list_to_char(alpm_list_t *list){
|
|
|
|
|
if (!list) return NULL;
|
|
|
|
|
int size = 0;
|
|
|
|
|
size_t list_size = alpm_list_count(list);
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
for (size_t i=0;i<list_size;i++){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parsed,&size,list->data)
|
|
|
|
|
list=list->next;
|
|
|
|
|
}
|
|
|
|
|
char *final = yon_char_parsed_to_string(parsed,size," ");
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
return final;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yon_packages_info *yon_packages_get_info_struct(enum YON_PACKAGES_DB_TYPE type, const char *package){
|
|
|
|
|
if (yon_char_is_empty(package)) return NULL;
|
|
|
|
|
|
|
|
|
|
alpm_list_t *databases = _yon_packages_get_db_list(type);
|
|
|
|
|
alpm_list_t *iter = NULL;
|
|
|
|
|
for (iter = databases; iter; iter=iter->next){
|
|
|
|
|
alpm_pkg_t *pkg = alpm_db_get_pkg(iter->data,package);
|
|
|
|
|
if (!pkg) continue;
|
|
|
|
|
const char *name = alpm_pkg_get_name(pkg);
|
|
|
|
|
if (!strcmp(name,package)){
|
|
|
|
|
yon_packages_info *package_info = malloc(sizeof(yon_packages_info));
|
|
|
|
|
memset(package_info,0,sizeof(yon_packages_info));
|
|
|
|
|
package_info->repo_name = yon_char_new(alpm_db_get_name(iter->data));
|
|
|
|
|
package_info->package_name = yon_char_new(alpm_pkg_get_name(pkg));
|
|
|
|
|
package_info->version = yon_char_new(alpm_pkg_get_version(pkg));
|
|
|
|
|
package_info->description = yon_char_new(alpm_pkg_get_desc(pkg));
|
|
|
|
|
package_info->architecture = yon_char_new(alpm_pkg_get_arch(pkg));
|
|
|
|
|
package_info->url = yon_char_new(alpm_pkg_get_url(pkg));
|
|
|
|
|
|
|
|
|
|
size_t size=0;
|
|
|
|
|
alpm_list_t *licence_list = alpm_pkg_get_licenses(pkg);
|
|
|
|
|
package_info->licence = yon_alpm_list_to_char(licence_list);
|
|
|
|
|
alpm_list_free(licence_list);
|
|
|
|
|
|
|
|
|
|
alpm_list_t *groups_list = alpm_pkg_get_groups(pkg);
|
|
|
|
|
package_info->groups = yon_alpm_list_to_char(groups_list);
|
|
|
|
|
alpm_list_free(groups_list);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
alpm_list_t *provides_list = alpm_pkg_get_provides(pkg);
|
|
|
|
|
size = alpm_list_count(provides_list);
|
|
|
|
|
int parsed_size=0;
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)provides_list->data)->name);
|
|
|
|
|
}
|
|
|
|
|
package_info->provides = yon_char_parsed_to_string(parsed,parsed_size, " ");
|
|
|
|
|
alpm_list_free(provides_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
alpm_list_t *depends_list = alpm_pkg_get_depends(pkg);
|
|
|
|
|
size = alpm_list_count(depends_list);
|
|
|
|
|
int parsed_size=0;
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)depends_list->data)->name);
|
|
|
|
|
}
|
|
|
|
|
package_info->depends = yon_char_parsed_to_string(parsed,parsed_size, " ");
|
|
|
|
|
alpm_list_free(depends_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
alpm_list_t *optdepends_list = alpm_pkg_get_optdepends(pkg);
|
|
|
|
|
size = alpm_list_count(optdepends_list);
|
|
|
|
|
int parsed_size=0;
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)optdepends_list->data)->name);
|
|
|
|
|
}
|
|
|
|
|
package_info->optional_depends = yon_char_parsed_to_string(parsed,parsed_size, " ");
|
|
|
|
|
alpm_list_free(optdepends_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
alpm_list_t *conflicts_list = alpm_pkg_get_conflicts(pkg);
|
|
|
|
|
size = alpm_list_count(conflicts_list);
|
|
|
|
|
int parsed_size=0;
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)conflicts_list->data)->name);
|
|
|
|
|
}
|
|
|
|
|
package_info->conflicts = yon_char_parsed_to_string(parsed,parsed_size, " ");
|
|
|
|
|
alpm_list_free(conflicts_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
alpm_list_t *replaces_list = alpm_pkg_get_replaces(pkg);
|
|
|
|
|
size = alpm_list_count(replaces_list);
|
|
|
|
|
int parsed_size=0;
|
|
|
|
|
config_str parsed = NULL;
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parsed,&parsed_size,((alpm_depend_t*)replaces_list->data)->name);
|
|
|
|
|
}
|
|
|
|
|
package_info->replaces = yon_char_parsed_to_string(parsed,parsed_size, " ");
|
|
|
|
|
alpm_list_free(replaces_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int size_mod = 0;
|
|
|
|
|
int fin_size = yon_size_convert_automatic(alpm_pkg_get_size(pkg),&size_mod);
|
|
|
|
|
char *size_letter = yon_size_get_mod(size_mod);
|
|
|
|
|
char *size_string = yon_char_from_int(fin_size);
|
|
|
|
|
package_info->download_size = yon_char_unite(size_string,size_letter,NULL);
|
|
|
|
|
free(size_string);
|
|
|
|
|
|
|
|
|
|
size_mod = 0;
|
|
|
|
|
fin_size = yon_size_convert_automatic(alpm_pkg_get_isize(pkg),&size_mod);
|
|
|
|
|
size_letter = yon_size_get_mod(size_mod);
|
|
|
|
|
size_string = yon_char_from_int(fin_size);
|
|
|
|
|
package_info->install_size = yon_char_unite(size_string,size_letter,NULL);
|
|
|
|
|
free(size_string);
|
|
|
|
|
|
|
|
|
|
package_info->packager = yon_char_new(alpm_pkg_get_packager(pkg));
|
|
|
|
|
GDateTime *datetime = g_date_time_new_from_unix_local(alpm_pkg_get_builddate(pkg));
|
|
|
|
|
package_info->build_date = g_date_time_format(datetime,"%Ec");
|
|
|
|
|
package_info->validate_by = alpm_pkg_get_validation(pkg);
|
|
|
|
|
|
|
|
|
|
return package_info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_packages_get_info_string(yon_packages_info *info){
|
|
|
|
|
char *packager = yon_char_return_if_exist(info->packager,"");
|
|
|
|
|
char *info_label = yon_char_unite(
|
|
|
|
|
"<b>Repository</b> :",yon_char_return_if_exist(info->repo_name,""),"\n",
|
|
|
|
|
"<b>Name</b> :",yon_char_return_if_exist(info->package_name,""),"\n",
|
|
|
|
|
"<b>Version</b> :",yon_char_return_if_exist(info->version,""),"\n",
|
|
|
|
|
"<b>Description</b> :",yon_char_return_if_exist(info->description,""),"\n",
|
|
|
|
|
"<b>Architecture</b> :",yon_char_return_if_exist(info->architecture,""),"\n",
|
|
|
|
|
"<b>URL</b> :",yon_char_return_if_exist(info->url,""),"\n",
|
|
|
|
|
"<b>Licenses</b> :",yon_char_return_if_exist(info->licence,""),"\n",
|
|
|
|
|
"<b>Groups</b> :",yon_char_return_if_exist(info->groups,""),"\n",
|
|
|
|
|
"<b>Provides</b> :",yon_char_return_if_exist(info->provides,""),"\n",
|
|
|
|
|
"<b>Depends On</b> :",yon_char_return_if_exist(info->depends,""),"\n",
|
|
|
|
|
"<b>Optional Deps</b> :",yon_char_return_if_exist(info->optional_depends,""),"\n",
|
|
|
|
|
"<b>Conflicts With</b> :",yon_char_return_if_exist(info->conflicts,""),"\n",
|
|
|
|
|
"<b>Replaces</b> :",yon_char_return_if_exist(info->replaces,""),"\n",
|
|
|
|
|
"<b>Download Size</b> :",yon_char_return_if_exist(info->download_size,""),"\n",
|
|
|
|
|
"<b>Installed Size</b> :",yon_char_return_if_exist(info->install_size,""),"\n",
|
|
|
|
|
"<b>Packager</b> :",g_markup_escape_text(packager,strlen(packager)),"\n",
|
|
|
|
|
"<b>Build Date</b> :",yon_char_return_if_exist(info->build_date,""),"\n",
|
|
|
|
|
"<b>Validated By</b> :",yon_char_return_if_exist(info->architecture,""),
|
|
|
|
|
NULL);
|
|
|
|
|
return info_label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_str yon_packages_get_depends(enum YON_PACKAGES_DB_TYPE type, const char *package, int *size){
|
|
|
|
|
(*size)=0;
|
|
|
|
|
if (yon_char_is_empty(package)) return NULL;
|
|
|
|
|
|