M CMakeLists.txt => CMakeLists.txt +0 -5
@@ 23,8 23,6 @@ include(SerialPort)
include(CopyGdbInit)
include(Utils)
include(ModuleUtils)
-include(FetchBootloader)
-include(FetchPureUpdater)
include(DiskImage)
include(AddPackage)
@@ 168,7 166,4 @@ add_library(version-header INTERFACE)
target_include_directories(version-header INTERFACE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/source/include>)
add_dependencies(version-header version)
-fetch_ecoboot()
-fetch_updater()
-
add_subdirectory(products)
M cmake/modules/AddVersionJson.cmake => cmake/modules/AddVersionJson.cmake +2 -2
@@ 6,17 6,17 @@ function(add_version_json SOURCE_TARGET)
-DDST_FILE=${CMAKE_BINARY_DIR}/${SOURCE_TARGET}-version.json
-DBOOTLOADER_FILENAME=ecoboot.bin
-DBOOTLOADER_FILE=${CMAKE_BINARY_DIR}/ecoboot.bin
- -DBOOTLOADER_VERSION_FILE=${CMAKE_BINARY_DIR}/ecoboot.version
-DBOOT_FILENAME=boot.bin
-DBOOT_FILE=$<TARGET_PROPERTY:${SOURCE_TARGET},BIN_FILE>
-DBOOT_VERSION=${PROJECT_VERSION}
-DUPDATER_FILENAME=updater.bin
-DUPDATER_FILE=${CMAKE_BINARY_DIR}/updater.bin
- -DUPDATER_VERSION_FILE=${CMAKE_BINARY_DIR}/PureUpdater.version
-DOS_VERSION_MAJOR=${OS_VERSION_MAJOR}
-DOS_VERSION_MINOR=${OS_VERSION_MINOR}
-DOS_VERSION_PATCH=${OS_VERSION_PATCH}
-DOS_VERSION_LABEL=${OS_VERSION_LABEL}
+ -DECOBOOT_BIN_VERSION=${ECOBOOT_BIN_VERSION}
+ -DUPDATER_BIN_VERSION=${UPDATER_BIN_VERSION}
-B ${CMAKE_BINARY_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/modules/ConfigureVersionJson.cmake
DEPENDS ecoboot.bin-target
M cmake/modules/ConfigureVersionJson.cmake => cmake/modules/ConfigureVersionJson.cmake +0 -4
@@ 1,12 1,8 @@
list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/cmake/modules")
include(Version)
-file(READ ${BOOTLOADER_VERSION_FILE} BOOTLOADER_VERSION)
file(MD5 ${BOOTLOADER_FILE} BOOTLOADER_MD5SUM)
file(MD5 ${BOOT_FILE} BOOT_MD5SUM)
-
-file(READ ${UPDATER_VERSION_FILE} UPDATER_VERSION)
-string(STRIP ${UPDATER_VERSION} UPDATER_VERSION)
file(MD5 ${UPDATER_FILE} UPDATER_MD5SUM)
message("Configuring version.json file")
A cmake/modules/DownloadAsset.cmake => cmake/modules/DownloadAsset.cmake +19 -0
@@ 0,0 1,19 @@
+function(download_asset asset_name_in asset_name_out asset_repo asset_version)
+ add_custom_command(OUTPUT ${asset_repo}
+ COMMAND ${CMAKE_SOURCE_DIR}/tools/download_asset.py
+ "$<$<BOOL:$ENV{ASSETS_TOKEN}>:-t$ENV{ASSETS_TOKEN}>"
+ --workdir ${CMAKE_BINARY_DIR}
+ --repository ${asset_repo}
+ download
+ --product ${PRODUCT}
+ --version ${asset_version}
+ --assetRepoName ${asset_name_in}
+ --assetOutName ${asset_name_out}
+ COMMENT "Downloading updater.bin"
+ )
+
+ add_custom_target(${asset_name_out}-target DEPENDS ${asset_repo})
+
+ multicomp_install(PROGRAMS ${CMAKE_BINARY_DIR}/${asset_repo} DESTINATION "./"
+ COMPONENTS Standalone Update)
+endfunction()
D cmake/modules/FetchBootloader.cmake => cmake/modules/FetchBootloader.cmake +0 -23
@@ 1,23 0,0 @@
-function(fetch_ecoboot)
- set(ECOBOOT_ASSET_NAME ecoboot.bin)
- if(${BOARD} STREQUAL "puretx" AND ${BOARD_REVISION} LESS_EQUAL 6)
- set(ECOBOOT_ASSET_NAME ecoboot_T6.bin)
- endif()
-
- add_custom_command(OUTPUT ecoboot.bin
- COMMAND ${CMAKE_SOURCE_DIR}/tools/download_asset.py
- "$<$<BOOL:$ENV{ASSETS_LOGIN}>:-l$ENV{ASSETS_LOGIN}>"
- "$<$<BOOL:$ENV{ASSETS_TOKEN}>:-t$ENV{ASSETS_TOKEN}>"
- -w ${CMAKE_BINARY_DIR}
- ecoboot download
- -n ${ECOBOOT_ASSET_NAME}
- -o ecoboot.bin
- COMMENT "Downloading ecoboot.bin"
- BYPRODUCTS ecoboot.version
- )
-
- add_custom_target(ecoboot.bin-target DEPENDS ecoboot.bin)
-
- multicomp_install(PROGRAMS ${CMAKE_BINARY_DIR}/ecoboot.bin DESTINATION "./"
- COMPONENTS Standalone Update)
-endfunction()
D cmake/modules/FetchPureUpdater.cmake => cmake/modules/FetchPureUpdater.cmake +0 -20
@@ 1,20 0,0 @@
-function(fetch_updater)
- set(UPDATER_ASSET_NAME PureUpdater_RT.bin)
-
- add_custom_command(OUTPUT updater.bin
- COMMAND ${CMAKE_SOURCE_DIR}/tools/download_asset.py
- "$<$<BOOL:$ENV{ASSETS_LOGIN}>:-l$ENV{ASSETS_LOGIN}>"
- "$<$<BOOL:$ENV{ASSETS_TOKEN}>:-t$ENV{ASSETS_TOKEN}>"
- -w ${CMAKE_BINARY_DIR}
- PureUpdater download
- -n ${UPDATER_ASSET_NAME}
- -o updater.bin
- COMMENT "Downloading updater.bin"
- BYPRODUCTS PureUpdater.version
- )
-
- add_custom_target(updater.bin-target DEPENDS updater.bin)
-
- multicomp_install(PROGRAMS ${CMAKE_BINARY_DIR}/updater.bin DESTINATION "./"
- COMPONENTS Standalone Update)
-endfunction()
M config/version.json.cmake_template => config/version.json.cmake_template +2 -2
@@ 10,7 10,7 @@
},
"bootloader":
{
- "version": "@BOOTLOADER_VERSION@",
+ "version": "@ECOBOOT_BIN_VERSION@",
"filename": "@BOOTLOADER_FILENAME@",
"md5sum": "@BOOTLOADER_MD5SUM@"
},
@@ 22,7 22,7 @@
},
"updater":
{
- "version": "@UPDATER_VERSION@",
+ "version": "@UPDATER_BIN_VERSION@",
"filename": "@UPDATER_FILENAME@",
"md5sum": "@UPDATER_MD5SUM@"
}
A products/BellHybrid/BinaryAssetsVersions.cmake => products/BellHybrid/BinaryAssetsVersions.cmake +9 -0
@@ 0,0 1,9 @@
+# This file sets versions of downloaded binaries for release packaging purposes
+
+if( NOT DEFINED ECOBOOT_BIN_VERSION)
+ set(ECOBOOT_BIN_VERSION 1.0.17 CACHE STRING "bootloader binary version to download from bootloader release page")
+endif()
+
+if (NOT DEFINED UPDATER_BIN_VERSION)
+ set(UPDATER_BIN_VERSION 1.1.2 CACHE STRING "updater binary version to download from updater release page")
+endif()
M products/BellHybrid/CMakeLists.txt => products/BellHybrid/CMakeLists.txt +5 -0
@@ 82,6 82,11 @@ add_image(
include(AddHexTarget)
add_hex_target(BellHybrid)
+include(BinaryAssetsVersions.cmake)
+include(DownloadAsset)
+download_asset(PureUpdater_RT.bin updater.bin PureUpdater ${UPDATER_BIN_VERSION})
+download_asset(ecoboot.bin ecoboot.bin ecoboot ${ECOBOOT_BIN_VERSION})
+
include(AddVersionJson)
add_version_json(BellHybrid)
A products/PurePhone/BinaryAssetsVersions.cmake => products/PurePhone/BinaryAssetsVersions.cmake +9 -0
@@ 0,0 1,9 @@
+# This file sets versions of downloaded binaries for release packaging purposes
+
+if( NOT DEFINED ECOBOOT_BIN_VERSION)
+ set(ECOBOOT_BIN_VERSION 1.0.17 CACHE STRING "bootloader binary version to download from bootloader release page")
+endif()
+
+if (NOT DEFINED UPDATER_BIN_VERSION)
+ set(UPDATER_BIN_VERSION 1.1.2 CACHE STRING "updater binary version to download from updater release page")
+endif()
M products/PurePhone/CMakeLists.txt => products/PurePhone/CMakeLists.txt +5 -0
@@ 99,6 99,11 @@ add_image(
include(AddHexTarget)
add_hex_target(PurePhone)
+include(BinaryAssetsVersions.cmake)
+include(DownloadAsset)
+download_asset(PureUpdater_RT.bin updater.bin PureUpdater ${UPDATER_BIN_VERSION})
+download_asset(ecoboot.bin ecoboot.bin ecoboot ${ECOBOOT_BIN_VERSION})
+
include(AddVersionJson)
add_version_json(PurePhone)
M tools/README.md => tools/README.md +1 -1
@@ 42,7 42,7 @@ curl -o /dev/null -H "Authorization: token $(git config user.apitoken)" "https:/
2. Check if you can list releases on repository:
```
-python3 ./tools/download_asset.py -w ./ PureUpdater list 21s[cbe063dc6]
+python3 ./tools/download_asset.py -w ./ --repository PureUpdater list 21s[cbe063dc6]
```
**if not** Then fix your token, or request access to PureUpdater
M tools/download_asset.py => tools/download_asset.py +39 -20
@@ 83,11 83,12 @@ class Getter(object):
def getReleases(self, args):
'''List only releases'''
+ print(f"{sys._getframe().f_code.co_name}")
self.args = args
self.getGHLogin(args)
self.getApiToken(args)
request = self.genRestPrefix() + "releases"
- print ("Request:", request)
+ print (f"Request: {request}")
headers = {'accept': 'application/vnd.github.v3+json'}
page = 0
itemsOnPage = 100
@@ 121,29 122,46 @@ class Getter(object):
for release in self.releases:
print(release['tag_name'], release['name'], release['published_at'], release['prerelease'], sep=" | ")
+ def getProductByName(self, repository: str, product: str, version: str) -> str:
+ '''
+ We have naming convetion of releases:
+ "$Product $Version"
+ where:
+ - product is product built i.e. ecoboot
+ - version - is semantic version we use
+ '''
+ if "bell" in product.lower():
+ product = "bell"
+ elif "pure" in product.lower():
+ product = "pure"
+ else:
+ print("we require short version in this script - either pure or bell")
+ sys.exit(2)
+
+ return f"{repository} {version}-{product}"
+
def downloadRelease(self, args):
- print(sys._getframe().f_code.co_name)
+ print(f"{sys._getframe().f_code.co_name} from: {args.repository}")
self.getReleases(args)
- print("tag:", args.tag)
- print("asset:", args.assetRepoName)
+ release_requested = self.getProductByName(args.repository, args.product, args.version)
release = None
- if args.tag is None:
- release = self.releases[0]
- else:
- for rel in self.releases:
- if rel['tag_name'] == args.tag:
- release = rel
- break
+ for rel in self.releases:
+ # warning just taken first from partial match, should be done differently
+ if release_requested in rel['name']:
+ release = rel
+ break
if release is None:
- print("No release with tag:", args.tag)
- print("release:", release['tag_name'])
+ raise RuntimeError(f"Can't get release by release name: {release_requested} with args: {args}")
+ print(f"Trying to download release from {args.repository} under name: {release_requested}")
assets = release['assets']
+ found = False
for asset in assets:
if asset['name'] == args.assetRepoName:
self.downloadAsset(asset, args.assetOutName)
- with open(args.workdir + '/' + args.repository + '.version', 'w+') as versionfile:
- versionfile.write(release['tag_name'])
+ found = True
+ if not found:
+ raise(RuntimeError(f"asset not found {args.assetRepoName} and cant be saved as {args.assetOutName}"))
def downloadAsset(self, asset, outName):
self.createWorkdir()
@@ 182,7 200,7 @@ def main():
getter = Getter()
parser = argparse.ArgumentParser(description="Download ecooboot")
- parser.add_argument('-w', '--workdir', help="Directory where package is build", default="update")
+ parser.add_argument('--workdir', help="Directory where package is build", default="update")
parser.add_argument('-t', '--token',
help="GitHub security token "
"by default read from `git config user.apitoken` "
@@ 197,7 215,7 @@ def main():
"`git config -add user.githublogin <login>`",
required=(getter.ghLogin is None))
- parser.add_argument('repository', help="repository name from which assets will be downloaded")
+ parser.add_argument('--repository', help="repository name from which assets will be downloaded")
parser.set_defaults(func=getter.run)
subparsers = parser.add_subparsers(title="commands",
@@ 209,9 227,10 @@ def main():
getReleases_args = subparsers.add_parser('download', aliases=['dw'],
description="Download Release based on tag or the latest")
getReleases_args.set_defaults(func=getter.downloadRelease)
- getReleases_args.add_argument('tag', help="Download release with selected tag", nargs='?')
- getReleases_args.add_argument('-n', '--assetRepoName', help="Asset name in repository", required=True)
- getReleases_args.add_argument('-o', '--assetOutName', help="Asset output name", required=True)
+ getReleases_args.add_argument('--assetRepoName', help="Asset name in repository", required=True)
+ getReleases_args.add_argument('--assetOutName', help="Asset output name", required=True)
+ getReleases_args.add_argument('--version', help="Asset version", required=True)
+ getReleases_args.add_argument('--product', help="Asset product", required=True)
args = parser.parse_args()
getter.repo = args.repository