Skip to content

Commit b3fdcb4

Browse files
authored
Fixed sha1 installer issue
1 parent 5848e45 commit b3fdcb4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

onie-mk-demo.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,51 +122,48 @@ echo -n "."
122122
echo "Error: $sharch not found"
123123
clean_up 1
124124
}
125+
sha1=$(cat $sharch | sha1sum | awk '{print $1}')
125126
echo -n "."
126127
cp $installer_dir/sharch_body.sh $output_file || {
127128
echo "Error: Problems copying sharch_body.sh"
128129
clean_up 1
129130
}
130131

131132
# Replace variables in the sharch template
133+
sed -i -e "s/%%IMAGE_SHA1%%/$sha1/" $output_file
132134
echo -n "."
133135
tar_size="$(wc -c < "${sharch}")"
134-
cat $sharch >> $output_file
135-
sha1=$(sed -e '1,/^exit_marker$/d' "$output_file" | sha1sum | awk '{ print $1 }')
136-
sed -i -e "s/%%IMAGE_SHA1%%/$sha1/" $output_file
137136
sed -i -e "s|%%PAYLOAD_IMAGE_SIZE%%|${tar_size}|" ${output_file}
137+
cat $sharch >> $output_file
138138
echo "secure upgrade flags: SECURE_UPGRADE_MODE = $SECURE_UPGRADE_MODE, \
139139
SECURE_UPGRADE_DEV_SIGNING_KEY = $SECURE_UPGRADE_DEV_SIGNING_KEY, SECURE_UPGRADE_DEV_SIGNING_CERT = $SECURE_UPGRADE_DEV_SIGNING_CERT"
140140

141141
if [ "$SECURE_UPGRADE_MODE" = "dev" -o "$SECURE_UPGRADE_MODE" = "prod" ]; then
142142
CMS_SIG="${tmp_dir}/signature.sig"
143-
144143
echo "$0 Creating CMS signature for ${output_file} with ${key_file}. Output file ${CMS_SIG}"
145144
DIR="$(dirname "$0")"
146-
147145
scripts_dir="${DIR}/scripts"
148146
if [ "$SECURE_UPGRADE_MODE" = "dev" ]; then
149147
. ${scripts_dir}/sign_image_dev.sh
150-
sign_image_dev ${cert_file} ${key_file} ${output_file} ${CMS_SIG} || {
148+
sign_image_dev ${cert_file} ${key_file} ${output_file} ${CMS_SIG} || {
151149
echo "CMS sign error $?"
152150
sudo rm -rf ${CMS_SIG}
153151
clean_up 1
154152
}
155153
else # "$SECURE_UPGRADE_MODE" has to be equal to "prod"
156154
. ${scripts_dir}/sign_image_${platform}.sh
157-
sign_image_prod ${output_file} ${CMS_SIG} || {
155+
sign_image_prod ${output_file} ${CMS_SIG} || {
158156
echo "CMS sign error $?"
159157
sudo rm -rf ${CMS_SIG}
160158
clean_up 1
161159
}
162160
fi
163-
164161
[ -f "$CMS_SIG" ] || {
165162
echo "Error: CMS signature not created - exiting without signing"
166163
clean_up 1
167164
}
168165
# append signature to binary
169-
cat ${CMS_SIG} >> ${output_file}
166+
cat ${CMS_SIG} >> ${output_file}
170167
sudo rm -rf ${CMS_SIG}
171168
elif [ "$SECURE_UPGRADE_MODE" != "no_sign" ]; then
172169
echo "SECURE_UPGRADE_MODE not defined or defined as $SECURE_UPGRADE_MODE - build without signing"

0 commit comments

Comments
 (0)