projects
/
oweals
/
opkg-lede.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
opkg: trivial, clean up obsolete code, and some typo
[oweals/opkg-lede.git]
/
libopkg
/
pkg.c
diff --git
a/libopkg/pkg.c
b/libopkg/pkg.c
index d9bae898ec3d8b192b0451f410c687ba8a247f36..6c07b840b8c978e194e49abdb42f89d37868b084 100644
(file)
--- a/
libopkg/pkg.c
+++ b/
libopkg/pkg.c
@@
-18,6
+18,7
@@
#include "includes.h"
#include <ctype.h>
#include <string.h>
#include "includes.h"
#include <ctype.h>
#include <string.h>
+#include <stdbool.h>
#include <errno.h>
#include "pkg.h"
#include <errno.h>
#include "pkg.h"
@@
-94,7
+95,6
@@
int pkg_init(pkg_t *pkg)
pkg->epoch = 0;
pkg->version = NULL;
pkg->revision = NULL;
pkg->epoch = 0;
pkg->version = NULL;
pkg->revision = NULL;
- pkg->familiar_revision = NULL;
pkg->dest = NULL;
pkg->src = NULL;
pkg->architecture = NULL;
pkg->dest = NULL;
pkg->src = NULL;
pkg->architecture = NULL;
@@
-142,6
+142,19
@@
int pkg_init(pkg_t *pkg)
return 0;
}
return 0;
}
+void compound_depend_deinit (compound_depend_t *depends)
+{
+ int i;
+ for (i = 0; i < depends->possibility_count; i++)
+ {
+ depend_t *d;
+ d = depends->possibilities[i];
+ free (d->version);
+ free (d);
+ }
+ free (depends->possibilities);
+}
+
void pkg_deinit(pkg_t *pkg)
{
int i;
void pkg_deinit(pkg_t *pkg)
{
int i;
@@
-151,10
+164,9
@@
void pkg_deinit(pkg_t *pkg)
pkg->epoch = 0;
free(pkg->version);
pkg->version = NULL;
pkg->epoch = 0;
free(pkg->version);
pkg->version = NULL;
- /* revision
and familiar_revision share
storage with version, so
+ /* revision
shares
storage with version, so
don't free */
pkg->revision = NULL;
don't free */
pkg->revision = NULL;
- pkg->familiar_revision = NULL;
/* owned by opkg_conf_t */
pkg->dest = NULL;
/* owned by opkg_conf_t */
/* owned by opkg_conf_t */
pkg->dest = NULL;
/* owned by opkg_conf_t */
@@
-171,35
+183,39
@@
void pkg_deinit(pkg_t *pkg)
pkg->state_flag = SF_OK;
pkg->state_status = SS_NOT_INSTALLED;
pkg->state_flag = SF_OK;
pkg->state_status = SS_NOT_INSTALLED;
+ //for (i = 0; i < pkg->replaces_count; i++)
+ free (pkg->replaces);
+ pkg->replaces = NULL;
+
for (i = 0; i < pkg->depends_count; i++)
free (pkg->depends_str[i]);
free(pkg->depends_str);
pkg->depends_str = NULL;
for (i = 0; i < pkg->depends_count; i++)
free (pkg->depends_str[i]);
free(pkg->depends_str);
pkg->depends_str = NULL;
- pkg->depends_count = 0;
for (i = 0; i < pkg->provides_count; i++)
free (pkg->provides_str[i]);
free(pkg->provides_str);
pkg->provides_str = NULL;
for (i = 0; i < pkg->provides_count; i++)
free (pkg->provides_str[i]);
free(pkg->provides_str);
pkg->provides_str = NULL;
- pkg->provides_count = 0;
for (i = 0; i < pkg->conflicts_count; i++)
free (pkg->conflicts_str[i]);
free(pkg->conflicts_str);
pkg->conflicts_str = NULL;
for (i = 0; i < pkg->conflicts_count; i++)
free (pkg->conflicts_str[i]);
free(pkg->conflicts_str);
pkg->conflicts_str = NULL;
- pkg->conflicts_count = 0;
for (i = 0; i < pkg->replaces_count; i++)
free (pkg->replaces_str[i]);
free(pkg->replaces_str);
pkg->replaces_str = NULL;
for (i = 0; i < pkg->replaces_count; i++)
free (pkg->replaces_str[i]);
free(pkg->replaces_str);
pkg->replaces_str = NULL;
- pkg->replaces_count = 0;
for (i = 0; i < pkg->recommends_count; i++)
free (pkg->recommends_str[i]);
free(pkg->recommends_str);
pkg->recommends_str = NULL;
for (i = 0; i < pkg->recommends_count; i++)
free (pkg->recommends_str[i]);
free(pkg->recommends_str);
pkg->recommends_str = NULL;
- pkg->recommends_count = 0;
+
+ for (i = 0; i < pkg->suggests_count; i++)
+ free (pkg->suggests_str[i]);
+ free(pkg->suggests_str);
+ pkg->suggests_str = NULL;
if (pkg->depends)
{
if (pkg->depends)
{
@@
-207,23
+223,19
@@
void pkg_deinit(pkg_t *pkg)
int x;
for (x = 0; x < count; x++)
int x;
for (x = 0; x < count; x++)
- {
- compound_depend_t *depends;
- depends = &pkg->depends[x];
-
- for (i = 0; i < depends->possibility_count; i++)
- {
- depend_t *d;
- d = depends->possibilities[i];
- free (d->version);
- free (d);
- }
- free (depends->possibilities);
- }
+ compound_depend_deinit (&pkg->depends[x]);
free (pkg->depends);
}
free (pkg->depends);
}
+
+ if (pkg->conflicts)
+ {
+ int x;
+ for (x = 0; x < pkg->conflicts_count; x++)
+ compound_depend_deinit (&pkg->conflicts[x]);
+ free (pkg->conflicts);
+ }
+
free (pkg->provides);
free (pkg->provides);
- free (pkg->conflicts);
pkg->pre_depends_count = 0;
free(pkg->pre_depends_str);
pkg->pre_depends_count = 0;
free(pkg->pre_depends_str);
@@
-1041,6
+1053,7
@@
char * pkg_formatted_field(pkg_t *pkg, const char *field )
void pkg_print_info(pkg_t *pkg, FILE *file)
{
void pkg_print_info(pkg_t *pkg, FILE *file)
{
+ int t=0;
char * buff;
if (pkg == NULL) {
return;
char * buff;
if (pkg == NULL) {
return;
@@
-1050,7
+1063,7
@@
void pkg_print_info(pkg_t *pkg, FILE *file)
if ( buff == NULL )
return;
if (strlen(buff)>2){
if ( buff == NULL )
return;
if (strlen(buff)>2){
- fwrite(buff, 1, strlen(buff), file);
+ t = fwrite(buff, 1, strlen(buff), file); //#~rzr:TODO
}
free(buff);
}
}
free(buff);
}
@@
-1068,7
+1081,7
@@
void pkg_print_status(pkg_t * pkg, FILE * file)
can be found in th available file.
But, someone proposed the idea to make it possible to
can be found in th available file.
But, someone proposed the idea to make it possible to
- reconstruct a .
i
pk from an installed package, (ie. for beaming
+ reconstruct a .
o
pk from an installed package, (ie. for beaming
from one handheld to another). So, maybe we actually want a few
more fields here, (depends, suggests, etc.), so that that would
be guaranteed to work even in the absence of more information
from one handheld to another). So, maybe we actually want a few
more fields here, (depends, suggests, etc.), so that that would
be guaranteed to work even in the absence of more information
@@
-1300,7
+1313,7
@@
str_list_t *pkg_get_installed_files(pkg_t *pkg)
return NULL;
}
return NULL;
}
- /* For uninstalled packages, get the file list
f
irectly from the package.
+ /* For uninstalled packages, get the file list
d
irectly from the package.
For installed packages, look at the package.list file in the database.
*/
if (pkg->state_status == SS_NOT_INSTALLED || pkg->dest == NULL) {
For installed packages, look at the package.list file in the database.
*/
if (pkg->state_status == SS_NOT_INSTALLED || pkg->dest == NULL) {
@@
-1398,6
+1411,7
@@
int pkg_free_installed_files(pkg_t *pkg)
}
str_list_deinit(pkg->installed_files);
}
str_list_deinit(pkg->installed_files);
+ free (pkg->installed_files);
}
pkg->installed_files = NULL;
}
pkg->installed_files = NULL;
@@
-1481,8
+1495,24
@@
int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
scripts when running with offline_root mode and/or a dest other
than '/'. I've been playing around with some clever chroot
tricks and I might come up with something workable. */
scripts when running with offline_root mode and/or a dest other
than '/'. I've been playing around with some clever chroot
tricks and I might come up with something workable. */
+ /*
+ * Attempt to provide a restricted environment for offline operation
+ * Need the following set as a minimum:
+ * OPKG_OFFLINE_ROOT = absolute path to root dir
+ * D = absolute path to root dir (for OE generated postinst)
+ * PATH = something safe (a restricted set of utilities)
+ */
+
+ bool AllowOfflineMode = false;
if (conf->offline_root) {
setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1);
if (conf->offline_root) {
setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1);
+ setenv("D", conf->offline_root, 1);
+ if (NULL == conf->offline_root_path || '\0' == conf->offline_root_path[0]) {
+ setenv("PATH", "/dev/null", 1);
+ } else {
+ setenv("PATH", conf->offline_root_path, 1);
+ AllowOfflineMode = true;
+ }
}
setenv("PKG_ROOT",
}
setenv("PKG_ROOT",
@@
-1493,7
+1523,7
@@
int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
return 0;
}
return 0;
}
- if (conf->offline_root) {
+ if (conf->offline_root
&& !AllowOfflineMode
) {
fprintf(stderr, "(offline root mode: not running %s.%s)\n", pkg->name, script);
free(path);
return 0;
fprintf(stderr, "(offline root mode: not running %s.%s)\n", pkg->name, script);
free(path);
return 0;
@@
-1701,7
+1731,7
@@
int pkg_info_preinstall_check(opkg_conf_t *conf)
pkg_t *pkg = available_pkgs->pkgs[i];
if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) {
/* clear flags and want for any uninstallable package */
pkg_t *pkg = available_pkgs->pkgs[i];
if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) {
/* clear flags and want for any uninstallable package */
- opkg_message(conf, OPKG_
NOTICE
, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n",
+ opkg_message(conf, OPKG_
DEBUG
, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n",
pkg->name, pkg->arch_priority, pkg->state_flag, pkg->state_want);
pkg->state_want = SW_UNKNOWN;
pkg->state_flag = 0;
pkg->name, pkg->arch_priority, pkg->state_flag, pkg->state_want);
pkg->state_want = SW_UNKNOWN;
pkg->state_flag = 0;
@@
-1725,6
+1755,7
@@
int pkg_info_preinstall_check(opkg_conf_t *conf)
// opkg_message(conf, OPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
file_hash_set_file_owner(conf, installed_file, pkg);
}
// opkg_message(conf, OPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
file_hash_set_file_owner(conf, installed_file, pkg);
}
+ pkg_free_installed_files(pkg);
}
pkg_vec_free(installed_pkgs);
}
pkg_vec_free(installed_pkgs);
@@
-1800,5
+1831,6
@@
int pkg_write_changed_filelists(opkg_conf_t *conf)
opkg_message(conf, OPKG_NOTICE, "pkg_write_filelist pkg=%s returned %d\n", pkg->name, err);
}
}
opkg_message(conf, OPKG_NOTICE, "pkg_write_filelist pkg=%s returned %d\n", pkg->name, err);
}
}
+ pkg_vec_free (installed_pkgs);
return 0;
}
return 0;
}