Add support for Linux and Mac OSX update scripts that should be run straight from the lib directory on the FS.
This commit is contained in:
parent
af13be7a29
commit
5a6ba07557
3 changed files with 49 additions and 12 deletions
|
|
@ -64,8 +64,7 @@ for subdirectory in os.listdir("libraries"):
|
|||
with open(package_init, 'a'):
|
||||
pass
|
||||
print(output_directory, 512)
|
||||
print(package_init, 512)
|
||||
total_size = 1024
|
||||
total_size += 512
|
||||
|
||||
for filename in py_files:
|
||||
full_path = os.path.join(library_path, filename)
|
||||
|
|
@ -75,14 +74,6 @@ for subdirectory in os.listdir("libraries"):
|
|||
print("mpy-cross failed on", full_path)
|
||||
success = False
|
||||
continue
|
||||
file_size = os.stat(output_file).st_size
|
||||
file_sector_size = file_size
|
||||
if file_size % 512 != 0:
|
||||
file_sector_size = (file_size // 512 + 1) * 512
|
||||
total_size += file_sector_size
|
||||
print(output_file, file_size, file_sector_size)
|
||||
|
||||
print(total_size, "B", total_size / 1024, "kiB", total_size / 1024 / 1024, "MiB")
|
||||
|
||||
version = None
|
||||
tag = subprocess.run(shlex.split("git describe --tags --exact-match"), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
|
@ -108,13 +99,29 @@ with open("build/lib/VERSIONS.txt", "w") as f:
|
|||
|
||||
zip_filename = 'build/adafruit-micropython-bundle-' + version.decode("utf-8", "strict") + '.zip'
|
||||
|
||||
def add_file(bundle, src_file, zip_name):
|
||||
global total_size
|
||||
bundle.write(src_file, zip_name)
|
||||
file_size = os.stat(src_file).st_size
|
||||
file_sector_size = file_size
|
||||
if file_size % 512 != 0:
|
||||
file_sector_size = (file_size // 512 + 1) * 512
|
||||
total_size += file_sector_size
|
||||
print(zip_name, file_size, file_sector_size)
|
||||
|
||||
|
||||
with zipfile.ZipFile(zip_filename, 'w') as bundle:
|
||||
for filename in os.listdir("update_scripts"):
|
||||
src_file = os.path.join("update_scripts", filename)
|
||||
add_file(bundle, src_file, os.path.join("lib", filename))
|
||||
for root, dirs, files in os.walk("build/lib"):
|
||||
ziproot = root[len("build/"):].replace("-", "_")
|
||||
for filename in files:
|
||||
bundle.write(os.path.join(root, filename),
|
||||
os.path.join(ziproot, filename.replace("-", "_")))
|
||||
add_file(bundle, os.path.join(root, filename),
|
||||
os.path.join(ziproot, filename.replace("-", "_")))
|
||||
|
||||
print()
|
||||
print(total_size, "B", total_size / 1024, "kiB", total_size / 1024 / 1024, "MiB")
|
||||
print("Bundled in", zip_filename)
|
||||
if not success:
|
||||
sys.exit(2)
|
||||
|
|
|
|||
15
update_scripts/update_linux.sh
Executable file
15
update_scripts/update_linux.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#! /bin/bash
|
||||
latest_release=$(curl -s "https://api.github.com/repos/adafruit/micropython-adafruit-bundle/releases/latest")
|
||||
download_link=$(echo $latest_release | grep -o "\"browser_download_url\": \"[^\"]*" | cut -d \" -f 4)
|
||||
tag=$(echo $latest_release | grep -o "\"tag_name\": \"[^\"]*" | cut -d \" -f 4)
|
||||
current=$(head -n 1 VERSIONS.txt | tr -d '[:space:]')
|
||||
if [ $? -ne 0 ]
|
||||
then echo "No VERSIONS.txt please run from lib/"
|
||||
fi
|
||||
if [ $current == $tag ]
|
||||
then echo "Already updated to the latest."; exit 0
|
||||
fi
|
||||
$save_to=~/Downloads/$(basename $download_link)
|
||||
echo "Downloading to " $save_to
|
||||
curl -sL $download_link > $save_to
|
||||
unzip -o $save_to -d ..
|
||||
15
update_scripts/update_macosx.command
Executable file
15
update_scripts/update_macosx.command
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#! /bin/bash
|
||||
latest_release=$(curl -s "https://api.github.com/repos/adafruit/micropython-adafruit-bundle/releases/latest")
|
||||
download_link=$(echo $latest_release | grep -o "\"browser_download_url\": \"[^\"]*" | cut -d \" -f 4)
|
||||
tag=$(echo $latest_release | grep -o "\"tag_name\": \"[^\"]*" | cut -d \" -f 4)
|
||||
current=$(head -n 1 VERSIONS.txt | tr -d '[:space:]')
|
||||
if [ $? -ne 0 ]
|
||||
then echo "No VERSIONS.txt please run from lib/"
|
||||
fi
|
||||
if [ $current == $tag ]
|
||||
then echo "Already updated to the latest."; exit 0
|
||||
fi
|
||||
$save_to=~/Downloads/$(basename $download_link)
|
||||
echo "Downloading to " $save_to
|
||||
curl -sL $download_link > $save_to
|
||||
unzip -o $save_to -d ..
|
||||
Loading…
Reference in a new issue