-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpackage-rpm.sh
More file actions
executable file
·111 lines (92 loc) · 4.22 KB
/
package-rpm.sh
File metadata and controls
executable file
·111 lines (92 loc) · 4.22 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# ##################################################################################################
# The MIT License (MIT)
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ##################################################################################################
set -euo pipefail
NONINTERACTIVE=0
while [[ $# -gt 0 ]]; do
case "$1" in
--noninteractive) NONINTERACTIVE=1; shift ;;
*) echo "Unknown argument: $1" >&2; exit 1 ;;
esac
done
# SLASH root
cd "$(dirname "$0")/.."
VERSION="$(tr -d '[:space:]' < packaging/version)"
TOPDIR="$(pwd)/rpmbuild"
ARTIFACTS_DIR="${ARTIFACTS_DIR:-$(pwd)/rpm}"
# Warn before overwriting an existing build
if [[ -d "${ARTIFACTS_DIR}" ]] && [[ -t 0 ]] && [[ "${NONINTERACTIVE}" -eq 0 ]]; then
echo "WARNING: A previous .rpm build already exists." >&2
echo "Proceeding will remove the following directories and restart the build from scratch:" >&2
[[ -d "${TOPDIR}" ]] && echo " ${TOPDIR} (rpmbuild tree)" >&2
[[ -d "${ARTIFACTS_DIR}" ]] && echo " ${ARTIFACTS_DIR} (built .rpm packages)" >&2
[[ -d pbuild ]] && echo " pbuild/ (CMake build tree)" >&2
echo " linker/install.prj" >&2
echo " linker/slashkit/resources/static_shell" >&2
echo "This includes the static shell, which can take several hours to rebuild." >&2
read -r -p "Overwrite existing build and start from scratch? [y/N] " _answer </dev/tty
case "${_answer}" in
[yY]|[yY][eE][sS]) ;;
*) echo "Aborted." >&2; exit 1 ;;
esac
fi
# Check build prerequisites
_prereq_ok=1
if ! command -v v++ > /dev/null 2>&1; then
echo "ERROR: v++ not found in PATH. Source Vitis 2025.1 before building:" >&2
echo " source <path-to-vitis>/settings64.sh" >&2
echo "See docs/tutorials/admin/platform-setup.rst for details." >&2
_prereq_ok=0
fi
if ! compgen -G 'linker/slashkit/resources/base/iprepo/smbus*/' > /dev/null 2>&1; then
echo "ERROR: SMBus IP (xilinx.com:ip:smbus:1.1) not found in linker/slashkit/resources/base/iprepo/." >&2
echo "Download it from https://www.xilinx.com/member/v80.html and place the IP" >&2
echo "directory into linker/slashkit/resources/base/iprepo/ before building." >&2
echo "See docs/tutorials/admin/platform-setup.rst for details." >&2
_prereq_ok=0
fi
if [[ "${_prereq_ok}" -eq 0 ]]; then
exit 1
fi
set -x
rm -rf "${TOPDIR}" "${ARTIFACTS_DIR}" pbuild
mkdir -p "${TOPDIR}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p "${ARTIFACTS_DIR}"
# Create source tarball (rpmbuild expects name-version/ inside)
tar czf "${TOPDIR}/SOURCES/slash-${VERSION}.tar.gz" \
--transform="s,^\.,slash-${VERSION}," \
--exclude='.git' \
--exclude='rpmbuild' \
--exclude='rpm' \
--exclude='deb' \
--exclude='pbuild' \
.
cp packaging/rpm/slash.spec "${TOPDIR}/SPECS/"
rpmbuild \
--define "_topdir ${TOPDIR}" \
--define "_version ${VERSION}" \
-bb "${TOPDIR}/SPECS/slash.spec"
cp "${TOPDIR}"/RPMS/*/*.rpm "${ARTIFACTS_DIR}/"
# Build AMI package into the same artifacts directory
ARTIFACTS_DIR="${ARTIFACTS_DIR}" "$(dirname "$0")/package-ami.sh"
pushd "${ARTIFACTS_DIR}"
createrepo .
popd
echo "RPMs available in ${ARTIFACTS_DIR}/"