Lott, Christopher (cl778h) | d59c1b8 | 2019-11-14 09:06:25 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Bin Yang | 76b5afb | 2020-06-04 05:10:19 +0000 | [diff] [blame] | 3 | # Copyright (C) 2020 Wind River Systems, Inc. |
Lott, Christopher (cl778h) | d59c1b8 | 2019-11-14 09:06:25 -0500 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Uploads a Yocto image to Nexus. |
| 18 | |
Bin Yang | 76b5afb | 2020-06-04 05:10:19 +0000 | [diff] [blame] | 19 | echo "--> upload-inf.sh" |
Lott, Christopher (cl778h) | d59c1b8 | 2019-11-14 09:06:25 -0500 | [diff] [blame] | 20 | |
| 21 | # Ensure we fail the job if any steps fail. |
| 22 | set -eu -o pipefail |
| 23 | |
Jackie Huang | 58aa008 | 2022-11-13 20:38:10 -0800 | [diff] [blame] | 24 | if [[ -f ~/lf-env.sh ]]; then |
| 25 | source ~/lf-env.sh |
| 26 | lf-activate-venv --python python3 lftools |
| 27 | else |
| 28 | echo "INFO: creating virtual environment" |
| 29 | virtualenv -p python3 /tmp/venv |
| 30 | PATH=/tmp/venv/bin:$PATH |
| 31 | |
| 32 | pip_pkgs="pip setuptools lftools" |
| 33 | for pkg in $pip_pkgs; do |
| 34 | cmd_pip="python -m pip install --upgrade $pkg" |
| 35 | echo "INFO: installing packages: $cmd_pip" |
| 36 | $cmd_pip |
| 37 | done |
| 38 | fi |
Lott, Christopher (cl778h) | d59c1b8 | 2019-11-14 09:06:25 -0500 | [diff] [blame] | 39 | |
| 40 | # NEXUS_URL is set by Jenkins |
| 41 | nexus_repo_id="images" |
| 42 | nexus_repo_url="$NEXUS_URL/content/sites/$nexus_repo_id" |
| 43 | echo "INFO: upload to $nexus_repo_url" |
| 44 | |
| 45 | repo_dir="$WORKSPACE/nexus/$nexus_repo_id" |
Jackie Huang | 462e5da | 2022-05-17 17:37:35 +0800 | [diff] [blame] | 46 | repo_iso_dir_latest="$repo_dir/org/o-ran-sc/pti/rtp/latest" |
| 47 | repo_iso_dir_branch="$repo_dir/org/o-ran-sc/pti/rtp/$GERRIT_BRANCH" |
| 48 | echo "INFO: create staging directory $repo_iso_dir_latest and $repo_iso_dir_branch" |
| 49 | mkdir -p "$repo_iso_dir_latest" "$repo_iso_dir_branch" |
Lott, Christopher (cl778h) | d59c1b8 | 2019-11-14 09:06:25 -0500 | [diff] [blame] | 50 | |
Jackie Huang | 462e5da | 2022-05-17 17:37:35 +0800 | [diff] [blame] | 51 | # Expect Yocto based ISO file: inf-image-yocto-aio-x86-64.iso |
| 52 | # in build subdir: workspace/workspace_yocto/prj_output/ |
| 53 | iso_yocto="workspace/workspace_yocto/prj_output/inf-image-yocto-aio-x86-64.iso" |
| 54 | |
Jackie Huang | c1b9401 | 2022-05-17 17:37:35 +0800 | [diff] [blame] | 55 | # Expect Debian based ISO file: inf-image-debian-all-x86-64.iso |
| 56 | # in build subdir: workspace/workspace_debian/prj_output/ |
| 57 | iso_debian="workspace/workspace_debian/prj_output/inf-image-debian-all-x86-64.iso" |
| 58 | |
Jackie Huang | 462e5da | 2022-05-17 17:37:35 +0800 | [diff] [blame] | 59 | # Expect CentOS based ISO file: inf-image-centos-all-x86-64.iso |
| 60 | # in build subdir: workspace/workspace_centos/prj_output/ |
| 61 | iso_centos="workspace/workspace_centos/prj_output/inf-image-centos-all-x86-64.iso" |
| 62 | |
Jackie Huang | c1b9401 | 2022-05-17 17:37:35 +0800 | [diff] [blame] | 63 | for iso_dir in $repo_iso_dir_latest $repo_iso_dir_branch; do |
| 64 | echo "INFO: copy ISO images to staging directory $iso_dir" |
| 65 | for iso_img in $iso_yocto $iso_centos $iso_debian; do |
| 66 | if [[ -f $iso_img ]]; then |
| 67 | echo "INFO: copying $iso_img" |
| 68 | cp "$iso_img" "$iso_dir" |
| 69 | fi |
| 70 | done |
| 71 | done |
Lott, Christopher (cl778h) | d59c1b8 | 2019-11-14 09:06:25 -0500 | [diff] [blame] | 72 | |
| 73 | cmd="lftools deploy nexus $nexus_repo_url $repo_dir" |
| 74 | echo "INFO: Upload ISO to Nexus: $cmd" |
| 75 | $cmd |
| 76 | |
Bin Yang | 76b5afb | 2020-06-04 05:10:19 +0000 | [diff] [blame] | 77 | echo "--> upload-inf.sh ends" |