From 4e2cace78c3c43d82ebc1af54c07e9bf4f8df5eb Mon Sep 17 00:00:00 2001 From: pan <601760354@163.com> Date: Sat, 23 Mar 2024 11:33:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90A-FOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/A-FOT/check_install_result.sh | 12 +++++++++ component/A-FOT/install.sh | 30 +++++++++++++++++++++ tools/download_dependency/src/download.py | 32 +++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 component/A-FOT/check_install_result.sh create mode 100644 component/A-FOT/install.sh diff --git a/component/A-FOT/check_install_result.sh b/component/A-FOT/check_install_result.sh new file mode 100644 index 0000000..dd46b25 --- /dev/null +++ b/component/A-FOT/check_install_result.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +a_fot_path=$(which a-fot) +if [[ ${a_fot_path} == ${HOME}/.local/a-fot/a-fot ]]; then + echo "true" +else + if [[ -f ${HOME}/.local/a-fot/a-fot ]] && [[ $(grep -A1 '^export A_FOT_HOME=${HOME}/.local/a-fot$' ${HOME}/.bashrc | grep '^export PATH=${A_FOT_HOME}:${PATH}$' | wc -l) == "1" ]]; then + echo "true" + else + echo "false" + fi +fi diff --git a/component/A-FOT/install.sh b/component/A-FOT/install.sh new file mode 100644 index 0000000..8f0157e --- /dev/null +++ b/component/A-FOT/install.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +cd /tmp/devkitdependencies/ + + +if [[ ! -d ${HOME}/.local/a-fot ]]; then + mkdir -p ${HOME}/.local + + echo "Decompress a-fot.tar.gz to ${HOME}/.local" + tar -zxf /tmp/devkitdependencies/a-fot.tar.gz -C ${HOME}/.local + chmod 750 -R ${HOME}/.local/a-fot + echo "Decompress a-fot.tar.gz to ${HOME}/.local finished." +fi + +a_fot_path=$(which a-fot) +if [[ ${a_fot_path} != ${HOME}/.local/a-fot/a-fot ]]; then + sed -i '/#*export A_FOT_HOME=${HOME}\/.local/d' ${HOME}/.bashrc + sed -i '/#*export PATH=${A_FOT_HOME}:${PATH}/d' ${HOME}/.bashrc + + echo "change ${HOME}/.bashrc" + cat >> ${HOME}/.bashrc <<'EOF' +export A_FOT_HOME=${HOME}/.local/a-fot +export PATH=${A_FOT_HOME}:${PATH} +EOF + echo "source ${HOME}/.bashrc" + set +x + source ${HOME}/.bashrc +else + echo "install a-fot success." +fi diff --git a/tools/download_dependency/src/download.py b/tools/download_dependency/src/download.py index 823f502..8a33211 100644 --- a/tools/download_dependency/src/download.py +++ b/tools/download_dependency/src/download.py @@ -4,6 +4,7 @@ import subprocess import sys import shutil import tarfile +import wget import download_config from download_utils import download_dependence_handler, download_dependence_file from download_command_line import process_command_line, CommandLine @@ -15,6 +16,16 @@ SAVE_PATH = "save_path" DEFAULT_PATH = "./devkitdependencies" DEPENDENCY_FILE = "devkitdependencies.tar.gz" +# A-FOT files +BASE_URL = "https://gitee.com/openeuler/A-FOT/raw/master/{}" +A_FOT = "a-fot" +A_FOT_INI = "a-fot.ini" +AUTO_FDO_SH = "auto_fdo.sh" +AUTO_BOLT_SH = "auto_bolt.sh" +AUTO_PREFETCH = "auto_prefetch.sh" +SPLIT_JSON_PY = "split_json.py" +FILE_LIST = (A_FOT, A_FOT_INI, AUTO_FDO_SH, AUTO_BOLT_SH, AUTO_PREFETCH, SPLIT_JSON_PY) + component_collection_map = { component.get("component_name"): { "download file": @@ -72,6 +83,27 @@ def download_dependence(): return ret +def download_a_fot(): + saved_path = os.path.join(DEFAULT_PATH, A_FOT) + try: + os.mkdir(saved_path) + except FileExistsError as e: + pass + + try: + for f in FILE_LIST: + wget.download(BASE_URL.format(f), os.path.join(saved_path, f)) + + with tarfile.open(os.path.join(DEFAULT_PATH, "a-fot.tar.gz"), "w:gz") as t: + t.add(saved_path, arcname="a-fot") + return True + except Exception as e: + print(e) + return False + finally: + shutil.rmtree(saved_path) + + iso_collection_map = { component.get("component_name"): { "download file": -- Gitee