]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow to specify supported architectures in appinfo.xml 22844/head
authorJulius Härtl <jus@bitgrid.net>
Mon, 14 Sep 2020 08:47:38 +0000 (10:47 +0200)
committerJulius Härtl <jus@bitgrid.net>
Thu, 17 Sep 2020 06:55:15 +0000 (08:55 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
lib/private/App/DependencyAnalyzer.php
lib/private/App/Platform.php
resources/app-info.xsd

index 8e7cdde68e4acf3df5a6ec05af3b08a8b81de9aa..f63cb384b156da898da5d31a81720617e0c95b42 100644 (file)
@@ -64,6 +64,7 @@ class DependencyAnalyzer {
                }
 
                return array_merge(
+                       $this->analyzeArchitecture($dependencies),
                        $this->analyzePhpVersion($dependencies),
                        $this->analyzeDatabases($dependencies),
                        $this->analyzeCommands($dependencies),
@@ -174,6 +175,29 @@ class DependencyAnalyzer {
                return $missing;
        }
 
+       private function analyzeArchitecture(array $dependencies) {
+               $missing = [];
+               if (!isset($dependencies['architecture'])) {
+                       return $missing;
+               }
+
+               $supportedArchitectures = $dependencies['architecture'];
+               if (empty($supportedArchitectures)) {
+                       return $missing;
+               }
+               if (!is_array($supportedArchitectures)) {
+                       $supportedArchitectures = [$supportedArchitectures];
+               }
+               $supportedArchitectures = array_map(function ($architecture) {
+                       return $this->getValue($architecture);
+               }, $supportedArchitectures);
+               $currentArchitecture = $this->platform->getArchitecture();
+               if (!in_array($currentArchitecture, $supportedArchitectures, true)) {
+                       $missing[] = (string)$this->l->t('The following architectures are supported: %s', [implode(', ', $supportedArchitectures)]);
+               }
+               return $missing;
+       }
+
        /**
         * @param array $dependencies
         * @return array
index 4a64177232f834a70d9125a2848e27021d2390a8..03e9c7d2767eceed3b501d75fed6db6a35eb7dab 100644 (file)
@@ -97,4 +97,8 @@ class Platform {
                $repo = new PlatformRepository();
                return $repo->findLibrary($name);
        }
+
+       public function getArchitecture(): string {
+               return php_uname('m');
+       }
 }
index 7c0f04efb591dbf9766703066d9b5abc7db54eae..f03fd0ed40243baab803d0e8b33049344654113e 100644 (file)
             <xs:selector xpath="dependencies/database"/>
             <xs:field xpath="."/>
         </xs:unique>
+        <xs:unique name="uniqueArchitecture">
+            <xs:selector xpath="dependencies/architecture"/>
+            <xs:field xpath="."/>
+        </xs:unique>
         <xs:unique name="uniqueLib">
             <xs:selector xpath="dependencies/lib"/>
             <xs:field xpath="."/>
                         maxOccurs="1"/>
             <xs:element name="nextcloud" type="nextcloud" minOccurs="1"
                         maxOccurs="1"/>
+            <xs:element name="architecture" type="architecture" minOccurs="0"
+                        maxOccurs="unbounded"/>
         </xs:sequence>
     </xs:complexType>
 
         </xs:restriction>
     </xs:simpleType>
 
+    <xs:simpleType name="architecture">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="x86"/>
+            <xs:enumeration value="x86_64"/>
+            <xs:enumeration value="aarch"/>
+            <xs:enumeration value="aarch64"/>
+        </xs:restriction>
+    </xs:simpleType>
+
     <xs:complexType name="repair-steps">
         <xs:sequence>
             <xs:element name="pre-migration" type="steps" minOccurs="0"