forked from ibm-op-release/swift-config-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_swift
executable file
·199 lines (171 loc) · 6.78 KB
/
setup_swift
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/bin/bash
###################################################################
# Setup constant used below
SWIFT_BR2_OPENPOWER_MACHINE_XML_VERSION=180a43b301fd880125152e17ba51616545263933
###################################################################
# Exit from the script on any fail
set -e
###################################################################
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} [-h] [-v] [--op-build-dir=OP_BULD_DIR] [--skip-link]
This script takes the witherspoon_defconfig file from OP_BUILD_DIR and creates
the swift_defconfig file by replacing swift-specific fields. It then links the
swift_defconfig and swift.config files into the right sub-directories of
OP_BUILD_DIR.
NOTE: If no OP_BUILD_DIR is provided, this script will clone op-build into the
current directory.
-h,--help Display this help and exit
-v Verbose mode. Can be used multiple times for
increased verbosity.
--op-build-dir=OP_BULD_DIR Uses the directory (incuding its path) for
op-build repo instead of the default ./op-build
---skip-link Skips linking the config files into the right
sub-directories of OP_BUILD_DIR
Example - No argements:
./setup_swift
Example - All argements:
./setup_swift -v -v --skip-link --op-build-dir=/<some>/<path>/<to>/op-build
EOF
}
###################################################################
# Process Input Parameters
# Initialize all the option variables.
OP_BUILD_DIR=
SKIP_LINK=0
VERBOSE=0
DO_CLONE=0
while :; do
case $1 in
-h|-\?|--help)
show_help # Display a usage synopsis.
exit
;;
--op-build-dir) # Takes an option argument; ensure it has been specified.
if [ "$2" ]; then
OP_BUILD_DIR=$2
shift
else
printf 'ERROR: "--op_build-dir" requires a non-empty option argument.\n'
exit 1
fi
;;
--op-build-dir=?*)
OP_BUILD_DIR=${1#*=} # Delete everything up to "=" and assign the remainder.
;;
--op-build-dir=) # Handle the case of an empty --op-build_dir=
printf 'ERROR: "--op-build_dir" requires a non-empty option argument.\n'
exit 1
;;
--skip-link) # Sets SKIP_LINK variable
SKIP_LINK=1
;;
-v|--verbose)
VERBOSE=$((VERBOSE + 1)) # Each -v adds 1 to verbosity.
;;
--) # End of all options.
shift
break
;;
-?*)
printf 'ERROR: Unknown option: %s\n' "$1" >&2
exit 1
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done
###################################################################
echo "Setting up Swift Config Files ...";
# check OP_BUILD_DIR
if [ ! $OP_BUILD_DIR ] ; then
# no dir was passed in so clone to default directory
OP_BUILD_DIR=./op-build
DO_CLONE=1
if [ $VERBOSE -ne "0" ] ; then
printf "No OP_BUILD_DIR Passed in so will clone $OP_BUILD_DIR\n"
fi
elif [ ! -d $OP_BUILD_DIR ]; then
printf "ERROR: Input OP_BULD_DIR $OP_BUILD_DIR Does Not Exist\n"
exit 1
else
DO_CLONE=0
if [ $VERBOSE -ne "0" ] ; then
printf "Using existing OP_BUILD_DIR $OP_BUILD_DIR (no cloning)\n"
fi
fi
# Set these variables
WD_FILE=${OP_BUILD_DIR}/openpower/configs/witherspoon_defconfig
SD_FILE=swift_defconfig
if [ $VERBOSE -gt "1" ] ; then
printf "Script Parameters:\n"
printf "\tOP_BUILD_DIR=$OP_BUILD_DIR\n"
printf "\tDO_CLONE=$DO_CLONE\n"
printf "\tSKIP_LINK=$SKIP_LINK\n"
printf "\tVERBOSE=$VERBOSE\n"
printf "\tWD_FILE=$WD_FILE\n"
printf "\tSD_FILE=$SD_FILE\n"
fi
###################################################################
# Clone open-power/op-build. Using master branch for now
if [ $DO_CLONE -ne "0" ] ; then
if [ $VERBOSE -ne "0" ] ; then
printf "Cloning op-build to $OP_BUILD_DIR ... \n"
fi
git clone --recursive https://github.com/open-power/op-build.git
fi
###################################################################
# Create swift_defconfig from witherspoon_defconfig
# 1) Remove witherspoon-specific values:
cat $WD_FILE \
|grep -v BR2_HOSTBOOT_CONFIG_FILE \
|grep -v BR2_OPENPOWER_MACHINE_XML_GITHUB_PROJECT \
|grep -v BR2_OPENPOWER_MACHINE_XML_GITHUB_PROJECT_VALUE \
|grep -v BR2_OPENPOWER_MACHINE_XML_CUSTOM_GIT \
|grep -v BR2_OPENPOWER_MACHINE_XML_CUSTOM_GIT_VALUE \
|grep -v BR2_OPENPOWER_MACHINE_XML_VERSION \
|grep -v BR2_OPENPOWER_MACHINE_XML_FILENAME \
|grep -v BR2_OPENPOWER_SYSTEM_XML_FILENAME \
|grep -v BR2_OPENPOWER_MRW_XML_FILENAME \
|grep -v BR2_OPENPOWER_BIOS_XML_FILENAME \
|grep -v BR2_OPENPOWER_PNOR_XML_LAYOUT_FILENAME \
|grep -v BR2_OPENPOWER_CONFIG_NAME \
|grep -v BR2_OPENPOWER_PNOR_FILENAME \
|grep -v BR2_HOSTBOOT_BINARY_SBE_FILENAME \
|grep -v BR2_HOSTBOOT_BINARY_WINK_FILENAME \
|grep -v BR2_OPENPOWER_TARGETING_BIN_FILENAME \
|grep -v BR2_OPENPOWER_TARGETING_ECC_FILENAME \
> $SD_FILE
# 2) Set swift-specific values:
sed -i '1iBR2_OPENPOWER_CONFIG_NAME=\"swift\"' $SD_FILE
sed -i '2iBR2_HOSTBOOT_CONFIG_FILE=\"swift.config\"' $SD_FILE
sed -i '3iBR2_OPENPOWER_MACHINE_XML_VERSION="'$SWIFT_BR2_OPENPOWER_MACHINE_XML_VERSION'"' $SD_FILE
sed -i '4iBR2_OPENPOWER_MACHINE_XML_GITHUB_PROJECT=n' $SD_FILE
sed -i '4iBR2_OPENPOWER_MACHINE_XML_GITHUB_PROJECT_VALUE=\"swift-xml\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_MACHINE_XML_CUSTOM_GIT=y' $SD_FILE
sed -i '4iBR2_OPENPOWER_MACHINE_XML_CUSTOM_GIT_VALUE=\"[email protected]:open-power/swift-xml.git\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_MACHINE_XML_FILENAME=\"swift.xml\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_SYSTEM_XML_FILENAME=\"SWIFT_hb.system.xml\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_MRW_XML_FILENAME=\"SWIFT_hb.mrw.xml\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_BIOS_XML_FILENAME=\"SWIFT_bios.xml\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_PNOR_XML_LAYOUT_FILENAME=\"axonePnorLayout_64.xml\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_PNOR_FILENAME=\"swift.pnor\"' $SD_FILE
sed -i '4iBR2_HOSTBOOT_BINARY_SBE_FILENAME=\"axone_sbe.img.ecc\"' $SD_FILE
sed -i '4iBR2_HOSTBOOT_BINARY_WINK_FILENAME=\"p9a.ref_image.hdr.bin.ecc\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_TARGETING_BIN_FILENAME=\"SWIFT_HB.targeting.bin\"' $SD_FILE
sed -i '4iBR2_OPENPOWER_TARGETING_ECC_FILENAME=\"SWIFT_HB.targeting.bin.ecc\"' $SD_FILE
###################################################################
# Add symbolic links inside op-build for the swift config files
if [ $SKIP_LINK -eq 0 ] ; then
if [ $VERBOSE -ne "0" ] ; then
printf "Setting up links for config files ...\n"
fi
ln -fs `pwd`/swift_defconfig -t $OP_BUILD_DIR/openpower/configs/
ln -fs `pwd`/swift.config -t $OP_BUILD_DIR/openpower/configs/hostboot/
else
if [ $VERBOSE -ne "0" ] ; then
printf "SKIPPING setting up links for config files\n"
fi
fi