You are not logged in.
Pages: 1
I am trying to install a package using alpm, I initialize handle, get pkg pointer from db... everything is ok,when i call alpm_trans_init() it exits with error, i don't know what is the reason, it outputs unexpected error when i output the error number.
this is my code:
alpm_errno_t err;
alpm_handle_t * handle = alpm_initialize("/", "/var/lib/pacman", &err);
//check for any errors
if(!handle){
std::cerr << "Error while initializing ALPM handle or regestring databases." << std::endl;
return {};
}
//set the call back function to show progress
alpm_option_set_dlcb(handle,(alpm_cb_download)progressCallBack,NULL);
alpm_db_t* extra_repo = alpm_register_syncdb(handle, "extra", ALPM_DB_USAGE_INSTALL)
if(community_repo== NULL)
{
std::cerr << "Error while registring sync database." << std::endl;
alpm_release(handle);
return 1;
}
alpm_pkg_t * pkg = alpm_db_get_pkg(extra_repo,"vlc");
if(pkg == NULL)
{
std::cerr << "Error while getting pkg from database" << std::endl;
alpm_release(handle);
return 1;
}
int trans = alpm_trans_init(handle,ALPM_TRANS_FLAG_ALLEXPLICIT); //it happens here
if(trans == -1) {
std::cerr << "Error while initializing transaction,reason:"<< alpm_strerror(err) << std::endl;
alpm_trans_release(handle);
alpm_release(handle);
return 1;
}
trans = alpm_add_pkg(handle,pkg);
if(trans == -1) {
std::cerr << "Error while adding package to transaction,reason:" << alpm_strerror(err) << std::endl;
alpm_release(handle);
return 1;
}
alpm_list_t * list = NULL;
trans = alpm_trans_prepare(handle,&list);
if(trans == -1) {
std::cerr << "Error while preparing transaction" << std::endl;
alpm_release(handle);
return 1;
}
trans = alpm_trans_commit(handle,&list);
if(trans == -1) {
std::cerr << "Error while comming transaction" << std::endl;
alpm_release(handle);
return 1;
}
}
this is what if statement print:
Error while initializing transaction,reason:unexpected error
Offline
Pages: 1