From bada571c96519f354f90b9175c31063ac64abfbc Mon Sep 17 00:00:00 2001 From: liuzekun Date: Tue, 9 Jun 2020 23:39:19 -0400 Subject: [PATCH] containerd: use git-commit to store commit ID Signed-off-by: liuzekun --- apply-patch | 3 +++ containerd.spec | 17 +++++++++--- gen-commit.sh | 12 +++++++++ git-commit | 1 + ...rd-use-git-commit-to-store-commit-ID.patch | 26 +++++++++++++++++++ series.conf | 1 + 6 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 gen-commit.sh create mode 100644 git-commit create mode 100644 patch/0058-containerd-use-git-commit-to-store-commit-ID.patch diff --git a/apply-patch b/apply-patch index 2a96e0d..f91206d 100755 --- a/apply-patch +++ b/apply-patch @@ -12,6 +12,9 @@ cwd=$PWD src=$cwd/$pkg unzip $pkg.zip +if [[ ! -d patch ]]; then + tar zxf patch.tar.gz +fi cd $src git init diff --git a/containerd.spec b/containerd.spec index 70ad3cf..3313b9f 100644 --- a/containerd.spec +++ b/containerd.spec @@ -2,11 +2,16 @@ %global debug_package %{nil} Version: 1.2.0 Name: containerd -Release: 101 +Release: 102 Summary: An industry-standard container runtime License: ASL 2.0 URL: https://containerd.io -Source0: %{name}-%{version}.tar.gz +Source0: containerd-1.2.0.zip +Source1: patch.tar.gz +Source2: apply-patch +Source3: series.conf +Source4: git-commit +Source5: gen-commit.sh BuildRequires: golang glibc-static make btrfs-progs-devel @@ -18,10 +23,14 @@ system: image transfer and storage, container execution and supervision, low-level storage and network attachments, etc. %prep -%setup -c -n containerd +cp %{SOURCE0} . +cp %{SOURCE1} . +cp %{SOURCE2} . +cp %{SOURCE3} . +cp %{SOURCE4} . %build -./apply-patch +bash ./apply-patch GO_BUILD_PATH=$PWD/_build install -m 0755 -vd $(dirname $GO_BUILD_PATH/src/%{goipath}) diff --git a/gen-commit.sh b/gen-commit.sh new file mode 100644 index 0000000..cb1e436 --- /dev/null +++ b/gen-commit.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. +# Description: This shell script is used to generate commitID store file. +# Author: liuzekun@huawei.com +# Create: 2020-06-10 + +change_id=$(git log -1 | grep Change-Id | awk '{print $2}') +if [[ "${change_id}" = "" ]]; then + change_id=$(date | sha256sum | head -c 40) +fi +echo "${change_id}" > git-commit diff --git a/git-commit b/git-commit new file mode 100644 index 0000000..d2a37d7 --- /dev/null +++ b/git-commit @@ -0,0 +1 @@ +3f69708bd238c592ce917876ee841524a51cb781 diff --git a/patch/0058-containerd-use-git-commit-to-store-commit-ID.patch b/patch/0058-containerd-use-git-commit-to-store-commit-ID.patch new file mode 100644 index 0000000..8cfc1c1 --- /dev/null +++ b/patch/0058-containerd-use-git-commit-to-store-commit-ID.patch @@ -0,0 +1,26 @@ +From fe8ce77e756f7f468ed65c8c42a9f91becabbf4e Mon Sep 17 00:00:00 2001 +From: liuzekun +Date: Wed, 10 Jun 2020 00:37:01 -0400 +Subject: [PATCH] containerd: use git-commit to store commit ID + +Signed-off-by: liuzekun +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 9e7f3ae..6011aa1 100644 +--- a/Makefile ++++ b/Makefile +@@ -21,7 +21,7 @@ DESTDIR=/usr/local + + # Used to populate variables in version package. + VERSION=$(shell echo version:)$(shell grep '^Version' ${ROOTDIR}/containerd.spec | sed 's/[^0-9.]*\([0-9.]*\).*/\1/').$(shell grep '^Release:' ${ROOTDIR}/containerd.spec | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') +-REVISION=$(shell echo commit:)$(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi) ++REVISION=$(shell cat ./git-commit | head -c 40) + + ifneq "$(strip $(shell command -v go 2>/dev/null))" "" + GOOS ?= $(shell go env GOOS) +-- +2.19.1 + diff --git a/series.conf b/series.conf index 05c09a3..4d459ac 100644 --- a/series.conf +++ b/series.conf @@ -60,3 +60,4 @@ patch/0054-containerd-clean-up-residual-container.patch patch/0055-containerd-add-LLT-for-containerd-shim-timeou.patch patch/0056-containerd-save-dumpstack-to-file.patch patch/0057-containerd-add-timeout-for-delete-command.patch +patch/0058-containerd-use-git-commit-to-store-commit-ID.patch -- Gitee