Rev 30 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 30 | Rev 31 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | setlocal enableextensions enabledelayedexpansion |
2 | setlocal enableextensions enabledelayedexpansion |
3 | 3 | ||
4 | rem // what we're building |
4 | rem // what we're building |
5 | set PRODUCT_NAME=the LLVM compiler suite |
5 | set PRODUCT_NAME=the LLVM compiler suite |
6 | 6 | ||
7 | rem // the WSL distribution to use |
7 | rem // the WSL distribution to use and hostname where its packages are downloaded from |
8 | set WSL_DISTR=Ubuntu-22.04 |
8 | set WSL_DISTR=Ubuntu-22.04 |
- | 9 | set WSL_SOURCE=archive.ubuntu.com |
|
9 | 10 | ||
10 | rem // name of the QNX SDK root directory |
11 | rem // name of the QNX SDK root directory |
11 | set QNXSDK_DIRNAME=qnx800 |
12 | set QNXSDK_DIRNAME=qnx800 |
12 | 13 | ||
13 | rem // list of Linux tools required by the cross-build script |
14 | rem // list of Linux tools required by the cross-build script |
Line 20... | Line 21... | ||
20 | 21 | ||
21 | rem // make sure we have at least Windows 10 |
22 | rem // make sure we have at least Windows 10 |
22 | for /f "tokens=4 delims=. " %%i in ('ver') do set VERSION=%%i |
23 | for /f "tokens=4 delims=. " %%i in ('ver') do set VERSION=%%i |
23 | echo Detected Windows NT kernel version: %VERSION% |
24 | echo Detected Windows NT kernel version: %VERSION% |
24 | if %VERSION% LSS 10 ( |
25 | if %VERSION% LSS 10 ( |
- | 26 | echo. |
|
25 | echo Error: you need at least Windows 10 to cross-build %PRODUCT_NAME% to QNX 8. |
27 | echo Error: you need at least Windows 10 to cross-build %PRODUCT_NAME% to QNX 8. |
26 | echo Please upgrade your Windows operating system to Windows 10 version 2004 build |
28 | echo Please upgrade your Windows operating system to Windows 10 version 2004 build |
27 | echo 19041 or a later version. |
29 | echo 19041 or a later version. |
28 | goto :exit_error |
30 | goto :exit_error |
29 | ) |
31 | ) |
Line 44... | Line 46... | ||
44 | echo no |
46 | echo no |
45 | echo|set /p=Attempting to convert the WSL distribution %WSL_DISTR% to WSL2... |
47 | echo|set /p=Attempting to convert the WSL distribution %WSL_DISTR% to WSL2... |
46 | rem // this distribution needs to be converted |
48 | rem // this distribution needs to be converted |
47 | wsl --set-version %WSL_DISTR% 2 || ( |
49 | wsl --set-version %WSL_DISTR% 2 || ( |
48 | echo failed |
50 | echo failed |
- | 51 | echo. |
|
49 | echo Error: you need the Windows Subsystem for Linux to support WSL2 for this |
52 | echo Error: you need the Windows Subsystem for Linux to support WSL2 for this |
50 | echo cross-build script to work consistently. |
53 | echo cross-build script to work consistently. |
51 | echo Please upgrade your Windows operating system to Windows 10 version 2004 build |
54 | echo Please upgrade your Windows operating system to Windows 10 version 2004 build |
52 | echo 19041 or a later version. |
55 | echo 19041 or a later version. |
53 | goto :exit_error |
56 | goto :exit_error |
54 | ) |
57 | ) |
55 | rem // alright, this distribution is on WSL2 |
58 | rem // alright, this distribution is on WSL2 |
56 | ) |
59 | ) |
57 | echo ok |
60 | echo ok |
- | 61 | ||
- | 62 | rem // make sure we're running from LOCAL STORAGE - if not, WSL2 will have relocated to $HOME and this will fuck everything up |
|
- | 63 | echo|set /p=Checking whether WSL knows the path to this very directory... |
|
- | 64 | wsl --distribution %WSL_DISTR% -- test ^"$^(pwd^)^" = ^"${HOME}^" && ( |
|
- | 65 | echo no |
|
- | 66 | echo. |
|
- | 67 | echo Error: you need to locate your working copy of this SVN repository on *local* |
|
- | 68 | echo storage for the cross-build script to work consistently. The Windows Subsystem |
|
- | 69 | echo for Linux cannot access Windows network shares. |
|
- | 70 | echo Please relocate this repository on a local hard drive and try again. |
|
- | 71 | goto :exit_error |
|
- | 72 | ) |
|
- | 73 | echo yes |
|
58 | 74 | ||
59 | rem // make sure we have the required tools, install them if not |
75 | rem // make sure we have the required tools, install them if not |
60 | set ETC_SUDOERS_PATCHED=0 |
76 | set ETC_SUDOERS_PATCHED=0 |
61 | for %%i in (%REQUIRED_TOOLS%) do ( |
77 | for %%i in (%REQUIRED_TOOLS%) do ( |
62 | rem // tool syntax: "<executable>:<optional APT package name>" |
78 | rem // tool syntax: "<executable>:<optional APT package name>" |
Line 72... | Line 88... | ||
72 | echo yes |
88 | echo yes |
73 | ) || ( |
89 | ) || ( |
74 | echo no |
90 | echo no |
75 | echo !REQUIRED_TOOL! needs installation. Attempting to install it. |
91 | echo !REQUIRED_TOOL! needs installation. Attempting to install it. |
76 | if "!ETC_SUDOERS_PATCHED!"=="0" ( |
92 | if "!ETC_SUDOERS_PATCHED!"=="0" ( |
77 | rem // allow ourselves to run any commands by patching /etc/sudoers. Do this once, and only if necessary. |
93 | rem // allow ourselves to run any commands by patching /etc/sudoers. Do this once, and only if necessary. Also drop a note for posterity on why this was done. |
78 | wsl --distribution %WSL_DISTR% -- sudo sh -c ^"grep '%%sudo ALL=^(ALL^) NOPASSWD:ALL' /etc/sudoers ^|^| echo '%%sudo ALL=^(ALL^) NOPASSWD:ALL' ^>^> /etc/sudoers^" |
94 | wsl --distribution %WSL_DISTR% -- sudo sh -c ^"grep -q '%%sudo ALL=^(ALL^) NOPASSWD:ALL' /etc/sudoers ^|^| { echo ''; echo '# Pierre-Marie Baty -- added automatically on %DATE% by %~nx0 script'; echo '# This line allows members of the sudo group to execute any command WITHOUT the need to enter the root password'; echo '%%sudo ALL=^(ALL^) NOPASSWD:ALL'; } ^>^> /etc/sudoers^" |
79 | rem rem // update APT cache before installing stuff, but just once. |
- | |
80 | rem wsl --distribution %WSL_DISTR% -- sudo apt-get -y update |
- | |
81 | set ETC_SUDOERS_PATCHED=1 |
95 | set ETC_SUDOERS_PATCHED=1 |
- | 96 | rem // TEST if we have a working network from within WSL. It's no point waiting around if we don't. If it turns out we don't, jump to the relevant label |
|
- | 97 | echo Testing network connectivity... |
|
- | 98 | wsl --distribution %WSL_DISTR% -- ping -c 1 %WSL_SOURCE% > nul 2>&1 || goto :no_network |
|
- | 99 | rem // we MIGHT have a working network. Update APT cache before installing stuff, but just once. If it turns out we can't, jump to the relevant label |
|
- | 100 | wsl --distribution %WSL_DISTR% -- sudo apt-get -y update || goto :no_network |
|
- | 101 | rem // at this point we can consider that networking works from within WSL. |
|
82 | ) |
102 | ) |
83 | rem wsl --distribution %WSL_DISTR% sudo apt-get -y install !REQUIRED_PACKAGE! || ( |
- | |
84 |
|
103 | rem // attempt installation of this package from the network. If it fails, assume it's a network problem (cable unplugged?) and jump to the relevant label |
85 |
|
104 | wsl --distribution %WSL_DISTR% sudo apt-get -y install !REQUIRED_PACKAGE! || goto :no_network |
86 | pause |
- | |
87 | goto :exit_error |
- | |
88 | ) |
- | |
89 | ) |
105 | ) |
90 | ) |
106 | ) |
- | 107 | rem // if we reach here it means all the tools were successfully installed from the network, so jump to the next step |
|
- | 108 | goto :packages_installed |
|
- | 109 | :no_network |
|
- | 110 | rem // if we reach here, it means package installation from the network failed. Stop being nice and stuff them up Linux's ass with maximal pain from local storage. |
|
- | 111 | echo Looks like the network is unavailable. Nevermind the bollocks. |
|
- | 112 | echo Installing all the necessary packages at once... |
|
- | 113 | wsl --distribution %WSL_DISTR% sudo dpkg -i "../../Third-party software/%WSL_DISTR:-= % Debian packages for WSL2/"*.deb || ( |
|
- | 114 | echo. |
|
- | 115 | echo Error: the required Linux tools %REQUIRED_TOOLS% can't be installed. |
|
- | 116 | goto :exit_error |
|
- | 117 | ) |
|
- | 118 | goto :packages_installed |
|
- | 119 | rem // nuff said. |
|
- | 120 | ||
- | 121 | :packages_installed |
|
91 | 122 | ||
92 | rem // setup the QNX SDP on the WSL side |
123 | rem // setup the QNX SDP on the WSL side |
93 | 124 | ||
94 | rem // The build script initially recursively transferred the contents of $QNX_HOST and $QNX_TARGET to the WSL2 ext4 partition |
125 | rem // The build script initially recursively transferred the contents of $QNX_HOST and $QNX_TARGET to the WSL2 ext4 partition |
95 | rem // when necessary using the Plan9 NTFS to ext4 bridge (9p file protocol) implemented by Microsoft to transfer files |
126 | rem // when necessary using the Plan9 NTFS to ext4 bridge (9p file protocol) implemented by Microsoft to transfer files |
Line 150... | Line 181... | ||
150 | goto :exit_success |
181 | goto :exit_success |
151 | 182 | ||
152 | 183 | ||
153 | :install_wsl |
184 | :install_wsl |
154 | echo Installing the Windows Subsystem for Linux... |
185 | echo Installing the Windows Subsystem for Linux... |
155 | echo |
186 | echo __________________________________________________________________________ |
- | 187 | echo ^| ^| |
|
156 | echo |
188 | echo ^| NOTE: please define a *non-root* Linux user name and password when asked ^| |
157 | echo |
189 | echo ^| ^(for example: 'utilisateur' / 'utilisateur'^) ^| |
158 | echo |
190 | echo ^| then type 'exit' at the Linux shell ^(green prompt^) to continue. ^| |
159 | echo |
191 | echo ^|__________________________________________________________________________^| |
- | 192 | echo. |
|
160 | wsl --install --distribution %WSL_DISTR% || ( |
193 | wsl --install --distribution %WSL_DISTR% || ( |
161 | echo Error: you need at least a version of Windows 10 which has the "wsl" command. |
194 | echo Error: you need at least a version of Windows 10 which has the "wsl" command. |
162 | echo Please upgrade your Windows operating system to Windows 10 version 2004 build |
195 | echo Please upgrade your Windows operating system to Windows 10 version 2004 build |
163 | echo 19041 or a later version. |
196 | echo 19041 or a later version. |
164 | goto :exit_error |
197 | goto :exit_error |
165 | ) |
198 | ) |
166 | echo The Windows Subsystem for Linux was successfully installed with the %WSL_DISTR% |
199 | echo The Windows Subsystem for Linux was successfully installed with the %WSL_DISTR% distribution. |
167 | echo distribution. |
- | |
168 | echo Action required: please reboot your computer and run this script again. |
200 | echo Action required: please reboot your computer if requested and run this script again. |
169 | goto :exit_success |
201 | goto :exit_success |
170 | 202 | ||
171 | :exit_error |
203 | :exit_error |
172 | rem // failure exit |
204 | rem // failure exit |
- | 205 | echo. |
|
173 | pause |
206 | pause |
174 | exit /b 1 |
207 | exit /b 1 |
175 | 208 | ||
176 | :exit_success |
209 | :exit_success |
177 | rem // successful exit |
210 | rem // successful exit |
- | 211 | echo. |
|
178 | pause |
212 | pause |
179 | exit /b 0 |
213 | exit /b 0 |