|
|
|
@ -8,6 +8,7 @@ import os
@@ -8,6 +8,7 @@ import os
|
|
|
|
|
import re |
|
|
|
|
import fnmatch |
|
|
|
|
import gen_stable |
|
|
|
|
import subprocess |
|
|
|
|
|
|
|
|
|
FIRMWARE_TYPES = ["AntennaTracker", "Copter", "Plane", "Rover", "Sub"] |
|
|
|
|
RELEASE_TYPES = ["beta", "latest", "stable", "stable-*", "dirty"] |
|
|
|
@ -230,6 +231,18 @@ class ManifestGenerator():
@@ -230,6 +231,18 @@ class ManifestGenerator():
|
|
|
|
|
self.add_USB_IDs_ChibiOS(firmware) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def firmware_format_for_filepath(self, filepath): |
|
|
|
|
filename = os.path.basename(filepath) |
|
|
|
|
if "." in filename: |
|
|
|
|
return "".join(filename.split(".")[-1:]) |
|
|
|
|
# no extension; ensure this is an elf: |
|
|
|
|
text = subprocess.check_output(["file", "-b", filepath]) |
|
|
|
|
if re.match("^ELF", text): |
|
|
|
|
return "ELF" |
|
|
|
|
print("Unknown file type (%s)" % filepath) |
|
|
|
|
print("Got: %s" % text) |
|
|
|
|
return "Unknown" # should raise an error somehow |
|
|
|
|
|
|
|
|
|
def add_firmware_data_from_dir(self, |
|
|
|
|
dir, |
|
|
|
|
firmware_data, |
|
|
|
@ -293,13 +306,13 @@ class ManifestGenerator():
@@ -293,13 +306,13 @@ class ManifestGenerator():
|
|
|
|
|
frame = vehicletype # e.g. Plane |
|
|
|
|
platform = platformdir # e.g. apm2 |
|
|
|
|
|
|
|
|
|
for file in os.listdir(some_dir): |
|
|
|
|
if file in ["git-version.txt", "firmware-version.txt", "files.html"]: |
|
|
|
|
for filename in os.listdir(some_dir): |
|
|
|
|
if filename in ["git-version.txt", "firmware-version.txt", "files.html"]: |
|
|
|
|
continue |
|
|
|
|
if file.startswith("."): |
|
|
|
|
if filename.startswith("."): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
m = variant_firmware_regex.match(file) |
|
|
|
|
m = variant_firmware_regex.match(filename) |
|
|
|
|
if m: |
|
|
|
|
# the platform variant is |
|
|
|
|
# encoded in the firmware filename |
|
|
|
@ -310,7 +323,10 @@ class ManifestGenerator():
@@ -310,7 +323,10 @@ class ManifestGenerator():
|
|
|
|
|
else: |
|
|
|
|
file_platform = platform |
|
|
|
|
|
|
|
|
|
firmware_format = "".join(file.split(".")[-1:]) |
|
|
|
|
filepath = os.path.join(some_dir, filename) |
|
|
|
|
firmware_format = self.firmware_format_for_filepath(filepath) |
|
|
|
|
if firmware_format not in [ "ELF", "abin", "apj", "hex", "px4" ]: |
|
|
|
|
print("Unknown firmware format (%s)" % firmware_format) |
|
|
|
|
|
|
|
|
|
firmware = Firmware() |
|
|
|
|
|
|
|
|
@ -320,17 +336,17 @@ class ManifestGenerator():
@@ -320,17 +336,17 @@ class ManifestGenerator():
|
|
|
|
|
firmware["latest"] = 0 |
|
|
|
|
if releasetype == "dev": |
|
|
|
|
if firmware["filepath"] is None: |
|
|
|
|
firmware["filepath"] = os.path.join(some_dir, file) |
|
|
|
|
firmware["filepath"] = filepath |
|
|
|
|
if firmware["release-type"] is None: |
|
|
|
|
firmware["release-type"] = "dev" |
|
|
|
|
elif releasetype == "latest": |
|
|
|
|
firmware["latest"] = 1 |
|
|
|
|
firmware["filepath"] = os.path.join(some_dir, file) |
|
|
|
|
firmware["filepath"] = filepath |
|
|
|
|
if firmware["release-type"] is None: |
|
|
|
|
firmware["release-type"] = "dev" |
|
|
|
|
else: |
|
|
|
|
if (not firmware["latest"]): |
|
|
|
|
firmware["filepath"] = os.path.join(some_dir, file) |
|
|
|
|
firmware["filepath"] = filepath |
|
|
|
|
firmware["release-type"] = releasetype |
|
|
|
|
|
|
|
|
|
firmware["platform"] = file_platform |
|
|
|
|