+ opkg_conf_override_string(&conf->offline_root_path,
+ args->offline_root_path);
+ opkg_conf_override_string(&conf->offline_root_pre_script_cmd,
+ args->offline_root_pre_script_cmd);
+ opkg_conf_override_string(&conf->offline_root_post_script_cmd,
+ args->offline_root_post_script_cmd);
+
+ opkg_conf_override_string(&conf->cache, args->cache);
+ opkg_conf_override_string(&conf->tmp_dir, args->tmp_dir);
+
+ /* check for lock file */
+ if (conf->offline_root)
+ sprintf_alloc (&lock_file, "%s/%s/lock", conf->offline_root, OPKG_STATE_DIR_PREFIX);
+ else
+ sprintf_alloc (&lock_file, "%s/lock", OPKG_STATE_DIR_PREFIX);
+
+ err = conf->lock_fd = creat (lock_file, S_IRUSR | S_IWUSR | S_IRGRP);
+ if (err != -1)
+ err = lockf (conf->lock_fd, F_TLOCK, 0);
+ errno_copy = errno;
+
+ if (err) {
+ opkg_message (conf, OPKG_ERROR, "Could not lock %s: %s\n",
+ lock_file, strerror(errno_copy));
+ free(lock_file);
+ return OPKG_CONF_ERR_LOCK;
+ }
+ free(lock_file);
+
+ if (conf->tmp_dir)
+ tmp_dir_base = conf->tmp_dir;
+ else
+ tmp_dir_base = getenv("TMPDIR");
+ sprintf_alloc(&tmp2, "%s/%s",
+ tmp_dir_base ? tmp_dir_base : OPKG_CONF_DEFAULT_TMP_DIR_BASE,
+ OPKG_CONF_TMP_DIR_SUFFIX);
+ if (conf->tmp_dir)
+ free(conf->tmp_dir);
+ conf->tmp_dir = mkdtemp(tmp2);
+ if (conf->tmp_dir == NULL) {
+ opkg_message(conf, OPKG_ERROR,
+ "%s: Creating temp dir %s failed: %s\n",
+ __FUNCTION__, tmp2, strerror(errno));
+ return OPKG_CONF_ERR_TMP_DIR;
+ }
+
+ pkg_hash_init("pkg-hash", &conf->pkg_hash, OPKG_CONF_DEFAULT_HASH_LEN);
+ hash_table_init("file-hash", &conf->file_hash, OPKG_CONF_DEFAULT_HASH_LEN);
+ hash_table_init("obs-file-hash", &conf->obs_file_hash, OPKG_CONF_DEFAULT_HASH_LEN/16);
+
+ if (conf->lists_dir == NULL)
+ conf->lists_dir = xstrdup(OPKG_CONF_LISTS_DIR);
+
+ if (conf->offline_root) {
+ char *tmp;
+ sprintf_alloc(&tmp, "%s/%s", conf->offline_root, conf->lists_dir);
+ free(conf->lists_dir);
+ conf->lists_dir = tmp;
+ }
+