Adding d/p/24_check_apt_usage from upstream
This commit is contained in:
parent
c662b299a7
commit
95eeed8974
131
debian/patches/24_check_apt_usage
vendored
Normal file
131
debian/patches/24_check_apt_usage
vendored
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
From 0899e41f5075d661153eb2c77ace1734a8f66bfa Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
|
||||||
|
Date: Sun, 8 Jan 2023 17:23:53 +0100
|
||||||
|
Subject: [PATCH] Check apt usage (#1793)
|
||||||
|
|
||||||
|
* Remove trailing whitespaces
|
||||||
|
|
||||||
|
* Use real booleans
|
||||||
|
|
||||||
|
* Fix comment
|
||||||
|
|
||||||
|
* Put upgrade options in the root sections
|
||||||
|
|
||||||
|
Co-authored-by: waja <waja@users.noreply.github.com>
|
||||||
|
---
|
||||||
|
plugins/check_apt.c | 40 ++++++++++++++++++++--------------------
|
||||||
|
1 file changed, 20 insertions(+), 20 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
|
||||||
|
index af3563a14..312909b7f 100644
|
||||||
|
--- a/plugins/check_apt.c
|
||||||
|
+++ b/plugins/check_apt.c
|
||||||
|
@@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
|
||||||
|
|
||||||
|
/* configuration variables */
|
||||||
|
static int verbose = 0; /* -v */
|
||||||
|
-static int list = 0; /* list packages available for upgrade */
|
||||||
|
-static int do_update = 0; /* whether to call apt-get update */
|
||||||
|
-static int only_critical = 0; /* whether to warn about non-critical updates */
|
||||||
|
+static bool list = false; /* list packages available for upgrade */
|
||||||
|
+static bool do_update = false; /* whether to call apt-get update */
|
||||||
|
+static bool only_critical = false; /* whether to warn about non-critical updates */
|
||||||
|
static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
|
||||||
|
static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
|
||||||
|
static char *update_opts = NULL; /* options to override defaults for update */
|
||||||
|
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
|
||||||
|
|
||||||
|
if(sec_count > 0){
|
||||||
|
result = max_state(result, STATE_CRITICAL);
|
||||||
|
- } else if(packages_available >= packages_warning && only_critical == 0){
|
||||||
|
+ } else if(packages_available >= packages_warning && only_critical == false){
|
||||||
|
result = max_state(result, STATE_WARNING);
|
||||||
|
} else if(result > STATE_UNKNOWN){
|
||||||
|
result = STATE_UNKNOWN;
|
||||||
|
@@ -144,7 +144,7 @@ int main (int argc, char **argv) {
|
||||||
|
|
||||||
|
for(i = 0; i < sec_count; i++)
|
||||||
|
printf("%s (security)\n", secpackages_list[i]);
|
||||||
|
- if (only_critical == 0) {
|
||||||
|
+ if (only_critical == false) {
|
||||||
|
for(i = 0; i < packages_available - sec_count; i++)
|
||||||
|
printf("%s\n", packages_list[i]);
|
||||||
|
}
|
||||||
|
@@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
|
||||||
|
{"upgrade", optional_argument, 0, 'U'},
|
||||||
|
{"no-upgrade", no_argument, 0, 'n'},
|
||||||
|
{"dist-upgrade", optional_argument, 0, 'd'},
|
||||||
|
- {"list", no_argument, 0, 'l'},
|
||||||
|
+ {"list", no_argument, false, 'l'},
|
||||||
|
{"include", required_argument, 0, 'i'},
|
||||||
|
{"exclude", required_argument, 0, 'e'},
|
||||||
|
{"critical", required_argument, 0, 'c'},
|
||||||
|
@@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
|
||||||
|
upgrade=NO_UPGRADE;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
- do_update=1;
|
||||||
|
+ do_update=true;
|
||||||
|
if(optarg!=NULL){
|
||||||
|
update_opts=strdup(optarg);
|
||||||
|
if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
- list=1;
|
||||||
|
+ list=true;
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
do_include=add_to_regexp(do_include, optarg);
|
||||||
|
@@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
|
||||||
|
do_critical=add_to_regexp(do_critical, optarg);
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
- only_critical=1;
|
||||||
|
+ only_critical=true;
|
||||||
|
break;
|
||||||
|
case INPUT_FILE_OPT:
|
||||||
|
input_filename = optarg;
|
||||||
|
@@ -371,7 +371,7 @@ int run_update(void){
|
||||||
|
struct output chld_out, chld_err;
|
||||||
|
char *cmdline;
|
||||||
|
|
||||||
|
- /* run the upgrade */
|
||||||
|
+ /* run the update */
|
||||||
|
cmdline = construct_cmdline(NO_UPGRADE, update_opts);
|
||||||
|
result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
|
||||||
|
/* apt-get update changes exit status if it can't fetch packages.
|
||||||
|
@@ -501,16 +501,6 @@ print_help (void)
|
||||||
|
|
||||||
|
printf(UT_PLUG_TIMEOUT, timeout_interval);
|
||||||
|
|
||||||
|
- printf (" %s\n", "-U, --upgrade=OPTS");
|
||||||
|
- printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
|
||||||
|
- printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
|
||||||
|
- printf (" %s", _("default "));
|
||||||
|
- printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
|
||||||
|
- printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
|
||||||
|
- printf (" %s\n", _("the default options."));
|
||||||
|
- printf (" %s\n", "-d, --dist-upgrade=OPTS");
|
||||||
|
- printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
|
||||||
|
- printf (" %s\n", _("can be provided to override the default options."));
|
||||||
|
printf (" %s\n", "-n, --no-upgrade");
|
||||||
|
printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
|
||||||
|
printf (" %s\n", "-l, --list");
|
||||||
|
@@ -547,6 +537,16 @@ print_help (void)
|
||||||
|
printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
|
||||||
|
printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
|
||||||
|
printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
|
||||||
|
+ printf (" %s\n", "-U, --upgrade=OPTS");
|
||||||
|
+ printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
|
||||||
|
+ printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
|
||||||
|
+ printf (" %s", _("default "));
|
||||||
|
+ printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
|
||||||
|
+ printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
|
||||||
|
+ printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
|
||||||
|
+ printf (" %s\n", "-d, --dist-upgrade=OPTS");
|
||||||
|
+ printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
|
||||||
|
+ printf (" %s\n", _("can be provided to override the default options."));
|
||||||
|
|
||||||
|
printf(UT_SUPPORT);
|
||||||
|
}
|
1
debian/patches/series
vendored
1
debian/patches/series
vendored
|
@ -11,3 +11,4 @@
|
||||||
20_check_apt_unknown_escape_sequence
|
20_check_apt_unknown_escape_sequence
|
||||||
21_check_http_faster_with_large_files
|
21_check_http_faster_with_large_files
|
||||||
22_check_curl_faster_with_large_files
|
22_check_curl_faster_with_large_files
|
||||||
|
24_check_apt_usage
|
||||||
|
|
Loading…
Reference in a new issue