From d7c20e620a785f307935a6289368d322483abed6 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Wed, 21 Oct 2020 17:25:17 +0800 Subject: [PATCH] 1.0.0.20102103 Former-commit-id: d49d71b655ee0555b6ad65c5b17f690be39301a8 Former-commit-id: 561b7598feaaac71a97623a62545fda95f1c463e --- projects/IoTDameon/UpdateIoTNodeService.cs | 29 +++++++++++----------- projects/IoTDameon/Version.cs | 2 +- projects/IoTNode/Version.cs | 2 +- publish/build.ps1 | 24 ++++++++++++++---- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/projects/IoTDameon/UpdateIoTNodeService.cs b/projects/IoTDameon/UpdateIoTNodeService.cs index 404fb382..6b61545c 100644 --- a/projects/IoTDameon/UpdateIoTNodeService.cs +++ b/projects/IoTDameon/UpdateIoTNodeService.cs @@ -197,30 +197,31 @@ namespace IoTDameon { ZipFile.ExtractToDirectory(file, root, Encoding.UTF8, true); this.Log($"解压更新文件 {file} 到 {appPath}"); + //设置权限 + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + var updateScript = Path.Combine(appPath, "update.sh"); + var command = $"chmod 755 {updateScript}"; + this.Log(command.Bash()); + this.Log($"修改权限:{updateScript}"); + this.Log(updateScript.Bash()); + this.Log($"执行更新脚本:{updateScript}"); + } + proxy.startProcess(processName); + this.Log($"启动进程:{processName}"); } catch (Exception ex) { - this.LogError("解压失败,开始还原"); + this.LogError("更新失败,开始还原"); this.LogError(ex.ToString()); Directory.Delete(appPath, true); this.LogError("删除失败的更新目录"); Directory.Move(backupPath, appPath); this.LogError("还原备份的程序"); + proxy.startProcess(processName); + this.Log($"启动进程:{processName}"); throw ex; } - //设置权限 - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - var updateScript = Path.Combine(appPath, "update.sh"); - var command = $"chmod 755 {updateScript}"; - this.Log(command.Bash()); - this.Log($"修改权限:{updateScript}"); - this.Log(updateScript.Bash()); - this.Log($"执行更新脚本:{updateScript}"); - } - //启动更新程序 - proxy.startProcess(processName); - this.Log($"启动进程:{processName}"); } } } diff --git a/projects/IoTDameon/Version.cs b/projects/IoTDameon/Version.cs index e5aaa5db..a49322e1 100644 --- a/projects/IoTDameon/Version.cs +++ b/projects/IoTDameon/Version.cs @@ -1,4 +1,4 @@ using System.Reflection; [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0.20101601")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("1.0.0.20102101")] \ No newline at end of file diff --git a/projects/IoTNode/Version.cs b/projects/IoTNode/Version.cs index 5e4c1b76..f1022e1c 100644 --- a/projects/IoTNode/Version.cs +++ b/projects/IoTNode/Version.cs @@ -1,4 +1,4 @@ using System.Reflection; [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0.20102102")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("1.0.0.20102103")] \ No newline at end of file diff --git a/publish/build.ps1 b/publish/build.ps1 index 332a29d1..4f44d5e7 100644 --- a/publish/build.ps1 +++ b/publish/build.ps1 @@ -36,20 +36,34 @@ dotnet publish ../projects/IoTCenter/IoTCenter.csproj -c Release -r linux-x64 -o dotnet publish ../projects/IoTNode/IoTNode.csproj -c Release -r linux-arm64 -o ../publish/dist/linux-arm64/publish/apps/IoTNode dotnet publish ../projects/IoTDameon/IoTDameon.csproj -c Release -r linux-arm64 -o ../publish/dist/linux-arm64/publish/apps/IoTDameon + + +$source=@" +public class Encoding : System.Text.UTF8Encoding + { + public override byte[] GetBytes(string s) + { + s = s.Replace("\\", "/"); + return base.GetBytes(s); + } + } +"@ +Add-Type -TypeDefinition $source +$encoding=New-Object Encoding Add-Type -Assembly "System.IO.Compression.FileSystem" echo 'create zip file' $level = [System.IO.Compression.CompressionLevel]::Optimal -[System.IO.Compression.ZipFile]::CreateFromDirectory((Get-Item .).FullName+"/dist/linux-arm64/publish", (Get-Item .).FullName+"/dist/linux-arm64/publish.zip",$level,$true) -[System.IO.Compression.ZipFile]::CreateFromDirectory((Get-Item .).FullName+"/dist/linux-arm64/publish/apps/IoTNode", (Get-Item .).FullName+"/dist/linux-arm64/IoTNode.zip",$level,$true) +[System.IO.Compression.ZipFile]::CreateFromDirectory((Get-Item .).FullName+"/dist/linux-arm64/publish", (Get-Item .).FullName+"/dist/linux-arm64/publish.zip",$level,$true,$encoding) +[System.IO.Compression.ZipFile]::CreateFromDirectory((Get-Item .).FullName+"/dist/linux-arm64/publish/apps/IoTNode", (Get-Item .).FullName+"/dist/linux-arm64/IoTNode.zip",$level,$true,$encoding) $zip=(Get-Item .).FullName+"/dist/linux-arm64/IoTNode.zip" echo 'create xml file' -$v=[System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-Item .).FullName+"/dist/linux-arm64/publish/apps/IoTNode/IoTNode.dll").ProductVersion; +$v=[System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-Item .).FullName+"/dist/linux-arm64/publish/apps/IoTNode/IoTNode.dll").ProductVersion $sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider -$checksum=[System.BitConverter]::ToString( $sha1.ComputeHash([System.IO.File]::ReadAllBytes($zip))) +$checksum=[System.BitConverter]::ToString( $sha1.ComputeHash([System.IO.File]::ReadAllBytes($zip))).Replace('-','') $file = (Get-Item .).FullName+'/dist/linux-arm64/iotnode.xml' $xml = New-Object System.Xml.XmlDocument $xml.PreserveWhitespace = $true -$xml.LoadXml(''+$v+'D71BD377E3A026C6E4A077554701E44C20B28798') +$xml.LoadXml(''+$v+''+$checksum+'') $xml.Save($file) echo end!