1.0.0.20102103

Former-commit-id: d49d71b655ee0555b6ad65c5b17f690be39301a8
Former-commit-id: 561b7598feaaac71a97623a62545fda95f1c463e
TSXN
wanggang 5 years ago
parent 7916ee7563
commit d7c20e620a

@ -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}");
}
}
}

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.20101601")]
[assembly: AssemblyInformationalVersion("1.0.0.20102101")]

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.20102102")]
[assembly: AssemblyInformationalVersion("1.0.0.20102103")]

@ -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('<?xml version="1.0" encoding="utf-8" ?><app><version>'+$v+'</version><checksum>D71BD377E3A026C6E4A077554701E44C20B28798</checksum></app>')
$xml.LoadXml('<?xml version="1.0" encoding="utf-8" ?><app><version>'+$v+'</version><checksum>'+$checksum+'</checksum></app>')
$xml.Save($file)
echo end!

Loading…
Cancel
Save