Skip to content

Commit 6e7fa57

Browse files
committed
CHANGE: including system/build/os-version information (if known)
1 parent 1dbefcd commit 6e7fa57

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

make/pre-make.r3

+3-1
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ arch: any [
150150
all [word? spec/arch spec/arch ]
151151
all [word? spec/target-arch spec/target-arch]
152152
]
153+
os-info: get-os-info
153154
os: any [
154-
select get-os-info 'ID
155+
select os-info 'ID
155156
all [word? spec/os spec/os]
156157
select #(
157158
Macintosh: macos
@@ -235,6 +236,7 @@ str-version: reform [
235236
build-date
236237
git-commit
237238
get-libc-version ;; musl, glibc_2.28,... or just none
239+
select os-info 'VERSION_ID
238240
]
239241

240242
;;format-date-time may not be available in older Builder tools!

make/tools/utils.reb

+34-10
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,48 @@ get-libc-version: function[][
141141
]
142142

143143
get-os-info: function[
144-
"Tries to collect information about hosting Linux operating system"
144+
"Tries to collect information about hosting operating system"
145145
;@@ Based on this research: https://www.tecmint.com/check-linux-os-version/
146146
][
147147
tmp: copy ""
148+
err: copy ""
148149
out: copy #()
149150
key: charset [#"A"-#"Z" #"_"]
150151
enl: system/catalog/bitsets/crlf
151152
whs: system/catalog/bitsets/whitespace
152-
try [
153-
call/output/shell/wait "cat /etc/*-release" :tmp
154-
parse probe tmp [
155-
any [
156-
copy k: some key #"=" copy v: to enl some whs (
157-
try [v: transcode/one v]
158-
try [parse v ["http" to end (v: as url! v)]]
159-
put out to word! k v
153+
num: system/catalog/bitsets/numeric
154+
any [
155+
;- macOS
156+
all [
157+
system/platform = 'macOS
158+
0 = call/shell/wait/output/error "sw_vers -productVersion" :tmp :err
159+
out/ID: 'macos
160+
out/VERSION_ID: attempt [transcode/one tmp]
161+
]
162+
;- Windows
163+
all [
164+
system/platform = 'Windows
165+
0 = call/shell/wait/output/error "ver" :tmp :err
166+
parse tmp [
167+
to num copy v: [some num #"." some num] to end (
168+
out/ID: 'windows
169+
out/VERSION_ID: to decimal! v
160170
)
161-
| thru enl
171+
]
172+
]
173+
;- Linux, OpenBSD, FreeBSD (but not tested on BSD yet)
174+
all [
175+
0 = call/shell/wait/output/error "cat /etc/*-release" :tmp :err
176+
parse tmp [
177+
any [
178+
copy k: some key #"=" copy v: to enl some whs (
179+
try [v: transcode/one v]
180+
try [parse v ["http" to end (v: as url! v)]]
181+
put out to word! k v
182+
)
183+
| thru enl
184+
]
185+
to end
162186
]
163187
]
164188
]

src/boot/sysobj.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ product: 'core
2222
; Next four fields are updated during build:
2323
platform: none
2424
version: 0.0.0
25-
build: object [os: abi: sys: arch: libc: vendor: target: compiler: date: git: none]
25+
build: object [os: os-version: abi: sys: arch: libc: vendor: target: compiler: date: git: none]
2626

2727
user: construct [
2828
name: none

src/mezz/sys-start.reb

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ start: func [
4848
system/build/date: ver/12
4949
system/build/git: ver/13
5050
system/build/libc: ver/14
51+
system/build/os-version: ver/15
5152

5253
if flags/verbose [system/options/log/rebol: 3] ;maximum log output for system messages
5354

0 commit comments

Comments
 (0)