forked from msys2/msys2-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-msys2-installer
238 lines (198 loc) · 7.12 KB
/
make-msys2-installer
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/usr/bin/env bash
set -e
source get_versions.sh
_spinal_version="$2"
_scala_version="$1"
_scala_full_version=${full_scala_versions["${_scala_version}-${_spinal_version}"]}
_verilator_version="4.228-1"
_srcdir="$(pwd)"
_thisdir="$( cd "$( dirname "$0" )" && pwd )"
_build="${_thisdir}/_build"
_ifwroot="${_build}/qt-ifw"
_date=$(date +'%Y%m%d')
_dateqif=$(date +'%Y-%m-%d')
_version="${_date}"
_newmsysbase="${_build}/newmsys"
_newmsys="${_newmsysbase}/msys64"
_yosys_version="${_yosys_major_version}-1"
if [ "$MINGW_PACKAGE_PREFIX" = "mingw-w64-i686" ]; then
mcode="mcode"
msystem="mingw32"
else
mcode="llvm"
msystem="mingw64"
fi
_custom_packages="
${MINGW_PACKAGE_PREFIX}-yosys-${_yosys_version}-any.pkg.tar.zst
${MINGW_PACKAGE_PREFIX}-python-sby-${_yosys_version}-any.pkg.tar.zst
"
_versioned_packages_url="
https://mirror.msys2.org/mingw/${msystem}/${MINGW_PACKAGE_PREFIX}-verilator-${_verilator_version}-any.pkg.tar.zst
"
_packages=$(cat << EOF
git
${MINGW_PACKAGE_PREFIX}-autotools
${MINGW_PACKAGE_PREFIX}-gtkwave
${MINGW_PACKAGE_PREFIX}-iverilog
${MINGW_PACKAGE_PREFIX}-ghdl-${mcode}
${MINGW_PACKAGE_PREFIX}-boost
${MINGW_PACKAGE_PREFIX}-z3
${MINGW_PACKAGE_PREFIX}-yices
${MINGW_PACKAGE_PREFIX}-python-click
EOF
)
prepare_tmp_dir(){
_tmp="${_newmsys}/tmp"
if [ ! -d "${_tmp}" ]; then
mkdir -p "${_tmp}"
fi
cd ${_tmp}
}
clean_tmp_dir(){
rm -rf ${_newmsys}/tmp/*
cd ${_newmsys}
}
install_versioned_packages(){
echo "export INSTALL_ROOT=\$(cygpath -w / | sed 's,[/\\]$,,')" >> ${_newmsys}/etc/skel/.bashrc
echo "export VERILATOR_ROOT=\${INSTALL_ROOT}/mingw64/share/verilator" >> ${_newmsys}/etc/skel/.bashrc
prepare_tmp_dir
for pkg_file in ${_versioned_packages_url}; do
if [ ! -f "${pkg_file}" ]; then
wget "${pkg_file}"
fi
done
pacman -U --noconfirm --root "${_newmsys}" ${MINGW_PACKAGE_PREFIX}-*-any.pkg.tar.*
clean_tmp_dir
}
install_custom_packages(){
_url="https://github.com/Readon/MINGW-SpinalHDL/releases/download/v${_yosys_major_version}"
prepare_tmp_dir
for pkg in ${_custom_packages}; do
if [ ! -f "${pkg}" ]; then
wget "${_url}/${pkg}"
fi
done
pacman -U --noconfirm --root "${_newmsys}" ${MINGW_PACKAGE_PREFIX}-*-any.pkg.tar.*
clean_tmp_dir
}
install_sdkman(){
export SDKMAN_DIR=${_newmsys}/sdkman
HOME=${_newmsys}/etc/skel ${_srcdir}/sdkman.sh
source $SDKMAN_DIR/bin/sdkman-init.sh
sdk install java $_java_version
sdk install sbt $_sbt_version
export SBT_OPTS="-Dsbt.version=${_sbt_version} -Dsbt.boot.directory=${_newmsys}/cache/.sbt/boot -Dsbt.global.base=${_newmsys}/cache/.sbt/1.0 -Dsbt.ivy.home=${_newmsys}/cache/.ivy2"
echo "export SBT_OPTS=\"-Dsbt.version=${_sbt_version} -Dsbt.boot.directory=\${INSTALL_ROOT}/cache/.sbt/boot -Dsbt.global.base=\${INSTALL_ROOT}/cache/.sbt/1.0 -Dsbt.ivy.home=\${INSTALL_ROOT}/cache/.ivy2\"" >> ${_newmsys}/etc/skel/.bashrc
}
install_dependencies(){
setup_sbt
install_spinalhdl_dependencies
}
install_coursier(){
export COURSIER_CACHE=${_newmsys}/cache/.coursier
echo "export COURSIER_CACHE=\${INSTALL_ROOT}/cache/.coursier" >> ${_newmsys}/etc/skel/.bashrc
export COURSIER_HOME=${_newmsys}/coursier
export COURSIER_BIN_DIR=${_newmsys}/coursier
echo "export PATH=\"\$PATH:\${INSTALL_ROOT}/coursier\"" >> ${_newmsys}/etc/skel/.bashrc
echo "alias coursier=cs.bat" >> ${_newmsys}/etc/skel/.bashrc
wget "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-win32.zip"
unzip cs-x86_64-pc-win32.zip
./cs-x86_64-pc-win32.exe setup -y --dir ${COURSIER_HOME}
export COURSIER="${COURSIER_HOME}/cs.bat"
}
setup_sbt(){
${COURSIER} install scala:2.12.17
${COURSIER} fetch org.scala-sbt:sbt:${_sbt_version}
${COURSIER} fetch --sources org.scala-sbt:compiler-bridge_${_scala_version}:1.8.0
${COURSIER} fetch jline:jline:2.14.6
${COURSIER} fetch jline:jline:2.14.3
${COURSIER} fetch org.fusesource.jansi:jansi:1.12
${COURSIER} fetch --sbt-plugin org.scalameta:sbt-scalafmt:2.4.6
echo "alias mill=mill.bat" >> ${_newmsys}/etc/skel/.bashrc
${COURSIER} install mill
}
_spinal_with_tester="1.8.0"
_scala_version_with_xml_error="2.12"
_spinal_version_with_xml_error="1.9.3"
_scala_version_without_xml_error="2.12.18"
install_spinalhdl_dependencies(){
${COURSIER} fetch com.github.spinalhdl:spinalhdl-core_${_scala_version}:${_spinal_version}
${COURSIER} fetch com.github.spinalhdl:spinalhdl-lib_${_scala_version}:${_spinal_version}
${COURSIER} fetch com.github.spinalhdl:spinalhdl-sim_${_scala_version}:${_spinal_version}
if [ $(is_version_smaller_eq ${_spinal_version} ${_spinal_with_tester}) == "false" ]; then
${COURSIER} fetch com.github.spinalhdl:spinalhdl-tester_${_scala_version}:${_spinal_version}
fi
if [ $(is_version_smaller_eq ${_spinal_version} ${_spinal_version_with_xml_error}) == "true" ] && [ ${_scala_version} == ${_scala_version_with_xml_error} ]; then
${COURSIER} install scala:${_scala_version_without_xml_error}
fi
}
create_installer_archive() {
echo "[Creating installer archive...]"
local _data="${_ifwroot}"/packages/com.msys2.root/data
pushd / > /dev/null
mkdir -p "${_data}"
7z a -mx9 -md128m "${_data}/msys64.7z" "${_newmsys}/"*
popd > /dev/null
}
create_archive() {
echo "[Creating archive...]"
pushd "${_newmsysbase}" > /dev/null
export XZ_OPT="-9T0"
/usr/bin/tar --transform='s/:/_/g' --dereference --hard-dereference -cJf "${_thisdir}/msys2-base-x86_64-${_date}.tar.xz" msys64
popd > /dev/null
}
create_sfx() {
echo "[Creating SFX...]"
pushd "${_newmsysbase}" > /dev/null
"${_thisdir}/create-sfx.sh" "msys64" "${_thisdir}/msys2-base-x86_64-${_date}.sfx.exe"
popd > /dev/null
}
copy_installer() {
echo "[Copying installer...]"
rm -Rf "${_ifwroot}" && cp -r "${_thisdir}"/qt-ifw "${_ifwroot}"
find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|@DATE@|${_dateqif}|g" "{}" \;
find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|@VERSION@|${_version}|g" "{}" \;
}
create_installer() {
echo "[Creating installer...]"
pushd "${_build}" > /dev/null
binarycreator \
-t "$(command -v installerbase)" \
-p "${_ifwroot}/packages" \
-c "${_ifwroot}/config/config.xml" \
--offline-only \
"${_thisdir}/msys2-x86_64-${_scala_version}-${_spinal_version}.exe" \
-v
popd > /dev/null
}
create_chroot_system() {
echo "[Creating chroot system...]"
rm -Rf "${_newmsysbase}" && mkdir -p "${_newmsys}"
pushd "${_newmsys}" > /dev/null
mkdir -p var/lib/pacman
mkdir -p var/log
mkdir -p tmp
pacman -Syu --root "${_newmsys}"
pacman -S filesystem msys2-runtime --noconfirm --root "${_newmsys}"
pacman -S base --noconfirm --root "${_newmsys}"
pacman -S ${_packages} --noconfirm --root "${_newmsys}"
install_versioned_packages
install_custom_packages
install_sdkman
install_coursier
install_dependencies
popd > /dev/null
}
main() {
pacman -S --noconfirm --needed \
"${MINGW_PACKAGE_PREFIX}-qt-installer-framework" \
"${MINGW_PACKAGE_PREFIX}-7zip" \
"tar"
create_chroot_system
copy_installer
create_installer_archive
create_installer
# create_archive
# create_sfx
}
main