forked from NVIDIA/bare-metal-manager-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile-package.toml
More file actions
82 lines (77 loc) · 3.01 KB
/
Makefile-package.toml
File metadata and controls
82 lines (77 loc) · 3.01 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
#
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
REPO_ROOT = { script = [
"dirname $(cargo locate-project --message-format plain --workspace)",
] }
PKG_VERSION = { script = [
"echo $(git describe --tags --first-parent --always --long | sed 's/^v//')",
] }
[tasks.package-component-local]
run_task = "package-component"
dependencies = [
{ name = "build-component-local", path = "./Makefile-build.toml" },
]
[tasks.package-component-in-container]
run_task = "package-component"
dependencies = [
{ name = "build-component-in-container", path = "./Makefile-build.toml" },
]
[tasks.package-component]
category = "Build"
description = "Build the .deb package"
workspace = false
script = '''
if [ "${CARBIDE_ARCH}" = "x86_64" ]
then
DEB_ARCH="amd64"
else
DEB_ARCH="arm64"
fi
PACKAGE_BIN=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(any(.; .name == "'${CARBIDE_CRATE}'")) | .targets[] | select(any(.kind[]; . == "bin")) | .name')
if [ -z "$PACKAGE_BIN" ]
then
echo "Could not determine binary for package ${CARBIDE_PACKAGE}"
exit 1
fi
MISC_DIR=${CARBIDE_CRATE_DIR}/misc
DEB_CONFIG_DIR=${MISC_DIR}/DEBIAN
: "${INSTALL_DIR:=/opt/forge}"
if [ ! -d ${DEB_CONFIG_DIR} ]
then
echo "Cannot package ${CARBIDE_PACKAGE}. No package configuration"
exit 1
fi
echo "creating package for ${CARBIDE_ARCH} ${CARBIDE_PACKAGE} (${PACKAGE_BIN}) (${PKG_VERSION}) with install path ${INSTALL_DIR}"
WORKING_DIR="${REPO_ROOT}/target/${CARBIDE_ARCH}-unknown-linux-gnu/${PACKAGE_BIN}_${PKG_VERSION}_${DEB_ARCH}"
mkdir -p "${WORKING_DIR}/lib/systemd/system"
mkdir -p "${WORKING_DIR}${INSTALL_DIR}"
cp "${REPO_ROOT}/target/${CARBIDE_ARCH}-unknown-linux-gnu/${CARBIDE_PROFILE}/${PACKAGE_BIN}" "${WORKING_DIR}${INSTALL_DIR}"
cp ${MISC_DIR}/*.service "${WORKING_DIR}/lib/systemd/system/"
cp -r ${DEB_CONFIG_DIR} "${WORKING_DIR}/"
echo 'Package: '${CARBIDE_PACKAGE}'
Version: '${PKG_VERSION}'
Section: base
Priority: optional
Architecture: '${DEB_ARCH}'
Maintainer: Forge team <swngc-forge-dev@nvidia.com>
Description: Forge scout for performaing hardware discovery
' > ${WORKING_DIR}/DEBIAN/control
mkdir -p ${REPO_ROOT}/target/debs/
dpkg-deb --build --root-owner-group ${WORKING_DIR} ${REPO_ROOT}/target/debs/${PACKAGE_BIN}_${PKG_VERSION}_${DEB_ARCH}.deb
'''