@cryptotaxi247 / netdata-1 / commits / 392e1fa0b

Update windows installer (#18385)

thiagoftsm committed Aug 21, 2024 at 12:07 UTC 392e1fa0b09f82a6ba8f456791c86b575b2a7640
5 files changed +268 -9
packaging/installer/installer.nsi new
+128
@@ -0,0 +1,128 @@
1 +!include "MUI2.nsh"
2 +!include "nsDialogs.nsh"
3 +!include "FileFunc.nsh"
4 +
5 +Name "Netdata"
6 +Outfile "netdata-installer.exe"
7 +InstallDir "$PROGRAMFILES\Netdata"
8 +RequestExecutionLevel admin
9 +
10 +!define MUI_ICON "NetdataWhite.ico"
11 +!define MUI_UNICON "NetdataWhite.ico"
12 +
13 +!define ND_UININSTALL_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata"
14 +
15 +!define MUI_ABORTWARNING
16 +!define MUI_UNABORTWARNING
17 +
18 +!insertmacro MUI_PAGE_WELCOME
19 +!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt"
20 +!insertmacro MUI_PAGE_DIRECTORY
21 +!insertmacro MUI_PAGE_INSTFILES
22 +!insertmacro MUI_PAGE_FINISH
23 +
24 +!insertmacro MUI_UNPAGE_CONFIRM
25 +!insertmacro MUI_UNPAGE_INSTFILES
26 +!insertmacro MUI_UNPAGE_FINISH
27 +
28 +!insertmacro MUI_LANGUAGE "English"
29 +
30 +Function .onInit
31 + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata'
32 + pop $0
33 + ${If} $0 == 0
34 + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata'
35 + pop $0
36 + ${EndIf}
37 +FunctionEnd
38 +
39 +Function NetdataUninstallRegistry
40 + ClearErrors
41 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
42 + "DisplayName" "Netdata - Real-time system monitoring."
43 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
44 + "DisplayIcon" "$INSTDIR\Uninstall.exe,0"
45 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
46 + "UninstallString" "$INSTDIR\Uninstall.exe"
47 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
48 + "RegOwner" "Netdata Inc."
49 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
50 + "RegCompany" "Netdata Inc."
51 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
52 + "Publisher" "Netdata Inc."
53 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
54 + "HelpLink" "https://learn.netdata.cloud/"
55 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
56 + "URLInfoAbout" "https://www.netdata.cloud/"
57 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
58 + "DisplayVersion" "${CURRVERSION}"
59 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
60 + "VersionMajor" "${MAJORVERSION}"
61 + WriteRegStr HKLM "${ND_UININSTALL_REG}" \
62 + "VersionMinor" "${MINORVERSION}"
63 +
64 + IfErrors 0 +2
65 + MessageBox MB_ICONEXCLAMATION|MB_OK "Unable to create an entry in the Control Panel!" IDOK end
66 +
67 + ClearErrors
68 + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
69 + IntFmt $0 "0x%08X" $0
70 + WriteRegDWORD HKLM "${ND_UININSTALL_REG}" "EstimatedSize" "$0"
71 +
72 + IfErrors 0 +2
73 + MessageBox MB_ICONEXCLAMATION|MB_OK "Cannot estimate the installation size." IDOK end
74 + end:
75 +FunctionEnd
76 +
77 +Section "Install Netdata"
78 + SetOutPath $INSTDIR
79 + SetCompress off
80 +
81 + File /r "C:\msys64\opt\netdata\*.*"
82 +
83 + ClearErrors
84 + nsExec::ExecToLog '$SYSDIR\sc.exe create Netdata binPath= "$INSTDIR\usr\bin\netdata.exe" start= delayed-auto'
85 + pop $0
86 + ${If} $0 != 0
87 + DetailPrint "Warning: Failed to create Netdata service."
88 + ${EndIf}
89 +
90 + ClearErrors
91 + nsExec::ExecToLog '$SYSDIR\sc.exe description Netdata "Real-time system monitoring service"'
92 + pop $0
93 + ${If} $0 != 0
94 + DetailPrint "Warning: Failed to add Netdata service description."
95 + ${EndIf}
96 +
97 + ClearErrors
98 + nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata'
99 + pop $0
100 + ${If} $0 != 0
101 + DetailPrint "Warning: Failed to start Netdata service."
102 + ${EndIf}
103 +
104 + WriteUninstaller "$INSTDIR\Uninstall.exe"
105 +
106 + Call NetdataUninstallRegistry
107 +SectionEnd
108 +
109 +Section "Uninstall"
110 + ClearErrors
111 + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata'
112 + pop $0
113 + ${If} $0 != 0
114 + DetailPrint "Warning: Failed to stop Netdata service."
115 + ${EndIf}
116 +
117 + ClearErrors
118 + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata'
119 + pop $0
120 + ${If} $0 != 0
121 + DetailPrint "Warning: Failed to delete Netdata service."
122 + ${EndIf}
123 +
124 + RMDir /r "$INSTDIR"
125 +
126 + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata"
127 +SectionEnd
128 +
packaging/installer/package-windows.sh new
+43
@@ -0,0 +1,43 @@
1 +#!/bin/bash
2 +
3 +repo_root="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")"
4 +
5 +if [ -n "${BUILD_DIR}" ]; then
6 + build="${BUILD_DIR}"
7 +elif [ -n "${OSTYPE}" ]; then
8 + if [ -n "${MSYSTEM}" ]; then
9 + build="${repo_root}/build-${OSTYPE}-${MSYSTEM}"
10 + else
11 + build="${repo_root}/build-${OSTYPE}"
12 + fi
13 +elif [ "$USER" = "vk" ]; then
14 + build="${repo_root}/build"
15 +else
16 + build="${repo_root}/build"
17 +fi
18 +
19 +set -exu -o pipefail
20 +
21 +${GITHUB_ACTIONS+echo "::group::Installing"}
22 +cmake --install "${build}"
23 +${GITHUB_ACTIONS+echo "::endgroup::"}
24 +
25 +if [ ! -f "/msys2-installer.exe" ]; then
26 + ${GITHUB_ACTIONS+echo "::group::Fetching MSYS2 installer"}
27 + "${repo_root}/packaging/windows/fetch-msys2-installer.py" /msys2-installer.exe
28 + ${GITHUB_ACTIONS+echo "::endgroup::"}
29 +fi
30 +
31 +${GITHUB_ACTIONS+echo "::group::Packaging"}
32 +NDVERSION=$"$(grep 'CMAKE_PROJECT_VERSION:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
33 +NDMAJORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MAJOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
34 +NDMINORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MINOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
35 +
36 +if [ -f "/gpl-3.0.txt" ]; then
37 + ${GITHUB_ACTIONS+echo "::group::Fetching GPL3 License"}
38 + curl -o /gpl-3.0.txt "https://www.gnu.org/licenses/gpl-3.0.txt"
39 + ${GITHUB_ACTIONS+echo "::endgroup::"}
40 +fi
41 +
42 +/mingw64/bin/makensis.exe -DCURRVERSION="${NDVERSION}" -DMAJORVERSION="${NDMAJORVERSION}" -DMINORVERSION="${NDMINORVERSION}" "${repo_root}/packaging/windows/installer.nsi"
43 +${GITHUB_ACTIONS+echo "::endgroup::"}
packaging/windows/fetch-msys2-installer.py
+2 -2
@@ -78,8 +78,8 @@ def main() -> None:
78 with TemporaryDirectory() as tmpdir:
79 tmppath = Path(tmpdir)
80
81 - installer = fetch_release_asset(tmppath, name, f'msys2-x86_64-{version}.exe')
82 - checksums = fetch_release_asset(tmppath, name, f'msys2-x86_64-{version}.exe.sha256')
81 + installer = fetch_release_asset(tmppath, name, f'msys2-base-x86_64-{version}.tar.zst')
82 + checksums = fetch_release_asset(tmppath, name, f'msys2-base-x86_64-{version}.tar.zst.sha256')
83
84 print('>>> Verifying SHA256 checksum')
85 expected_checksum = checksums.read_text().partition(' ')[0].casefold()
packaging/windows/installer.nsi
+63
@@ -16,8 +16,11 @@ RequestExecutionLevel admin
16 !define MUI_UNABORTWARNING
17
18 !insertmacro MUI_PAGE_WELCOME
19 +!insertmacro MUI_PAGE_LICENSE "C:\msys64\cloud.txt"
20 +!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt"
21 !insertmacro MUI_PAGE_DIRECTORY
22 !insertmacro MUI_PAGE_INSTFILES
23 +Page Custom NetdataConfigPage NetdataConfigLeave
24 !insertmacro MUI_PAGE_FINISH
25
26 !insertmacro MUI_UNPAGE_CONFIRM
@@ -26,9 +29,69 @@ RequestExecutionLevel admin
29
30 !insertmacro MUI_LANGUAGE "English"
31
32 +var hStartMsys
33 +var startMsys
34 +
35 +var hCloudToken
36 +var cloudToken
37 +var hCloudRoom
38 +var cloudRoom
39 +
40 Function .onInit
41 nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata'
42 pop $0
43 + ${If} $0 == 0
44 + nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata'
45 + pop $0
46 + ${EndIf}
47 +
48 + StrCpy $startMsys ${BST_UNCHECKED}
49 +FunctionEnd
50 +
51 +Function NetdataConfigPage
52 + !insertmacro MUI_HEADER_TEXT "Netdata configuration" "Claim your agent on Netdata Cloud"
53 +
54 + nsDialogs::Create 1018
55 + Pop $0
56 + ${If} $0 == error
57 + Abort
58 + ${EndIf}
59 +
60 + ${NSD_CreateLabel} 0 0 100% 12u "Enter your Token and Cloud Room."
61 + ${NSD_CreateLabel} 0 15% 100% 12u "Optionally, you can open a terminal to execute additional commands."
62 +
63 + ${NSD_CreateLabel} 0 35% 20% 10% "Token"
64 + Pop $0
65 + ${NSD_CreateText} 21% 35% 79% 10% ""
66 + Pop $hCloudToken
67 +
68 + ${NSD_CreateLabel} 0 55% 20% 10% "Room"
69 + Pop $0
70 + ${NSD_CreateText} 21% 55% 79% 10% ""
71 + Pop $hCloudRoom
72 +
73 + ${NSD_CreateCheckbox} 0 70% 100% 10u "Open terminal"
74 + Pop $hStartMsys
75 + nsDialogs::Show
76 +FunctionEnd
77 +
78 +Function NetdataConfigLeave
79 + ${NSD_GetText} $hCloudToken $cloudToken
80 + ${NSD_GetText} $hCloudRoom $cloudRoom
81 + ${NSD_GetState} $hStartMsys $startMsys
82 +
83 + StrLen $0 $cloudToken
84 + StrLen $1 $cloudRoom
85 + ${If} $0 == 125
86 + ${AndIf} $0 == 36
87 + # We should start our new claiming software here
88 + MessageBox MB_OK "$cloudToken | $cloudRoom | $startMsys"
89 + ${EndIf}
90 +
91 + ${If} $startMsys == 1
92 + nsExec::ExecToLog '$INSTDIR\msys2.exe'
93 + pop $0
94 + ${EndIf}
95 FunctionEnd
96
97 Function NetdataUninstallRegistry
packaging/windows/package-windows.sh
+32 -7
@@ -1,9 +1,20 @@
1 #!/bin/bash
2
3 -REPO_ROOT="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")"
3 +repo_root="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")"
4
5 -# shellcheck source=./win-build-dir.sh
6 -. "${REPO_ROOT}/packaging/windows/win-build-dir.sh"
5 +if [ -n "${BUILD_DIR}" ]; then
6 + build="${BUILD_DIR}"
7 +elif [ -n "${OSTYPE}" ]; then
8 + if [ -n "${MSYSTEM}" ]; then
9 + build="${repo_root}/build-${OSTYPE}-${MSYSTEM}"
10 + else
11 + build="${repo_root}/build-${OSTYPE}"
12 + fi
13 +elif [ "$USER" = "vk" ]; then
14 + build="${repo_root}/build"
15 +else
16 + build="${repo_root}/build"
17 +fi
18
19 set -exu -o pipefail
20
@@ -11,16 +22,30 @@ ${GITHUB_ACTIONS+echo "::group::Installing"}
22 cmake --install "${build}"
23 ${GITHUB_ACTIONS+echo "::endgroup::"}
24
14 -if [ ! -f "/msys2-installer.exe" ]; then
15 - ${GITHUB_ACTIONS+echo "::group::Fetching MSYS2 installer"}
16 - "${REPO_ROOT}/packaging/windows/fetch-msys2-installer.py" /msys2-installer.exe
25 +if [ ! -f "/msys2-latest.tar.zst" ]; then
26 + ${GITHUB_ACTIONS+echo "::group::Fetching MSYS2 files"}
27 + "${repo_root}/packaging/windows/fetch-msys2-installer.py" /msys2-latest.tar.zst
28 ${GITHUB_ACTIONS+echo "::endgroup::"}
29 fi
30
31 +${GITHUB_ACTIONS+echo "::group::Licenses"}
32 +if [ ! -f "/gpl-3.0.txt" ]; then
33 + curl -o /gpl-3.0.txt "https://www.gnu.org/licenses/gpl-3.0.txt"
34 +fi
35 +
36 +if [ ! -f "/cloud.txt" ]; then
37 + curl -o /cloud.txt "https://raw.githubusercontent.com/netdata/netdata/master/src/web/gui/v2/LICENSE.md"
38 +fi
39 +${GITHUB_ACTIONS+echo "::endgroup::"}
40 +
41 ${GITHUB_ACTIONS+echo "::group::Packaging"}
42 +tar -xf /msys2-latest.tar.zst -C /opt/netdata/ || exit 1
43 +cp -R /opt/netdata/msys64/* /opt/netdata/ || exit 1
44 +rm -rf /opt/netdata/msys64/
45 NDVERSION=$"$(grep 'CMAKE_PROJECT_VERSION:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
46 NDMAJORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MAJOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
47 NDMINORVERSION=$"$(grep 'CMAKE_PROJECT_VERSION_MINOR:STATIC' "${build}/CMakeCache.txt"| cut -d= -f2)"
48
25 -/mingw64/bin/makensis.exe -DCURRVERSION="${NDVERSION}" -DMAJORVERSION="${NDMAJORVERSION}" -DMINORVERSION="${NDMINORVERSION}" "${REPO_ROOT}/packaging/windows/installer.nsi"
49 +/mingw64/bin/makensis.exe -DCURRVERSION="${NDVERSION}" -DMAJORVERSION="${NDMAJORVERSION}" -DMINORVERSION="${NDMINORVERSION}" "${repo_root}/packaging/windows/installer.nsi"
50 ${GITHUB_ACTIONS+echo "::endgroup::"}
51 +