forked from msys2/msys2-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-msys2-installer
111 lines (89 loc) · 3.3 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
#!/usr/bin/env bash
set -e
_thisdir="$( cd "$( dirname "$0" )" && pwd )"
_build="${_thisdir}/_build"
_ifwroot="${_build}/qt-ifw"
_arch=$(uname -m)
_date=$(date +'%Y%m%d')
_dateqif=$(date +'%Y-%m-%d')
_version="${_date}"
if [ "${_arch}" = "x86_64" ]; then
_bitness=64
else
_bitness=32
fi
_newmsysbase="${_build}/newmsys"
_newmsys="${_newmsysbase}/msys${_bitness}"
create_installer_archive() {
echo "[Creating installer archive...]"
local _data="${_ifwroot}"/packages/com.msys2.root/data
pushd / > /dev/null
mkdir -p "${_data}"
/mingw64/bin/7z a -mx9 -md128m "${_data}/msys${_bitness}.7z" "${_newmsys}/"*
popd > /dev/null
}
create_archives() {
echo "[Creating tarball...]"
pushd "${_newmsysbase}" > /dev/null
/usr/bin/tar --transform='s/:/_/g' --dereference --hard-dereference -cf "${_thisdir}/msys2-base-${_arch}-${_date}.tar" msys${_bitness}
popd > /dev/null
echo "[Creating xz archive...]"
xz -9 --keep --verbose --force --compress --threads=0 "${_thisdir}/msys2-base-${_arch}-${_date}.tar"
xz --test "${_thisdir}/msys2-base-${_arch}-${_date}.tar.xz"
echo "[Creating zstd archive...]"
/mingw64/bin/zstd -T0 -22 --ultra --force "${_thisdir}/msys2-base-${_arch}-${_date}.tar" -o "${_thisdir}/msys2-base-${_arch}-${_date}.tar.zst"
zstd --test "${_thisdir}/msys2-base-${_arch}-${_date}.tar.zst"
rm "${_thisdir}/msys2-base-${_arch}-${_date}.tar"
}
create_sfx() {
echo "[Creating SFX...]"
pushd "${_newmsysbase}" > /dev/null
"${_thisdir}/create-sfx.sh" "msys${_bitness}" "${_thisdir}/msys2-base-${_arch}-${_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" "{}" \;
find "${_ifwroot}" \( -name "package.xml" -or -name "config.xml" -or -name "installscript.js" \) -exec sed -i "s|@BITNESS@|${_bitness}|g" "{}" \;
}
create_installer() {
echo "[Creating installer...]"
pushd "${_build}" > /dev/null
true binarycreator \
-t "$(command -v installerbase)" \
-p "${_ifwroot}/packages" \
-c "${_ifwroot}/config/config.xml" \
--offline-only \
"${_thisdir}/msys2-${_arch}-${_date}.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-3.3 --noconfirm --root "${_newmsys}"
pacman -S base --noconfirm --root "${_newmsys}"
grep -F '[build32]' etc/pacman.conf || sed -i '/\[msys\]/i [build32]\nServer = https://github.com/jeremyd2019/msys2-build32/releases/download/repo\nSigLevel = Optional\n' etc/pacman.conf
pacman -Q --root "${_newmsys}" > "${_thisdir}/msys2-base-${_arch}-${_date}.packages.txt"
popd > /dev/null
}
main() {
pacman -S --noconfirm --needed \
"${MINGW_PACKAGE_PREFIX}-xz" \
"${MINGW_PACKAGE_PREFIX}-zstd" \
"tar"
create_chroot_system
copy_installer
create_installer_archive
create_installer
create_archives
create_sfx
}
main