diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2021-04-23 11:39:15 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2021-04-23 12:26:46 +0200 |
commit | 64127478630b676838735b509fec5cdfa36874c8 (patch) | |
tree | 1c7bd0e0fd4c51f1d5a40e65de90535db9ed4a39 | |
parent | 80dd1447595c536d31912c486ac5e96f983ccc7a (diff) |
2.3-only: Warn that the 0.1 protocol is deprecated
-rw-r--r-- | apt-private/private-json-hooks.cc | 1 | ||||
-rwxr-xr-x | test/integration/test-apt-cli-json-hooks | 18 |
2 files changed, 12 insertions, 7 deletions
diff --git a/apt-private/private-json-hooks.cc b/apt-private/private-json-hooks.cc index 957140525..acb9a3bf0 100644 --- a/apt-private/private-json-hooks.cc +++ b/apt-private/private-json-hooks.cc @@ -474,6 +474,7 @@ bool RunJsonHook(std::string const &option, std::string const &method, const cha if (strstr(line, "\"0.1\"")) { + _error->Warning("Hook %s uses deprecated 0.1 protocol", Opts->Value.c_str()); hookVersion = 0x010; } else if (strstr(line, "\"0.2\"")) diff --git a/test/integration/test-apt-cli-json-hooks b/test/integration/test-apt-cli-json-hooks index 59cf6e5ef..3ec470284 100755 --- a/test/integration/test-apt-cli-json-hooks +++ b/test/integration/test-apt-cli-json-hooks @@ -193,7 +193,7 @@ HOOK: BYE' apt dist-upgrade -s ################## version 0.1 ######################### TEST_HOOK_VERSION=0.1 -testsuccessequal 'Reading package lists... +testequal 'Reading package lists... Building dependency tree... Calculating upgrade... HOOK: HELLO @@ -224,7 +224,11 @@ HOOK: request {"jsonrpc":"2.0","method":"org.debian.apt.hooks.hello","id":0,"par HOOK: empty HOOK: request {"jsonrpc":"2.0","method":"org.debian.apt.hooks.install.post","params":{"command":"dist-upgrade","search-terms":[],"unknown-packages":[],"packages":[{"id":1,"name":"upgrade","architecture":"i386","mode":"install","automatic":false,"versions":{"candidate":{"id":1,"version":"2.0","architecture":"i386","pin":500,"origins":[{"archive":"testing","codename":"testing","origin":"Oranges","label":"Lemons","site":""}]},"install":{"id":1,"version":"2.0","architecture":"i386","pin":500,"origins":[{"archive":"testing","codename":"testing","origin":"Oranges","label":"Lemons","site":""}]},"current":{"id":4,"version":"1.0","architecture":"i386","pin":100,"origins":[]}}}]}} HOOK: empty -HOOK: BYE' apt dist-upgrade -s +HOOK: BYE +W: Hook '$HOOK' uses deprecated 0.1 protocol +W: Hook '$HOOK' uses deprecated 0.1 protocol +W: Hook '$HOOK' uses deprecated 0.1 protocol +W: Hook '$HOOK' uses deprecated 0.1 protocol' apt dist-upgrade -s ################## Wrong version ######################### @@ -256,7 +260,7 @@ while true; do read empty <&\$APT_HOOK_SOCKET if echo "\$request" | grep -q ".hello"; then - printf '{"jsonrpc": "2.0", "error": {"version": "0.1"}, "id": 0}\n\n' >&\$APT_HOOK_SOCKET + printf '{"jsonrpc": "2.0", "error": {"version": "0.2"}, "id": 0}\n\n' >&\$APT_HOOK_SOCKET break fi done @@ -266,8 +270,8 @@ EOF testfailureequal 'Reading package lists... Building dependency tree... -E: Hook '$HOOK' reported an error during hello: {"jsonrpc": "2.0", "error": {"version": "0.1"}, "id": 0} -E: Hook '$HOOK' reported an error during hello: {"jsonrpc": "2.0", "error": {"version": "0.1"}, "id": 0}' apt install foo -s +E: Hook '$HOOK' reported an error during hello: {"jsonrpc": "2.0", "error": {"version": "0.2"}, "id": 0} +E: Hook '$HOOK' reported an error during hello: {"jsonrpc": "2.0", "error": {"version": "0.2"}, "id": 0}' apt install foo -s ################## Missing separator line ######################### cat > json-hook.sh << EOF @@ -279,7 +283,7 @@ while true; do read empty <&\$APT_HOOK_SOCKET if echo "\$request" | grep -q ".hello"; then - printf '{"jsonrpc": "2.0", "result": {"version": "0.1"}, "id": 0}\n' >&\$APT_HOOK_SOCKET + printf '{"jsonrpc": "2.0", "result": {"version": "0.2"}, "id": 0}\n' >&\$APT_HOOK_SOCKET break fi done @@ -302,7 +306,7 @@ while true; do read empty <&\$APT_HOOK_SOCKET if echo "\$request" | grep -q ".hello"; then - printf '{"jsonrpc": "2.0", "result": {"version": "0.1"}, "id": 0}\nXX' >&\$APT_HOOK_SOCKET + printf '{"jsonrpc": "2.0", "result": {"version": "0.2"}, "id": 0}\nXX' >&\$APT_HOOK_SOCKET break fi done |