summaryrefslogtreecommitdiffstats
path: root/meta-vitis-tc/files
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@amd.com>2024-07-16 08:48:05 -0600
committerMark Hatle <mark.hatle@amd.com>2024-07-17 10:50:39 -0500
commitd7ef33e13555cca4c388cd3eea656f11190ebdb8 (patch)
tree81df01979c3ba711a839e008a86c8d60ccd3e08e /meta-vitis-tc/files
parent3958e8ed2cbbc58cbb404785c39d3d9068e65bdf (diff)
downloadmeta-xilinx-d7ef33e13555cca4c388cd3eea656f11190ebdb8.tar.gz
meta-vitis-tc: Create new layer from meta-petalinux as of 2024.1
These components are used to build SDKs that are often shipped with the AMD Vitis and Vivado products. Signed-off-by: Mark Hatle <mark.hatle@amd.com> (cherry picked from commit 5f481ae55aa646b334e15e16ef826b8d42792edf) Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-vitis-tc/files')
-rw-r--r--meta-vitis-tc/files/toolchain-shar-extract.sh303
-rw-r--r--meta-vitis-tc/files/toolchain-shar-relocate.sh117
2 files changed, 420 insertions, 0 deletions
diff --git a/meta-vitis-tc/files/toolchain-shar-extract.sh b/meta-vitis-tc/files/toolchain-shar-extract.sh
new file mode 100644
index 00000000..ec2008c8
--- /dev/null
+++ b/meta-vitis-tc/files/toolchain-shar-extract.sh
@@ -0,0 +1,303 @@
1#!/bin/sh
2
3export LC_ALL=en_US.UTF-8
4#Make sure at least one python is installed
5INIT_PYTHON=$(which python3 2>/dev/null )
6[ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(which python2 2>/dev/null)
7[ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1
8
9# Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted
10PATH=`$INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'`
11
12tweakpath () {
13 case ":${PATH}:" in
14 *:"$1":*)
15 ;;
16 *)
17 PATH=$PATH:$1
18 esac
19}
20
21# Some systems don't have /usr/sbin or /sbin in the cleaned environment PATH but we make need it
22# for the system's host tooling checks
23tweakpath /usr/sbin
24tweakpath /sbin
25
26INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/")
27SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/")
28
29INST_GCC_VER=$(gcc --version 2>/dev/null | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p')
30SDK_GCC_VER='@SDK_GCC_VER@'
31
32verlte () {
33 [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ]
34}
35
36verlt() {
37 [ "$1" = "$2" ] && return 1 || verlte $1 $2
38}
39
40verlt `uname -r` @OLDEST_KERNEL@
41if [ $? = 0 ]; then
42 echo "Error: The SDK needs a kernel > @OLDEST_KERNEL@"
43 exit 1
44fi
45
46if [ "$INST_ARCH" != "$SDK_ARCH" ]; then
47 # Allow for installation of ix86 SDK on x86_64 host
48 if [ "$INST_ARCH" != x86_64 -o "$SDK_ARCH" != ix86 ]; then
49 echo "Error: Incompatible SDK installer! Your host is $INST_ARCH and this SDK was built for $SDK_ARCH hosts."
50 exit 1
51 fi
52fi
53
54if ! xz -V > /dev/null 2>&1; then
55 echo "Error: xz is required for installation of this SDK, please install it first"
56 exit 1
57fi
58
59SDK_BUILD_PATH="@SDKPATH@"
60DEFAULT_INSTALL_DIR="@SDKPATHINSTALL@"
61SUDO_EXEC=""
62EXTRA_TAR_OPTIONS=""
63target_sdk_dir=""
64answer=""
65relocate=1
66savescripts=0
67verbose=0
68publish=0
69listcontents=0
70while getopts ":yd:npDRrSl" OPT; do
71 case $OPT in
72 y)
73 answer="Y"
74 ;;
75 d)
76 target_sdk_dir=$OPTARG
77 ;;
78 n)
79 prepare_buildsystem="no"
80 ;;
81 p)
82 prepare_buildsystem="no"
83 publish=1
84 ;;
85 D)
86 verbose=1
87 ;;
88 r)
89 relocate=2
90 ;;
91 R)
92 relocate=0
93 savescripts=1
94 ;;
95 S)
96 savescripts=1
97 ;;
98 l)
99 listcontents=1
100 ;;
101 *)
102 echo "Usage: $(basename "$0") [-y] [-d <dir>]"
103 echo " -y Automatic yes to all prompts"
104 echo " -d <dir> Install the SDK to <dir>"
105 echo "======== PetaLinux SDK only options ============"
106 echo " -r Enable runtime relocation, note this is slower"
107 #echo "======== Extensible SDK only options ============"
108 #echo " -n Do not prepare the build system"
109 #echo " -p Publish mode (implies -n)"
110 echo "======== Advanced DEBUGGING ONLY OPTIONS ========"
111 echo " -S Save relocation scripts"
112 echo " -R Do not relocate executables"
113 echo " -D use set -x to see what is going on"
114 echo " -l list files that will be extracted"
115 exit 1
116 ;;
117 esac
118done
119
120payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1))
121if [ "$listcontents" = "1" ] ; then
122 if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then
123 tail -n +$payload_offset "$0" > sdk.zip
124 if unzip -l sdk.zip;then
125 rm sdk.zip
126 else
127 rm sdk.zip && exit 1
128 fi
129 else
130 tail -n +$payload_offset "$0"| tar tvJ || exit 1
131 fi
132 exit
133fi
134
135titlestr="@SDK_TITLE@ installer version @SDK_VERSION@"
136printf "%s\n" "$titlestr"
137printf "%${#titlestr}s\n" | tr " " "="
138
139if [ $verbose = 1 ] ; then
140 set -x
141fi
142
143@SDK_PRE_INSTALL_COMMAND@
144
145# SDK_EXTENSIBLE is exposed from the SDK_PRE_INSTALL_COMMAND above
146if [ "$SDK_EXTENSIBLE" = "1" ]; then
147 DEFAULT_INSTALL_DIR="@SDKEXTPATH@"
148 if [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '4.9' ] || [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '' ] || \
149 [ "$INST_GCC_VER" = '4.9' -a "$SDK_GCC_VER" = '' ]; then
150 echo "Error: Incompatible SDK installer! Your host gcc version is $INST_GCC_VER and this SDK was built by gcc higher version."
151 exit 1
152 fi
153fi
154
155if [ "$target_sdk_dir" = "" ]; then
156 if [ "$answer" = "Y" ]; then
157 target_sdk_dir="$DEFAULT_INSTALL_DIR"
158 else
159 read -p "Enter target directory for SDK (default: $DEFAULT_INSTALL_DIR): " target_sdk_dir
160 [ "$target_sdk_dir" = "" ] && target_sdk_dir=$DEFAULT_INSTALL_DIR
161 fi
162fi
163
164eval target_sdk_dir=$(echo "$target_sdk_dir"|sed 's/ /\\ /g')
165if [ -d "$target_sdk_dir" ]; then
166 target_sdk_dir=$(cd "$target_sdk_dir"; pwd)
167else
168 target_sdk_dir=$(readlink -m "$target_sdk_dir")
169fi
170
171# limit the length for target_sdk_dir, ensure the relocation behaviour in relocate_sdk.py has right result.
172if [ ${#target_sdk_dir} -gt 2048 ]; then
173 echo "Error: The target directory path is too long!!!"
174 exit 1
175fi
176
177if [ "$SDK_EXTENSIBLE" = "1" ]; then
178 # We're going to be running the build system, additional restrictions apply
179 if echo "$target_sdk_dir" | grep -q '[+\ @$]'; then
180 echo "The target directory path ($target_sdk_dir) contains illegal" \
181 "characters such as spaces, @, \$ or +. Abort!"
182 exit 1
183 fi
184 # The build system doesn't work well with /tmp on NFS
185 fs_dev_path="$target_sdk_dir"
186 while [ ! -d "$fs_dev_path" ] ; do
187 fs_dev_path=`dirname $fs_dev_path`
188 done
189 fs_dev_type=`stat -f -c '%t' "$fs_dev_path"`
190 if [ "$fsdevtype" = "6969" ] ; then
191 echo "The target directory path $target_sdk_dir is on NFS, this is not possible. Abort!"
192 exit 1
193 fi
194else
195 if [ -n "$(echo $target_sdk_dir|grep ' ')" ]; then
196 echo "The target directory path ($target_sdk_dir) contains spaces. Abort!"
197 exit 1
198 fi
199fi
200
201if [ -e "$target_sdk_dir/environment-setup-@REAL_MULTIMACH_TARGET_SYS@" ]; then
202 echo "The directory \"$target_sdk_dir\" already contains a SDK for this architecture."
203 printf "If you continue, existing files will be overwritten! Proceed [y/N]? "
204
205 default_answer="n"
206else
207 printf "You are about to install the SDK to \"$target_sdk_dir\". Proceed [Y/n]? "
208
209 default_answer="y"
210fi
211
212if [ "$answer" = "" ]; then
213 read answer
214 [ "$answer" = "" ] && answer="$default_answer"
215else
216 echo $answer
217fi
218
219if [ "$answer" != "Y" -a "$answer" != "y" ]; then
220 echo "Installation aborted!"
221 exit 1
222fi
223
224# Try to create the directory (this will not succeed if user doesn't have rights)
225mkdir -p $target_sdk_dir >/dev/null 2>&1
226
227# if don't have the right to access dir, gain by sudo
228if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; then
229 if [ "$SDK_EXTENSIBLE" = "1" ]; then
230 echo "Unable to access \"$target_sdk_dir\", will not attempt to use" \
231 "sudo as as extensible SDK cannot be used as root."
232 exit 1
233 fi
234
235 SUDO_EXEC=$(which "sudo")
236 if [ -z $SUDO_EXEC ]; then
237 echo "No command 'sudo' found, please install sudo first. Abort!"
238 exit 1
239 fi
240
241 # test sudo could gain root right
242 $SUDO_EXEC pwd >/dev/null 2>&1
243 [ $? -ne 0 ] && echo "Sorry, you are not allowed to execute as root." && exit 1
244
245 # now that we have sudo rights, create the directory
246 $SUDO_EXEC mkdir -p $target_sdk_dir >/dev/null 2>&1
247fi
248
249printf "Extracting SDK..."
250if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then
251 tail -n +$payload_offset "$0" > sdk.zip
252 if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then
253 rm sdk.zip
254 else
255 rm sdk.zip && exit 1
256 fi
257else
258 tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1
259fi
260echo "done"
261
262printf "Setting it up..."
263# fix environment paths
264real_env_setup_script=""
265for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do
266 if grep -q 'OECORE_NATIVE_SYSROOT=' $env_setup_script; then
267 # Handle custom env setup scripts that are only named
268 # environment-setup-* so that they have relocation
269 # applied - what we want beyond here is the main one
270 # rather than the one that simply sorts last
271 real_env_setup_script="$env_setup_script"
272 fi
273 $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $env_setup_script
274done
275if [ -n "$real_env_setup_script" ] ; then
276 env_setup_script="$real_env_setup_script"
277fi
278
279@SDK_POST_INSTALL_COMMAND@
280
281# delete the relocating script, so that user is forced to re-run the installer
282# if he/she wants another location for the sdk
283if [ $savescripts = 0 ] ; then
284 $SUDO_EXEC rm -f ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh ${env_setup_script%/*}/relocate-wrapper.py
285fi
286
287# Execute post-relocation script
288post_relocate="$target_sdk_dir/post-relocate-setup.sh"
289if [ -e "$post_relocate" ]; then
290 $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $post_relocate
291 $SUDO_EXEC /bin/sh $post_relocate "$target_sdk_dir" "@SDKPATH@"
292 $SUDO_EXEC rm -f $post_relocate
293fi
294
295echo "SDK has been successfully set up and is ready to be used."
296echo "Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g."
297for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do
298 echo " \$ . $env_setup_script"
299done
300
301exit 0
302
303MARKER:
diff --git a/meta-vitis-tc/files/toolchain-shar-relocate.sh b/meta-vitis-tc/files/toolchain-shar-relocate.sh
new file mode 100644
index 00000000..0c396e6d
--- /dev/null
+++ b/meta-vitis-tc/files/toolchain-shar-relocate.sh
@@ -0,0 +1,117 @@
1if ! xargs --version > /dev/null 2>&1; then
2 echo "xargs is required by the relocation script, please install it first. Abort!"
3 exit 1
4fi
5
6# fix dynamic loader paths in all ELF SDK binaries
7native_sysroot=$($SUDO_EXEC cat $env_setup_script |grep 'OECORE_NATIVE_SYSROOT='|cut -d'=' -f2|tr -d '"')
8dl_path=$($SUDO_EXEC find $native_sysroot/lib -maxdepth 1 -name "ld-linux*")
9if [ "$dl_path" = "" ] ; then
10 echo "SDK could not be set up. Relocate script unable to find ld-linux.so. Abort!"
11 exit 1
12fi
13executable_files=$($SUDO_EXEC find $native_sysroot -type f \
14 \( -perm -0100 -o -perm -0010 -o -perm -0001 \) -printf "'%h/%f' ")
15if [ "x$executable_files" = "x" ]; then
16 echo "SDK relocate failed, could not get executalbe files"
17 exit 1
18fi
19
20tdir=`mktemp -d`
21if [ x$tdir = x ] ; then
22 echo "SDK relocate failed, could not create a temporary directory"
23 exit 1
24fi
25cat <<EOF >> $tdir/relocate_sdk.sh
26#!/bin/sh
27for py in python python2 python3
28do
29 PYTHON=\`which \${py} 2>/dev/null\`
30 if [ \$? -eq 0 ]; then
31 break;
32 fi
33done
34
35if [ x\${PYTHON} = "x" ]; then
36 echo "SDK could not be relocated. No python found."
37 exit 1
38fi
39\${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files
40EOF
41
42$SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
43$SUDO_EXEC chmod 755 ${env_setup_script%/*}/relocate_sdk.sh
44rm -rf $tdir
45# Run for either relocate = 1 or = 2
46if [ $relocate = 1 -o $relocate = 2 ] ; then
47 $SUDO_EXEC ${env_setup_script%/*}/relocate_sdk.sh
48 if [ $? -ne 0 ]; then
49 echo "SDK could not be set up. Relocate script failed. Abort!"
50 exit 1
51 fi
52fi
53if [ $relocate = 2 ] ; then
54 $SUDO_EXEC ${PYTHON} ${env_setup_script%/*}/relocate-wrapper.py $target_sdk_dir > relocate.log 2>&1
55 if [ $? -ne 0 ]; then
56 cat relocate.log
57 echo "SDK could not be set up. Runtime-Relocate script failed. Abort!"
58 exit 1
59 fi
60 rm -f relocate.log
61
62 for env_setup_scripts in `ls $target_sdk_dir/environment-setup-*`; do
63 cat << EOF > ${env_setup_scripts}.new
64if [ -n "\$BASH_SOURCE" ]; then
65 THIS_SCRIPT=\$BASH_SOURCE
66elif [ -n "\$ZSH_NAME" ]; then
67 THIS_SCRIPT=\$0
68else
69 THIS_SCRIPT="\$(pwd)/$env_setup_scripts"
70 if [ ! -e "\$THIS_SCRIPT" ]; then
71 echo "Error: \$THIS_SCRIPT doesn't exist!" >&2
72 echo "Please run this script in sdk directory." >&2
73 exit 1
74 fi
75fi
76
77THIS_SCRIPT=\$(realpath \${THIS_SCRIPT})
78SDK_BASE_PATH=\$(dirname \${THIS_SCRIPT})
79echo "Configuring environment for base path of \$SDK_BASE_PATH"
80
81EOF
82 cat ${env_setup_scripts} >> ${env_setup_scripts}.new
83 $SUDO_EXEC sed -e "s:$target_sdk_dir:\${SDK_BASE_PATH}:g" -i ${env_setup_scripts}.new
84 mv ${env_setup_scripts}.new ${env_setup_scripts}
85 done
86fi
87
88# replace @SDKPATH@ with the new prefix in all text files: configs/scripts/etc.
89# replace the host perl with SDK perl.
90for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do
91 $SUDO_EXEC find $replace -type f
92done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \
93 awk -F': ' '{printf "\"%s\"\n", $1}' | \
94 grep -Fv -e "$target_sdk_dir/environment-setup-" \
95 -e "$target_sdk_dir/relocate_sdk" \
96 -e "$target_sdk_dir/post-relocate-setup" \
97 -e "$target_sdk_dir/${0##*/}" | \
98 xargs -n100 $SUDO_EXEC sed -i \
99 -e "s:$SDK_BUILD_PATH:$target_sdk_dir:g" \
100 -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" \
101 -e "s: /usr/bin/perl: /usr/bin/env perl:g"
102
103if [ $? -ne 0 ]; then
104 echo "Failed to replace perl. Relocate script failed. Abort!"
105 exit 1
106fi
107
108# change all symlinks pointing to @SDKPATH@
109for l in $($SUDO_EXEC find $native_sysroot -type l); do
110 $SUDO_EXEC ln -sfn $(readlink $l|$SUDO_EXEC sed -e "s:$SDK_BUILD_PATH:$target_sdk_dir:") $l
111 if [ $? -ne 0 ]; then
112 echo "Failed to setup symlinks. Relocate script failed. Abort!"
113 exit 1
114 fi
115done
116
117echo done