Compare commits

4 Commits
Author SHA1 Message Date
ge 7e8b9bac7d ci: update V setup step 2026-12-01 12:37:00 +03:00
ge 1f01c51d8b update known options, deprecate options, bump version 2026-12-01 12:36:43 +03:00
ge a50f83be68 mod: bump version 2026-06-12 04:24:49 +03:00
ge 8e51234ca9 remove strings dependency 2026-06-12 04:24:22 +03:00
4 changed files with 23 additions and 21 deletions

No files matched your search

+3 -4
View File
@@ -12,10 +12,9 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup V - name: Setup V
run: | uses: vlang/setup-v@v1.7
wget -qO /tmp/v.zip https://github.com/vlang/v/releases/latest/download/v_linux.zip with:
unzip -q /tmp/v.zip -d /tmp check-latest: true
echo /tmp/v >> "$GITHUB_PATH"
- name: Build docs - name: Build docs
run: | run: |
+3 -4
View File
@@ -14,10 +14,9 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup V - name: Setup V
run: | uses: vlang/setup-v@v1.7
wget -qO /tmp/v.zip https://github.com/vlang/v/releases/latest/download/v_linux.zip with:
unzip -q /tmp/v.zip -d /tmp check-latest: true
echo /tmp/v >> "$GITHUB_PATH"
- name: Run tests - name: Run tests
run: | run: |
+15 -11
View File
@@ -1,15 +1,19 @@
module os_release module os_release
import os import os
import strings
// options contains list of default os-release, initrd-release, extension-release options. // known_options contains list of known options that may be used in os-release, initrd-release and extension-release
pub const options = ['NAME', 'ID', 'ID_LIKE', 'PRETTY_NAME', 'CPE_NAME', 'VARIANT', 'VARIANT_ID', // files described in [os_release(5)](https://www.freedesktop.org/software/systemd/man/latest/os-release.html#Options).
'VERSION', 'VERSION_ID', 'VERSION_CODENAME', 'BUILD_ID', 'IMAGE_ID', 'IMAGE_VERSION', // Do NOT rely on elements order in this array.
pub const known_options = ['NAME', 'ID', 'ID_LIKE', 'PRETTY_NAME', 'FANCY_NAME', 'CPE_NAME', 'VARIANT',
'VARIANT_ID', 'VERSION', 'VERSION_ID', 'VERSION_CODENAME', 'BUILD_ID', 'IMAGE_ID', 'IMAGE_VERSION',
'RELEASE_TYPE', 'HOME_URL', 'DOCUMENTATION_URL', 'SUPPORT_URL', 'BUG_REPORT_URL', 'RELEASE_TYPE', 'HOME_URL', 'DOCUMENTATION_URL', 'SUPPORT_URL', 'BUG_REPORT_URL',
'PRIVACY_POLICY_URL', 'SUPPORT_END', 'LOGO', 'ANSI_COLOR', 'VENDOR_NAME', 'VENDOR_URL', 'PRIVACY_POLICY_URL', 'SUPPORT_END', 'LOGO', 'ANSI_COLOR', 'ANSI_COLOR_REVERSE', 'VENDOR_NAME',
'EXPERIMENT', 'EXPERIMENT_URL', 'DEFAULT_HOSTNAME', 'ARCHITECTURE', 'SYSEXT_LEVEL', 'VENDOR_URL', 'EXPERIMENT', 'EXPERIMENT_URL', 'DEFAULT_HOSTNAME', 'ARCHITECTURE', 'SYSEXT_LEVEL',
'CONFEXT_LEVEL', 'SYSEXT_SCOPE', 'CONFEXT_SCOPE', 'PORTABLE_PREFIXES']! 'CONFEXT_LEVEL', 'SYSEXT_SCOPE', 'CONFEXT_SCOPE', 'PORTABLE_PREFIXES', 'PORTABLE_SCOPE']!
@[deprecated: 'use known_options instead']
pub const options = known_options
// os_release reads `/etc/os-release` and `/usr/lib/os-release` files and returns parsed // os_release reads `/etc/os-release` and `/usr/lib/os-release` files and returns parsed
// os-release data. Empty map will be returned if files does not exits or reading issues // os-release data. Empty map will be returned if files does not exits or reading issues
@@ -53,17 +57,17 @@ pub fn parse(content string) map[string]string {
} }
fn unescape(s string) string { fn unescape(s string) string {
mut ret := strings.new_builder(128) mut ret := []u8{cap: 128}
for i := 0; i < s.len; i++ { for i := 0; i < s.len; i++ {
if (i == 0 || i == s.len - 1) && s[i] in [`"`, `'`] { if (i == 0 || i == s.len - 1) && s[i] in [`"`, `'`] {
continue // trim leading and trailing quotes continue // trim leading and trailing quotes
} }
if s[i] == `\\` && i + 1 < s.len { if s[i] == `\\` && i + 1 < s.len {
ret.write_byte(s[i + 1]) ret << s[i + 1]
i++ i++
} else { } else {
ret.write_byte(s[i]) ret << s[i]
} }
} }
return ret.str() return ret.bytestr()
} }
+2 -2
View File
@@ -1,7 +1,7 @@
Module { Module {
name: 'os_release' name: 'os_release'
description: 'Freedesktop OS Release Parser' description: 'freedesktop.org os-release parser'
version: '1.0.0' version: '1.1.0'
license: 'Unlicense' license: 'Unlicense'
dependencies: [] dependencies: []
} }