mirror of
https://github.com/Ascend/ascend-docker-runtime.git
synced 2025-10-27 23:01:33 +08:00
Match-id-cd39ed830f78ed33f1c036cde662457c1dd8870b
This commit is contained in:
@@ -14,8 +14,6 @@ BUILD=${ROOT}/build
|
||||
CLIDIR=${ROOT}/cli
|
||||
CLISRCNAME="main.c"
|
||||
|
||||
INSTALLHELPERDIR=${ROOT}/install
|
||||
INSTALLHELPERSRCNAME="main.c"
|
||||
|
||||
HOOKDIR=${ROOT}/hook
|
||||
HOOKSRCNAME="main.go"
|
||||
@@ -25,8 +23,7 @@ RUNTIMESRCNAME="main.go"
|
||||
|
||||
CLISRCPATH=$(find ${CLIDIR} -name "${CLISRCNAME}")
|
||||
CLISRCDIR=${CLISRCPATH%/${CLISRCNAME}}
|
||||
INSTALLHELPERSRCPATH=$(find ${INSTALLHELPERDIR} -name "${INSTALLHELPERSRCNAME}")
|
||||
INSTALLHELPERSRCDIR=${INSTALLHELPERSRCPATH%/${INSTALLHELPERSRCNAME}}
|
||||
|
||||
HOOKSRCPATH=$(find ${HOOKDIR} -name "${HOOKSRCNAME}")
|
||||
HOOKSRCDIR=${HOOKSRCPATH%/${HOOKSRCNAME}}
|
||||
RUNTIMESRCPATH=$(find ${RUNTIMEDIR} -name "${RUNTIMESRCNAME}")
|
||||
@@ -46,13 +43,6 @@ function build_bin()
|
||||
make clean
|
||||
make
|
||||
|
||||
echo "make installhelper"
|
||||
[ -d "${BUILD}/build/helper/build" ] && rm -rf ${BUILD}/build/helper/build
|
||||
mkdir -p ${BUILD}/build/helper/build && cd ${BUILD}/build/helper/build
|
||||
cmake ${INSTALLHELPERSRCDIR}
|
||||
make clean
|
||||
make
|
||||
|
||||
[ -d "${ROOT}/opensource/src" ] && rm -rf ${ROOT}/opensource/src
|
||||
mkdir ${ROOT}/opensource/src
|
||||
cd ${HOOKDIR}
|
||||
@@ -87,12 +77,12 @@ function build_run_package()
|
||||
cd ${BUILD}
|
||||
mkdir run_pkg
|
||||
|
||||
/bin/cp -f {${RUNTIMESRCDIR},${HOOKSRCDIR},${BUILD}/build/helper,${BUILD}/build/cli}/build/ascend-docker* run_pkg
|
||||
/bin/cp -f {${RUNTIMESRCDIR},${HOOKSRCDIR},${BUILD}/build/cli}/build/ascend-docker* run_pkg
|
||||
/bin/cp -f scripts/uninstall.sh run_pkg
|
||||
/bin/cp -f scripts/base.list run_pkg
|
||||
FILECNT=$(ls -l run_pkg |grep "^-"|wc -l)
|
||||
echo "prepare package $FILECNT bins"
|
||||
if [ $FILECNT -ne 6 ]; then
|
||||
if [ $FILECNT -ne 5 ]; then
|
||||
exit 1
|
||||
fi
|
||||
/bin/cp -rf ${ROOT}/assets run_pkg
|
||||
|
||||
@@ -18,11 +18,9 @@ function install()
|
||||
cp -f ./ascend-docker-runtime ${INSTALL_PATH}/ascend-docker-runtime
|
||||
cp -f ./ascend-docker-hook ${INSTALL_PATH}/ascend-docker-hook
|
||||
cp -f ./ascend-docker-cli ${INSTALL_PATH}/ascend-docker-cli
|
||||
cp -f ./ascend-docker-plugin-install-helper ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-runtime
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-hook
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-cli
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
|
||||
cp -rf ./assets ${INSTALL_PATH}/assets
|
||||
cp -f ./README.md ${INSTALL_PATH}/README.md
|
||||
@@ -46,7 +44,6 @@ function install()
|
||||
|
||||
SRC="${DOCKER_CONFIG_DIR}/daemon.json.${PPID}"
|
||||
DST="${DOCKER_CONFIG_DIR}/daemon.json"
|
||||
./ascend-docker-plugin-install-helper add ${DST} ${SRC} ${INSTALL_PATH}/ascend-docker-runtime
|
||||
if [ "$?" != "0" ]; then
|
||||
echo 'create damon.json failed'
|
||||
exit 1
|
||||
@@ -92,13 +89,11 @@ function upgrade()
|
||||
cp -f ./ascend-docker-runtime ${INSTALL_PATH}/ascend-docker-runtime
|
||||
cp -f ./ascend-docker-hook ${INSTALL_PATH}/ascend-docker-hook
|
||||
cp -f ./ascend-docker-cli ${INSTALL_PATH}/ascend-docker-cli
|
||||
cp -f ./ascend-docker-plugin-install-helper ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
cp -f ./uninstall.sh ${INSTALL_PATH}/script/uninstall.sh
|
||||
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-runtime
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-hook
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-cli
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
chmod 500 ${INSTALL_PATH}/script/uninstall.sh
|
||||
chmod 440 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ if [ ! -f "${DST}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${ROOT}/ascend-docker-plugin-install-helper rm ${DST} ${SRC}
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "ERROR: del damon.json failed"
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "ERROR: del damon.json failed" >>${LOG_FILE}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Maintainer: huawei
|
||||
Description: asenddockertool.
|
||||
The asend docker tool help usr to modify a customed deamon.json.
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
DIR=/etc/docker
|
||||
if [ ! -d "${DIR}" ]; then
|
||||
mkdir ${DIR}
|
||||
fi
|
||||
SRC="${DIR}/daemon.json.${PPID}"
|
||||
DST="${DIR}/daemon.json"
|
||||
BINDIR=/usr/bin
|
||||
${BINDIR}/ascend-docker-plugin-install-helper add ${DST} ${SRC}
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "create damon.json failed\n"
|
||||
exit 1
|
||||
fi
|
||||
\mv ${SRC} ${DST}
|
||||
echo "create damom.json success\n"
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
DIR=/etc/docker
|
||||
SRC="${DIR}/daemon.json.${PPID}"
|
||||
DST="${DIR}/daemon.json"
|
||||
if [ ! -f "${DST}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
BINDIR=/usr/bin
|
||||
${BINDIR}/ascend-docker-plugin-install-helper rm ${DST} ${SRC}
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "del damon.json failed\n"
|
||||
exit 1
|
||||
fi
|
||||
\mv ${SRC} ${DST}
|
||||
echo "del damom.json success\n"
|
||||
@@ -1,32 +0,0 @@
|
||||
# CMake 最低版本号要求
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
# 项目信息
|
||||
project (ascend-docker-plugin-install-helper)
|
||||
|
||||
message(STATUS "CMAKE_SHARED_LIBRARY_LINK_C_FLAGS = " ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
|
||||
|
||||
#导入头文件所在路径
|
||||
#PROJECT_SOURCE_DIR为cmake宏
|
||||
include_directories("../../../opensource/cJSON-1.7.14")
|
||||
include_directories("../../../platform/HuaweiSecureC/include")
|
||||
|
||||
# 查找当前目录下的所有源文件
|
||||
# 并将名称保存到 SRC 变量
|
||||
aux_source_directory(. SRC)
|
||||
|
||||
# 指定生成目标
|
||||
add_executable(ascend-docker-plugin-install-helper ${SRC})
|
||||
|
||||
# 添加子目录
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../build/cjson ${CMAKE_CURRENT_SOURCE_DIR}/../../../build/cjson)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../build/HuaweiSecureC ${CMAKE_CURRENT_SOURCE_DIR}/../../../build/HuaweiSecureC)
|
||||
|
||||
# 添加链接库
|
||||
#该命令要在add_executable命令下方,否则报错
|
||||
target_compile_options(ascend-docker-plugin-install-helper PRIVATE -fstack-protector-all -fpie)
|
||||
target_link_libraries(ascend-docker-plugin-install-helper -pie -Wl,-s,-z,now cjson)
|
||||
target_link_libraries(ascend-docker-plugin-install-helper -pie -Wl,-s,-z,now HuaweiSecureC)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#! /bin/bash
|
||||
echo "extract files\n"
|
||||
if [ ! -d "../cjson" ];then
|
||||
mkdir ../src
|
||||
else
|
||||
rm -rf ../src
|
||||
fi
|
||||
/bin/cp -rf ${files} ../cjson
|
||||
tar -zxvf ../*.tar.gz
|
||||
files=`find ../ -name "cJSON.*"`
|
||||
@@ -1,323 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
||||
* Description: ascend_docker_install工具,用于辅助用户安装ascend_docker
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "cJSON.h"
|
||||
|
||||
#define MAX_JSON_FILE_SIZE 65535
|
||||
#define MIN_ARGS_NUM 4
|
||||
#define ADD_CMD_ARGS_NUM 5
|
||||
#define ADD_CMD "add"
|
||||
#define RM_CMD "rm"
|
||||
#define CMD_INDEX 1
|
||||
#define FINAL_FILE_INDEX 2
|
||||
#define TEMP_FILE_INDEX 3
|
||||
#define RUNTIME_PATH_INDEX 4
|
||||
#define ASCEND_RUNTIME_PATH_KEY "path"
|
||||
#define ASCEND_RUNTIME_ARGS_KEY "runtimeArgs"
|
||||
#define RUNTIME_KEY "runtimes"
|
||||
#define ASCEND_RUNTIME_NAME "ascend"
|
||||
#define DEFALUT_KEY "default-runtime"
|
||||
#define DEFAULT_VALUE "ascend"
|
||||
|
||||
void ReadJsonFile(FILE *pf, char *text, int maxBufferSize)
|
||||
{
|
||||
fseek(pf, 0, SEEK_END);
|
||||
|
||||
int size = (int)ftell(pf);
|
||||
if (size >= maxBufferSize) {
|
||||
fprintf(stderr, "file size too large\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(pf, 0, SEEK_SET);
|
||||
fread(text, sizeof(char), size, pf);
|
||||
text[size] = '\0';
|
||||
}
|
||||
|
||||
cJSON *CreateAscendRuntimeInfo(const char *runtimePath)
|
||||
{
|
||||
cJSON *root = NULL;
|
||||
root = cJSON_CreateObject();
|
||||
if (root == NULL) {
|
||||
fprintf(stderr, "create ascend runtime info root err\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON *newString = NULL;
|
||||
newString = cJSON_CreateString(runtimePath);
|
||||
if (newString == NULL) {
|
||||
fprintf(stderr, "create ascend runtime info path value err\n");
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON *paraArray = NULL;
|
||||
paraArray = cJSON_CreateArray();
|
||||
if (paraArray == NULL) {
|
||||
fprintf(stderr, "create ascend runtime info args err\n");
|
||||
cJSON_Delete(root);
|
||||
cJSON_Delete(newString);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(root, ASCEND_RUNTIME_PATH_KEY, newString);
|
||||
cJSON_AddItemToObject(root, ASCEND_RUNTIME_ARGS_KEY, paraArray);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
cJSON *CreateRuntimes(const char *runtimePath)
|
||||
{
|
||||
cJSON *ascendRuntime = NULL;
|
||||
ascendRuntime = CreateAscendRuntimeInfo(runtimePath);
|
||||
if (ascendRuntime == NULL) {
|
||||
fprintf(stderr, "create ascendruntime err\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON *runtimes = NULL;
|
||||
runtimes = cJSON_CreateObject();
|
||||
if (runtimes == NULL) {
|
||||
fprintf(stderr, "create runtimes err\n");
|
||||
cJSON_Delete(ascendRuntime);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(runtimes, ASCEND_RUNTIME_NAME, ascendRuntime);
|
||||
|
||||
return runtimes;
|
||||
}
|
||||
|
||||
int DelJsonContent(cJSON *root, const char *key)
|
||||
{
|
||||
cJSON *existItem = NULL;
|
||||
existItem = cJSON_GetObjectItem(root, key);
|
||||
if (existItem == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cJSON *removedItem = NULL;
|
||||
removedItem = cJSON_DetachItemViaPointer(root, existItem);
|
||||
if (removedItem == NULL) {
|
||||
fprintf(stderr, "remove %s failed\n", key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cJSON_Delete(removedItem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cJSON *CreateContent(const char *runtimePath)
|
||||
{
|
||||
/* 插入ascend runtime */
|
||||
cJSON *runtimes = NULL;
|
||||
runtimes = CreateRuntimes(runtimePath);
|
||||
if (runtimes == NULL) {
|
||||
fprintf(stderr, "create runtimes err\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON *defaultRuntime = NULL;
|
||||
defaultRuntime = cJSON_CreateString(DEFAULT_VALUE);
|
||||
if (defaultRuntime == NULL) {
|
||||
cJSON_Delete(runtimes);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON *root = NULL;
|
||||
root = cJSON_CreateObject();
|
||||
if (root == NULL) {
|
||||
/* ascendRuntime已经挂载到runtimes上了,再释放会coredump */
|
||||
fprintf(stderr, "create root err\n");
|
||||
cJSON_Delete(runtimes);
|
||||
cJSON_Delete(defaultRuntime);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(root, RUNTIME_KEY, runtimes);
|
||||
|
||||
cJSON_AddItemToObject(root, DEFALUT_KEY, defaultRuntime);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
cJSON *ModifyContent(FILE *pf, const char *runtimePath)
|
||||
{
|
||||
char jsonStr[MAX_JSON_FILE_SIZE] = {0x0};
|
||||
ReadJsonFile(pf, &jsonStr[0], MAX_JSON_FILE_SIZE);
|
||||
|
||||
cJSON *root = NULL;
|
||||
root = cJSON_Parse(jsonStr);
|
||||
if (root == NULL) {
|
||||
fprintf(stderr, "Error before: [%s]\n", cJSON_GetErrorPtr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 插入ascend runtime */
|
||||
cJSON *runtimes = NULL;
|
||||
runtimes = cJSON_GetObjectItem(root, "runtimes");
|
||||
if (runtimes == NULL) {
|
||||
runtimes = CreateRuntimes(runtimePath);
|
||||
if (runtimes == NULL) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
cJSON_AddItemToObject(root, RUNTIME_KEY, runtimes);
|
||||
} else {
|
||||
int ret = DelJsonContent(runtimes, ASCEND_RUNTIME_NAME);
|
||||
if (ret != 0) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
cJSON *ascendRuntime = NULL;
|
||||
ascendRuntime = CreateAscendRuntimeInfo(runtimePath);
|
||||
if (ascendRuntime == NULL) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
cJSON_AddItemToObject(runtimes, ASCEND_RUNTIME_NAME, ascendRuntime);
|
||||
}
|
||||
|
||||
/* 插入defaul runtime */
|
||||
int ret = DelJsonContent(root, DEFALUT_KEY);
|
||||
if (ret != 0) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
cJSON *defaultRuntime = cJSON_CreateString(DEFAULT_VALUE);
|
||||
if (defaultRuntime == NULL) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
cJSON_AddItemToObject(root, DEFALUT_KEY, defaultRuntime);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
cJSON *RemoveContent(FILE *pf)
|
||||
{
|
||||
char jsonStr[MAX_JSON_FILE_SIZE] = {0x0};
|
||||
ReadJsonFile(pf, &jsonStr[0], MAX_JSON_FILE_SIZE);
|
||||
|
||||
cJSON *root = NULL;
|
||||
root = cJSON_Parse(jsonStr);
|
||||
if (root == NULL) {
|
||||
fprintf(stderr, "Error before: [%s]\n", cJSON_GetErrorPtr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 去除default runtimes */
|
||||
int ret = DelJsonContent(root, DEFALUT_KEY);
|
||||
if (ret != 0) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 去除runtimes */
|
||||
cJSON *runtimes = NULL;
|
||||
runtimes = cJSON_GetObjectItem(root, RUNTIME_KEY);
|
||||
if (runtimes == NULL) {
|
||||
fprintf(stderr, "no runtime key found\n");
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = DelJsonContent(runtimes, DEFAULT_VALUE);
|
||||
if (ret != 0) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
int DetectAndCreateJsonFile(const char *filePath, const char *tempPath, const char *runtimePath)
|
||||
{
|
||||
cJSON *root = NULL;
|
||||
FILE *pf = NULL;
|
||||
pf = fopen(filePath, "r+");
|
||||
if (pf == NULL) {
|
||||
root = CreateContent(runtimePath);
|
||||
} else {
|
||||
root = ModifyContent(pf, runtimePath);
|
||||
fclose(pf);
|
||||
}
|
||||
|
||||
if (root == NULL) {
|
||||
fprintf(stderr, "error: failed to create json\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pf = fopen(tempPath, "w");
|
||||
if (pf == NULL) {
|
||||
fprintf(stderr, "error: failed to create file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(pf, "%s", cJSON_Print(root));
|
||||
fclose(pf);
|
||||
|
||||
cJSON_Delete(root);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CreateRevisedJsonFile(const char *filePath, const char *tempPath)
|
||||
{
|
||||
FILE *pf = NULL;
|
||||
pf = fopen(filePath, "r+");
|
||||
if (pf == NULL) {
|
||||
fprintf(stderr, "error: no json files found\n");
|
||||
return -1;
|
||||
}
|
||||
cJSON *newContent = NULL;
|
||||
newContent = RemoveContent(pf);
|
||||
fclose(pf);
|
||||
|
||||
if (newContent == NULL) {
|
||||
fprintf(stderr, "error: failed to create json\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pf = fopen(tempPath, "w");
|
||||
if (pf == NULL) {
|
||||
fprintf(stderr, "error: failed to create file\n");
|
||||
cJSON_Delete(newContent);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(pf, "%s", cJSON_Print(newContent));
|
||||
fclose(pf);
|
||||
|
||||
cJSON_Delete(newContent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 该函数只负责生成json.bak文件,由调用者进行覆盖操作 */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < MIN_ARGS_NUM) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s\n", argv[FINAL_FILE_INDEX]);
|
||||
printf("%s\n", argv[TEMP_FILE_INDEX]);
|
||||
printf("%s\n", argv[CMD_INDEX]);
|
||||
|
||||
if (strcmp(argv[CMD_INDEX], ADD_CMD) == 0) {
|
||||
if (argc != ADD_CMD_ARGS_NUM) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return DetectAndCreateJsonFile(argv[FINAL_FILE_INDEX], argv[TEMP_FILE_INDEX], argv[RUNTIME_PATH_INDEX]);
|
||||
}
|
||||
|
||||
return CreateRevisedJsonFile(argv[FINAL_FILE_INDEX], argv[TEMP_FILE_INDEX]);
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
Name: ascend-docker-runtime
|
||||
Version: 20.10.0.B020
|
||||
Release: 1
|
||||
Summary: simple RPM package
|
||||
License: FIXME
|
||||
|
||||
%define _binaries_in_noarch_packages_terminate_build 0
|
||||
|
||||
%description
|
||||
ascend-docker-plugin helps usrs to use NPU in docker
|
||||
|
||||
%prep
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}/usr/bin/
|
||||
cp -rf %{buildroot}/../../SOURCES/ascend* %{buildroot}/usr/bin/
|
||||
|
||||
%pre
|
||||
|
||||
%post
|
||||
#!/bin/bash
|
||||
DIR=/etc/docker
|
||||
SRC="${DIR}/daemon.json.${PPID}"
|
||||
DST="${DIR}/daemon.json"
|
||||
BINDIR=/usr/bin
|
||||
if [ ! -d "${DIR}" ]; then
|
||||
mkdir ${DIR}
|
||||
fi
|
||||
${BINDIR}/ascend-docker-plugin-install-helper add ${DST} ${SRC}
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "create damon.json failed\n"
|
||||
exit 1
|
||||
fi
|
||||
\mv ${SRC} ${DST}
|
||||
echo "create damom.json success\n"
|
||||
|
||||
%preun
|
||||
#!/bin/bash
|
||||
DIR=/etc/docker
|
||||
BINDIR=/usr/bin
|
||||
SRC="${DIR}/daemon.json.${PPID}"
|
||||
DST="${DIR}/daemon.json"
|
||||
if [ ! -f "${DST}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
${BINDIR}/ascend-docker-plugin-install-helper rm ${DST} ${SRC}
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "del damon.json failed\n"
|
||||
exit 1
|
||||
fi
|
||||
\mv ${SRC} ${DST}
|
||||
echo "del damom.json success\n"
|
||||
|
||||
%postun
|
||||
|
||||
%clean
|
||||
|
||||
%files
|
||||
%defattr(0755,root,root,0755)
|
||||
/usr/bin/*
|
||||
Reference in New Issue
Block a user