forked from ms-iot/iot-adk-addonkit
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ms-iot#251 from ms-iot/develop
Device Update center tools update
- Loading branch information
Showing
14 changed files
with
356 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
###################################### | ||
# DeviceModel.ps1 | ||
# Creates the Device Model XML file to upload in the Device Update Center | ||
###################################### | ||
|
||
Param( | ||
[string] $productname, | ||
[switch] $Silent | ||
) | ||
|
||
################ | ||
# Main Function | ||
################ | ||
|
||
$dixmlfile = "$env:SRC_DIR\Products\$productname\IoTDeviceModel_$($productname).xml" | ||
Write-Host "DeviceInventory file : $dixmlfile" | ||
if (Test-Path $dixmlfile) { | ||
Write-Host "$dixmlfile already exists" -ForegroundColor Red | ||
return | ||
} | ||
|
||
$arch = $env:ARCH | ||
$key = "Registry::HKEY_CLASSES_ROOT\Installer\Dependencies\Microsoft.Windows.Windows_10_IoT_Core_$($arch)_Packages.x86.10" | ||
if (Test-Path $key) { | ||
$corekitver = (Get-ItemProperty -Path $key).Version | ||
$corekitver = $corekitver.Replace("10.1.", "10.0.") | ||
} | ||
else { | ||
Write-Host "IoT Core kit ver not found in registry" -ForegroundColor Red | ||
return | ||
} | ||
|
||
Write-Host "OS Version : $corekitver" | ||
Write-Host "BSP Version : $env:BSP_VERSION" | ||
|
||
$smbioscfg = "$env:SRC_DIR\Products\$productname\SMBIOS.CFG" | ||
if (Test-Path $smbioscfg) { | ||
Write-Host "Parsing SMBIOS.CFG to get SMBIOS information" | ||
$doc = Get-Content $smbioscfg | ||
foreach ($line in $doc) { | ||
$parts = $line.Split(",") | ||
if ($parts[0] -eq "01") { | ||
switch ($parts[1]) { | ||
'04' { | ||
$Manufacturer = $parts[3] -replace '"', "" | ||
Write-Host "Manufacturer : $Manufacturer" | ||
break | ||
} | ||
'05' { | ||
$ProductName = $parts[3] -replace '"', "" | ||
Write-Host "Product Name : $ProductName" | ||
break | ||
} | ||
'19' { | ||
$SKUNumber = $parts[3] -replace '"', "" | ||
Write-Host "SKU Number : $SKUNumber" | ||
break | ||
} | ||
'1A' { | ||
$Family = $parts[3] -replace '"', "" | ||
Write-Host "Family : $Family" | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} | ||
$encoding = [System.Text.Encoding]::UTF8 | ||
$xmlwriter = New-Object System.Xml.XmlTextWriter($dixmlfile, $encoding) | ||
$xmlwriter.Formatting = "Indented" | ||
$xmlwriter.Indentation = 4 | ||
$xmlwriter.WriteStartDocument() | ||
$xmlwriter.WriteStartElement("DeviceInventory") | ||
$xmlwriter.WriteAttributeString("SchemaVersion", "1") | ||
$xmlwriter.WriteAttributeString("BuildArch", $env:BSP_ARCH) | ||
$xmlwriter.WriteAttributeString("OSString", $corekitver) | ||
$xmlwriter.WriteAttributeString("OCPString", $env:BSP_VERSION) | ||
$xmlwriter.WriteStartElement("MachineInfo") | ||
if ($Manufacturer) { | ||
$usrinput = $Manufacturer | ||
} | ||
else { | ||
if (!$Silent) { | ||
$usrinput = Read-Host("Enter Manufacturer ") | ||
} | ||
else { $usrinput = $env:OEM_NAME } | ||
} | ||
$xmlwriter.WriteAttributeString("Manufacturer", $usrinput) | ||
if ($Family) { | ||
$usrinput = $Family | ||
} | ||
else { | ||
if (!$Silent) { | ||
$usrinput = Read-Host("Enter Family ") | ||
} | ||
else { $usrinput = $env:OEM_NAME + "Family" } | ||
} | ||
$xmlwriter.WriteAttributeString("Family", $usrinput) | ||
if ($ProductName) { | ||
$usrinput = $ProductName | ||
} | ||
else { | ||
$usrinput = $productname | ||
} | ||
$xmlwriter.WriteAttributeString("ProductName", $usrinput) | ||
if ($SKUNumber) { | ||
$usrinput = $SKUNumber | ||
} | ||
else { | ||
if (!$Silent) { | ||
$usrinput = Read-Host("Enter SKUNumber ") | ||
} | ||
else { $usrinput = $productname + "01" } | ||
} | ||
$xmlwriter.WriteAttributeString("SKUNumber", $usrinput) | ||
$usrinput = "Fabrikam" | ||
if (!$Silent) { | ||
$usrinput = Read-Host("Enter BaseboardManufacturer ") | ||
} | ||
$xmlwriter.WriteAttributeString("BaseboardManufacturer", $usrinput) | ||
$usrinput = $productname + "_v01" | ||
if (!$Silent) { | ||
$usrinput = Read-Host("Enter BaseboardProduct (HWvID) ") | ||
} | ||
$xmlwriter.WriteAttributeString("BaseboardProduct", $usrinput) | ||
$xmlwriter.WriteEndElement() # MachineInfo element | ||
$xmlwriter.WriteEndElement() # DeviceInventory element | ||
$xmlwriter.WriteEndDocument() | ||
$xmlwriter.Flush() | ||
$xmlwriter.Close() | ||
Write-Host "DeviceInventory created" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
###################################### | ||
# ExportBSPDB.ps1 | ||
# Exports the cab files referred in the BSPDBPublish xml file | ||
###################################### | ||
|
||
Param( | ||
[string] $FFUDir, | ||
[string] $DestDir | ||
) | ||
|
||
################ | ||
# Main Function | ||
################ | ||
$BSPDBPublishxml = "$FFUDir\$($env:FFUNAME).BSPDB_publish.xml" | ||
|
||
$bspdbpubdoc = [xml] (get-content $BSPDBPublishxml) | ||
$BSPVersion = $bspdbpubdoc.CompDBPublishingInfo.BSPVersion | ||
Write-Host "BSP Version : $BSPVersion" | ||
|
||
if ($BSPVersion -ine $env:BSP_VERSION ) { | ||
Write-Host "BSP version is different from $env:BSP_VERSION." -ForegroundColor Red | ||
#return | ||
} | ||
Write-Host "Exporting required packages to $outputpath" | ||
$packages = $bspdbpubdoc.GetElementsByTagName("Package") | ||
Foreach ($package in $packages) { | ||
Write-Host $package.Path | ||
if (!(Test-Path $package.Path )) { | ||
$package.Path = $env:MSPACKAGE + "\" + $package.Path | ||
if (!(Test-Path $package.Path )) { | ||
Write-Host "$($package.Path) not found" -ForegroundColor Red | ||
} | ||
} | ||
Copy-Item $package.Path $DestDir | ||
} | ||
$BSPDBxml = "$FFUDir\$($env:FFUNAME).BSPDB.xml" | ||
Write-Host "Exporting BSP DB" | ||
Copy-Item $BSPDBxml $DestDir | ||
$bspdbdoc = [xml] (get-content $BSPDBxml) | ||
$pkgs = $bspdbdoc.CompDB.Packages.Package | ||
$ocpname = Split-Path $DestDir -Leaf | ||
$outfile = "$DestDir\..\$($ocpname)_pkgver.txt" | ||
#$outfile = Resolve-Path $outfile | ||
Set-Content -Path $outfile -Value "PackageName,Version" | ||
foreach ($pkg in $pkgs) { | ||
Add-Content -Path $outfile -Value "$($pkg.ID).cab,$($pkg.Version)" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<# | ||
# ImportConfig.ps1 | ||
# Imports the CUSConfig.zip file (downloaded from Device Update Center) into the product directory | ||
# and updates the input xmls with the required changes | ||
#> | ||
|
||
Param( | ||
[string] $productname, | ||
[string] $zipfile | ||
) | ||
|
||
################ | ||
# Main Function | ||
################ | ||
|
||
$productdir = "$env:SRC_DIR\Products\$productname" | ||
if (!(Test-Path $productdir)) { | ||
Write-Host "Error: $productdir not found." -ForegroundColor Red | ||
return | ||
} | ||
if (!(Test-Path $zipfile)) { | ||
Write-Host "Error: $zipfile not found." -ForegroundColor Red | ||
return | ||
} | ||
|
||
#check if config files are already present | ||
$cfgdir = "$productdir\Packages\CUSConfig" | ||
if (Test-Path $cfgdir){ | ||
Write-Host "Error: CUSConfig files already exists." | ||
return | ||
} else { | ||
New-Item $cfgdir -ItemType Directory | Out-Null | ||
} | ||
|
||
#unzip the file | ||
Expand-Archive -Path $zipfile -DestinationPath $cfgdir | ||
Write-Host "Updating OEMInputXML files" | ||
|
||
$ocpfmfile = "%BLD_DIR%\MergedFMs\OCPUpdateFM.xml" | ||
|
||
$files = Get-ChildItem -Path $productdir\ -File -Filter *OEMInput.xml | Foreach-Object {$_.FullName} | ||
foreach ($file in $files) { | ||
$filename = Split-Path -Path $file -Leaf | ||
Write-Host "Processing $filename" | ||
$xmlfile = [xml] (Get-Content -Path $file) | ||
# add the FM file | ||
$node = $xmlfile.GetElementsByTagName("AdditionalFM") | Where-Object { ($_.InnerText) -ieq $ocpfmfile } | ||
if ($node) { | ||
Write-Host " Add OCPUpdateFM : Exists" | ||
}else{ | ||
$fmnode = $xmlfile.OEMInput.AdditionalFMs | ||
$newfm = $xmlfile.CreateElement("AdditionalFM", "http://schemas.microsoft.com/embedded/2004/10/ImageUpdate") | ||
$newfm.InnerText = $ocpfmfile | ||
$retval = $fmnode.AppendChild($newfm) | ||
Write-Debug "$newfm added" | ||
Write-Host " Add OCPUpdateFM : Added" | ||
$dirty = $true | ||
} | ||
# remove featureid IOT_GENERIC_POP | ||
$fid = "IOT_GENERIC_POP" | ||
$node = $xmlfile.GetElementsByTagName("Feature") | Where-Object { ($_.InnerText) -ieq $fid } | ||
if ($node) { | ||
$parentnode = $node.ParentNode | ||
$oldnode = $parentnode.RemoveChild($node) | ||
Write-Host " Remove $fid : Removed" | ||
Write-Debug "$oldnode removed" | ||
$dirty = $true | ||
} else { | ||
Write-Host " Remove $fid : Skip, doesn't exist" | ||
} | ||
# add feature id CUS_DEVICE_INFO | ||
$fid = "CUS_DEVICE_INFO" | ||
$node = $xmlfile.GetElementsByTagName("Feature") | Where-Object { ($_.InnerText) -ieq $fid } | ||
if ($node) { | ||
Write-Host " Add $fid : Exists" | ||
} else { | ||
$node = $xmlfile.OEMInput.Features.OEM | ||
$newfid = $xmlfile.CreateElement("Feature","http://schemas.microsoft.com/embedded/2004/10/ImageUpdate") | ||
$newfid.InnerText = $fid | ||
$retval = $node.AppendChild($newfid) | ||
Write-Debug "$newfid added" | ||
Write-Host " Add $fid : Added" | ||
$dirty = $true | ||
} | ||
if ($dirty) { | ||
$xmlfile.Save($file) | Out-Null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.