diff --git a/Tools/scripts/gen_stable.py b/Tools/scripts/gen_stable.py new file mode 100755 index 0000000000..178a12af2d --- /dev/null +++ b/Tools/scripts/gen_stable.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +''' +create stable-x.y.z directories so we keep all past stable releases for users to download +''' + +import os +import shutil + +VEHICLES = ['AntennaTracker', 'Copter', 'Plane', 'Rover', 'Sub'] + + +def make_stable(basedir, vehicle): + '''make stable version for a vehicle''' + stable_dir = os.path.join(basedir, vehicle, 'stable') + if not os.path.exists(stable_dir): + print("Missing %s" % stable_dir) + return + for b in sorted(os.listdir(stable_dir)): + if not os.path.isdir(os.path.join(stable_dir, b)): + continue + vfile = os.path.join(stable_dir, b, "firmware-version.txt") + if not os.path.exists(vfile): + print("Missing %s" % vfile) + continue + vstr = open(vfile).read() + version = vstr.split('-')[0] + new_dir_parent = os.path.join(basedir, vehicle, 'stable-%s' % version) + new_dir = os.path.join(new_dir_parent, b) + if os.path.exists(new_dir): + continue + if not os.path.exists(new_dir_parent): + os.mkdir(new_dir_parent) + print('Creating %s' % new_dir) + old_dir = os.path.join(stable_dir, b) + shutil.copytree(old_dir, new_dir) + + +def make_all_stable(basedir): + '''make stable directory for all vehicles''' + for v in VEHICLES: + make_stable(basedir, v) + + +if __name__ == "__main__": + import argparse + parser = argparse.ArgumentParser(description='gen_stable.py') + parser.add_argument('basedir', type=str, default="-", help='base binaries directory') + args = parser.parse_args() + + make_all_stable(args.basedir) diff --git a/Tools/scripts/generate_manifest.py b/Tools/scripts/generate_manifest.py index 8e14cbed26..2ed138afeb 100755 --- a/Tools/scripts/generate_manifest.py +++ b/Tools/scripts/generate_manifest.py @@ -7,6 +7,7 @@ import json import os import re import fnmatch +import gen_stable FIRMWARE_TYPES = ["AntennaTracker", "Copter", "Plane", "Rover", "Sub"] RELEASE_TYPES = ["beta", "latest", "stable", "stable-*"] @@ -433,6 +434,9 @@ if __name__ == "__main__": args = parser.parse_args() + # ensure all stable directories are created + gen_stable.make_all_stable(args.basedir) + generator = ManifestGenerator(args.basedir, args.baseurl) if args.outfile is None: print(generator.json())