Go to the source code of this file.
Functions | |
| gboolean | apt_init (const gchar *sourcelist, const gchar *suite_codename, gboolean verbose) |
| initialise the apt cache | |
| gint | check_pkg_name (gconstpointer a, gconstpointer b) |
| gboolean | aptcache_lookup (const gchar *pkg) |
| gboolean apt_init | ( | const gchar * | sourcelist, | |
| const gchar * | suite_codename, | |||
| gboolean | verbose | |||
| ) |
initialise the apt cache
When installed this uses the emdebian cache for the current arch.
00079 { 00080 FILE * fout = NULL; 00081 gchar * pkg, * config_str, * path; 00082 MMap *Map = 0; 00083 GError * em_gerr = NULL; 00084 pkgSourceList *SrcList = 0; 00085 gboolean All = _config->FindB("APT::Cache::AllNames","false"); 00086 00087 path = g_strconcat ("/var/lib/langupdate/", suite_codename, "/lists/partial", NULL); 00088 g_mkdir_with_parents (path, 0755); 00089 g_free (path); 00090 path = g_strconcat ("/var/lib/langupdate/", suite_codename, "/archives/partial", NULL); 00091 g_mkdir_with_parents (path, 0755); 00092 g_free (path); 00093 fout = fopen ("/var/lib/langupdate/status", "a"); 00094 fclose (fout); 00095 path = g_strconcat ("/var/lib/langupdate/", suite_codename, "/lists/lock", NULL); 00096 fout = fopen (path, "a"); 00097 fclose (fout); 00098 g_free (path); 00099 config_str = g_strconcat("apt-get ", lu_get_aptstring(), " update", NULL); 00100 g_spawn_command_line_sync (config_str, NULL, NULL, NULL, &em_gerr); 00101 /* always initialise the config BEFORE changing values - init resets everything. */ 00102 g_return_val_if_fail (pkgInitConfig(*_config), FALSE); 00103 g_return_val_if_fail (pkgInitSystem(*_config,_system), FALSE); 00104 if (verbose) 00105 _config->Set("quiet", 2); 00106 else 00107 _config->Set("quiet", 0); 00108 #ifdef FOREIGN 00109 _config->Set("Apt::Architecture", "arm"); 00110 #endif 00111 _config->Set("help", true); 00112 _config->Set("APT::Get::List-Cleanup", "off"); 00113 _config->Set("Apt::Install-Recommends","false"); 00114 _config->Set("Dir", "/var/lib/langupdate"); 00115 _config->Set("Dir::Etc", "/var/lib/langupdate"); 00116 _config->Set("Dir::Etc::SourceList", "/var/lib/langupdate/sources.list"); 00117 _config->Set("Dir::State", suite_codename); 00118 _config->Set("Dir::State::Status", "/var/lib/langupdate/status"); 00119 _config->Set("Dir::Cache", suite_codename); 00120 #ifdef FOREIGN 00121 if (verbose) 00122 _config->Dump(); 00123 #endif 00124 if (_config->FindB("APT::Cache::Generate",true) == false) 00125 Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"), 00126 FileFd::ReadOnly),MMap::Public|MMap::ReadOnly); 00127 else 00128 { 00129 // Open the cache file 00130 SrcList = new pkgSourceList; 00131 if (SrcList->Read(sourcelist) == false) 00132 { 00133 g_error (_("Failed to read sources")); 00134 return false; 00135 } 00136 00137 // Generate it and map it 00138 OpProgress Prog; 00139 pkgMakeStatusCache(*SrcList,Prog,&Map,true); 00140 } 00141 00142 // Print any errors or warnings found during parsing 00143 if (_error->PendingError()) 00144 { 00145 _error->DumpErrors(); 00146 return FALSE; 00147 } 00148 pkgCache Cache(Map); 00149 LangCache = &Cache; 00150 00151 // Print any errors or warnings found during parsing 00152 if (_error->empty() == false) 00153 { 00154 bool Errors = _error->PendingError(); 00155 _error->DumpErrors(); 00156 return Errors == true?100:0; 00157 } 00158 LoadPkgNames(); 00159 return TRUE; 00160 }
| gboolean aptcache_lookup | ( | const gchar * | pkg | ) |
lookup the package name against the cache.
00179 { 00180 GList * available = NULL; 00181 00182 available = g_list_find_custom (apt_list, pkg, check_pkg_name); 00183 if (g_list_length (available)) 00184 return TRUE; 00185 return FALSE; 00186 }
| gint check_pkg_name | ( | gconstpointer | a, | |
| gconstpointer | b | |||
| ) |
1.5.4