M cmake/modules/AddPackage.cmake => cmake/modules/AddPackage.cmake +3 -3
@@ 62,15 62,15 @@ function(add_update_package SOURCE_TARGET)
OUTPUT ${UPDATE_PKG}
DEPENDS ${SOURCE_TARGET}
DEPENDS ${SOURCE_TARGET}-boot.bin
+ DEPENDS ${SOURCE_TARGET}-version.json-target
DEPENDS ecoboot.bin-target
- DEPENDS version.json-target
DEPENDS assets
COMMAND ${CMAKE_SOURCE_DIR}/tools/generate_update_image.sh ${SOURCE_TARGET} ${CMAKE_PROJECT_VERSION} ${CPACK_SYSTEM_NAME}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating update image"
- )
+ )
message("Adding '${SOURCE_TARGET}-UpdatePackage' target")
add_custom_target(${SOURCE_TARGET}-UpdatePackage
DEPENDS ${UPDATE_PKG}
- )
+ )
endfunction()
A cmake/modules/AddVersionJson.cmake => cmake/modules/AddVersionJson.cmake +21 -0
@@ 0,0 1,21 @@
+function(add_version_json SOURCE_TARGET)
+ add_custom_command(OUTPUT ${SOURCE_TARGET}-version.json
+ COMMAND ${CMAKE_COMMAND}
+ -DSRC_DIR=${CMAKE_SOURCE_DIR}
+ -DSRC_FILE=${CMAKE_SOURCE_DIR}/config/version.json.cmake_template
+ -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_FILE:${SOURCE_TARGET}>
+ -B ${CMAKE_BINARY_DIR}
+ -P ${CMAKE_SOURCE_DIR}/cmake/modules/ConfigureVersionJson.cmake
+ DEPENDS ecoboot.bin-target
+ DEPENDS ${SOURCE_TARGET}-boot.bin
+ )
+
+ add_custom_target(${SOURCE_TARGET}-version.json-target DEPENDS ${SOURCE_TARGET}-version.json)
+
+ multicomp_install(FILES ${CMAKE_BINARY_DIR}/${SOURCE_TARGET}-version.json DESTINATION "./" RENAME "version.json" COMPONENTS Standalone Update)
+endfunction()
A cmake/modules/ConfigureVersionJson.cmake => cmake/modules/ConfigureVersionJson.cmake +9 -0
@@ 0,0 1,9 @@
+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)
+
+message("Configuring version.json file")
+configure_file(${SRC_FILE} ${DST_FILE} @ONLY)
M cmake/modules/FetchBootloader.cmake => cmake/modules/FetchBootloader.cmake +16 -28
@@ 1,35 1,23 @@
-# download the bootloader
-set(ECOBOOT_FILE ecoboot.bin)
-set(VERSION_JSON_FILE version.json)
-
function(fetch_ecoboot)
- set(ECOBOOT_DOWNLOAD_LOG ${CMAKE_BINARY_DIR}/download_info.txt)
- add_custom_command(OUTPUT ${ECOBOOT_FILE}
- COMMAND ${CMAKE_SOURCE_DIR}/tools/download_asset.py
+ set(ECOBOOT_ASSET_NAME ecoboot.bin)
+ if(${PURE_HW_TARGET} STREQUAL "T6")
+ 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
- > ${ECOBOOT_DOWNLOAD_LOG}
- COMMENT "Downloading ${ECOBOOT_FILE}"
- BYPRODUCTS ${ECOBOOT_DOWNLOAD_LOG}
- )
-
- add_custom_target(${ECOBOOT_FILE}-target DEPENDS ${ECOBOOT_FILE})
+ -w ${CMAKE_BINARY_DIR}
+ ecoboot download
+ -n ${ECOBOOT_ASSET_NAME}
+ -o ecoboot.bin
+ COMMENT "Downloading ecoboot.bin"
+ BYPRODUCTS ecoboot.version
+ )
- # generate version.json file (runs CMake script at build time)
- add_custom_command(OUTPUT ${VERSION_JSON_FILE}
- COMMAND ${CMAKE_COMMAND}
- -DSRC_DIR=${CMAKE_SOURCE_DIR}
- -DECOBOOT_DOWNLOAD_LOG=${ECOBOOT_DOWNLOAD_LOG}
- -B ${CMAKE_BINARY_DIR}
- -P ${CMAKE_SOURCE_DIR}/cmake/modules/GenUpdateVersionJson.cmake
- DEPENDS ${ECOBOOT_FILE}-target ${ECOBOOT_DOWNLOAD_LOG}
- )
+ add_custom_target(ecoboot.bin-target DEPENDS ecoboot.bin)
- add_custom_target(${VERSION_JSON_FILE}-target DEPENDS ${VERSION_JSON_FILE})
-
- multicomp_install(PROGRAMS ${CMAKE_BINARY_DIR}/${ECOBOOT_FILE} DESTINATION "./"
- COMPONENTS Standalone Update)
- multicomp_install(FILES ${CMAKE_BINARY_DIR}/${VERSION_JSON_FILE} DESTINATION "./"
+ multicomp_install(PROGRAMS ${CMAKE_BINARY_DIR}/ecoboot.bin DESTINATION "./"
COMPONENTS Standalone Update)
endfunction()
D cmake/modules/GenUpdateVersionJson.cmake => cmake/modules/GenUpdateVersionJson.cmake +0 -22
@@ 1,22 0,0 @@
-# This script generates the version.json file which contains project
-# and bootloader version information for update packages . It is meant to be run
-# at build time by running CMake as a target.
-
-list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/cmake/modules")
-include(Version)
-
-set(BOOTLOADER_INCLUDED "true")
-set(BOOTLOADER_FILENAME "ecoboot.bin")
-execute_process(
- COMMAND grep "release:" "${ECOBOOT_DOWNLOAD_LOG}"
- COMMAND awk "{print $2}"
- OUTPUT_VARIABLE BOOTLOADER_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-message("preparing version file")
-configure_file(
- ${SRC_DIR}/config/version.json.cmake_template
- ${CMAKE_BINARY_DIR}/version.json
- @ONLY
- )
M config/version.json.cmake_template => config/version.json.cmake_template +32 -27
@@ 1,29 1,34 @@
{
- "git":
- {
- "git_branch": "@GIT_BRANCH@",
- "git_commit": "@GIT_REV@",
- "git_tag": "@GIT_TAG@"
- },
- "misc":
- {
- "codename": "@VERSION_CODENAME@",
- "kernel": "@KERNEL_VERSION@",
- "buildon": "@BUILD_HOST@",
- "builddate": "@BUILD_DATE@",
- "builduser": "@BUILD_USER@"
- },
- "version":
- {
- "major": "@CMAKE_PROJECT_VERSION_MAJOR@",
- "minor": "@CMAKE_PROJECT_VERSION_MINOR@",
- "patch": "@CMAKE_PROJECT_VERSION_PATCH@",
- "string": "@CMAKE_PROJECT_VERSION@"
- },
- "bootloader":
- {
- "included": "@BOOTLOADER_INCLUDED@",
- "version": "@BOOTLOADER_VERSION@",
- "filename": "@BOOTLOADER_FILENAME@"
- }
+ "git":
+ {
+ "git_branch": "@GIT_BRANCH@",
+ "git_commit": "@GIT_REV@",
+ "git_tag": "@GIT_TAG@"
+ },
+ "misc":
+ {
+ "codename": "@VERSION_CODENAME@",
+ "kernel": "@KERNEL_VERSION@",
+ "buildon": "@BUILD_HOST@",
+ "builddate": "@BUILD_DATE@",
+ "builduser": "@BUILD_USER@"
+ },
+ "version":
+ {
+ "major": "@CMAKE_PROJECT_VERSION_MAJOR@",
+ "minor": "@CMAKE_PROJECT_VERSION_MINOR@",
+ "patch": "@CMAKE_PROJECT_VERSION_PATCH@",
+ "string": "@CMAKE_PROJECT_VERSION@"
+ },
+ "bootloader":
+ {
+ "version": "@BOOTLOADER_VERSION@",
+ "filename": "@BOOTLOADER_FILENAME@",
+ "md5sum": "@BOOTLOADER_MD5SUM@"
+ },
+ "boot":
+ {
+ "filename": "@BOOT_FILENAME@",
+ "md5sum": "@BOOT_MD5SUM@"
+ }
}
M products/BellHybrid/CMakeLists.txt => products/BellHybrid/CMakeLists.txt +3 -0
@@ 81,6 81,9 @@ add_image(BellHybrid)
include(AddHexTarget)
add_hex_target(BellHybrid)
+include(AddVersionJson)
+add_version_json(BellHybrid)
+
add_standalone_image(BellHybrid)
add_update_package(BellHybrid)
M products/PurePhone/CMakeLists.txt => products/PurePhone/CMakeLists.txt +3 -0
@@ 90,6 90,9 @@ add_image(PurePhone)
include(AddHexTarget)
add_hex_target(PurePhone)
+include(AddVersionJson)
+add_version_json(PurePhone)
+
add_standalone_image(PurePhone)
add_update_package(PurePhone)
M tools/download_asset.py => tools/download_asset.py +11 -17
@@ 1,6 1,6 @@
#!/usr/bin/env python3
"""
-Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
Download ecooboot.bin from repository
@@ 122,7 122,7 @@ class Getter(object):
print(sys._getframe().f_code.co_name)
self.getReleases(args)
print("tag:", args.tag)
- print("asset:", args.asset)
+ print("asset:", args.assetRepoName)
release = None
if args.tag is None:
release = self.releases[0]
@@ 135,21 135,14 @@ class Getter(object):
print("No release with tag:", args.tag)
print("release:", release['tag_name'])
assets = release['assets']
- if len(assets) > 1 and args.asset is None:
- print("Available assets")
- i=0
- for asset in assets:
- print(i, asset['name'])
- i+=1
- print("Use `-a <number>` to select file")
- return
- if args.asset is not None:
- self.downloadAsset(assets[int(args.asset)])
- else:
- self.downloadAsset(assets[0])
+ 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'])
- def downloadAsset(self, asset):
+ def downloadAsset(self, asset, outName):
self.createWorkdir()
print("name:", asset['name'])
print("url:", asset['url'])
@@ 159,7 152,7 @@ class Getter(object):
auth=(self.ghLogin, self.apitoken),
headers=headers,
stream=True)
- destination_file = self.args.workdir + "/" + asset['name']
+ destination_file = self.args.workdir + "/" + outName
print("downloading to:", destination_file)
progres_bar = tqdm(total=asset['size'], unit='iB', unit_scale=True)
with open(destination_file, 'wb') as fd:
@@ 213,7 206,8 @@ def main():
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('-a', '--asset', help="Asset name to download, use asset number")
+ 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)
args = parser.parse_args()
getter.repo = args.repository
M tools/generate_update_image.sh => tools/generate_update_image.sh +1 -8
@@ 70,13 70,7 @@ function linkInStageing(){
ln -s ../sys/current/country-codes.db
ln -s ../sys/current/Luts.bin
ln -s ../ecoboot.bin
- ln -s ../version.json
- popd 1> /dev/null
-}
-
-function addChecksums() {
- pushd ${STAGEING_DIR} 1> /dev/null
- rhash -u checksums.txt -r .
+ ln -s ../${SOURCE_TARGET}-version.json version.json
popd 1> /dev/null
}
@@ 93,7 87,6 @@ setVars "${1}" "${2}" "${3}"
checkForDeps ${DEPS}
cleanStagingDir ${STAGEING_DIR}
linkInStageing
-addChecksums
compress