#include "xregex.h"
#include "sprintf_alloc.h"
-#include "opkg_conf.h"
+#include "args.h"
#include "opkg_message.h"
#include "file_util.h"
#include "str_util.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <errno.h>
+
+extern char *conf_file_dir;
static int opkg_conf_parse_file(opkg_conf_t *conf, const char *filename,
pkg_src_list_t *pkg_src_list,
opkg_option_t tmp[] = {
{ "cache", OPKG_OPT_TYPE_STRING, &conf->cache},
{ "force_defaults", OPKG_OPT_TYPE_BOOL, &conf->force_defaults },
+ { "force_maintainer", OPKG_OPT_TYPE_BOOL, &conf->force_maintainer },
{ "force_depends", OPKG_OPT_TYPE_BOOL, &conf->force_depends },
{ "force_overwrite", OPKG_OPT_TYPE_BOOL, &conf->force_overwrite },
{ "force_downgrade", OPKG_OPT_TYPE_BOOL, &conf->force_downgrade },
{ "force_reinstall", OPKG_OPT_TYPE_BOOL, &conf->force_reinstall },
{ "force_space", OPKG_OPT_TYPE_BOOL, &conf->force_space },
+ { "check_signature", OPKG_OPT_TYPE_INT, &conf->check_signature },
{ "ftp_proxy", OPKG_OPT_TYPE_STRING, &conf->ftp_proxy },
{ "http_proxy", OPKG_OPT_TYPE_STRING, &conf->http_proxy },
{ "no_proxy", OPKG_OPT_TYPE_STRING, &conf->no_proxy },
{ "proxy_user", OPKG_OPT_TYPE_STRING, &conf->proxy_user },
{ "query-all", OPKG_OPT_TYPE_BOOL, &conf->query_all },
{ "verbosity", OPKG_OPT_TYPE_BOOL, &conf->verbosity },
+ { "signature_ca_file", OPKG_OPT_TYPE_STRING, &conf->signature_ca_file },
+ { "signature_ca_path", OPKG_OPT_TYPE_STRING, &conf->signature_ca_path },
{ NULL }
};
int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
{
int err;
+ int errno_copy;
char *tmp_dir_base;
nv_pair_list_t tmp_dest_nv_pair_list;
char *lists_dir = NULL, *lock_file = NULL;
glob_t globbuf;
- char *etc_opkg_conf_pattern = "/etc/opkg/*.conf";
+ char *etc_opkg_conf_pattern;
char *pending_dir = NULL;
memset(conf, 0, sizeof(opkg_conf_t));
conf->lock_fd = creat (lock_file, S_IRUSR | S_IWUSR | S_IRGRP);
err = lockf (conf->lock_fd, F_TLOCK, 0);
+ errno_copy = errno;
free (lock_file);
if (err)
{
- opkg_message (conf, OPKG_ERROR, "Could not obtain administrative lock\n");
+ if(args->offline_root) {
+ opkg_message (conf, OPKG_ERROR, "Could not obtain administrative lock for offline root (ERR: %s) at %s/%s/lock\n",
+ strerror(errno_copy), args->offline_root, OPKG_STATE_DIR_PREFIX);
+ } else {
+ opkg_message (conf, OPKG_ERROR, "Could not obtain administrative lock (ERR: %s) at %s/lock\n",
+ strerror(errno_copy), OPKG_STATE_DIR_PREFIX);
+ }
return OPKG_CONF_ERR_LOCK;
}
if (args->offline_root)
sprintf_alloc(&etc_opkg_conf_pattern, "%s/etc/opkg/*.conf", args->offline_root);
+ else
+ sprintf_alloc(&etc_opkg_conf_pattern, "%s/*.conf", conf_file_dir);
memset(&globbuf, 0, sizeof(globbuf));
err = glob(etc_opkg_conf_pattern, 0, NULL, &globbuf);
- if (args->offline_root)
- free (etc_opkg_conf_pattern);
+ free (etc_opkg_conf_pattern);
if (!err) {
int i;
for (i = 0; i < globbuf.gl_pathc; i++) {
if (args->force_defaults) {
conf->force_defaults = 1;
}
+ if (args->force_maintainer) {
+ conf->force_maintainer = 1;
+ }
if (args->force_overwrite) {
conf->force_overwrite = 1;
}
int opkg_conf_write_status_files(opkg_conf_t *conf)
{
- pkg_dest_list_elt_t *iter;
pkg_dest_t *dest;
pkg_vec_t *all;
pkg_t *pkg;
- register int i;
+ int i;
int err;
+ FILE * status_file=NULL;
if (conf->noaction)
return 0;
- for (iter = void_list_first(&conf->pkg_dest_list); iter; iter = void_list_next(&conf->pkg_dest_list, iter)) {
- dest = (pkg_dest_t *)iter->data;
- dest->status_file = fopen(dest->status_file_tmp_name, "w");
- if (dest->status_file == NULL) {
- fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
- __FUNCTION__, dest->status_file_name, strerror(errno));
- }
+
+ dest = (pkg_dest_t *)void_list_first(&conf->pkg_dest_list)->data;
+ status_file = fopen(dest->status_file_tmp_name, "w");
+ if (status_file == NULL) {
+ fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
+ __FUNCTION__, dest->status_file_tmp_name, strerror(errno));
}
all = pkg_vec_alloc();
__FUNCTION__, pkg->name);
continue;
}
- if (pkg->dest->status_file) {
- pkg_print_status(pkg, pkg->dest->status_file);
+ if (status_file) {
+ pkg_print_status(pkg, status_file);
}
}
pkg_vec_free(all);
- for (iter = void_list_first(&conf->pkg_dest_list); iter; iter = void_list_next(&conf->pkg_dest_list, iter)) {
- dest = (pkg_dest_t *)iter->data;
- if (dest->status_file) {
- err = ferror(dest->status_file);
- fclose(dest->status_file);
- dest->status_file = NULL;
- if (!err) {
- file_move(dest->status_file_tmp_name, dest->status_file_name);
- } else {
- fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
- "retaining old %s\n", __FUNCTION__,
- dest->status_file_tmp_name, dest->status_file_name);
- }
- }
+ if (status_file) {
+ err = ferror(status_file);
+ fclose(status_file);
+ if (!err) {
+ file_move(dest->status_file_tmp_name, dest->status_file_name);
+ } else {
+ fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
+ "retaining old %s\n", __FUNCTION__,
+ dest->status_file_tmp_name, dest->status_file_name);
+ }
+ status_file = NULL;
}
-
return 0;
}