Skip to content

Commit

Permalink
CHANGE: including system/build/os-version information (if known)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Feb 12, 2023
1 parent 1dbefcd commit 6e7fa57
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
4 changes: 3 additions & 1 deletion make/pre-make.r3
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ arch: any [
all [word? spec/arch spec/arch ]
all [word? spec/target-arch spec/target-arch]
]
os-info: get-os-info
os: any [
select get-os-info 'ID
select os-info 'ID
all [word? spec/os spec/os]
select #(
Macintosh: macos
Expand Down Expand Up @@ -235,6 +236,7 @@ str-version: reform [
build-date
git-commit
get-libc-version ;; musl, glibc_2.28,... or just none
select os-info 'VERSION_ID
]

;;format-date-time may not be available in older Builder tools!
Expand Down
44 changes: 34 additions & 10 deletions make/tools/utils.reb
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,48 @@ get-libc-version: function[][
]

get-os-info: function[
"Tries to collect information about hosting Linux operating system"
"Tries to collect information about hosting operating system"
;@@ Based on this research: https://www.tecmint.com/check-linux-os-version/
][
tmp: copy ""
err: copy ""
out: copy #()
key: charset [#"A"-#"Z" #"_"]
enl: system/catalog/bitsets/crlf
whs: system/catalog/bitsets/whitespace
try [
call/output/shell/wait "cat /etc/*-release" :tmp
parse probe tmp [
any [
copy k: some key #"=" copy v: to enl some whs (
try [v: transcode/one v]
try [parse v ["http" to end (v: as url! v)]]
put out to word! k v
num: system/catalog/bitsets/numeric
any [
;- macOS
all [
system/platform = 'macOS
0 = call/shell/wait/output/error "sw_vers -productVersion" :tmp :err
out/ID: 'macos
out/VERSION_ID: attempt [transcode/one tmp]
]
;- Windows
all [
system/platform = 'Windows
0 = call/shell/wait/output/error "ver" :tmp :err
parse tmp [
to num copy v: [some num #"." some num] to end (
out/ID: 'windows
out/VERSION_ID: to decimal! v
)
| thru enl
]
]
;- Linux, OpenBSD, FreeBSD (but not tested on BSD yet)
all [
0 = call/shell/wait/output/error "cat /etc/*-release" :tmp :err
parse tmp [
any [
copy k: some key #"=" copy v: to enl some whs (
try [v: transcode/one v]
try [parse v ["http" to end (v: as url! v)]]
put out to word! k v
)
| thru enl
]
to end
]
]
]
Expand Down
2 changes: 1 addition & 1 deletion src/boot/sysobj.reb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ product: 'core
; Next four fields are updated during build:
platform: none
version: 0.0.0
build: object [os: abi: sys: arch: libc: vendor: target: compiler: date: git: none]
build: object [os: os-version: abi: sys: arch: libc: vendor: target: compiler: date: git: none]

user: construct [
name: none
Expand Down
1 change: 1 addition & 0 deletions src/mezz/sys-start.reb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ start: func [
system/build/date: ver/12
system/build/git: ver/13
system/build/libc: ver/14
system/build/os-version: ver/15

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

Expand Down

0 comments on commit 6e7fa57

Please sign in to comment.