-
Notifications
You must be signed in to change notification settings - Fork 0
/
runBuildPrep.rhel.sh
executable file
·173 lines (143 loc) · 5.41 KB
/
runBuildPrep.rhel.sh
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
# Add OS-appropriate repos for build dependencies
set -x
cat > vars.sh <<- END
ROOT_DIR=`pwd`
PRODUCT=${PRODUCT:-"slingshot"}
EXTRA=${EXTRA:-"slingshot-host-software"}
TARGET_ARCH=${TARGET_ARCH:-"x86_64"}
BRANCH_NAME=${BRANCH_NAME:-"master"}
ARTIFACT_REPO_HOST=${ARTIFACT_REPO_HOST:-"arti.hpc.amslabs.hpecorp.net"}
TARGET_OS=${TARGET_OS:-"sle15_sp5_ncn"}
END
. vars.sh
. zypper-local.sh
if [[ "${BRANCH_NAME}" == release/* ]]; then
ARTI_LOCATION='rpm-stable-local'
ARTI_BRANCH=${BRANCH_NAME}
elif [[ "${CHANGE_TARGET}" == release/* ]]; then
# CHANGE_TARGET is only set for PR builds and points to the PR target branch
ARTI_LOCATION='rpm-stable-local'
ARTI_BRANCH=${CHANGE_TARGET}
else
ARTI_LOCATION='rpm-master-local'
ARTI_BRANCH=dev/master
fi
cat >> vars.sh <<- END
ARTI_URL=${ARTI_URL:-"https://${ARTIFACT_REPO_HOST}/artifactory"}
ARTI_LOCATION=${ARTI_LOCATION:-"rpm-master-local"}
ARTI_BRANCH=${ARTI_BRANCH:-"dev/master"}
OS_TYPE=`cat /etc/os-release | grep "^ID=" | sed "s/\"//g" | cut -d "=" -f 2`
OS_VERSION=`cat /etc/os-release | grep "^VERSION_ID=" | sed "s/\"//g" | cut -d "=" -f 2`
BRANCH=`git branch --show-current`
END
. vars.sh
OS_TYPE=`cat /etc/os-release | grep "^ID=" | sed "s/\"//g" | cut -d "=" -f 2`
OS_VERSION=`cat /etc/os-release | grep "^VERSION_ID=" | sed "s/\"//g" | cut -d "=" -f 2`
OS_MAJOR_VERSION=`echo ${OS_VERSION} | cut -d "." -f 1`
if [ -d hpc-shs-version ]; then
git -C hpc-shs-version pull
else
if [[ -n "${SHS_LOCAL_BUILD}" ]]; then
git clone [email protected]:hpe/hpc-shs-version.git
else
git clone https://[email protected]/hpe/hpc-shs-version.git
fi
fi
. hpc-shs-version/scripts/get-shs-version.sh
. hpc-shs-version/scripts/get-shs-label.sh
PRODUCT_VERSION=$(get_shs_version)
PRODUCT_LABEL=$(get_shs_label)
cat >> vars.sh <<- END
PRODUCT_VERSION=${PRODUCT_VERSION}
PRODUCT_LABEL=${PRODUCT_LABEL}
END
sed -i -e "s/Release:.*/Release: ${PRODUCT_LABEL}${PRODUCT_VERSION}_%(echo \\\${BUILD_METADATA:-1})/g" sl-driver.spec
if [ -d ${WORKSPACE} ]; then
rm -rf ${WORKSPACE}
fi
echo "$0: --> BRANCH_NAME: '${BRANCH_NAME}'"
echo "$0: --> CHANGE_TARGET: '${CHANGE_TARGET}'"
echo "$0: --> PRODUCT: '${PRODUCT}'"
echo "$0: --> TARGET_ARCH: '${TARGET_ARCH}'"
echo "$0: --> TARGET_OS: '${TARGET_OS}'"
echo "$0: --> OS_VERSION: '${OS_VERSION}'"
echo "$0: --> OS_MAJOR_VERSION: '${OS_MAJOR_VERSION}'"
echo "$0: --> ARTI_LOCATION: '${ARTI_LOCATION}'"
echo "$0: --> ARTI_BRANCH: '${ARTI_BRANCH}'"
echo "$0: --> WORKSPACE: '${WORKSPACE}'"
repo_remove_add_refresh () {
# $1 - repo name
# $2 - repo_url
${ZYPPER_COMMAND} lr $1
res=$?
if [ $res -eq 0 ]; then
echo "Removing repo \"$1\""
${ZYPPER_COMMAND} rr $1
else
echo "Repo \"$1\" not present"
fi
${ZYPPER_COMMAND} addrepo --no-gpgcheck --check \
--priority 1 --name=$1 \
$2/ \
$1
${ZYPPER_COMMAND} refresh $1
}
if [ "$ZYPPER_COMMAND" ]; then
mkdir -p $ZYPPER_ROOT/etc/zypp/repos.d
mkdir -p $ZYPPER_ROOT/var/cache/zypp
mkdir -p $ZYPPER_ROOT/var/cache/zypp/raw
mkdir -p $ZYPPER_ROOT/var/cache/zypp/solv
mkdir -p $ZYPPER_ROOT/var/cache/zypp/packages
cp -r /etc/zypp ${WORKSPACE}/zypp/etc
cp -r /var/cache/zypp ${WORKSPACE}/zypp/var/cache
repo_remove_add_refresh "${EXTRA}-${ARTI_LOCATION}" "${ARTI_URL}/${EXTRA}-${ARTI_LOCATION}/${ARTI_BRANCH}/${TARGET_OS}"
# We need to manually install this RPM (rather than let the build process
# install it automatically) since it contains the kernel-module-package
# macros that our specfile uses
V1=$(uname -r | cut -d"-" -f1)
V2=$(uname -r | cut -d"-" -f2)
${ZYPPER_COMMAND} install -y kernel-default-devel
exit 0
elif command -v yum > /dev/null; then
yum-config-manager --setopt=gpgcheck=0 --save
version_support_file=./hpc-sshot-slingshot-version/shs-kernel-support/${OS_TYPE}${OS_VERSION}.json
if [ -f ${version_support_file} ]; then
yum install -y jq
for repo in $(jq -r '.[].repo | select( . != null)' ${version_support_file}); do
yum-config-manager --add-repo $repo
done
yum -y install $(jq -r '.[].packages[] | select( . != null)' ${version_support_file})
fi
if [[ "$TARGET_OS" == centos_8* ]]; then
# Pin kernel version to 4.18.0-305 from Centos 8.4
# This repo URL will still need to point to CAR until DST-9238 is resolved
cat > /etc/yum.repos.d/dst-remote-centos8.repo <<- END
[dst-remote-centos8.4.2105]
name=DST remote centos8.4.2105
baseurl=${ARTI_URL}/mirror-centos8.4/8.4.2105/BaseOS/x86_64/os/
enabled=1
gpgcheck=0
logfile=/var/log/yum.log
exclude=kernel
[dst-remote-centos8.4.2105-appstream]
name=DST remote centos8.4.2105 AppStream
baseurl=${ARTI_URL}/mirror-centos8.4/8.4.2105/AppStream/x86_64/os/
enabled=1
gpgcheck=0
logfile=/var/log/yum.log
exclude=kernel
END
yum clean all
yum install -y python3-dnf-plugin-versionlock
yum install -y kernel-devel-4.18.0-305.25.1.el8_4
yum versionlock 'kernel-*'
fi
yum-config-manager --add-repo=${ARTI_URL}/slingshot-host-software-${ARTI_LOCATION}/${ARTI_BRANCH}/${TARGET_OS}/
# We need to manually install this RPM (rather than let the build process
# install it automatically) since it contains the kernel-module-package
# macros that our specfile uses
yum install -y kernel-rpm-macros
else
"Unsupported package manager or package manager not found -- installing nothing"
fi