Skip to content
Snippets Groups Projects
Commit a0fff97f authored by James Goppert's avatar James Goppert Committed by Lorenz Meier
Browse files

Moved deployment logic to python scripts.

parent 50159cab
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,9 @@
Archives/*
Build/*
Testing/
Binaries/*
Meta/*
Packages/*
s3deploy-branch/
s3deploy-archive/
build/*
build_*/
core
......
......@@ -78,9 +78,7 @@ script:
after_success:
- if [[ "${TRAVIS_OS_NAME}" = "linux" && "${TRAVIS_BRANCH}" != "coverity" ]]; then
make package_firmware && mkdir s3deploy-archive && cp Firmware.zip s3deploy-archive/
&& cp Binaries/* .
&& find . -maxdepth 1 -mindepth 1 -type f -name 'nuttx-*-default.px4' | sed 's/.\/nuttx-//' | sed 's/-default.px4//' | xargs -I{} mv nuttx-{}-default.px4 {}_default.px4
&& mkdir s3deploy-branch && mv *_default.px4 Meta/px4fmu-v4_default/parameters.xml Meta/px4fmu-v4_default/airframes.xml s3deploy-branch/;
&& Tools/s3_deploy.py;
fi
- if [[ "${TRAVIS_OS_NAME}" = "linux" && "$GCC_VER" == "5.4" && "${TRAVIS_BRANCH}" != "coverity" ]]; then
export PX4_S3_DEPLOY=1;
......
......@@ -300,7 +300,7 @@ clang-tidy:
@$(SRC_DIR)/Tools/clang-tool.sh -b build_posix_sitl_default -t clang-tidy
package_firmware:
@zip --junk-paths Firmware.zip `find Binaries/. -name \*.px4`
@./Tools/package_firmware.py
clean:
@rm -rf build_*/
......
#!/usr/bin/env python
import glob
import zipfile
import os
FIRMWARE_FILE = 'Firmware.zip'
def extract_file_only(filename, dest):
"""
Extract a file without keeping directories.
"""
# extract firmware files without paths
f_src = archive.open(filename, 'r')
data = f_src.read()
dst_name = os.path.join(dest, os.path.basename(filename))
with open(dst_name, 'w') as f_dst:
f_dst.write(data)
f_src.close()
# open destination archive
with zipfile.ZipFile(FIRMWARE_FILE, 'w') as dest_archive:
# get all zip files in Packages directory
for zip_filename in glob.glob("Packages/*.zip"):
# open zipfile
with zipfile.ZipFile(zip_filename, 'r') as archive:
# look for interesting names
for src_filename in archive.namelist():
# extract firmware files
if os.path.splitext(src_filename)[1] == '.px4':
base_name = os.path.basename(src_filename)
dest_archive.writestr(base_name, archive.read(src_filename))
#!/usr/bin/env python
import glob
import zipfile
import os
import re
import shutil
S3_DIR = 's3deploy-branch'
S3_ARCHIVE_DIR = 's3deploy-branch'
if not os.path.isdir(S3_DIR):
os.mkdir(S3_DIR)
if not os.path.isdir(S3_ARCHIVE_DIR):
os.mkdir(S3_ARCHIVE_DIR)
shutil.copyfile(Firmware.zip, S3_ARCHIVE_DIR)
def extract_file_only(filename, dest):
# extract firmware files without paths
f_src = archive.open(filename, 'r')
data = f_src.read()
with open(os.path.join(dest,
os.path.basename(filename)), 'w') as f_dst:
f_dst.write(data)
f_src.close()
# get all zip files in Packages directory
for zip_filename in glob.glob("Packages/*.zip"):
# open zipfile
with zipfile.ZipFile(zip_filename, 'r') as archive:
# look for interesting names
for filename in archive.namelist():
# extract firmware files
if os.path.splitext(filename)[1] == '.px4':
extract_file_only(filename, S3_DIR)
# copy px4fmu-v4_default xml files for qgroundcontrol
if re.match(filename, r'.*px4fmu-v4_default.*\.xml') is not None:
extract_file_only(filename, S3_DIR)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment