projects
/
oweals
/
opkg-lede.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Be consistent in how to check return codes for these functions.
[oweals/opkg-lede.git]
/
libopkg
/
opkg_cmd.c
diff --git
a/libopkg/opkg_cmd.c
b/libopkg/opkg_cmd.c
index 0fa471e3b43f3a7f2429d99bbb7752b62af7961c..c5ba3f400ec128d877ec22d892997f3d6e47de4c 100644
(file)
--- a/
libopkg/opkg_cmd.c
+++ b/
libopkg/opkg_cmd.c
@@
-390,8
+390,8
@@
opkg_configure_packages(char *pkg_name)
goto error;
}
goto error;
}
- for(i = 0; i <
all
->len; i++) {
- pkg =
all
->pkgs[i];
+ for(i = 0; i <
ordered
->len; i++) {
+ pkg =
ordered
->pkgs[i];
if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
continue;
if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
continue;
@@
-405,15
+405,13
@@
opkg_configure_packages(char *pkg_name)
pkg->state_flag &= ~SF_PREFER;
opkg_state_changed++;
} else {
pkg->state_flag &= ~SF_PREFER;
opkg_state_changed++;
} else {
- if (!err)
- err = r;
+ err = -1;
}
}
}
}
}
}
- r = opkg_finalize_intercepts (ic);
- if (r && !err)
- err = r;
+ if (opkg_finalize_intercepts (ic))
+ err = -1;
error:
pkg_vec_free(all);
error:
pkg_vec_free(all);
@@
-423,12
+421,23
@@
error:
return err;
}
return err;
}
+static int
+opkg_remove_cmd(int argc, char **argv);
+
static int
opkg_install_cmd(int argc, char **argv)
{
static int
opkg_install_cmd(int argc, char **argv)
{
- int i
, r
;
+ int i;
char *arg;
char *arg;
- int err=0;
+ int err = 0;
+
+ if (conf->force_reinstall) {
+ int saved_force_depends = conf->force_depends;
+ conf->force_depends = 1;
+ (void)opkg_remove_cmd(argc, argv);
+ conf->force_depends = saved_force_depends;
+ conf->force_reinstall = 0;
+ }
signal(SIGINT, sigint_handler);
signal(SIGINT, sigint_handler);
@@
-439,23
+448,21
@@
opkg_install_cmd(int argc, char **argv)
arg = argv[i];
opkg_msg(DEBUG2, "%s\n", arg);
arg = argv[i];
opkg_msg(DEBUG2, "%s\n", arg);
- err = opkg_prepare_url_for_install(arg, &argv[i]);
- if (err)
- return err;
+ if (opkg_prepare_url_for_install(arg, &argv[i]))
+ return -1;
}
pkg_info_preinstall_check();
for (i=0; i < argc; i++) {
arg = argv[i];
}
pkg_info_preinstall_check();
for (i=0; i < argc; i++) {
arg = argv[i];
- err = opkg_install_by_name(arg);
- if (err) {
+ if (opkg_install_by_name(arg)) {
opkg_msg(ERROR, "Cannot install package %s.\n", arg);
opkg_msg(ERROR, "Cannot install package %s.\n", arg);
+ err = -1;
}
}
}
}
- r = opkg_configure_packages(NULL);
- if (!err)
- err = r;
+ if (opkg_configure_packages(NULL))
+ err = -1;
write_status_files_if_changed();
write_status_files_if_changed();
@@
-465,9
+472,9
@@
opkg_install_cmd(int argc, char **argv)
static int
opkg_upgrade_cmd(int argc, char **argv)
{
static int
opkg_upgrade_cmd(int argc, char **argv)
{
- int i
, r
;
+ int i;
pkg_t *pkg;
pkg_t *pkg;
- int err;
+ int err
= 0
;
signal(SIGINT, sigint_handler);
signal(SIGINT, sigint_handler);
@@
-475,9
+482,8
@@
opkg_upgrade_cmd(int argc, char **argv)
for (i=0; i < argc; i++) {
char *arg = argv[i];
for (i=0; i < argc; i++) {
char *arg = argv[i];
- err = opkg_prepare_url_for_install(arg, &arg);
- if (err)
- return err;
+ if (opkg_prepare_url_for_install(arg, &arg))
+ return -1;
}
pkg_info_preinstall_check();
}
pkg_info_preinstall_check();
@@
-494,10
+500,12
@@
opkg_upgrade_cmd(int argc, char **argv)
} else {
pkg = pkg_hash_fetch_installed_by_name(argv[i]);
}
} else {
pkg = pkg_hash_fetch_installed_by_name(argv[i]);
}
- if (pkg)
- opkg_upgrade_pkg(pkg);
- else {
- opkg_install_by_name(arg);
+ if (pkg) {
+ if (opkg_upgrade_pkg(pkg))
+ err = -1;
+ } else {
+ if (opkg_install_by_name(arg))
+ err = -1;
}
}
} else {
}
}
} else {
@@
-508,18
+516,18
@@
opkg_upgrade_cmd(int argc, char **argv)
pkg_hash_fetch_all_installed(installed);
for (i = 0; i < installed->len; i++) {
pkg = installed->pkgs[i];
pkg_hash_fetch_all_installed(installed);
for (i = 0; i < installed->len; i++) {
pkg = installed->pkgs[i];
- opkg_upgrade_pkg(pkg);
+ if (opkg_upgrade_pkg(pkg))
+ err = -1;
}
pkg_vec_free(installed);
}
}
pkg_vec_free(installed);
}
- r = opkg_configure_packages(NULL);
- if (!err)
- err = r;
+ if (opkg_configure_packages(NULL))
+ err = -1;
write_status_files_if_changed();
write_status_files_if_changed();
- return
0
;
+ return
err
;
}
static int
}
static int
@@
-539,7
+547,8
@@
opkg_download_cmd(int argc, char **argv)
continue;
}
continue;
}
- err = opkg_download_pkg(pkg, ".");
+ if (opkg_download_pkg(pkg, "."))
+ err = -1;
if (err) {
opkg_msg(ERROR, "Failed to download %s.\n", pkg->name);
if (err) {
opkg_msg(ERROR, "Failed to download %s.\n", pkg->name);
@@
-702,7
+711,7
@@
opkg_configure_cmd(int argc, char **argv)
static int
opkg_remove_cmd(int argc, char **argv)
{
static int
opkg_remove_cmd(int argc, char **argv)
{
- int i, a, done,
r,
err = 0;
+ int i, a, done, err = 0;
pkg_t *pkg;
pkg_t *pkg_to_remove;
pkg_vec_t *available;
pkg_t *pkg;
pkg_t *pkg_to_remove;
pkg_vec_t *available;
@@
-734,15
+743,15
@@
opkg_remove_cmd(int argc, char **argv)
opkg_msg(ERROR, "Package %s is not installed.\n", pkg->name);
continue;
}
opkg_msg(ERROR, "Package %s is not installed.\n", pkg->name);
continue;
}
- if (pkg->state_status == SS_NOT_INSTALLED) {
// Added the control, so every already removed package could be skipped
+ if (pkg->state_status == SS_NOT_INSTALLED) {
opkg_msg(ERROR, "Package %s not installed.\n", pkg->name);
continue;
}
opkg_msg(ERROR, "Package %s not installed.\n", pkg->name);
continue;
}
- r = opkg_remove_pkg(pkg_to_remove, 0);
- if (!err)
- err = r;
- done = 1;
+ if (opkg_remove_pkg(pkg_to_remove, 0))
+ err = -1;
+ else
+ done = 1;
}
}
}
}