Add FileBow Windows app, Store identity and optional Ko-fi link
This commit is contained in:
commit
65cebb31ca
139 files changed
+375057
No files matched your search
@@ -0,0 +1,15 @@
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
const root=path.resolve(__dirname,'..');
|
||||
const args=['-m','PyInstaller','--noconfirm','--clean','--onedir','--console','--name','FileBowEngine',
|
||||
'--distpath','build/engine','--workpath','build/pyinstaller','--specpath','build',
|
||||
'--collect-all','pillow_heif','--collect-all','pypdf','--collect-all','fpdf',
|
||||
'--hidden-import','PIL.AvifImagePlugin','--hidden-import','PIL.IcoImagePlugin',
|
||||
'--exclude-module','tkinter','--exclude-module','pandas','--exclude-module','numpy',
|
||||
'--exclude-module','markitdown','--exclude-module','onnxruntime','--exclude-module','magika',
|
||||
'--exclude-module','pytest','engine/filebow_engine.py'];
|
||||
const result=spawnSync(path.join(root,'.venv/Scripts/python.exe'),args,{cwd:root,stdio:'inherit',windowsHide:true});
|
||||
if(result.status!==0)process.exit(result.status||1);
|
||||
fs.mkdirSync(path.join(root,'vendor/engine'),{recursive:true});
|
||||
fs.cpSync(path.join(root,'build/engine/FileBowEngine'),path.join(root,'vendor/engine'),{recursive:true});
|
||||
@@ -0,0 +1,84 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet('Development','Store')][string]$Channel = 'Development',
|
||||
[string]$IdentityFile,
|
||||
[switch]$SignDevelopment,
|
||||
[string]$SdkBin
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$projectRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
if (-not $IdentityFile) { $IdentityFile = Join-Path $projectRoot $(if ($Channel -eq 'Store') { 'store\identity.store.json' } else { 'store\identity.dev.json' }) }
|
||||
$identity = Get-Content -LiteralPath $IdentityFile -Raw | ConvertFrom-Json
|
||||
foreach ($field in 'Name','Publisher','PublisherDisplayName','DisplayName','Version') {
|
||||
if ([string]::IsNullOrWhiteSpace($identity.$field)) { throw "Store-Identität fehlt: $field. Werte aus Partner Center > Produktidentität in $IdentityFile eintragen." }
|
||||
}
|
||||
if ($identity.Name -notmatch '^[A-Za-z0-9.-]{3,50}$') { throw 'Ungültiger Package Identity Name.' }
|
||||
if ($identity.Version -notmatch '^\d+\.\d+\.\d+\.0$') { throw 'MSIX-Version muss vier Zahlen enthalten; Store-Pakete enden auf .0.' }
|
||||
foreach ($part in $identity.Version.Split('.')) { if ([int]$part -gt 65535) { throw 'Versionssegment zu groß.' } }
|
||||
if ($Channel -eq 'Store' -and ($identity.Name -match 'Development|PLACEHOLDER' -or $identity.Publisher -eq 'CN=FileBow Development')) { throw 'Entwicklungsidentität darf nicht für den Store verwendet werden.' }
|
||||
if ($Channel -eq 'Store' -and $SignDevelopment) { throw 'Store-Pakete erhalten keine Entwicklungssignatur.' }
|
||||
if (-not $SdkBin) {
|
||||
$candidates = @("$env:USERPROFILE\.nuget\packages\microsoft.windows.sdk.buildtools\10.0.26100.8249\bin\10.0.26100.0\x64")
|
||||
$candidates += @(Get-ChildItem 'C:\Program Files (x86)\Windows Kits\10\bin' -Directory -ErrorAction SilentlyContinue | Sort-Object Name -Descending | ForEach-Object { Join-Path $_.FullName 'x64' })
|
||||
$SdkBin = $candidates | Where-Object { Test-Path (Join-Path $_ 'makeappx.exe') } | Select-Object -First 1
|
||||
}
|
||||
if (-not $SdkBin) { throw 'Windows SDK BuildTools fehlt. Zuerst dotnet restore native/FileBow.Windows.csproj ausführen.' }
|
||||
$appPath = Join-Path $projectRoot 'out\FileBow-win32-x64'
|
||||
if (-not (Test-Path "$appPath\FileBow.exe")) { throw 'Zuerst pnpm build ausführen.' }
|
||||
$stage = [IO.Path]::GetFullPath((Join-Path $projectRoot "build\msix-$Channel-$([Guid]::NewGuid().ToString('N').Substring(0,8))"))
|
||||
$expectedParent = [IO.Path]::GetFullPath((Join-Path $projectRoot 'build'))
|
||||
if ([IO.Path]::GetDirectoryName($stage) -ne $expectedParent) { throw 'Unerwarteter Staging-Pfad.' }
|
||||
New-Item -ItemType Directory -Path $stage | Out-Null
|
||||
Copy-Item -LiteralPath $appPath -Destination (Join-Path $stage 'app') -Recurse
|
||||
Copy-Item -LiteralPath (Join-Path $projectRoot 'store\Assets') -Destination (Join-Path $stage 'Assets') -Recurse
|
||||
function XmlEscape([string]$value) { return [System.Security.SecurityElement]::Escape($value) }
|
||||
$name = XmlEscape $identity.Name; $publisher = XmlEscape $identity.Publisher
|
||||
$display = XmlEscape $identity.DisplayName; $publisherDisplay = XmlEscape $identity.PublisherDisplayName
|
||||
$manifest = @"
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
|
||||
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap desktop uap10 rescap">
|
||||
<Identity Name="$name" Publisher="$publisher" Version="$($identity.Version)" ProcessorArchitecture="x64" />
|
||||
<Properties><DisplayName>$display</DisplayName><PublisherDisplayName>$publisherDisplay</PublisherDisplayName><Logo>Assets\StoreLogo.png</Logo><Description>Dateien konvertieren, komprimieren und bearbeiten.</Description></Properties>
|
||||
<Dependencies><TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.26100.0" /></Dependencies>
|
||||
<Resources><Resource Language="de-de" /></Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="app\FileBow.exe" EntryPoint="Windows.FullTrustApplication" uap10:RuntimeBehavior="packagedClassicApp" uap10:TrustLevel="mediumIL">
|
||||
<uap:VisualElements DisplayName="$display" Description="Dateien konvertieren und bearbeiten" BackgroundColor="#14161B" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />
|
||||
</uap:VisualElements>
|
||||
<Extensions>
|
||||
<desktop:Extension Category="windows.startupTask" Executable="app\FileBow.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--hidden">
|
||||
<desktop:StartupTask TaskId="FileBowStartup" Enabled="false" DisplayName="$display" />
|
||||
</desktop:Extension>
|
||||
</Extensions>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities><rescap:Capability Name="runFullTrust" /></Capabilities>
|
||||
</Package>
|
||||
"@
|
||||
[IO.File]::WriteAllText((Join-Path $stage 'AppxManifest.xml'), $manifest, [Text.UTF8Encoding]::new($false))
|
||||
$outputDir = Join-Path $projectRoot 'out\msix'
|
||||
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
|
||||
$package = Join-Path $outputDir "FileBow_$($identity.Version)_x64_$Channel.msix"
|
||||
$packLog = Join-Path $projectRoot "build\makeappx-$Channel.log"
|
||||
& (Join-Path $SdkBin 'makeappx.exe') pack /d $stage /p $package /o /h SHA256 *> $packLog
|
||||
if ($LASTEXITCODE -ne 0) { throw 'MakeAppx-Validierung fehlgeschlagen.' }
|
||||
$certificatePath = $null
|
||||
if ($SignDevelopment) {
|
||||
$certificate = Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.Subject -eq $identity.Publisher -and $_.FriendlyName -eq 'FileBow local development' -and $_.HasPrivateKey -and $_.NotAfter -gt (Get-Date).AddDays(7) } | Select-Object -First 1
|
||||
if (-not $certificate) {
|
||||
$certificate = New-SelfSignedCertificate -Type Custom -Subject $identity.Publisher -FriendlyName 'FileBow local development' -CertStoreLocation Cert:\CurrentUser\My -KeyUsage DigitalSignature -KeyExportPolicy NonExportable -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3','2.5.29.19={text}') -NotAfter (Get-Date).AddYears(1)
|
||||
}
|
||||
& (Join-Path $SdkBin 'signtool.exe') sign /fd SHA256 /sha1 $certificate.Thumbprint /s My $package
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Signieren fehlgeschlagen.' }
|
||||
$certificatePath = Join-Path $outputDir 'FileBow-Development.cer'
|
||||
Export-Certificate -Cert $certificate -FilePath $certificatePath -Force | Out-Null
|
||||
}
|
||||
$record = @{ Channel=$Channel; Package=$package; Stage=$stage; Identity=$identity; Signed=[bool]$SignDevelopment; Certificate=$certificatePath; SHA256=(Get-FileHash $package -Algorithm SHA256).Hash; BuiltAt=(Get-Date).ToUniversalTime().ToString('o') }
|
||||
$record | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $outputDir "build-$Channel.json") -Encoding utf8
|
||||
Write-Output $package
|
||||
@@ -0,0 +1,12 @@
|
||||
const fs=require('node:fs'),path=require('node:path');
|
||||
const root=path.resolve(__dirname,'..');
|
||||
(async()=>{
|
||||
const {packager}=await import('@electron/packager');
|
||||
for(const file of ['vendor/engine/FileBowEngine.exe','vendor/windows/FileBow.Windows.exe','vendor/ffmpeg/ffmpeg.exe','licenses/THIRD_PARTY.html'])if(!fs.existsSync(path.join(root,file)))throw new Error(`Build prerequisite missing: ${file}`);
|
||||
const output=await packager({dir:root,name:'FileBow',executableName:'FileBow',platform:'win32',arch:'x64',electronVersion:'43.7.0',out:path.join(root,'out'),overwrite:true,asar:false,
|
||||
icon:path.join(root,'assets/icon.ico'),appVersion:require('../package.json').version,
|
||||
win32metadata:{ProductName:'FileBow',FileDescription:'FileBow – Dateiwerkzeuge',InternalName:'FileBow',OriginalFilename:'FileBow.exe'},
|
||||
ignore:[/^\/(?:\.venv|\.git|build|out|test-results|tests|scripts|native|store|engine|node_modules)(?:\/|$)/,/\/\.gitignore$/,/default-docx-template(?:\/|$)/,/\.pyc$/,/\.pdb$/,/requirements\./,/pnpm/,/^\/vendor\/native(?:\/|$)/],
|
||||
prune:true});
|
||||
console.log(output.join('\n'));
|
||||
})().catch(error=>{console.error(error);process.exit(1);});
|
||||
@@ -0,0 +1,20 @@
|
||||
const {_electron:electron}=require('playwright');
|
||||
const fs=require('node:fs/promises'),path=require('node:path');
|
||||
const root=path.resolve(__dirname,'..');
|
||||
(async()=>{
|
||||
const output=path.join(root,'store/screenshots');await fs.mkdir(output,{recursive:true});
|
||||
const profile=await fs.mkdtemp(path.join(root,'test-results/store-profile-'));
|
||||
const app=await electron.launch({executablePath:path.join(root,'out/FileBow-win32-x64/FileBow.exe'),args:[],env:{...process.env,FILEBOW_TEST:'1',FILEBOW_USER_DATA:profile}});
|
||||
try{
|
||||
const page=await app.firstWindow();await page.waitForSelector('#pick');
|
||||
await app.evaluate(({BrowserWindow})=>BrowserWindow.getAllWindows()[0].setContentSize(1600,900));
|
||||
await page.screenshot({path:path.join(output,'01-Dateien.png')});
|
||||
const file=path.join(root,'test-results/Beispielbild.png');await fs.copyFile(path.join(root,'assets/icon.png'),file);
|
||||
await page.evaluate(file=>window.orbit.selectFiles([file]),file);await page.locator('#tab-tools').click();
|
||||
await page.screenshot({path:path.join(output,'02-Werkzeuge.png')});
|
||||
await page.locator('[data-page="settings"]').click();await page.screenshot({path:path.join(output,'03-Einstellungen.png')});
|
||||
await page.locator('#theme').selectOption('light');await page.waitForFunction(()=>document.documentElement.dataset.theme==='light');
|
||||
await page.locator('[data-page="files"]').click();await page.locator('#tab-quick').click();await page.screenshot({path:path.join(output,'04-Konvertieren-Hell.png')});
|
||||
}finally{await app.close();}
|
||||
console.log(output);
|
||||
})().catch(error=>{console.error(error);process.exitCode=1;});
|
||||
@@ -0,0 +1,38 @@
|
||||
from importlib import metadata
|
||||
from pathlib import Path
|
||||
import html
|
||||
import json
|
||||
import shutil
|
||||
import sys
|
||||
root=Path(__file__).resolve().parents[1];out=root/'licenses';out.mkdir(exist_ok=True)
|
||||
packages=['pillow','pillow-heif','pypdf','cryptography','cffi','pycparser','python-docx','lxml','fpdf2','fonttools','defusedxml','typing-extensions','python-pptx','xlsxwriter','openpyxl','et-xmlfile','xlrd','striprtf','beautifulsoup4','soupsieve','packaging']
|
||||
records=[]
|
||||
for package in packages:
|
||||
try: dist=metadata.distribution(package)
|
||||
except metadata.PackageNotFoundError: continue
|
||||
folder=out/'python'/package;folder.mkdir(parents=True,exist_ok=True)
|
||||
files=[]
|
||||
for entry in dist.files or []:
|
||||
if any(word in str(entry).lower() for word in ['license','copying','copyright','notice']) and dist.locate_file(entry).is_file():
|
||||
source=dist.locate_file(entry)
|
||||
# Keep wheel-provided notices, including bundled codec licenses.
|
||||
name=str(entry).replace('/','__').replace('\\','__')
|
||||
shutil.copy2(source,folder/name);files.append(str((folder/name).relative_to(out)))
|
||||
records.append({'name':dist.metadata['Name'],'version':dist.version,'license':dist.metadata.get('License-Expression') or dist.metadata.get('License') or '', 'files':files})
|
||||
shutil.copy2(Path(sys.base_prefix)/'LICENSE.txt',out/'Python.txt')
|
||||
shutil.copy2(root/'vendor/ffmpeg/LICENSE.txt',out/'FFmpeg-LGPL-3.0.txt')
|
||||
electron=root/'node_modules/electron/dist'
|
||||
for name in ['LICENSE','LICENSES.chromium.html']:
|
||||
if (electron/name).exists():shutil.copy2(electron/name,out/('Electron-'+name))
|
||||
(out/'components.json').write_text(json.dumps(records,indent=2,ensure_ascii=False),encoding='utf-8')
|
||||
parts=['<!doctype html><html lang="de"><meta charset="utf-8"><title>FileBow – Lizenzhinweise</title><style>body{font:15px system-ui;max-width:960px;margin:40px auto;padding:24px;line-height:1.6;color:#20232a}pre{white-space:pre-wrap;overflow-wrap:anywhere;font:12px monospace}summary{cursor:pointer}a{color:#9a4518}</style><h1>FileBow – Drittanbieterkomponenten</h1><p>Die folgenden Komponenten unterliegen den Lizenzen ihrer jeweiligen Urheber. Diese Hinweise ändern keine Rechte aus diesen Lizenzen.</p><h2>FFmpeg</h2><p>FileBow verwendet FFmpeg-Bibliotheken unter der GNU LGPL Version 3. FFmpeg läuft als separater Prozess. Die dynamischen Bibliotheken liegen unverändert im Paket. Version: n9.0.2-36-g6882969ce9, BtbN LGPL shared x64. Quellcode und Buildskripte liegen im Verzeichnis <code>licenses/sources</code>.</p>']
|
||||
for file in sorted(out.glob('*.txt')):
|
||||
parts.append(f'<details><summary>{html.escape(file.name)}</summary><pre>{html.escape(file.read_text(encoding="utf-8",errors="replace"))}</pre></details>')
|
||||
parts.append('<h2>Electron / Chromium</h2><p><a href="Electron-LICENSES.chromium.html">Chromium-Lizenzhinweise</a></p>')
|
||||
for record in records:
|
||||
parts.append(f'<h2>{html.escape(record["name"])} {record["version"]}</h2>')
|
||||
for name in record['files']:
|
||||
file=out/name
|
||||
parts.append(f'<details><summary>{html.escape(file.name)}</summary><pre>{html.escape(file.read_text(encoding="utf-8",errors="replace"))}</pre></details>')
|
||||
(out/'THIRD_PARTY.html').write_text('\n'.join(parts)+'</html>',encoding='utf-8')
|
||||
print(f'Collected notices for {len(records)} Python distributions, Python, FFmpeg and Electron.')
|
||||
@@ -0,0 +1,17 @@
|
||||
[CmdletBinding()]param()
|
||||
$ErrorActionPreference='Stop'
|
||||
$root=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
$download=Join-Path $root 'build\downloads\ffmpeg-lgpl.zip'
|
||||
$url='https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-25-13-00/ffmpeg-n9.0.2-36-g6882969ce9-win64-lgpl-shared-9.0.zip'
|
||||
$expected='72E3FBAF17F8D5162C3010F9E58872FCB93BA2B03731FD0FFF1CA9AABB616EA6'
|
||||
New-Item -ItemType Directory -Force (Split-Path $download) | Out-Null
|
||||
if (-not (Test-Path $download)) { Invoke-WebRequest $url -OutFile $download }
|
||||
if ((Get-FileHash $download -Algorithm SHA256).Hash -ne $expected) { throw 'FFmpeg-Prüfsumme stimmt nicht überein.' }
|
||||
$unpack=Join-Path $root 'build\downloads\ffmpeg'
|
||||
Expand-Archive $download $unpack -Force
|
||||
$source=Join-Path $unpack 'ffmpeg-n9.0.2-36-g6882969ce9-win64-lgpl-shared-9.0'
|
||||
$target=Join-Path $root 'vendor\ffmpeg'
|
||||
New-Item -ItemType Directory -Force $target | Out-Null
|
||||
Copy-Item "$source\bin\ffmpeg.exe","$source\bin\ffprobe.exe","$source\bin\*.dll" $target -Force
|
||||
Copy-Item "$source\LICENSE.txt" $target -Force
|
||||
Write-Output 'FFmpeg heruntergeladen und SHA-256 geprüft.'
|
||||
@@ -0,0 +1,11 @@
|
||||
# Run explicitly in an elevated PowerShell. Trusts only the FileBow development certificate.
|
||||
[CmdletBinding()]param()
|
||||
$ErrorActionPreference='Stop'
|
||||
$root=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||||
$record=Get-Content (Join-Path $root 'out\msix\build-Development.json') -Raw | ConvertFrom-Json
|
||||
if (-not $record.Signed) { throw 'Zuerst build-msix.ps1 -SignDevelopment ausführen.' }
|
||||
if ((Get-FileHash $record.Package -Algorithm SHA256).Hash -ne $record.SHA256) { throw 'Paket-Prüfsumme stimmt nicht überein.' }
|
||||
$cert=[Security.Cryptography.X509Certificates.X509Certificate2]::new($record.Certificate)
|
||||
if ($cert.Subject -ne 'CN=FileBow Development') { throw 'Unerwartetes Zertifikat.' }
|
||||
Import-Certificate -FilePath $record.Certificate -CertStoreLocation Cert:\LocalMachine\TrustedPeople | Out-Null
|
||||
Add-AppxPackage -Path $record.Package
|
||||
@@ -0,0 +1,13 @@
|
||||
from pathlib import Path
|
||||
from PIL import Image, ImageDraw
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
(root / 'assets').mkdir(exist_ok=True)
|
||||
im = Image.new('RGBA', (512, 512), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
d.rounded_rectangle((16, 16, 496, 496), radius=115, fill='#151821')
|
||||
d.arc((91, 91, 421, 421), 30, 315, fill='#ff9850', width=34)
|
||||
d.arc((151, 151, 361, 361), 210, 495, fill='#ee6377', width=25)
|
||||
d.ellipse((225, 225, 287, 287), fill='#fff1de')
|
||||
d.ellipse((374, 332, 432, 390), fill='#ffb347')
|
||||
im.save(root / 'assets/icon.png')
|
||||
im.save(root / 'assets/icon.ico', sizes=[(16,16),(24,24),(32,32),(48,48),(64,64),(128,128),(256,256)])
|
||||
@@ -0,0 +1,18 @@
|
||||
from PIL import Image
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
source=Image.open(root/'assets/icon.png')
|
||||
target=root/'store/Assets';target.mkdir(parents=True,exist_ok=True)
|
||||
for name,size in [('StoreLogo',50),('Square44x44Logo',44),('Square71x71Logo',71),('Square150x150Logo',150),('Square310x310Logo',310)]:
|
||||
for scale in [1,1.25,1.5,2,4]:
|
||||
dimension=round(size*scale);image=source.resize((dimension,dimension),Image.Resampling.LANCZOS)
|
||||
suffix='' if scale==1 else f'.scale-{int(scale*100)}'
|
||||
image.save(target/f'{name}{suffix}.png')
|
||||
for scale in [1,1.25,1.5,2,4]:
|
||||
image=Image.new('RGBA',(round(310*scale),round(150*scale)), '#14161b')
|
||||
mark=source.resize((round(114*scale),round(114*scale)),Image.Resampling.LANCZOS)
|
||||
image.alpha_composite(mark,((image.width-mark.width)//2,(image.height-mark.height)//2))
|
||||
suffix='' if scale==1 else f'.scale-{int(scale*100)}';image.save(target/f'Wide310x150Logo{suffix}.png')
|
||||
for size in [16,24,32,48,256]:
|
||||
source.resize((size,size),Image.Resampling.LANCZOS).save(target/f'Square44x44Logo.targetsize-{size}_altform-unplated.png')
|
||||
source.resize((300,300),Image.Resampling.LANCZOS).save(root/'store/StoreListingLogo.png')
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Verify every uncompressed 64 KiB payload hash in an MSIX block map."""
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import zipfile
|
||||
from xml.etree import ElementTree as ET
|
||||
from urllib.parse import unquote
|
||||
package=Path(sys.argv[1]);count=0
|
||||
with zipfile.ZipFile(package) as archive:
|
||||
names={unquote(name):name for name in archive.namelist()}
|
||||
tree=ET.fromstring(archive.read('AppxBlockMap.xml'))
|
||||
for file in tree:
|
||||
name=file.attrib['Name'].replace('\\','/')
|
||||
with archive.open(names[name]) as payload:
|
||||
size=0;whole=hashlib.sha256()
|
||||
for block in file:
|
||||
if block.tag.endswith('FileHash'):
|
||||
assert base64.b64encode(whole.digest()).decode()==block.attrib['Hash'],name
|
||||
continue
|
||||
chunk=payload.read(65536);size+=len(chunk)
|
||||
whole.update(chunk)
|
||||
assert base64.b64encode(hashlib.sha256(chunk).digest()).decode()==block.attrib['Hash'],name
|
||||
assert not payload.read(1),name
|
||||
assert size==int(file.attrib['Size']),name
|
||||
count+=1
|
||||
assert 'AppxSignature.p7x' in archive.namelist(),'Development package is unsigned'
|
||||
print(json.dumps({'package':str(package),'payloads':count,'blockHashesValid':True,
|
||||
'sha256':hashlib.sha256(package.read_bytes()).hexdigest()},indent=2))
|
||||
Reference in new issue
Block a user