From d82dd0a91f44d75cff74f23c8012e221fbd69f4b Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 6 Sep 2023 13:22:23 +0200 Subject: [PATCH 1/5] Add skip_pre_uninstall parameter to gRPC platform requests --- rpc/cc/arduino/cli/commands/v1/core.pb.go | 251 +++++++++++++--------- rpc/cc/arduino/cli/commands/v1/core.proto | 9 + 2 files changed, 154 insertions(+), 106 deletions(-) diff --git a/rpc/cc/arduino/cli/commands/v1/core.pb.go b/rpc/cc/arduino/cli/commands/v1/core.pb.go index b02ce998be1..42871130dae 100644 --- a/rpc/cc/arduino/cli/commands/v1/core.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/core.pb.go @@ -54,6 +54,9 @@ type PlatformInstallRequest struct { // Set to true to skip installation if a different version of the platform // is already installed. NoOverwrite bool `protobuf:"varint,6,opt,name=no_overwrite,json=noOverwrite,proto3" json:"no_overwrite,omitempty"` + // Set to true to not run (eventual) pre uninstall scripts for trusted + // platforms when performing platform upgrades + SkipPreUninstall bool `protobuf:"varint,7,opt,name=skip_pre_uninstall,json=skipPreUninstall,proto3" json:"skip_pre_uninstall,omitempty"` } func (x *PlatformInstallRequest) Reset() { @@ -130,6 +133,13 @@ func (x *PlatformInstallRequest) GetNoOverwrite() bool { return false } +func (x *PlatformInstallRequest) GetSkipPreUninstall() bool { + if x != nil { + return x.SkipPreUninstall + } + return false +} + type PlatformInstallResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -358,6 +368,9 @@ type PlatformUninstallRequest struct { PlatformPackage string `protobuf:"bytes,2,opt,name=platform_package,json=platformPackage,proto3" json:"platform_package,omitempty"` // Architecture name of the platform (e.g., `avr`). Architecture string `protobuf:"bytes,3,opt,name=architecture,proto3" json:"architecture,omitempty"` + // Set to true to not run (eventual) pre uninstall scripts for trusted + // platforms + SkipPreUninstall bool `protobuf:"varint,4,opt,name=skip_pre_uninstall,json=skipPreUninstall,proto3" json:"skip_pre_uninstall,omitempty"` } func (x *PlatformUninstallRequest) Reset() { @@ -413,6 +426,13 @@ func (x *PlatformUninstallRequest) GetArchitecture() string { return "" } +func (x *PlatformUninstallRequest) GetSkipPreUninstall() bool { + if x != nil { + return x.SkipPreUninstall + } + return false +} + type PlatformUninstallResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -515,6 +535,9 @@ type PlatformUpgradeRequest struct { // Set to true to not run (eventual) post install scripts for trusted // platforms SkipPostInstall bool `protobuf:"varint,4,opt,name=skip_post_install,json=skipPostInstall,proto3" json:"skip_post_install,omitempty"` + // Set to true to not run (eventual) pre uninstall scripts for trusted + // platforms when performing platform upgrades + SkipPreUninstall bool `protobuf:"varint,5,opt,name=skip_pre_uninstall,json=skipPreUninstall,proto3" json:"skip_pre_uninstall,omitempty"` } func (x *PlatformUpgradeRequest) Reset() { @@ -577,6 +600,13 @@ func (x *PlatformUpgradeRequest) GetSkipPostInstall() bool { return false } +func (x *PlatformUpgradeRequest) GetSkipPreUninstall() bool { + if x != nil { + return x.SkipPreUninstall + } + return false +} + type PlatformUpgradeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -884,7 +914,7 @@ var file_cc_arduino_cli_commands_v1_core_proto_rawDesc = []byte{ 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x27, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x02, 0x0a, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc0, 0x02, 0x0a, 0x16, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, @@ -902,40 +932,24 @@ var file_cc_arduino_cli_commands_v1_core_proto_rawDesc = []byte{ 0x6b, 0x69, 0x70, 0x50, 0x6f, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x6f, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x4f, 0x76, 0x65, 0x72, 0x77, 0x72, 0x69, 0x74, - 0x65, 0x22, 0xb2, 0x01, 0x0a, 0x17, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, - 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x2c, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, - 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x4d, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x5f, - 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, - 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, - 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0c, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x72, - 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x16, 0x0a, 0x14, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, - 0x72, 0x6d, 0x4c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xc4, - 0x01, 0x0a, 0x17, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x6c, - 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, + 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x75, 0x6e, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, + 0x6b, 0x69, 0x70, 0x50, 0x72, 0x65, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x22, + 0xb2, 0x01, 0x0a, 0x17, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, + 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, + 0x6f, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x08, 0x70, 0x72, 0x6f, + 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x4d, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x72, + 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x29, 0x0a, 0x10, - 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, - 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, - 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, - 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x64, 0x0a, 0x18, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x48, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, - 0x73, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0xab, 0x01, 0x0a, 0x18, - 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, - 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x72, + 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0c, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, + 0x72, 0x65, 0x73, 0x73, 0x22, 0x16, 0x0a, 0x14, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, + 0x4c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xc4, 0x01, 0x0a, + 0x17, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, @@ -944,82 +958,107 @@ var file_cc_arduino_cli_commands_v1_core_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, - 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x22, 0x6a, 0x0a, 0x19, 0x50, 0x6c, 0x61, - 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x70, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, - 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x50, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0c, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, - 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x41, 0x6c, 0x72, 0x65, 0x61, 0x64, 0x79, - 0x41, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x22, 0xd5, 0x01, 0x0a, 0x16, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, - 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x70, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x6c, 0x61, - 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, - 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, - 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x70, 0x6f, 0x73, 0x74, 0x5f, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x73, 0x6b, 0x69, - 0x70, 0x50, 0x6f, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x22, 0xf4, 0x01, 0x0a, - 0x17, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x63, 0x2e, - 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, - 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x4d, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x67, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, + 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x22, 0x64, 0x0a, 0x18, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x44, + 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x48, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, + 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, + 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0xd9, 0x01, 0x0a, 0x18, 0x50, 0x6c, + 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, + 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, + 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, + 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x6b, 0x69, 0x70, 0x5f, + 0x70, 0x72, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x6b, 0x69, 0x70, 0x50, 0x72, 0x65, 0x55, 0x6e, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x22, 0x6a, 0x0a, 0x19, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, + 0x6d, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0c, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, - 0x73, 0x12, 0x40, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, - 0x6f, 0x72, 0x6d, 0x22, 0x9d, 0x01, 0x0a, 0x15, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, - 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, - 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, - 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x6c, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x6c, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x22, 0x63, 0x0a, 0x16, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, - 0x0d, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x41, 0x6c, 0x72, 0x65, 0x61, 0x64, 0x79, 0x41, 0x74, 0x4c, 0x61, + 0x74, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x22, 0x83, 0x02, 0x0a, 0x16, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x55, 0x70, 0x67, + 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, + 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x29, 0x0a, + 0x10, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, + 0x6d, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, + 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2a, 0x0a, 0x11, + 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x70, 0x6f, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x73, 0x6b, 0x69, 0x70, 0x50, 0x6f, 0x73, + 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x6b, 0x69, 0x70, + 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x6b, 0x69, 0x70, 0x50, 0x72, 0x65, 0x55, 0x6e, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x22, 0xf4, 0x01, 0x0a, 0x17, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x0c, 0x73, 0x65, 0x61, 0x72, - 0x63, 0x68, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x90, 0x01, 0x0a, 0x13, 0x50, 0x6c, 0x61, - 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, - 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, - 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x61, 0x6c, 0x6c, 0x22, 0x6d, 0x0a, 0x14, 0x50, - 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, - 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, - 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, - 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, - 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, - 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, + 0x73, 0x73, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x4d, 0x0a, 0x0d, + 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x52, 0x0c, 0x74, + 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x40, 0x0a, 0x08, 0x70, + 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, + 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x22, 0x9d, 0x01, + 0x0a, 0x15, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, + 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, + 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x6c, + 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0b, 0x61, 0x6c, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x63, 0x0a, + 0x16, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0d, 0x73, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, + 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x0c, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4f, 0x75, 0x74, 0x70, + 0x75, 0x74, 0x22, 0x90, 0x01, 0x0a, 0x13, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x0e, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4f, + 0x6e, 0x6c, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x03, 0x61, 0x6c, 0x6c, 0x22, 0x6d, 0x0a, 0x14, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, + 0x6d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, + 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, + 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, + 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x73, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, + 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/rpc/cc/arduino/cli/commands/v1/core.proto b/rpc/cc/arduino/cli/commands/v1/core.proto index d52251f470a..70ec4d46886 100644 --- a/rpc/cc/arduino/cli/commands/v1/core.proto +++ b/rpc/cc/arduino/cli/commands/v1/core.proto @@ -36,6 +36,9 @@ message PlatformInstallRequest { // Set to true to skip installation if a different version of the platform // is already installed. bool no_overwrite = 6; + // Set to true to not run (eventual) pre uninstall scripts for trusted + // platforms when performing platform upgrades + bool skip_pre_uninstall = 7; } message PlatformInstallResponse { @@ -69,6 +72,9 @@ message PlatformUninstallRequest { string platform_package = 2; // Architecture name of the platform (e.g., `avr`). string architecture = 3; + // Set to true to not run (eventual) pre uninstall scripts for trusted + // platforms + bool skip_pre_uninstall = 4; } message PlatformUninstallResponse { @@ -90,6 +96,9 @@ message PlatformUpgradeRequest { // Set to true to not run (eventual) post install scripts for trusted // platforms bool skip_post_install = 4; + // Set to true to not run (eventual) pre uninstall scripts for trusted + // platforms when performing platform upgrades + bool skip_pre_uninstall = 5; } message PlatformUpgradeResponse { From e0f0051309b80a8318473796d7cd245a82506710 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 6 Sep 2023 13:45:00 +0200 Subject: [PATCH 2/5] Add pre-uninstall flags to CLI arguments --- .../{post_install.go => pre_post_script.go} | 49 ++++++++++++++++--- internal/cli/core/install.go | 4 +- internal/cli/core/upgrade.go | 2 +- internal/cli/upgrade/upgrade.go | 2 +- 4 files changed, 45 insertions(+), 12 deletions(-) rename internal/cli/arguments/{post_install.go => pre_post_script.go} (52%) diff --git a/internal/cli/arguments/post_install.go b/internal/cli/arguments/pre_post_script.go similarity index 52% rename from internal/cli/arguments/post_install.go rename to internal/cli/arguments/pre_post_script.go index a98f6dc982b..99a54e02d94 100644 --- a/internal/cli/arguments/post_install.go +++ b/internal/cli/arguments/pre_post_script.go @@ -21,33 +21,47 @@ import ( "github.com/spf13/cobra" ) -// PostInstallFlags contains flags data used by the core install and the upgrade command +// PrePostScriptsFlags contains flags data used by the core install and the upgrade command // This is useful so all flags used by commands that need // this information are consistent with each other. -type PostInstallFlags struct { - runPostInstall bool // force the execution of installation scripts - skipPostInstall bool // skip the execution of installation scripts +type PrePostScriptsFlags struct { + runPostInstall bool // force the execution of installation scripts + skipPostInstall bool // skip the execution of installation scripts + runPreUninstall bool // force the execution of pre uninstall scripts + skipPreUninstall bool // skip the execution of pre uninstall scripts } // AddToCommand adds flags that can be used to force running or skipping // of post installation scripts -func (p *PostInstallFlags) AddToCommand(cmd *cobra.Command) { +func (p *PrePostScriptsFlags) AddToCommand(cmd *cobra.Command) { cmd.Flags().BoolVar(&p.runPostInstall, "run-post-install", false, tr("Force run of post-install scripts (if the CLI is not running interactively).")) cmd.Flags().BoolVar(&p.skipPostInstall, "skip-post-install", false, tr("Force skip of post-install scripts (if the CLI is running interactively).")) + cmd.Flags().BoolVar(&p.runPreUninstall, "run-pre-uninstall", false, tr("Force run of pre-uninstall scripts (if the CLI is not running interactively).")) + cmd.Flags().BoolVar(&p.skipPreUninstall, "skip-pre-uninstall", false, tr("Force skip of pre-uninstall scripts (if the CLI is running interactively).")) } // GetRunPostInstall returns the run-post-install flag value -func (p *PostInstallFlags) GetRunPostInstall() bool { +func (p *PrePostScriptsFlags) GetRunPostInstall() bool { return p.runPostInstall } // GetSkipPostInstall returns the skip-post-install flag value -func (p *PostInstallFlags) GetSkipPostInstall() bool { +func (p *PrePostScriptsFlags) GetSkipPostInstall() bool { return p.skipPostInstall } +// GetRunPreUninstall returns the run-post-install flag value +func (p *PrePostScriptsFlags) GetRunPreUninstall() bool { + return p.runPreUninstall +} + +// GetSkipPreUninstall returns the skip-post-install flag value +func (p *PrePostScriptsFlags) GetSkipPreUninstall() bool { + return p.skipPreUninstall +} + // DetectSkipPostInstallValue returns true if a post install script must be run -func (p *PostInstallFlags) DetectSkipPostInstallValue() bool { +func (p *PrePostScriptsFlags) DetectSkipPostInstallValue() bool { if p.GetRunPostInstall() { logrus.Info("Will run post-install by user request") return false @@ -64,3 +78,22 @@ func (p *PostInstallFlags) DetectSkipPostInstallValue() bool { logrus.Info("Running from console, will run post-install by default") return false } + +// DetectSkipPreUninstallValue returns true if a post install script must be run +func (p *PrePostScriptsFlags) DetectSkipPreUninstallValue() bool { + if p.GetRunPreUninstall() { + logrus.Info("Will run pre-uninstall by user request") + return false + } + if p.GetSkipPreUninstall() { + logrus.Info("Will skip pre-uninstall by user request") + return true + } + + if !configuration.IsInteractive { + logrus.Info("Not running from console, will skip pre-uninstall by default") + return true + } + logrus.Info("Running from console, will run pre-uninstall by default") + return false +} diff --git a/internal/cli/core/install.go b/internal/cli/core/install.go index 9aa367740c5..507819d286d 100644 --- a/internal/cli/core/install.go +++ b/internal/cli/core/install.go @@ -31,7 +31,7 @@ import ( func initInstallCommand() *cobra.Command { var noOverwrite bool - var postInstallFlags arguments.PostInstallFlags + var postInstallFlags arguments.PrePostScriptsFlags installCommand := &cobra.Command{ Use: fmt.Sprintf("install %s:%s[@%s]...", tr("PACKAGER"), tr("ARCH"), tr("VERSION")), Short: tr("Installs one or more cores and corresponding tool dependencies."), @@ -56,7 +56,7 @@ func initInstallCommand() *cobra.Command { return installCommand } -func runInstallCommand(args []string, postInstallFlags arguments.PostInstallFlags, noOverwrite bool) { +func runInstallCommand(args []string, postInstallFlags arguments.PrePostScriptsFlags, noOverwrite bool) { inst := instance.CreateAndInit() logrus.Info("Executing `arduino-cli core install`") diff --git a/internal/cli/core/upgrade.go b/internal/cli/core/upgrade.go index 7324fce12be..afeb3623796 100644 --- a/internal/cli/core/upgrade.go +++ b/internal/cli/core/upgrade.go @@ -32,7 +32,7 @@ import ( ) func initUpgradeCommand() *cobra.Command { - var postInstallFlags arguments.PostInstallFlags + var postInstallFlags arguments.PrePostScriptsFlags upgradeCommand := &cobra.Command{ Use: fmt.Sprintf("upgrade [%s:%s] ...", tr("PACKAGER"), tr("ARCH")), Short: tr("Upgrades one or all installed platforms to the latest version."), diff --git a/internal/cli/upgrade/upgrade.go b/internal/cli/upgrade/upgrade.go index 0cc93735d43..84943414e00 100644 --- a/internal/cli/upgrade/upgrade.go +++ b/internal/cli/upgrade/upgrade.go @@ -31,7 +31,7 @@ var tr = i18n.Tr // NewCommand creates a new `upgrade` command func NewCommand() *cobra.Command { - var postInstallFlags arguments.PostInstallFlags + var postInstallFlags arguments.PrePostScriptsFlags upgradeCommand := &cobra.Command{ Use: "upgrade", Short: tr("Upgrades installed cores and libraries."), From 4b1eac3d5032a208e8254dce7865f446b45af53b Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 6 Sep 2023 14:01:59 +0200 Subject: [PATCH 3/5] Run pre-uninstall script when a platform or tool is uninstalled --- .../cores/packagemanager/install_uninstall.go | 63 ++++++++++++++----- .../packagemanager/package_manager_test.go | 2 +- commands/core/install.go | 2 +- commands/core/uninstall.go | 4 +- commands/core/upgrade.go | 3 +- internal/cli/core/install.go | 21 ++++--- internal/cli/core/uninstall.go | 15 +++-- internal/cli/core/upgrade.go | 17 ++--- internal/cli/upgrade/upgrade.go | 6 +- 9 files changed, 85 insertions(+), 48 deletions(-) diff --git a/arduino/cores/packagemanager/install_uninstall.go b/arduino/cores/packagemanager/install_uninstall.go index 73a75c7b00d..fb34d3971c9 100644 --- a/arduino/cores/packagemanager/install_uninstall.go +++ b/arduino/cores/packagemanager/install_uninstall.go @@ -38,6 +38,7 @@ func (pme *Explorer) DownloadAndInstallPlatformUpgrades( downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB, skipPostInstall bool, + skipPreUninstall bool, ) (*cores.PlatformRelease, error) { if platformRef.PlatformVersion != nil { return nil, &arduino.InvalidArgumentError{Message: tr("Upgrade doesn't accept parameters with version")} @@ -62,7 +63,7 @@ func (pme *Explorer) DownloadAndInstallPlatformUpgrades( if err != nil { return nil, &arduino.PlatformNotFoundError{Platform: platformRef.String()} } - if err := pme.DownloadAndInstallPlatformAndTools(platformRelease, tools, downloadCB, taskCB, skipPostInstall); err != nil { + if err := pme.DownloadAndInstallPlatformAndTools(platformRelease, tools, downloadCB, taskCB, skipPostInstall, skipPreUninstall); err != nil { return nil, err } @@ -75,7 +76,7 @@ func (pme *Explorer) DownloadAndInstallPlatformUpgrades( func (pme *Explorer) DownloadAndInstallPlatformAndTools( platformRelease *cores.PlatformRelease, requiredTools []*cores.ToolRelease, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB, - skipPostInstall bool) error { + skipPostInstall bool, skipPreUninstall bool) error { log := pme.log.WithField("platform", platformRelease) // Prerequisite checks before install @@ -142,7 +143,7 @@ func (pme *Explorer) DownloadAndInstallPlatformAndTools( // If upgrading remove previous release if installed != nil { - uninstallErr := pme.UninstallPlatform(installed, taskCB) + uninstallErr := pme.UninstallPlatform(installed, taskCB, skipPreUninstall) // In case of error try to rollback if uninstallErr != nil { @@ -150,7 +151,7 @@ func (pme *Explorer) DownloadAndInstallPlatformAndTools( taskCB(&rpc.TaskProgress{Message: tr("Error upgrading platform: %s", uninstallErr)}) // Rollback - if err := pme.UninstallPlatform(platformRelease, taskCB); err != nil { + if err := pme.UninstallPlatform(platformRelease, taskCB, skipPreUninstall); err != nil { log.WithError(err).Error("Error rolling-back changes.") taskCB(&rpc.TaskProgress{Message: tr("Error rolling-back changes: %s", err)}) } @@ -162,7 +163,7 @@ func (pme *Explorer) DownloadAndInstallPlatformAndTools( for _, tool := range installedTools { taskCB(&rpc.TaskProgress{Name: tr("Uninstalling %s, tool is no more required", tool)}) if !pme.IsToolRequired(tool) { - pme.UninstallTool(tool, taskCB) + pme.UninstallTool(tool, taskCB, skipPreUninstall) } } @@ -175,7 +176,7 @@ func (pme *Explorer) DownloadAndInstallPlatformAndTools( if !platformRelease.IsInstalled() { return errors.New(tr("platform not installed")) } - stdout, stderr, err := pme.RunPostInstallScript(platformRelease.InstallDir) + stdout, stderr, err := pme.RunPreOrPostScript(platformRelease.InstallDir, "post_install") skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stdout), Completed: true}) skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stderr), Completed: true}) if err != nil { @@ -229,16 +230,16 @@ func (pme *Explorer) cacheInstalledJSON(platformRelease *cores.PlatformRelease) return nil } -// RunPostInstallScript runs the post_install.sh (or post_install.bat) script for the -// specified platformRelease or toolRelease. -func (pme *Explorer) RunPostInstallScript(installDir *paths.Path) ([]byte, []byte, error) { - postInstallFilename := "post_install.sh" +// RunPreOrPostScript runs either the post_install.sh (or post_install.bat) or the pre_uninstall.sh (or pre_uninstall.bat) +// script for the specified platformRelease or toolRelease. +func (pme *Explorer) RunPreOrPostScript(installDir *paths.Path, prefix string) ([]byte, []byte, error) { + scriptFilename := prefix + ".sh" if runtime.GOOS == "windows" { - postInstallFilename = "post_install.bat" + scriptFilename = prefix + ".bat" } - postInstall := installDir.Join(postInstallFilename) - if postInstall.Exist() && postInstall.IsNotDir() { - cmd, err := executils.NewProcessFromPath(pme.GetEnvVarsForSpawnedProcess(), postInstall) + script := installDir.Join(scriptFilename) + if script.Exist() && script.IsNotDir() { + cmd, err := executils.NewProcessFromPath(pme.GetEnvVarsForSpawnedProcess(), script) if err != nil { return []byte{}, []byte{}, err } @@ -270,7 +271,7 @@ func (pme *Explorer) IsManagedPlatformRelease(platformRelease *cores.PlatformRel } // UninstallPlatform remove a PlatformRelease. -func (pme *Explorer) UninstallPlatform(platformRelease *cores.PlatformRelease, taskCB rpc.TaskProgressCB) error { +func (pme *Explorer) UninstallPlatform(platformRelease *cores.PlatformRelease, taskCB rpc.TaskProgressCB, skipPreUninstall bool) error { log := pme.log.WithField("platform", platformRelease) log.Info("Uninstalling platform") @@ -289,6 +290,20 @@ func (pme *Explorer) UninstallPlatform(platformRelease *cores.PlatformRelease, t return &arduino.FailedUninstallError{Message: err.Error()} } + if !skipPreUninstall { + log.Info("Running pre_uninstall script") + taskCB(&rpc.TaskProgress{Message: tr("Running pre_uninstall script.")}) + stdout, stderr, err := pme.RunPreOrPostScript(platformRelease.InstallDir, "pre_uninstall") + skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stdout), Completed: true}) + skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stderr), Completed: true}) + if err != nil { + taskCB(&rpc.TaskProgress{Message: tr("WARNING cannot run pre_uninstall script: %s", err), Completed: true}) + } + } else { + log.Info("Skipping pre_uninstall script.") + taskCB(&rpc.TaskProgress{Message: tr("Skipping pre_uninstall script.")}) + } + if err := platformRelease.InstallDir.RemoveAll(); err != nil { err = fmt.Errorf(tr("removing platform files: %s"), err) log.WithError(err).Error("Error uninstalling") @@ -339,7 +354,7 @@ func (pme *Explorer) InstallTool(toolRelease *cores.ToolRelease, taskCB rpc.Task if !skipPostInstall { log.Info("Running tool post_install script") taskCB(&rpc.TaskProgress{Message: tr("Configuring tool.")}) - stdout, stderr, err := pme.RunPostInstallScript(toolRelease.InstallDir) + stdout, stderr, err := pme.RunPreOrPostScript(toolRelease.InstallDir, "post_install") skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stdout)}) skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stderr)}) if err != nil { @@ -373,7 +388,7 @@ func (pme *Explorer) IsManagedToolRelease(toolRelease *cores.ToolRelease) bool { } // UninstallTool remove a ToolRelease. -func (pme *Explorer) UninstallTool(toolRelease *cores.ToolRelease, taskCB rpc.TaskProgressCB) error { +func (pme *Explorer) UninstallTool(toolRelease *cores.ToolRelease, taskCB rpc.TaskProgressCB, skipPreUninstall bool) error { log := pme.log.WithField("Tool", toolRelease) log.Info("Uninstalling tool") @@ -388,6 +403,20 @@ func (pme *Explorer) UninstallTool(toolRelease *cores.ToolRelease, taskCB rpc.Ta return err } + if !skipPreUninstall { + log.Info("Running pre_uninstall script") + taskCB(&rpc.TaskProgress{Message: tr("Running pre_uninstall script.")}) + stdout, stderr, err := pme.RunPreOrPostScript(toolRelease.InstallDir, "pre_uninstall") + skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stdout), Completed: true}) + skipEmptyMessageTaskProgressCB(taskCB)(&rpc.TaskProgress{Message: string(stderr), Completed: true}) + if err != nil { + taskCB(&rpc.TaskProgress{Message: tr("WARNING cannot run pre_uninstall script: %s", err), Completed: true}) + } + } else { + log.Info("Skipping pre_uninstall script.") + taskCB(&rpc.TaskProgress{Message: tr("Skipping pre_uninstall script.")}) + } + if err := toolRelease.InstallDir.RemoveAll(); err != nil { err = &arduino.FailedUninstallError{Message: err.Error()} log.WithError(err).Error("Error uninstalling") diff --git a/arduino/cores/packagemanager/package_manager_test.go b/arduino/cores/packagemanager/package_manager_test.go index 92d064e65cf..8c04d052b1b 100644 --- a/arduino/cores/packagemanager/package_manager_test.go +++ b/arduino/cores/packagemanager/package_manager_test.go @@ -949,7 +949,7 @@ func TestRunPostInstall(t *testing.T) { require.NoError(t, err) err = os.Chmod(scriptPath.String(), 0777) require.NoError(t, err) - stdout, stderr, err := pme.RunPostInstallScript(dir) + stdout, stderr, err := pme.RunPreOrPostScript(dir, "post_install") require.NoError(t, err) // `HasPrefix` because windows seem to add a trailing space at the end diff --git a/commands/core/install.go b/commands/core/install.go index 7eb0383aa09..20525ec58ae 100644 --- a/commands/core/install.go +++ b/commands/core/install.go @@ -63,7 +63,7 @@ func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallRequest, downl } } - if err := pme.DownloadAndInstallPlatformAndTools(platformRelease, tools, downloadCB, taskCB, req.GetSkipPostInstall()); err != nil { + if err := pme.DownloadAndInstallPlatformAndTools(platformRelease, tools, downloadCB, taskCB, req.GetSkipPostInstall(), req.GetSkipPreUninstall()); err != nil { return err } diff --git a/commands/core/uninstall.go b/commands/core/uninstall.go index 165b1fc16ea..3bdbf85fbcc 100644 --- a/commands/core/uninstall.go +++ b/commands/core/uninstall.go @@ -64,14 +64,14 @@ func platformUninstall(ctx context.Context, req *rpc.PlatformUninstallRequest, t return &arduino.NotFoundError{Message: tr("Can't find dependencies for platform %s", ref), Cause: err} } - if err := pme.UninstallPlatform(platform, taskCB); err != nil { + if err := pme.UninstallPlatform(platform, taskCB, req.GetSkipPreUninstall()); err != nil { return err } for _, tool := range tools { if !pme.IsToolRequired(tool) { taskCB(&rpc.TaskProgress{Name: tr("Uninstalling %s, tool is no more required", tool)}) - pme.UninstallTool(tool, taskCB) + pme.UninstallTool(tool, taskCB, req.GetSkipPreUninstall()) } } diff --git a/commands/core/upgrade.go b/commands/core/upgrade.go index ee8f4b0a3f7..49b81e68488 100644 --- a/commands/core/upgrade.go +++ b/commands/core/upgrade.go @@ -17,6 +17,7 @@ package core import ( "context" + "github.com/arduino/arduino-cli/arduino/cores" "github.com/arduino/arduino-cli/arduino" @@ -39,7 +40,7 @@ func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeRequest, downl Package: req.PlatformPackage, PlatformArchitecture: req.Architecture, } - platform, err := pme.DownloadAndInstallPlatformUpgrades(ref, downloadCB, taskCB, req.GetSkipPostInstall()) + platform, err := pme.DownloadAndInstallPlatformUpgrades(ref, downloadCB, taskCB, req.GetSkipPostInstall(), req.GetSkipPreUninstall()) if err != nil { return platform, err } diff --git a/internal/cli/core/install.go b/internal/cli/core/install.go index 507819d286d..8193a8b4344 100644 --- a/internal/cli/core/install.go +++ b/internal/cli/core/install.go @@ -31,7 +31,7 @@ import ( func initInstallCommand() *cobra.Command { var noOverwrite bool - var postInstallFlags arguments.PrePostScriptsFlags + var scriptFlags arguments.PrePostScriptsFlags installCommand := &cobra.Command{ Use: fmt.Sprintf("install %s:%s[@%s]...", tr("PACKAGER"), tr("ARCH"), tr("VERSION")), Short: tr("Installs one or more cores and corresponding tool dependencies."), @@ -45,18 +45,18 @@ func initInstallCommand() *cobra.Command { arguments.CheckFlagsConflicts(cmd, "run-post-install", "skip-post-install") }, Run: func(cmd *cobra.Command, args []string) { - runInstallCommand(args, postInstallFlags, noOverwrite) + runInstallCommand(args, scriptFlags, noOverwrite) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return arguments.GetInstallableCores(), cobra.ShellCompDirectiveDefault }, } - postInstallFlags.AddToCommand(installCommand) + scriptFlags.AddToCommand(installCommand) installCommand.Flags().BoolVar(&noOverwrite, "no-overwrite", false, tr("Do not overwrite already installed platforms.")) return installCommand } -func runInstallCommand(args []string, postInstallFlags arguments.PrePostScriptsFlags, noOverwrite bool) { +func runInstallCommand(args []string, scriptFlags arguments.PrePostScriptsFlags, noOverwrite bool) { inst := instance.CreateAndInit() logrus.Info("Executing `arduino-cli core install`") @@ -67,12 +67,13 @@ func runInstallCommand(args []string, postInstallFlags arguments.PrePostScriptsF for _, platformRef := range platformsRefs { platformInstallRequest := &rpc.PlatformInstallRequest{ - Instance: inst, - PlatformPackage: platformRef.PackageName, - Architecture: platformRef.Architecture, - Version: platformRef.Version, - SkipPostInstall: postInstallFlags.DetectSkipPostInstallValue(), - NoOverwrite: noOverwrite, + Instance: inst, + PlatformPackage: platformRef.PackageName, + Architecture: platformRef.Architecture, + Version: platformRef.Version, + SkipPostInstall: scriptFlags.DetectSkipPostInstallValue(), + NoOverwrite: noOverwrite, + SkipPreUninstall: scriptFlags.DetectSkipPreUninstallValue(), } _, err := core.PlatformInstall(context.Background(), platformInstallRequest, feedback.ProgressBar(), feedback.TaskProgress()) if err != nil { diff --git a/internal/cli/core/uninstall.go b/internal/cli/core/uninstall.go index fb31d4ea1b5..10992ef9bdf 100644 --- a/internal/cli/core/uninstall.go +++ b/internal/cli/core/uninstall.go @@ -30,21 +30,25 @@ import ( ) func initUninstallCommand() *cobra.Command { + var preUninstallFlags arguments.PrePostScriptsFlags uninstallCommand := &cobra.Command{ Use: fmt.Sprintf("uninstall %s:%s ...", tr("PACKAGER"), tr("ARCH")), Short: tr("Uninstalls one or more cores and corresponding tool dependencies if no longer used."), Long: tr("Uninstalls one or more cores and corresponding tool dependencies if no longer used."), Example: " " + os.Args[0] + " core uninstall arduino:samd\n", Args: cobra.MinimumNArgs(1), - Run: runUninstallCommand, + Run: func(cmd *cobra.Command, args []string) { + runUninstallCommand(args, preUninstallFlags) + }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return arguments.GetUninstallableCores(), cobra.ShellCompDirectiveDefault }, } + preUninstallFlags.AddToCommand(uninstallCommand) return uninstallCommand } -func runUninstallCommand(cmd *cobra.Command, args []string) { +func runUninstallCommand(args []string, preUninstallFlags arguments.PrePostScriptsFlags) { inst := instance.CreateAndInit() logrus.Info("Executing `arduino-cli core uninstall`") @@ -60,9 +64,10 @@ func runUninstallCommand(cmd *cobra.Command, args []string) { } for _, platformRef := range platformsRefs { _, err := core.PlatformUninstall(context.Background(), &rpc.PlatformUninstallRequest{ - Instance: inst, - PlatformPackage: platformRef.PackageName, - Architecture: platformRef.Architecture, + Instance: inst, + PlatformPackage: platformRef.PackageName, + Architecture: platformRef.Architecture, + SkipPreUninstall: preUninstallFlags.DetectSkipPreUninstallValue(), }, feedback.NewTaskProgressCB()) if err != nil { feedback.Fatal(tr("Error during uninstall: %v", err), feedback.ErrGeneric) diff --git a/internal/cli/core/upgrade.go b/internal/cli/core/upgrade.go index afeb3623796..f8484dc985b 100644 --- a/internal/cli/core/upgrade.go +++ b/internal/cli/core/upgrade.go @@ -43,21 +43,21 @@ func initUpgradeCommand() *cobra.Command { " # " + tr("upgrade arduino:samd to the latest version") + "\n" + " " + os.Args[0] + " core upgrade arduino:samd", Run: func(cmd *cobra.Command, args []string) { - runUpgradeCommand(args, postInstallFlags.DetectSkipPostInstallValue()) + runUpgradeCommand(args, postInstallFlags.DetectSkipPostInstallValue(), postInstallFlags.DetectSkipPreUninstallValue()) }, } postInstallFlags.AddToCommand(upgradeCommand) return upgradeCommand } -func runUpgradeCommand(args []string, skipPostInstall bool) { +func runUpgradeCommand(args []string, skipPostInstall bool, skipPreUninstall bool) { inst := instance.CreateAndInit() logrus.Info("Executing `arduino-cli core upgrade`") - Upgrade(inst, args, skipPostInstall) + Upgrade(inst, args, skipPostInstall, skipPreUninstall) } // Upgrade upgrades one or all installed platforms to the latest version. -func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool) { +func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUninstall bool) { // if no platform was passed, upgrade allthethings if len(args) == 0 { targets, err := core.PlatformList(&rpc.PlatformListRequest{ @@ -102,10 +102,11 @@ func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool) { } r := &rpc.PlatformUpgradeRequest{ - Instance: inst, - PlatformPackage: platformRef.PackageName, - Architecture: platformRef.Architecture, - SkipPostInstall: skipPostInstall, + Instance: inst, + PlatformPackage: platformRef.PackageName, + Architecture: platformRef.Architecture, + SkipPostInstall: skipPostInstall, + SkipPreUninstall: skipPreUninstall, } response, err := core.PlatformUpgrade(context.Background(), r, feedback.ProgressBar(), feedback.TaskProgress()) warningMissingIndex(response) diff --git a/internal/cli/upgrade/upgrade.go b/internal/cli/upgrade/upgrade.go index 84943414e00..937abd845fa 100644 --- a/internal/cli/upgrade/upgrade.go +++ b/internal/cli/upgrade/upgrade.go @@ -39,16 +39,16 @@ func NewCommand() *cobra.Command { Example: " " + os.Args[0] + " upgrade", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - runUpgradeCommand(postInstallFlags.DetectSkipPostInstallValue()) + runUpgradeCommand(postInstallFlags.DetectSkipPostInstallValue(), postInstallFlags.DetectSkipPreUninstallValue()) }, } postInstallFlags.AddToCommand(upgradeCommand) return upgradeCommand } -func runUpgradeCommand(skipPostInstall bool) { +func runUpgradeCommand(skipPostInstall bool, skipPreUninstall bool) { inst := instance.CreateAndInit() logrus.Info("Executing `arduino-cli upgrade`") lib.Upgrade(inst, []string{}) - core.Upgrade(inst, []string{}, skipPostInstall) + core.Upgrade(inst, []string{}, skipPostInstall, skipPreUninstall) } From 59af039e60a56346594a4e7e896d6bf801ca0f4a Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Mon, 11 Sep 2023 16:18:28 +0200 Subject: [PATCH 4/5] Document the changes --- docs/platform-specification.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/platform-specification.md b/docs/platform-specification.md index 59031916c84..98921400f66 100644 --- a/docs/platform-specification.md +++ b/docs/platform-specification.md @@ -1559,3 +1559,21 @@ software is in use: - **Arduino CLI**: (since 0.12.0) runs the script for any installed platform when Arduino CLI is in "interactive" mode. This behavior [can be configured](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_core_install/#options) + +## Pre-uninstall script + +Before Boards Manager starts uninstalling a platform, it checks for the presence of a script named: + +- `pre_uninstall.bat` - when running on Windows +- `pre_uninstall.sh` - when running on any non-Windows operating system + +If present, the script is executed. + +This script may be used to configure the user's system for the removal of drivers, stopping background programs and +execute any action that should be performed before the platform files are removed. + +The circumstances under which the pre-uninstall script will run are different depending on which Arduino development +software is in use: + +- **Arduino CLI**: runs the script for any installed platform when Arduino CLI is in "interactive" mode. This behavior + [can be configured](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_core_install/#options) From cc4fc1615299b3d5c996ca5d9953ac0207ef466a Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 13 Sep 2023 16:10:14 +0200 Subject: [PATCH 5/5] Include pre-uninstall script run into the unit test --- .../packagemanager/package_manager_test.go | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/arduino/cores/packagemanager/package_manager_test.go b/arduino/cores/packagemanager/package_manager_test.go index 8c04d052b1b..c02fa34eaa6 100644 --- a/arduino/cores/packagemanager/package_manager_test.go +++ b/arduino/cores/packagemanager/package_manager_test.go @@ -921,7 +921,7 @@ func TestVariantAndCoreSelection(t *testing.T) { }) } -func TestRunPostInstall(t *testing.T) { +func TestRunScript(t *testing.T) { pmb := NewBuilder(nil, nil, nil, nil, "test") pm := pmb.Build() pme, release := pm.NewExplorer() @@ -930,29 +930,49 @@ func TestRunPostInstall(t *testing.T) { // prepare dummy post install script dir := paths.New(t.TempDir()) - var scriptPath *paths.Path - var err error - if runtime.GOOS == "windows" { - scriptPath = dir.Join("post_install.bat") - - err = scriptPath.WriteFile([]byte( - `@echo off - echo sent in stdout - echo sent in stderr 1>&2`)) - } else { - scriptPath = dir.Join("post_install.sh") - err = scriptPath.WriteFile([]byte( - `#!/bin/sh - echo "sent in stdout" - echo "sent in stderr" 1>&2`)) + type Test struct { + testName string + scriptName string + } + + tests := []Test{ + { + testName: "PostInstallScript", + scriptName: "post_install", + }, + { + testName: "PreUninstallScript", + scriptName: "pre_uninstall", + }, } - require.NoError(t, err) - err = os.Chmod(scriptPath.String(), 0777) - require.NoError(t, err) - stdout, stderr, err := pme.RunPreOrPostScript(dir, "post_install") - require.NoError(t, err) - // `HasPrefix` because windows seem to add a trailing space at the end - require.Equal(t, "sent in stdout", strings.Trim(string(stdout), "\n\r ")) - require.Equal(t, "sent in stderr", strings.Trim(string(stderr), "\n\r ")) + for _, test := range tests { + t.Run(test.testName, func(t *testing.T) { + var scriptPath *paths.Path + var err error + if runtime.GOOS == "windows" { + scriptPath = dir.Join(test.scriptName + ".bat") + + err = scriptPath.WriteFile([]byte( + `@echo off + echo sent in stdout + echo sent in stderr 1>&2`)) + } else { + scriptPath = dir.Join(test.scriptName + ".sh") + err = scriptPath.WriteFile([]byte( + `#!/bin/sh + echo "sent in stdout" + echo "sent in stderr" 1>&2`)) + } + require.NoError(t, err) + err = os.Chmod(scriptPath.String(), 0777) + require.NoError(t, err) + stdout, stderr, err := pme.RunPreOrPostScript(dir, test.scriptName) + require.NoError(t, err) + + // `HasPrefix` because windows seem to add a trailing space at the end + require.Equal(t, "sent in stdout", strings.Trim(string(stdout), "\n\r ")) + require.Equal(t, "sent in stderr", strings.Trim(string(stderr), "\n\r ")) + }) + } }