diff --git a/VERSION-openeuler b/VERSION-openeuler deleted file mode 100644 index c85b840..0000000 --- a/VERSION-openeuler +++ /dev/null @@ -1 +0,0 @@ -1.0.0-4 diff --git a/VERSION-vendor b/VERSION-vendor new file mode 100644 index 0000000..91dc9a2 --- /dev/null +++ b/VERSION-vendor @@ -0,0 +1 @@ +1.0.0-5 diff --git a/apply-patch b/apply-patch index 8c0ab1e..c39ca51 100755 --- a/apply-patch +++ b/apply-patch @@ -10,7 +10,7 @@ set -ex pkg=rubik cwd=$PWD src=$cwd/$pkg -tar_file=v"$(awk -F"-" '{print $1}' < VERSION-openeuler)".tar.gz +tar_file=v"$(awk -F"-" '{print $1}' < VERSION-vendor)".tar.gz mkdir ${src} && tar -zxvf "${tar_file}" -C ${src} --strip-components 1 if [ ! -d patch ]; then @@ -28,5 +28,5 @@ done <"$series" cd $cwd cp -rf $src/* . -cp -f VERSION-openeuler VERSION +cp -f VERSION-vendor VERSION rm -rf $src diff --git a/build_rubik_image.sh b/build_rubik_image.sh new file mode 100755 index 0000000..33a7708 --- /dev/null +++ b/build_rubik_image.sh @@ -0,0 +1,44 @@ +#!/bin/bash +################################################################################################### +# Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. +# rubik licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# Author: Xiang Li +# Create: 2022-11-29 +# Description: Build container image for rubik. Enjoy and cherrs! +# Steps: +# 1. build image and tag it with rubik version and release number +# 2. modify `rubik-daemonset.yaml` file +################################################################################################### +set -e + +CURRENT_DIR=$(cd "$(dirname "$0")" && pwd) +BINARY_NAME="rubik" + +RUBIK_FILE="${CURRENT_DIR}/build/rubik" +DOCKERFILE="${CURRENT_DIR}/Dockerfile" +YAML_FILE="${CURRENT_DIR}/rubik-daemonset.yaml" + +# Get version and release number of rubik binary +VERSION=$(${RUBIK_FILE} -v | grep ^Version | awk '{print $NF}') +RELEASE=$(${RUBIK_FILE} -v | grep ^Release | awk '{print $NF}') +IMG_TAG="${VERSION}-${RELEASE}" + +# Get rubik image name and tag +IMG_NAME_AND_TAG="${BINARY_NAME}:${IMG_TAG}" + +# Build container image for rubik +docker build -f "${DOCKERFILE}" -t "${IMG_NAME_AND_TAG}" "${CURRENT_DIR}" + +echo -e "\n" +# Check image existence +docker images | grep -E "REPOSITORY|${BINARY_NAME}" + +# Modify rubik-daemonset.yaml file, set rubik image name +sed -i "s/rubik_image_name_and_tag/${IMG_NAME_AND_TAG}/g" "${YAML_FILE}" diff --git a/gen-version.sh b/gen-version.sh index eff17e3..8ea91e8 100755 --- a/gen-version.sh +++ b/gen-version.sh @@ -16,7 +16,7 @@ # Basic info top_dir=$(git rev-parse --show-toplevel) -version_file="${top_dir}/VERSION-openeuler" +version_file="${top_dir}/VERSION-vendor" spec_file="${top_dir}/rubik.spec" color=$(tput setaf 2) # red color_reset=$(tput sgr0) diff --git a/git-commit b/git-commit index 4f6f58e..4ab4b8d 100644 --- a/git-commit +++ b/git-commit @@ -1 +1 @@ -333208525a24588c45bd34b048a5ae82803efaad +8e373d25ff4a5b76c9dc1735a40098254f49e1c6 diff --git a/rubik.spec b/rubik.spec index 2caf6d4..ec8cac6 100644 --- a/rubik.spec +++ b/rubik.spec @@ -1,16 +1,17 @@ Name: rubik Version: 1.0.0 -Release: 4 +Release: 5 Summary: Hybrid Deployment for Cloud Native License: Mulan PSL V2 URL: https://gitee.com/openeuler/rubik Source0: https://gitee.com/openeuler/rubik/repository/archive/v%{version}.tar.gz Source1: git-commit -Source2: VERSION-openeuler +Source2: VERSION-vendor Source3: apply-patch Source4: gen-version.sh Source5: series.conf Source6: patch.tar.gz +Source7: build_rubik_image.sh BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: golang >= 1.13 @@ -25,6 +26,7 @@ cp %{SOURCE3} . cp %{SOURCE4} . cp %{SOURCE5} . cp %{SOURCE6} . +cp %{SOURCE7} . %build sh ./apply-patch @@ -34,22 +36,32 @@ strip ./build/rubik %install # create directory /var/lib/rubik install -d %{buildroot}%{_sharedstatedir}/%{name} -# install rubik binary -install -Dp ./build/rubik %{buildroot}%{_sharedstatedir}/%{name} +# create directory /var/lib/rubik/build for image build +install -d %{buildroot}%{_sharedstatedir}/%{name}/build +# install rubik binary to build folder +install -Dp ./build/rubik %{buildroot}%{_sharedstatedir}/%{name}/build # install artifacts install -Dp ./hack/rubik-daemonset.yaml %{buildroot}%{_sharedstatedir}/%{name}/rubik-daemonset.yaml install -Dp ./Dockerfile %{buildroot}%{_sharedstatedir}/%{name}/Dockerfile +install -Dp ./build_rubik_image.sh %{buildroot}%{_sharedstatedir}/%{name}/build_rubik_image.sh %files %dir %attr(750,root,root) %{_sharedstatedir}/%{name} -%attr(550,root,root) %{_sharedstatedir}/%{name}/rubik +%attr(550,root,root) %{_sharedstatedir}/%{name}/build/rubik %attr(640,root,root) %{_sharedstatedir}/%{name}/rubik-daemonset.yaml %attr(640,root,root) %{_sharedstatedir}/%{name}/Dockerfile +%attr(550,root,root) %{_sharedstatedir}/%{name}/build_rubik_image.sh %clean rm -rf %{buildroot} %changelog +* Tue Nov 29 2022 CooperLi - 1.0.0-5 +- Type:bugfix +- CVE:NA +- SUG:restart +- DESC:add build folder for container image build + * Mon Nov 21 2022 yangjiaqi - 1.0.0-4 - Type:bugfix - CVE:NA