-
Notifications
You must be signed in to change notification settings - Fork 42
Add the dependency analyser with the go toolchain to kraft (V2) #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Authors: Gaulthier Gain <[email protected]> | ||
# | ||
# Copyright (c) 2020, Université de Liège., ULiege. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
from __future__ import absolute_import | ||
from __future__ import unicode_literals | ||
|
||
import os | ||
import sys | ||
|
||
import click | ||
|
||
from kraft.commands.list import update | ||
from kraft.components.library import Library | ||
from kraft.components.types import RepositoryType | ||
from kraft.context import kraft_context | ||
from kraft.errors import KraftError | ||
from kraft.logger import logger | ||
from kraft.utils import op, dir | ||
|
||
import platform | ||
import subprocess | ||
|
||
TOOLS_PATH = './package/docker/gotools/tools_' | ||
|
||
@click.command('dependency', short_help='Gather the dependencies of a specific application.', context_settings=dict( | ||
ignore_unknown_options=True, | ||
allow_extra_args=True)) # noqa: C901 | ||
@click.pass_context | ||
def dependency(ctx): | ||
""" | ||
Gather the dependencies of a specific application. | ||
""" | ||
try: | ||
|
||
path = TOOLS_PATH + platform.system() | ||
if not op.isExecutable(path): | ||
op.execute_command('chmod +x', [path]) | ||
|
||
# Execute the toolchain with unparsed arguments | ||
op.execute_command(path, ctx.args) | ||
|
||
except KraftError as e: | ||
logger.critical(e) | ||
sys.exit(1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Authors: Alexander Jung <[email protected]> | ||
# Gaulthier Gain <[email protected]> | ||
# | ||
# Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved. | ||
# | ||
|
@@ -32,10 +33,22 @@ | |
from __future__ import unicode_literals | ||
|
||
import os | ||
import stat | ||
import shlex | ||
import subprocess | ||
|
||
from kraft.logger import logger | ||
|
||
def isExecutable(filepath): | ||
"""Check if a file is executable.""" | ||
stats = os.stat(filepath) | ||
return bool(stats.st_mode & stat.S_IXUSR) | ||
|
||
|
||
def execute_command(command, parameters=' '): | ||
"""Run a specific command on the host.""" | ||
subprocess.call(shlex.split(command + ' ' + ' '.join(parameters))) | ||
|
||
|
||
def merge_dicts(x, y): | ||
z = x.copy() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Authors: Gaulthier Gain <[email protected]> | ||
# | ||
# Copyright (c) 2020, Université de Liège., ULiege. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
ARG GOLANG_VERSION=1.14.4 | ||
ARG SHARED_DIR=/usr/shared | ||
|
||
FROM golang:${GOLANG_VERSION} | ||
|
||
RUN mkdir /usr/src/gotools | ||
COPY gotools/tools_Linux /usr/src/gotools | ||
WORKDIR /usr/src/gotools | ||
|
||
RUN mkdir /usr/shared | ||
VOLUME [${SHARED_DIR}] | ||
|
||
RUN set -xe | ||
RUN chmod +x ./tools_Linux | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likely this file can be put into the Dockerfile verbatim as it won't be run outside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just seen this is a binary. The Dockerfile is intended to build go files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by binary? Creating the binary from sources only in the Dockerfile ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
ENTRYPOINT ["./tools_Linux"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,10 @@ | |
|
||
ARG UK_ARCH=x86_64 | ||
ARG GCC_VERSION=9.2.0 | ||
ARG GO_VERSION=1.14.4 | ||
|
||
FROM unikraft/gcc:${GCC_VERSION}-${UK_ARCH} AS gcc | ||
FROM unikraft/gotools:${GO_VERSION} AS gotools | ||
|
||
LABEL MAINTAINER="Alexander Jung <[email protected]>" | ||
|
||
|
@@ -43,6 +45,8 @@ COPY --from=gcc /lib/ /lib | |
COPY --from=gcc /include/ /include | ||
COPY --from=gcc /libexec/ /libexec | ||
|
||
COPY --from=gotools /usr/src/gotools /usr/src/gotools | ||
|
||
COPY . /usr/src/kraft | ||
|
||
WORKDIR /usr/src/unikraft/apps/app | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,26 @@ else | |
$(DOCKER_BUILD_EXTRA) $(DOCKERDIR) | ||
endif | ||
|
||
# GO build targets | ||
GO_VERSION ?= 1.14.4 | ||
|
||
.PHONY: docker-gotools | ||
docker-gotools: IMAGE_NAME ?= $(ORG)/gotools:$(GO_VERSION) | ||
docker-gotools: | ||
ifneq (,$(findstring help,$(MAKECMDGOALS))) | ||
@echo "Usage: [IMAGE_NAME=...] $(MAKE) $@ " | ||
@echo " " | ||
@echo | ||
else | ||
$(DOCKER) build \ | ||
--build-arg GO_VERSION=$(GO_VERSION) \ | ||
--tag $(IMAGE_NAME) \ | ||
--cache-from $(ORG)/gotools:$(GO_VERSION) \ | ||
--cache-from $(IMAGE_NAME) \ | ||
--file $(DOCKERDIR)/Dockerfile.gotools \ | ||
$(DOCKER_BUILD_EXTRA) $(DOCKERDIR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may have to be |
||
endif | ||
|
||
# GCC build targets | ||
GCC_VERSION ?= 9.2.0 | ||
BINUTILS_VERSION ?= 2.31.1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be dependent on where how the package is installed, the extra binaries can be referenced globally, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean, using an absolute path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the
TOOLS_PATH
may just need to call a method to determine where the binaries were installed on the system. I will check this.