提交 878ea6c3 编写于 作者: S Shirong Hao 提交者: jia zhang

sgx-tools: Add `make package` command to build rpm and deb packages.

Signed-off-by: NShirong Hao <shirong@linux.alibaba.com>
上级 b003da31
......@@ -2,7 +2,6 @@
export INCLAVARE_CONTAINERS_VERSION := $(shell cat ./VERSION)
components := rune shim sgx-tools
dist_release_components := rune shim
all:
for name in $(components); do \
......@@ -25,6 +24,6 @@ uninstall:
done
package:
for name in $(dist_release_components); do \
for name in $(components); do \
$(MAKE) -C $$name package; \
done
......@@ -38,3 +38,6 @@ install: $(APP)
uninstall:
@rm -f $(BINDIR)/$(APP)
package:
$(MAKE) -C dist package
PROJECT_DIR := $(shell cd ../..; pwd)
RPMBUILD_DIR := $(shell mktemp -u /tmp/rpmbuild.XXXX)
RELEASE_TARBALL_URL := https://github.com/alibaba/inclavare-containers/archive/v$(INCLAVARE_CONTAINERS_VERSION).tar.gz
RELEASE_TARBALL_FILE := $(RPMBUILD_DIR)/SOURCES/v$(INCLAVARE_CONTAINERS_VERSION).tar.gz
RELEASE_TARBALL_EXIST := $(shell if [ -f $(RELEASE_TARBALL_FILE) ]; then echo "y"; else echo "n"; fi;)
release-tarball:
ifneq ($(RELEASE_TARBALL_EXIST), y)
@mkdir -p $(RPMBUILD_DIR)/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
@wget -P $(RPMBUILD_DIR)/SOURCES $(RELEASE_TARBALL_URL)
endif
rpm: release-tarball
@rpmbuild -D "_topdir $(RPMBUILD_DIR)" -ba rpm/sgx-tools.spec
@cp $(RPMBUILD_DIR)/RPMS/x86_64/*.rpm $(PROJECT_DIR)
@rm -rf $(RPMBUILD_DIR)
@echo "the rpms of sgx-tools located in $(PROJECT_DIR)"
deb:
@cd deb && ./build.sh
@echo "the debs of sgx-tools located in $(PROJECT_DIR)"
package:
ifeq (/etc/debian_version, $(wildcard /etc/debian_version))
make deb
else ifeq (/etc/redhat-release, $(wildcard /etc/redhat-release))
make rpm
else
@echo "error! don't support generating packages on this system"
endif
.PHONY: release-tarball rpm deb package
#!/bin/bash
PROJECT_DIR=$(cd ../../..; pwd)
DEBBUILD_DIR=$(mktemp -u /tmp/debbuild.XXXX)
SCRIPT_DIR=$(pwd)
PACKAGE=sgx-tools
PROJECT=inclavare-containers
VERSION=$(cd ../../..; cat ./VERSION)
RELEASE_TARBALL=$DEBBUILD_DIR/v$VERSION.tar.gz
RELEASE_TARBALL_URL=https://github.com/alibaba/inclavare-containers/archive/v$VERSION.tar.gz
TARBALL_NAME=$PACKAGE\_$VERSION.orig.tar.gz
DEB_BUILD_FOLDER=$DEBBUILD_DIR/$PACKAGE-$VERSION
# create and rename the tarball
mkdir -p $DEBBUILD_DIR
if [ ! -f "$RELEASE_TARBALL" ]; then
wget -P $DEBBUILD_DIR $RELEASE_TARBALL_URL
fi
tar zxfP $DEBBUILD_DIR/v$VERSION.tar.gz -C $DEBBUILD_DIR
mv $DEBBUILD_DIR/$PROJECT-$VERSION $DEBBUILD_DIR/$PACKAGE-$VERSION
cd $DEBBUILD_DIR && tar zcfP $TARBALL_NAME $PACKAGE-$VERSION
# check the go version
if ! [ -x "$(command -v go)" ]; then
echo 'Error: go is not installed. Please install Go 1.14 and above'
exit 1
fi
NEED_GO_VERSION=14
CURRENT_GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//g' | sed 's/\./ /g' | awk '{print $2}')
if [ $CURRENT_GO_VERSION -lt $NEED_GO_VERSION ]; then
echo 'Error: go version is less than 1.14.0. Please install Go 1.14 and above'
exit
fi
# build_deb_package
cp -rf $SCRIPT_DIR/debian $DEB_BUILD_FOLDER
cd $DEB_BUILD_FOLDER
dpkg-buildpackage -us -uc
cp $DEBBUILD_DIR/*.*deb $PROJECT_DIR
rm -rf $DEBBUILD_DIR
sgx-tools (0.4.1-1) unstable; urgency=low
* Initial release.
-- Shirong Hao <shirong@linux.alibaba.com> Sun, 30 Aug 2020 13:48:35 +0000
Source: sgx-tools
Section: devel
Priority: extra
Maintainer: shirong <shirong@linux.alibaba.com>
Build-Depends: debhelper (>=9), libprotobuf-dev (>=3), protobuf-compiler
Standards-Version: 3.9.8
Homepage: https://github.com/alibaba/inclavare-containers
Package: sgx-tools
Architecture: amd64
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: sgx-tools is a command line tool for inclavare-containers. Interact Intel SGX aesm service to retrieve various materials such as launch token, Quoting Enclave's target information, enclave quote and enclave remote attestation report from IAS.
#!/usr/bin/make -f
BUILD_ROOT := $(CURDIR)/debian/sgx-tools
BUILD_DIR := /usr/local/bin
PROTOBUF_VERSION := 1.3.5
NAME := sgx-tools
export GO111MODULE := on
%:
dh $@
override_dh_auto_build:
go get github.com/golang/protobuf/protoc-gen-go@v$(PROTOBUF_VERSION)
make -C $(NAME)
override_dh_auto_install:
install -d -p $(BUILD_ROOT)$(BUILD_DIR)
install -p -m 755 $(CURDIR)/$(NAME)/$(NAME) $(BUILD_ROOT)$(BUILD_DIR)
override_dh_usrlocal:
%define centos_base_release 1
%define _debugsource_template %{nil}
%global PROTOBUF_VERSION 1.3.5
%global PROJECT inclavare-containers
%global BIN_DIR /usr/local/bin
Name: sgx-tools
Version: 0.4.1
Release: %{centos_base_release}%{?dist}
Summary: sgx-tools is a commandline tool, used to interact Intel SGx aesm service.
Group: Development/Tools
License: Apache License 2.0
URL: https://github.com/alibaba/%{PROJECT}
Source0: https://github.com/alibaba/%{PROJECT}/archive/v%{version}.tar.gz
BuildRequires: protobuf >= 3
BuildRequires: protobuf-compiler
ExclusiveArch: x86_64
%description
sgx-tools is a command line tool for inclavare-containers. Interact Intel SGX aesm service to retrieve various materials such as launch token, Quoting Enclave's target information, enclave quote and enclave remote attestation report from IAS.
%prep
%setup -q -n %{PROJECT}-%{version}
%build
# we cann't download go1.14 through 'yum install' in centos, so that wo check the go version in the '%build' section rather than in the 'BuildRequires' section.
if ! [ -x "$(command -v go)" ]; then
echo 'Error: go is not installed. Please install Go 1.14 and above'
exit 1
fi
NEED_GO_VERSION=14
CURRENT_GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//g' | sed 's/\./ /g' | awk '{print $2}')
if [ $CURRENT_GO_VERSION -lt $NEED_GO_VERSION ]; then
echo 'Error: go version is less than 1.14.0. Please install Go 1.14 and above'
exit 1
fi
export GOPATH=${RPM_BUILD_DIR}/%{PROJECT}-%{version}
export GOPROXY="https://mirrors.aliyun.com/goproxy,direct"
export PATH=$PATH:${GOPATH}/bin
export GO111MODULE=on
go get github.com/golang/protobuf/protoc-gen-go@v%{PROTOBUF_VERSION}
pushd %{name}
make
popd
%install
install -d -p %{buildroot}%{BIN_DIR}
install -p -m 755 %{name}/%{name} %{buildroot}%{BIN_DIR}
%files
%{BIN_DIR}/%{name}
%changelog
* Wed Sep 23 2020 Shirong Hao <shirong@linux.alibaba.com> - 0.4.1
- Package init.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册