General Public License for more details.
*/
-#include <config.h>
+#include "config.h"
+
+#include <stdio.h>
+#include <unistd.h>
#include <fnmatch.h>
#include "opkg.h"
}
+static struct opkg_conf saved_conf;
/*** Public API ***/
int
opkg_new()
{
+ saved_conf = *conf;
+
if (opkg_conf_init())
goto err0;
+ if (opkg_conf_load())
+ goto err0;
+
if (pkg_hash_load_feeds())
goto err1;
int
opkg_re_read_config_files(void)
{
- pkg_hash_deinit();
- pkg_hash_init();
-
- if (pkg_hash_load_feeds())
- goto err;
-
- if (pkg_hash_load_status_files())
- goto err;
-
- return 0;
-
-err:
- pkg_hash_deinit();
- return -1;
+ opkg_free();
+ *conf = saved_conf;
+ return opkg_new();
}
void
/**
* @brief libopkg API: Install package
* @param package_name The name of package in which is going to install
- * @param progress_callback The callback function that report the status to caller.
+ * @param progress_callback The callback function that report the status to caller.
*/
int
opkg_install_package(const char *package_name,
err = opkg_download(url, pkg->local_filename,
(curl_progress_func) curl_progress_cb,
- &cb_data);
+ &cb_data, 0);
free(url);
if (err) {
if (err)
return 1;
+ /* write out status files and file lists */
+ opkg_conf_write_status_files();
+ pkg_write_changed_filelists();
+
pdata.pkg = NULL;
progress(pdata, 100);
return 0;
err = opkg_download(url, tmp_file_name,
(curl_progress_func) curl_progress_cb,
- &cb_data);
+ &cb_data, 0);
if (err == 0) {
opkg_msg(INFO, "Inflating %s...\n",
}
free(tmp_file_name);
} else
- err = opkg_download(url, list_file_name, NULL, NULL);
+ err = opkg_download(url, list_file_name, NULL, NULL, 0);
if (err) {
opkg_msg(ERROR, "Couldn't retrieve %s\n", url);
/* make sure there is no existing signature file */
unlink(sig_file_name);
- err = opkg_download(url, sig_file_name, NULL, NULL);
+ err = opkg_download(url, sig_file_name, NULL, NULL, 0);
if (err) {
opkg_msg(ERROR, "Couldn't retrieve %s\n", url);
} else {
}
}
free(sig_file_name);
- free(list_file_name);
free(url);
}
#else
" has not been enabled in this build\n",
list_file_name);
#endif
+ free(list_file_name);
sources_done++;
progress(pdata, 100 * sources_done / sources_list_count);
head = prepare_upgrade_list();
for (node = active_list_next(head, head); node;
- active_list_next(head, node)) {
+ node = active_list_next(head, node)) {
old = list_entry(node, pkg_t, list);
new = pkg_hash_fetch_best_installation_candidate_by_name(old->name);
if (new == NULL)
opkg_find_package(const char *name, const char *ver, const char *arch,
const char *repo)
{
+ int pkg_found = 0;
pkg_t *pkg = NULL;
pkg_vec_t *all;
int i;
}
/* match found */
+ pkg_found = 1;
break;
}
pkg_vec_free(all);
- return pkg;
+ return pkg_found ? pkg : NULL;
}
-#ifdef HAVE_CURL
-#include <curl/curl.h>
-#endif
/**
- * @brief Check the accessibility of repositories. It will try to access the repository to check if the respository is accessible throught current network status.
- * @return return how many repositories cannot access. 0 means all okay.
+ * @brief Check the accessibility of repositories.
+ * @return return how many repositories cannot access. 0 means all okay.
*/
int
opkg_repository_accessibility_check(void)
str_list_t *src;
int repositories = 0;
int ret = 0;
- int err;
char *repo_ptr;
char *stmp;
char *host, *end;
free(repo_ptr);
repositories++;
}
+
while (repositories > 0) {
iter1 = str_list_pop(src);
repositories--;
- err = opkg_download(iter1->data, "/dev/null", NULL, NULL);
-#ifdef HAVE_CURL
- if (!(err == CURLE_OK ||
- err == CURLE_HTTP_RETURNED_ERROR ||
- err == CURLE_FILE_COULDNT_READ_FILE ||
- err == CURLE_REMOTE_FILE_NOT_FOUND ||
- err == CURLE_TFTP_NOTFOUND)) {
-#else
- if (!(err == 0)) {
-#endif
+ if (opkg_download(iter1->data, "/dev/null", NULL, NULL, 0))
ret++;
- }
str_list_elt_deinit(iter1);
}
+
free(src);
+
return ret;
}