-
Notifications
You must be signed in to change notification settings - Fork 6
/
build
executable file
·70 lines (60 loc) · 1.83 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#
# Copyright (c) 2020-2022 IAR Systems AB
#
# build
#
# Build a Docker image containing the IAR Build Tools
#
# See LICENSE for detailed license information
#
function _bx_show_help() {
echo "Usage: ${BASH_SOURCE[0]} /path/to/bx<package>.deb"
echo " "
}
function _bx_build_docker_image()
{
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
echo "ERROR: the script should be executed directly. Do not source." >&2
_bx_show_help
return 1
fi
if [ $# -lt 1 ]; then
_bx_show_help
return 1
fi
local SCRIPT_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
local PKG_PATH=$(dirname $1)
local PKG_FILE=$(basename $1)
local PKG_BASE=${PKG_FILE%.deb}
local PKG_NAME=$(echo $PKG_BASE | cut -d- -f1)
local PKG_VERSION=$(echo $PKG_BASE | cut -d- -f2)
if [ ! -f "${PKG_PATH}/${PKG_FILE}" ]; then
echo "ERROR: file [${1}] not found." >&2
_bx_show_help
return 1
fi
case ${PKG_NAME^^} in
BXARM) local BX_ARCH=arm;;
BXARMFS) local BX_ARCH=arm;;
BXRH850) local BX_ARCH=rh850;;
BXRH850FS) local BX_ARCH=rh850;;
BXRISCV) local BX_ARCH=riscv;;
BXRISCVFS) local BX_ARCH=riscv;;
BXRL78) local BX_ARCH=rl78;;
BXRX) local BX_ARCH=rx;;
BXAVR) local BX_ARCH=avr;;
*) echo "ERROR: invalid package. (${PKG_NAME^^})" >&2; _bx_show_help; return 1;;
esac
# Copy the installer package to the Docker context
#cp -v "${PKG_PATH}/${PKG_FILE}" "${SCRIPT_PATH}"
echo -- Building the Docker image for ${PKG_NAME,,}-${PKG_VERSION}...
docker buildx build --tag iarsystems/${PKG_NAME}:${PKG_VERSION} \
--build-arg BX_PACKAGE_DEB=${PKG_FILE} \
${SCRIPT_PATH}
# Cleanup
#rm "${SCRIPT_PATH}/${PKG_FILE}" 2>/dev/null
}
_bx_build_docker_image $@
unset -f _bx_build_docker_image
unset -f _bx_show_help