forked from msys2/msys2-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-msys2-installer
executable file
·90 lines (71 loc) · 3.01 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
#!/usr/bin/env bash
set -e
cd $(dirname $0)
_thisdir=`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"
PACMAN="fakeroot pacman"
OLDROOT="${_thisdir}/msys2"
BINCREATOR="${OLDROOT}/mingw64/bin/binarycreator.exe"
INSTALLERBASE="${OLDROOT}/mingw64/bin/installerbase.exe"
MINGW_PACKAGE_PREFIX="mingw-w64-x86_64"
OLDCONFIG="--config ${OLDROOT}/etc/pacman.conf --cachedir ${OLDROOT}/msys/cache"
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
}
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
wine64 ${BINCREATOR} \
-t "${INSTALLERBASE}" \
-p "${_ifwroot}/packages" \
-c "${_ifwroot}/config/config.xml" \
--offline-only \
"${_thisdir}/msys2-x86_64.exe" \
-v
popd > /dev/null
}
create_tmp_system() {
echo "[Creating temporary 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}" ${OLDCONFIG}
${PACMAN} -S filesystem msys2-runtime base --noconfirm --root "${_newmsys}" ${OLDCONFIG}
printf "\n[artiq]\nSigLevel = Optional TrustAll\nServer = https://msys2.m-labs.hk/artiq-beta\n" >> ${_newmsys}/etc/pacman.conf
printf "\n[artiq]\nSigLevel = Optional TrustAll\nServer = https://msys2.m-labs.hk/artiq-beta\n" >> ${OLDROOT}/etc/pacman.conf
${PACMAN} -Syy --root "${_newmsys}" ${OLDCONFIG}
${PACMAN} -S ${MINGW_PACKAGE_PREFIX}-artiq --noconfirm --root "${_newmsys}" ${OLDCONFIG}
${PACMAN} -Q --root "${_newmsys}" ${OLDCONFIG} > "${_thisdir}/msys2-base-x86_64.packages.txt"
popd > /dev/null
}
main() {
mkdir -p $OLDROOT/var/lib/pacman $OLDROOT/msys/etc
curl -L https://repo.msys2.org/msys/x86_64/pacman-mirrors-20240210-1-any.pkg.tar.zst | tar xvf - -C $OLDROOT --zstd
curl -L https://raw.githubusercontent.com/msys2/MSYS2-packages/master/pacman/pacman.conf | sed -e "s|/etc/pacman.d|$OLDROOT/etc/pacman.d|g" -e "s|SigLevel = Required|SigLevel = Never|g" > $OLDROOT/etc/pacman.conf
${PACMAN} --root $OLDROOT --config $OLDROOT/etc/pacman.conf -Syy
${PACMAN} --root $OLDROOT --config $OLDROOT/etc/pacman.conf --cachedir $OLDROOT/msys/cache -S ${MINGW_PACKAGE_PREFIX}-qt-installer-framework --noconfirm --needed
create_tmp_system
copy_installer
create_installer_archive
create_installer
}
main