Subversion Repositories QNX 8.QNX8 GNU binutils

Rev

Rev 15 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15 Rev 16
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 GNU binary utilities
5
set PRODUCT_NAME=the GNU binary utilities
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 APT_CACHE_UPDATED=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>"
63
        rem // if package name is not specified, it defaults to <executable>
79
        rem // if package name is not specified, it defaults to <executable>
64
        set REQUIRED_TOOL_AND_PACKAGE=%%i
80
        set REQUIRED_TOOL_AND_PACKAGE=%%i
65
        for /f "tokens=1-2 delims=:" %%j in ('echo !REQUIRED_TOOL_AND_PACKAGE!') do (
81
        for /f "tokens=1-2 delims=:" %%j in ('echo !REQUIRED_TOOL_AND_PACKAGE!') do (
Line 71... Line 87...
71
        wsl --distribution %WSL_DISTR% -- !REQUIRED_TOOL! --version > nul 2>&1 && (
87
        wsl --distribution %WSL_DISTR% -- !REQUIRED_TOOL! --version > nul 2>&1 && (
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 "!APT_CACHE_UPDATED!"=="0" (
92
                if "!ETC_SUDOERS_PATCHED!"=="0" (
77
                        rem // allow ourselves to run any commands by patching /etc/sudoers. Do this once.
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 ^"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^"
-
 
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
79
                        rem // update APT cache before installing stuff, but just once.
97
                        echo Testing network connectivity...
80
                        wsl --distribution %WSL_DISTR% -- sudo apt-get -y update
98
                        wsl --distribution %WSL_DISTR% -- ping -c 1 %WSL_SOURCE% > nul 2>&1 || goto :no_network
81
                        set APT_CACHE_UPDATED=1
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
82
                )
-
 
83
                wsl --distribution %WSL_DISTR% sudo apt-get -y install !REQUIRED_PACKAGE! || (
100
                        wsl --distribution %WSL_DISTR% -- sudo apt-get -y update || goto :no_network
84
                        echo Error: the required Linux tool !REQUIRED_TOOL! can't be installed with apt-get.
101
                        rem // at this point we can consider that networking works from within WSL.
85
                        pause
-
 
86
                        goto :exit_error
-
 
87
                )
102
                )
-
 
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
-
 
104
                wsl --distribution %WSL_DISTR% sudo apt-get -y install !REQUIRED_PACKAGE! || goto :no_network
88
        )
105
        )
89
)
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
90
 
122
 
91
rem // setup the QNX SDP on the WSL side
123
rem // setup the QNX SDP on the WSL side
92
 
124
 
93
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
94
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 106... Line 138...
106
 
138
 
107
rem // see if the SDP needs to be copied at all. Only do this when the modification time of the SDP directory on Windows is more recent than the one on Linux.
139
rem // see if the SDP needs to be copied at all. Only do this when the modification time of the SDP directory on Windows is more recent than the one on Linux.
108
rem // So test for the presence of the symlinks state file as it's the last file that's created (this ensures a complete copy), then check for the directory mtimes.
140
rem // So test for the presence of the symlinks state file as it's the last file that's created (this ensures a complete copy), then check for the directory mtimes.
109
rem // NOTE: on WSL2, the QNX SDK will always be copied to $HOME, regardless of what xdg-user-dir DESKTOP says.
141
rem // NOTE: on WSL2, the QNX SDK will always be copied to $HOME, regardless of what xdg-user-dir DESKTOP says.
110
echo|set /p=Checking if the %QNXSDK_DIRNAME% directory is present in WSL and up to date...
142
echo|set /p=Checking if the %QNXSDK_DIRNAME% directory is present in WSL and up to date...
111
wsl --distribution %WSL_DISTR% -- test -f "${HOME}/%QNXSDK_DIRNAME%/.symlinks-state" -a "${HOME}/%QNXSDK_DIRNAME%" -nt "../%QNXSDK_DIRNAME%" || (
143
wsl --distribution %WSL_DISTR% -- test ! -f "${HOME}/%QNXSDK_DIRNAME%/.symlinks-state" -o "../%QNXSDK_DIRNAME%" -nt "${HOME}/%QNXSDK_DIRNAME%" && (
112
        echo no
144
        echo no
113
 
145
 
114
        rem // copy needed - cleanup and create the directories we'll need in $HOME to accomodate the QNX SDK. We want the Linux host tools, and the QNX target sysroot files
146
        rem // copy needed - cleanup and create the directories we'll need in $HOME to accomodate the QNX SDK. We want the Linux host tools, and the QNX target sysroot files
115
        echo|set /p=Preparing to copy QNX8 SDK files to WSL2 ext4 filesystem...
147
        echo|set /p=Preparing to copy QNX8 SDK files to WSL2 ext4 filesystem...
116
        wsl --distribution %WSL_DISTR% -- rm -rf "${HOME}/%QNXSDK_DIRNAME%"; mkdir -p "${HOME}/%QNXSDK_DIRNAME%/host" "${HOME}/%QNXSDK_DIRNAME%/target" 2>nul
148
        wsl --distribution %WSL_DISTR% -- rm -rf "${HOME}/%QNXSDK_DIRNAME%"; mkdir -p "${HOME}/%QNXSDK_DIRNAME%/host" "${HOME}/%QNXSDK_DIRNAME%/target" 2>nul
Line 149... Line 181...
149
goto :exit_success
181
goto :exit_success
150
 
182
 
151
 
183
 
152
:install_wsl
184
:install_wsl
153
        echo Installing the Windows Subsystem for Linux...
185
        echo Installing the Windows Subsystem for Linux...
154
        echo ############################################################################
186
        echo  __________________________________________________________________________
-
 
187
        echo ^|                                                                          ^|
155
        echo # NOTE: please define a *non-root* Linux user name and password when asked #
188
        echo ^| NOTE: please define a *non-root* Linux user name and password when asked ^|
156
        echo #       ^(for example: 'utilisateur' / 'utilisateur'^)                       #
189
        echo ^|       ^(for example: 'utilisateur' / 'utilisateur'^)                       ^|
157
        echo #       then type 'exit' at the Linux shell ^(green prompt^) to continue.    #
190
        echo ^|       then type 'exit' at the Linux shell ^(green prompt^) to continue.    ^|
158
        echo ############################################################################
191
        echo ^|__________________________________________________________________________^|
-
 
192
        echo.
159
        wsl --install --distribution %WSL_DISTR% || (
193
        wsl --install --distribution %WSL_DISTR% || (
160
                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.
161
                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
162
                echo 19041 or a later version.
196
                echo 19041 or a later version.
163
                goto :exit_error
197
                goto :exit_error
164
        )
198
        )
165
        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.
166
        echo distribution.
-
 
167
        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.
168
        pause
-
 
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