forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_working_folder.sh
executable file
·154 lines (121 loc) · 4.56 KB
/
build_working_folder.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
#!/bin/bash
#
# file build_working_folder.sh
#
FULL_BUNDLE_FILE="${BUNDLE_FULL_NAME}.zip"
UPDATE_BUNDLE_FILE="${BUNDLE_FULL_NAME}_autoupdate.zip"
echo "${BUNDLE_FULL_NAME}: Packaging temp/$FULL_BUNDLE_FILE file"
rm -rf temp
mkdir temp
SCRIPT_NAME=build_working_folder.sh
echo "Entering $SCRIPT_NAME"
pwd
# This working folder name starts with 'temp/'
echo "$SCRIPT_NAME: Working folder: $FOLDER"
mkdir $FOLDER
echo $BUNDLE_FULL_NAME > $FOLDER/bundle_name.txt
CONSOLE_FOLDER="$FOLDER/console"
DRIVERS_FOLDER="$FOLDER/drivers"
mkdir $CONSOLE_FOLDER
mkdir $DRIVERS_FOLDER
ls -l $FOLDER
wget https://rusefi.com/build_server/st_files/silent_st_drivers2.exe -P $DRIVERS_FOLDER
[ -e $DRIVERS_FOLDER/silent_st_drivers2.exe ] || { echo "$SCRIPT_NAME: ERROR DOWNLOADING silent_st_drivers2.exe"; exit 1; }
if [ "$INI_FILE_OVERRIDE" = "no" ]; then
INI_FILE_OVERRIDE="rusefi.ini"
echo "$SCRIPT_NAME: N/a ini_file_override specified"
fi
if [ -z $INI_FILE_OVERRIDE ]; then
INI_FILE_OVERRIDE="rusefi.ini"
echo "$SCRIPT_NAME: No ini_file_override specified"
fi
echo "$SCRIPT_NAME: Will use $INI_FILE_OVERRIDE"
if [ -z $RUSEFI_CONSOLE_SETTINGS ]; then
echo "$SCRIPT_NAME: No rusefi_console_settings"
else
echo "Using rusefi_console_settings [$RUSEFI_CONSOLE_SETTINGS]"
cp $RUSEFI_CONSOLE_SETTINGS $CONSOLE_FOLDER
fi
cp java_console/rusefi_autoupdate.jar $CONSOLE_FOLDER
cp java_console_binary/rusefi_console.jar $CONSOLE_FOLDER
cp java_tools/ts_plugin_launcher/build/jar/rusefi_ts_plugin_launcher.jar $FOLDER
cp simulator/build/rusefi_simulator.exe $CONSOLE_FOLDER
cp misc/console_launcher/rusefi_*.exe $CONSOLE_FOLDER
cp java_console/*.dll $CONSOLE_FOLDER
cp java_console/rusefi.xml $CONSOLE_FOLDER
cp -r java_console/bin $FOLDER
cp misc/console_launcher/readme.html $FOLDER
cp firmware/tunerstudio/generated/$INI_FILE_OVERRIDE $FOLDER
# Unsetting since would not be used anywhere else
INI_FILE_OVERRIDE=""
RUSEFI_CONSOLE_SETTINGS=""
# users probably do not really care for this file
# cp firmware/svnversion.h $FOLDER
cp -r misc/install/openocd $CONSOLE_FOLDER
cp -r misc/install/STM32_Programmer_CLI $CONSOLE_FOLDER
# 407 has additional version of firmware
#cp firmware/deliver/rusefi_no_asserts.bin $FOLDER
#cp firmware/deliver/rusefi_no_asserts.dfu $FOLDER
# just for now - DFU work in progress
#cp firmware/deliver/rusefi_no_asserts.hex $FOLDER
cp firmware/deliver/rusefi.bin $FOLDER
# probably not needed cp firmware/build/rusefi.elf $FOLDER
cp firmware/deliver/rusefi.dfu $FOLDER
# just for now - DFU work in progress
cp firmware/deliver/rusefi.hex $FOLDER
# bootloader
[ -e firmware/deliver/openblt.bin ] && { cp firmware/deliver/openblt.bin $FOLDER ; }
[ -e firmware/deliver/openblt.dfu ] && { cp firmware/deliver/openblt.dfu $FOLDER ; }
# update srec
[ -e firmware/deliver/rusefi_update.srec ] && { cp firmware/deliver/rusefi_update.srec $FOLDER ; }
if [ -n "$BUNDLE_NAME" ]; then
mv $FOLDER/rusefi.dfu $FOLDER/rusefi_$BUNDLE_NAME.dfu
fi
[ -e firmware/deliver/rusefi.bin ] || { echo "$SCRIPT_NAME: rusefi.bin not found"; exit 1; }
cd temp
echo "Building bundle"
pwd
zip -r $FULL_BUNDLE_FILE *
[ $? -eq 0 ] || (echo "$SCRIPT_NAME: ERROR INVOKING zip"; exit 1)
echo "$SCRIPT_FILE: Bundle $FULL_BUNDLE_FILE ready"
ls -l $FULL_BUNDLE_FILE
[ -e $FULL_BUNDLE_FILE ] || { echo "$SCRIPT_NAME: ERROR not found $FULL_BUNDLE_FILE"; exit 1; }
if [ -n "$RUSEFI_SSH_USER" ]; then
echo "$SCRIPT_NAME: Uploading full bundle"
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "tar -xzf - -C build_server"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "full bundle upload failed"
exit 1
fi
else
echo "Upload not configured"
fi
cd ..
mkdir -p artifacts
mv temp/$FULL_BUNDLE_FILE artifacts
echo "Removing static content from ${CONSOLE_FOLDER} and $DRIVERS_FOLDER"
rm -rf $CONSOLE_FOLDER/*.exe
rm -rf $CONSOLE_FOLDER/DfuSe
rm -rf $CONSOLE_FOLDER/openocd
rm -rf $DRIVERS_FOLDER
# for autoupdate we do not want the unique folder name with timestamp
cd $FOLDER
zip -r ../$UPDATE_BUNDLE_FILE *
cd ..
ls -l $UPDATE_BUNDLE_FILE
if [ -n "$RUSEFI_SSH_USER" ]; then
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "tar -xzf - -C build_server/autoupdate"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "autoupdate upload failed"
exit 1
fi
else
echo "Upload not configured"
fi
cd ..
mv temp/$UPDATE_BUNDLE_FILE artifacts
echo "$SCRIPT_NAME: We are back in root directory"
pwd
echo "Exiting $SCRIPT_NAME"