Add download URL and package family names to DistributioInfo.json (#7783)
Blue committed
Dec 1, 2021 at 18:41 UTC
8d5b7e63ab77ca00c480a9afc89c7bed5c814c94
2 files changed
+93
-9
distributions/DistributionInfo.json
+33
-9
@@ -5,56 +5,80 @@
5
"FriendlyName": "Ubuntu",
6
"StoreAppId": "9NBLGGH4MSV6",
7
"Amd64": true,
8
- "Arm64": true
8
+ "Arm64": true,
9
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu.2020.424.0_x64.appx",
10
+ "Arm64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu.2020.424.0_ARM64.appx",
11
+ "PackageFamilyName": "CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc"
12
},
13
{
14
"Name": "Debian",
15
"FriendlyName": "Debian GNU/Linux",
16
"StoreAppId": "9MSVKQC78PK6",
17
"Amd64": true,
15
- "Arm64": false
18
+ "Arm64": false,
19
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/DebianGNULinux_1-1-3-0_x64__76v4gfsz19hv4.Appx",
20
+ "Arm64PackageUrl": null,
21
+ "PackageFamilyName": "TheDebianProject.DebianGNULinux_76v4gfsz19hv4"
22
},
23
{
24
"Name": "kali-linux",
25
"FriendlyName": "Kali Linux Rolling",
26
"StoreAppId": "9PKR34TNCV07",
27
"Amd64": true,
22
- "Arm64": false
28
+ "Arm64": false,
29
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/kali-linux-08-06-2019.appx",
30
+ "Arm64PackageUrl": null,
31
+ "PackageFamilyName": "KaliLinux.54290C8133FEE_ey8k8hqnwqnmg"
32
},
33
{
34
"Name": "openSUSE-42",
35
"FriendlyName": "openSUSE Leap 42",
36
"StoreAppId": "9N6J06BMCGT3",
37
"Amd64": true,
29
- "Arm64": false
38
+ "Arm64": false,
39
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/openSUSE-42_v1.appx",
40
+ "Arm64PackageUrl": null,
41
+ "PackageFamilyName": "46932SUSE.openSUSELeap42.2_022rs5jcyhyac"
42
},
43
{
44
"Name": "SLES-12",
45
"FriendlyName": "SUSE Linux Enterprise Server v12",
34
- "StoreAppId": "9NVGTG6752JM",
46
+ "StoreAppId": "9MZ3D1TRP8T1",
47
"Amd64": true,
36
- "Arm64": false
48
+ "Arm64": false,
49
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/SLES-12_v1.appx",
50
+ "Arm64PackageUrl": null,
51
+ "PackageFamilyName": "46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac"
52
},
53
{
54
"Name": "SLES-15",
55
"FriendlyName": "SUSE Linux Enterprise Server v15",
56
"StoreAppId": "9NJFZK00FGKV",
57
"Amd64": true,
43
- "Arm64": false
58
+ "Arm64": false,
59
+ "Amd64PackageUrl": null,
60
+ "Arm64PackageUrl": null,
61
+ "PackageFamilyName": null
62
},
63
{
64
"Name": "Ubuntu-18.04",
65
"FriendlyName": "Ubuntu 18.04 LTS",
66
"StoreAppId": "9N9TNGVNDL3Q",
67
"Amd64": true,
50
- "Arm64": true
68
+ "Arm64": true,
69
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_1804.2019.522.0_x64.appx",
70
+ "Arm64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_1804.2019.522.0_ARM64.appx",
71
+ "PackageFamilyName": "CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc"
72
},
73
{
74
"Name": "Ubuntu-20.04",
75
"FriendlyName": "Ubuntu 20.04 LTS",
76
"StoreAppId": "9N6SVWS3RX71",
77
"Amd64": true,
57
- "Arm64": true
78
+ "Arm64": true,
79
+ "Amd64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_2004.2020.424.0_x64.appx",
80
+ "Arm64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_2004.2020.424.0_ARM64.appx",
81
+ "PackageFamilyName": "46932SUSE.openSUSELeap42.2_022rs5jcyhyac"
82
}
83
]
84
}
\ No newline at end of file
distributions/validate.py
new
+60
@@ -0,0 +1,60 @@
1
+import requests
2
+import json
3
+import sys
4
+from urllib.request import urlretrieve
5
+from xml.etree import ElementTree
6
+import tempfile
7
+import zipfile
8
+
9
+def download_and_get_manifest(url: str):
10
+ print(f'Downloading {url}')
11
+
12
+ filename, _ = urlretrieve(url)
13
+ with zipfile.ZipFile(filename) as archive:
14
+ try:
15
+ with archive.open('AppxManifest.xml') as manifest:
16
+ return ElementTree.fromstring(manifest.read())
17
+ except KeyError:
18
+ # In the case of a bundle
19
+ with archive.open('AppxMetadata/AppxBundleManifest.xml') as manifest:
20
+ return ElementTree.fromstring(manifest.read())
21
+
22
+def validate_package_url(url: str, family_name: str, platform: str):
23
+ manifest = download_and_get_manifest(url)
24
+ identity = manifest.find('.//{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity')
25
+
26
+ if identity is not None:
27
+ # Check the architecture if the package isn't bundled
28
+ assert platform == identity.attrib['ProcessorArchitecture']
29
+ else:
30
+ # Only check the package name for bundles
31
+ identity = manifest.find('.//{http://schemas.microsoft.com/appx/2013/bundle}Identity')
32
+
33
+ assert identity.attrib['Name'] in family_name
34
+
35
+def validate_distro(distro: dict):
36
+ if distro['Amd64PackageUrl'] is not None:
37
+ validate_package_url(distro['Amd64PackageUrl'], distro['PackageFamilyName'], 'x64')
38
+
39
+ if distro['Arm64PackageUrl'] is not None:
40
+ validate_package_url(distro['Arm64PackageUrl'], distro['PackageFamilyName'], 'arm64')
41
+
42
+def is_unique(collection: list):
43
+ unique_list = set(collection)
44
+ return len(collection) == len(unique_list)
45
+
46
+
47
+if __name__ == "__main__":
48
+ if len(sys.argv) < 2:
49
+ print(f'Usage: {sys.argv[0]} /path/to/file', file=sys.stderr)
50
+ exit(1)
51
+
52
+ with open(sys.argv[1]) as fd:
53
+ content = json.loads(fd.read())
54
+
55
+ distros = content['Distributions']
56
+ assert is_unique([e.get('StoreAppId') for e in distros if e])
57
+ assert is_unique([e.get('Name') for e in distros if e])
58
+
59
+ for e in content['Distributions']:
60
+ validate_distro(e)
\ No newline at end of file