From 444a37987e00b962c96bede4f5bc77d848eff609 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 30 Oct 2015 17:40:17 +0300 Subject: [PATCH] Use jq to generate package json --- .gitignore | 2 +- .../build_boards_manager_package.sh | 84 +------- .../package_esp8266com_index.template.json | 193 ++++++++++++++++++ tools/get.py | 8 +- tools/tools.json | 123 ----------- 5 files changed, 209 insertions(+), 201 deletions(-) rename build_boards_manager_package.sh => package/build_boards_manager_package.sh (58%) create mode 100644 package/package_esp8266com_index.template.json delete mode 100644 tools/tools.json diff --git a/.gitignore b/.gitignore index b13d67e4a..2623c405a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ tools/dist/ tools/xtensa-lx106-elf/ tools/esptool/ tools/mkspiffs/ -versions/ +package/versions/ exclude.txt diff --git a/build_boards_manager_package.sh b/package/build_boards_manager_package.sh similarity index 58% rename from build_boards_manager_package.sh rename to package/build_boards_manager_package.sh index 4820e978c..ac6ccc215 100755 --- a/build_boards_manager_package.sh +++ b/package/build_boards_manager_package.sh @@ -17,17 +17,16 @@ echo "Package name: $package_name" # Create directory for the package outdir=versions/$ver/$package_name -srcdir=$PWD +srcdir=$PWD/.. rm -rf versions/$ver mkdir -p $outdir # Some files should be excluded from the package cat << EOF > exclude.txt -versions .git .gitignore .travis.yml -build_boards_manager_package.sh +package EOF # Also include all files which are ignored by git git ls-files --other --ignored --exclude-standard --directory >> exclude.txt @@ -71,76 +70,13 @@ echo Size: $size echo SHA-256: $sha echo "Making package_esp8266com_index.json" -cat << EOF > package_esp8266com_index.json -{ - "packages": [ { - "name":"esp8266", - "maintainer":"ESP8266 Community", - "websiteURL":"https://github.com/esp8266/Arduino", - "email":"ivan@esp8266.com", - "help":{ - "online":"$REMOTE_URL/versions/$ver/doc/reference.html" - }, - - "platforms": [ { - "name":"esp8266", - "architecture":"esp8266", - "version":"$ver", - "category":"ESP8266", - "url":"$REMOTE_URL/versions/$ver/$package_name.zip", - "archiveFileName":"$package_name.zip", - "checksum":"SHA-256:$sha", - "size":"$size", - "help":{ - "online":"$REMOTE_URL/versions/$ver/doc/reference.html" - }, - "boards":[ - { - "name":"Generic ESP8266 Module" - }, - { - "name":"Olimex MOD-WIFI-ESP8266(-DEV)" - }, - { - "name":"NodeMCU 0.9 (ESP-12 Module)" - }, - { - "name":"NodeMCU 1.0 (ESP-12E Module)" - }, - { - "name":"Adafruit HUZZAH ESP8266 (ESP-12)" - }, - { - "name":"SparkFun Thing" - }, - { - "name":"SweetPea ESP-210" - } - ], - "toolsDependencies":[ { - "packager":"esp8266", - "name":"esptool", - "version":"0.4.6" - }, - { - "packager":"esp8266", - "name":"xtensa-lx106-elf-gcc", - "version":"1.20.0-26-gb404fb9-2" - }, - { - "packager":"esp8266", - "name":"mkspiffs", - "version":"0.1.2" - } ] - } ], - "tools": -EOF - -cat $srcdir/tools/tools.json >> package_esp8266com_index.json - -cat << EOF >> package_esp8266com_index.json - } ] -} -EOF +cat $srcdir/package/package_esp8266com_index.template.json | \ +jq ".packages[0].platforms[0].version = \"$ver\" | \ + .packages[0].platforms[0].url = \"$REMOTE_URL/versions/$ver/$package_name.zip\" |\ + .packages[0].platforms[0].archiveFileName = \"$package_name.zip\" |\ + .packages[0].platforms[0].checksum = \"SHA-256:$sha\" |\ + .packages[0].platforms[0].size = \"$size\" |\ + .packages[0].platforms[0].help.online = \"$REMOTE_URL/versions/$ver/doc/reference.html\"" \ + > package_esp8266com_index.json popd diff --git a/package/package_esp8266com_index.template.json b/package/package_esp8266com_index.template.json new file mode 100644 index 000000000..9535db4a1 --- /dev/null +++ b/package/package_esp8266com_index.template.json @@ -0,0 +1,193 @@ +{ + "packages": [ + { + "name": "esp8266", + "maintainer": "ESP8266 Community", + "websiteURL": "https://github.com/esp8266/Arduino", + "email": "ivan@esp8266.com", + "help": { + "online": "http://esp8266.com/arduino" + }, + "platforms": [ + { + "name": "esp8266", + "architecture": "esp8266", + "version": "", + "category": "ESP8266", + "url": "", + "archiveFileName": "", + "checksum": "", + "size": "", + "help": { + "online": "" + }, + "boards": [ + { + "name": "Generic ESP8266 Module" + }, + { + "name": "Olimex MOD-WIFI-ESP8266(-DEV)" + }, + { + "name": "NodeMCU 0.9 (ESP-12 Module)" + }, + { + "name": "NodeMCU 1.0 (ESP-12E Module)" + }, + { + "name": "Adafruit HUZZAH ESP8266 (ESP-12)" + }, + { + "name": "SparkFun Thing" + }, + { + "name": "SweetPea ESP-210" + } + ], + "toolsDependencies": [ + { + "packager": "esp8266", + "name": "esptool", + "version": "0.4.6" + }, + { + "packager": "esp8266", + "name": "xtensa-lx106-elf-gcc", + "version": "1.20.0-26-gb404fb9-2" + }, + { + "packager": "esp8266", + "name": "mkspiffs", + "version": "0.1.2" + } + ] + } + ], + "tools": [ + { + "name": "esptool", + "version": "0.4.6", + "systems": [ + { + "host": "i686-mingw32", + "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-win32.zip", + "archiveFileName": "esptool-0.4.6-win32.zip", + "checksum": "SHA-256:0248bf78514a3195f583e29218ca7828a66e13c6e5545a078f1c1257033e4927", + "size": "17481" + }, + { + "host": "x86_64-apple-darwin", + "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-osx.tar.gz", + "archiveFileName": "esptool-0.4.6-osx.tar.gz", + "checksum": "SHA-256:0fe87ba7e29ee90a9fc72492aada8c0796f9e8f8a1c594b6b26cee2610d09bb3", + "size": "20926" + }, + { + "host": "i386-apple-darwin", + "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-osx.tar.gz", + "archiveFileName": "esptool-0.4.6-osx.tar.gz", + "checksum": "SHA-256:0fe87ba7e29ee90a9fc72492aada8c0796f9e8f8a1c594b6b26cee2610d09bb3", + "size": "20926" + }, + { + "host": "x86_64-pc-linux-gnu", + "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-linux64.tar.gz", + "archiveFileName": "esptool-0.4.6-linux64.tar.gz", + "checksum": "SHA-256:f9f456e9a42bb2597126c513cb8865f923fb978865d4838b9623d322216b74d0", + "size": "12885" + }, + { + "host": "i686-pc-linux-gnu", + "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-linux32.tar.gz", + "archiveFileName": "esptool-0.4.6-linux32.tar.gz", + "checksum": "SHA-256:85275ca03a82bfc456f5a84e86962ca1e470ea2e168829c38ca29ee668831d93", + "size": "13417" + } + ] + }, + { + "name": "xtensa-lx106-elf-gcc", + "version": "1.20.0-26-gb404fb9-2", + "systems": [ + { + "host": "i686-mingw32", + "url": "http://arduino.esp8266.com/win32-xtensa-lx106-elf-gb404fb9-2.tar.gz", + "archiveFileName": "win32-xtensa-lx106-elf-gb404fb9-2.tar.gz", + "checksum": "SHA-256:10476b9c11a7a90f40883413ddfb409f505b20692e316c4e597c4c175b4be09c", + "size": "153527527" + }, + { + "host": "x86_64-apple-darwin", + "url": "http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", + "archiveFileName": "osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", + "checksum": "SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", + "size": "35385382" + }, + { + "host": "i386-apple-darwin", + "url": "http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", + "archiveFileName": "osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", + "checksum": "SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", + "size": "35385382" + }, + { + "host": "x86_64-pc-linux-gnu", + "url": "http://arduino.esp8266.com/linux64-xtensa-lx106-elf-gb404fb9.tar.gz", + "archiveFileName": "linux64-xtensa-lx106-elf-gb404fb9.tar.gz", + "checksum": "SHA-256:46f057fbd8b320889a26167daf325038912096d09940b2a95489db92431473b7", + "size": "30262903" + }, + { + "host": "i686-pc-linux-gnu", + "url": "http://arduino.esp8266.com/linux32-xtensa-lx106-elf.tar.gz", + "archiveFileName": "linux32-xtensa-lx106-elf.tar.gz", + "checksum": "SHA-256:b24817819f0078fb05895a640e806e0aca9aa96b47b80d2390ac8e2d9ddc955a", + "size": "32734156" + } + ] + }, + { + "name": "mkspiffs", + "version": "0.1.2", + "systems": [ + { + "host": "i686-mingw32", + "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-windows.zip", + "archiveFileName": "mkspiffs-0.1.2-windows.zip", + "checksum": "SHA-256:0a29119b8458b61a877408f7995e4944623a712e0d313a2c2f76af9ab55cc9f2", + "size": "230802" + }, + { + "host": "x86_64-apple-darwin", + "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-osx.tar.gz", + "archiveFileName": "mkspiffs-0.1.2-osx.tar.gz", + "checksum": "SHA-256:df656fae21a41c1269ea50cb53752dcaf6a4e1437255f3a9fb50b4025549b58e", + "size": "115091" + }, + { + "host": "i386-apple-darwin", + "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-osx.tar.gz", + "archiveFileName": "mkspiffs-0.1.2-osx.tar.gz", + "checksum": "SHA-256:df656fae21a41c1269ea50cb53752dcaf6a4e1437255f3a9fb50b4025549b58e", + "size": "115091" + }, + { + "host": "x86_64-pc-linux-gnu", + "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux64.tar.gz", + "archiveFileName": "mkspiffs-0.1.2-linux64.tar.gz", + "checksum": "SHA-256:1a1dd81b51daf74c382db71b42251757ca4136e8762107e69feaa8617bac315f", + "size": "46281" + }, + { + "host": "i686-pc-linux-gnu", + "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux32.tar.gz", + "archiveFileName": "mkspiffs-0.1.2-linux32.tar.gz", + "checksum": "SHA-256:e990d545dfcae308aabaac5fa9e1db734cc2b08167969e7eedac88bd0839667c", + "size": "45272" + } + ] + } + ] + } + ] +} diff --git a/tools/get.py b/tools/get.py index 3f780205f..b32eb884f 100755 --- a/tools/get.py +++ b/tools/get.py @@ -6,6 +6,7 @@ from __future__ import print_function import urllib import os +import shutil import errno import os.path import hashlib @@ -56,7 +57,8 @@ def unpack(filename, destination): rename_to = re.match(r'^([a-z][^\-]*\-*)+', dirname).group(0).encode('ascii').strip('-') if rename_to != dirname: print('Renaming {0} to {1}'.format(dirname, rename_to)) - os.rename(dirname, rename_to) + shutil.rmtree(rename_to) + shutil.move(dirname, rename_to) def get_tool(tool): archive_name = tool['archiveFileName'] @@ -77,7 +79,7 @@ def get_tool(tool): unpack(local_path, '.') def load_tools_list(filename, platform): - tools_info = json.load(open(filename)) + tools_info = json.load(open(filename))['packages'][0]['tools'] tools_to_download = [] for t in tools_info: tool_platform = [p for p in t['systems'] if p['host'] == platform] @@ -97,7 +99,7 @@ def identify_platform(): if __name__ == '__main__': print('Platform: {0}'.format(identify_platform())) - tools_to_download = load_tools_list('tools.json', identify_platform()) + tools_to_download = load_tools_list('../package/package_esp8266com_index.template.json', identify_platform()) mkdir_p(dist_dir) for tool in tools_to_download: get_tool(tool) diff --git a/tools/tools.json b/tools/tools.json deleted file mode 100644 index a708f4e3e..000000000 --- a/tools/tools.json +++ /dev/null @@ -1,123 +0,0 @@ -[ { - "name":"esptool", - "version":"0.4.6", - "systems": [ - { - "host":"i686-mingw32", - "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-win32.zip", - "archiveFileName":"esptool-0.4.6-win32.zip", - "checksum":"SHA-256:0248bf78514a3195f583e29218ca7828a66e13c6e5545a078f1c1257033e4927", - "size":"17481" - }, - { - "host":"x86_64-apple-darwin", - "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-osx.tar.gz", - "archiveFileName":"esptool-0.4.6-osx.tar.gz", - "checksum":"SHA-256:0fe87ba7e29ee90a9fc72492aada8c0796f9e8f8a1c594b6b26cee2610d09bb3", - "size":"20926" - }, - { - "host":"i386-apple-darwin", - "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-osx.tar.gz", - "archiveFileName":"esptool-0.4.6-osx.tar.gz", - "checksum":"SHA-256:0fe87ba7e29ee90a9fc72492aada8c0796f9e8f8a1c594b6b26cee2610d09bb3", - "size":"20926" - }, - { - "host":"x86_64-pc-linux-gnu", - "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-linux64.tar.gz", - "archiveFileName":"esptool-0.4.6-linux64.tar.gz", - "checksum":"SHA-256:f9f456e9a42bb2597126c513cb8865f923fb978865d4838b9623d322216b74d0", - "size":"12885" - }, - { - "host":"i686-pc-linux-gnu", - "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-linux32.tar.gz", - "archiveFileName":"esptool-0.4.6-linux32.tar.gz", - "checksum":"SHA-256:85275ca03a82bfc456f5a84e86962ca1e470ea2e168829c38ca29ee668831d93", - "size":"13417" - } - ] -}, -{ - "name":"xtensa-lx106-elf-gcc", - "version":"1.20.0-26-gb404fb9-2", - "systems": [ - { - "host":"i686-mingw32", - "url":"http://arduino.esp8266.com/win32-xtensa-lx106-elf-gb404fb9-2.tar.gz", - "archiveFileName":"win32-xtensa-lx106-elf-gb404fb9-2.tar.gz", - "checksum":"SHA-256:10476b9c11a7a90f40883413ddfb409f505b20692e316c4e597c4c175b4be09c", - "size":"153527527" - }, - { - "host":"x86_64-apple-darwin", - "url":"http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", - "archiveFileName":"osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", - "checksum":"SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", - "size":"35385382" - }, - { - "host":"i386-apple-darwin", - "url":"http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", - "archiveFileName":"osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", - "checksum":"SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", - "size":"35385382" - }, - { - "host":"x86_64-pc-linux-gnu", - "url":"http://arduino.esp8266.com/linux64-xtensa-lx106-elf-gb404fb9.tar.gz", - "archiveFileName":"linux64-xtensa-lx106-elf-gb404fb9.tar.gz", - "checksum":"SHA-256:46f057fbd8b320889a26167daf325038912096d09940b2a95489db92431473b7", - "size":"30262903" - }, - { - "host":"i686-pc-linux-gnu", - "url":"http://arduino.esp8266.com/linux32-xtensa-lx106-elf.tar.gz", - "archiveFileName":"linux32-xtensa-lx106-elf.tar.gz", - "checksum":"SHA-256:b24817819f0078fb05895a640e806e0aca9aa96b47b80d2390ac8e2d9ddc955a", - "size":"32734156" - } - ] -}, -{ - "name":"mkspiffs", - "version":"0.1.2", - "systems": [ - { - "host":"i686-mingw32", - "url":"https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-windows.zip", - "archiveFileName":"mkspiffs-0.1.2-windows.zip", - "checksum":"SHA-256:0a29119b8458b61a877408f7995e4944623a712e0d313a2c2f76af9ab55cc9f2", - "size":"230802" - }, - { - "host":"x86_64-apple-darwin", - "url":"https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-osx.tar.gz", - "archiveFileName":"mkspiffs-0.1.2-osx.tar.gz", - "checksum":"SHA-256:df656fae21a41c1269ea50cb53752dcaf6a4e1437255f3a9fb50b4025549b58e", - "size":"115091" - }, - { - "host":"i386-apple-darwin", - "url":"https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-osx.tar.gz", - "archiveFileName":"mkspiffs-0.1.2-osx.tar.gz", - "checksum":"SHA-256:df656fae21a41c1269ea50cb53752dcaf6a4e1437255f3a9fb50b4025549b58e", - "size":"115091" - }, - { - "host":"x86_64-pc-linux-gnu", - "url":"https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux64.tar.gz", - "archiveFileName":"mkspiffs-0.1.2-linux64.tar.gz", - "checksum":"SHA-256:1a1dd81b51daf74c382db71b42251757ca4136e8762107e69feaa8617bac315f", - "size":"46281" - }, - { - "host":"i686-pc-linux-gnu", - "url":"https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux32.tar.gz", - "archiveFileName":"mkspiffs-0.1.2-linux32.tar.gz", - "checksum":"SHA-256:e990d545dfcae308aabaac5fa9e1db734cc2b08167969e7eedac88bd0839667c", - "size":"45272" - } - ] -} ]