summaryrefslogtreecommitdiffstats
path: root/patches/0003-cli-Optionally-enforce-argument-to-upgrade-command.patch
blob: 7a354035d902c415acd7f517df28312849273d4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From f96d300f0c236ebd4edb8e8b11aa948257cb7fb0 Mon Sep 17 00:00:00 2001
From: Patrick McDermott <patrick.mcdermott@libiquity.com>
Date: Thu, 4 Apr 2019 18:25:51 -0400
Subject: [PATCH 3/6] cli: Optionally enforce argument to upgrade command

This reverts and amends commit 673d7213175c2cf209b25c8eb2632941cdbb8519.

Signed-off-by: Patrick McDermott <patrick.mcdermott@libiquity.com>
---
 CMakeLists.txt     |  4 ++++
 libopkg/opkg_cmd.c | 17 +++++++++++++++++
 src/opkg-cl.c      |  4 ++++
 3 files changed, 25 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9acd6b4..dfb1b81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,7 @@ SET(VERSION "" CACHE STRING "Override version")
 OPTION(STATIC_UBOX "Statically link libubox" OFF)
 OPTION(BUILD_TESTS "Build test programs" ON)
 OPTION(ENABLE_USIGN "Enable usign support" ON)
+OPTION(REQUIRE_UPGRADE_ARGS "Require arguments to upgrade command" ON)
 
 IF(NOT HOST_CPU)
 	SET(HOST_CPU "${CMAKE_HOST_SYSTEM_PROCESSOR}")
@@ -52,6 +53,9 @@ ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -Wmissing-declarations
 IF(ENABLE_USIGN)
 	ADD_DEFINITIONS(-DHAVE_USIGN)
 ENDIF()
+IF(REQUIRE_UPGRADE_ARGS)
+	ADD_DEFINITIONS(-DREQUIRE_UPGRADE_ARGS)
+ENDIF()
 
 IF(WORDS_BIGENDIAN)
 	ADD_DEFINITIONS(-DWORDS_BIGENDIAN)
diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index c823df8..0a4180d 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -529,6 +529,19 @@ static int opkg_upgrade_cmd(int argc, char **argv)
 					err = -1;
 			}
 		}
+#if !defined(REQUIRE_UPGRADE_ARGS)
+	} else {
+		pkg_vec_t *installed = pkg_vec_alloc();
+
+		pkg_info_preinstall_check();
+		pkg_hash_fetch_all_installed(installed);
+		for (i = 0; i < installed->len; i++) {
+			pkg = installed->pkgs[i];
+			if (opkg_upgrade_pkg(pkg))
+				err = -1;
+		}
+		pkg_vec_free(installed);
+#endif
 	}
 
 	if (opkg_configure_packages(NULL))
@@ -1256,7 +1269,11 @@ static int opkg_print_architecture_cmd(int argc, char **argv)
 static opkg_cmd_t cmds[] = {
 	{"update", 0, (opkg_cmd_fun_t) opkg_update_cmd,
 	 PFM_DESCRIPTION | PFM_SOURCE},
+#if defined(REQUIRE_UPGRADE_ARGS)
 	{"upgrade", 1, (opkg_cmd_fun_t) opkg_upgrade_cmd,
+#else
+	{"upgrade", 0, (opkg_cmd_fun_t) opkg_upgrade_cmd,
+#endif
 	 PFM_DESCRIPTION | PFM_SOURCE},
 	{"list", 0, (opkg_cmd_fun_t) opkg_list_cmd, PFM_SOURCE},
 	{"list_installed", 0, (opkg_cmd_fun_t) opkg_list_installed_cmd,
diff --git a/src/opkg-cl.c b/src/opkg-cl.c
index a299514..6488e00 100644
--- a/src/opkg-cl.c
+++ b/src/opkg-cl.c
@@ -260,7 +260,11 @@ static void usage()
 	printf("\nPackage Manipulation:\n");
 	printf
 	    ("\tupdate			Update list of available packages\n");
+#if defined(REQUIRE_UPGRADE_ARGS)
 	printf("\tupgrade <pkgs>		Upgrade packages\n");
+#else
+	printf("\tupgrade			Upgrade packages\n");
+#endif
 	printf("\tinstall <pkgs>		Install package(s)\n");
 	printf("\tconfigure <pkgs>	Configure unpacked package(s)\n");
 	printf("\tremove <pkgs|regexp>	Remove package(s)\n");
-- 
2.11.0