Compare commits

...

1 Commits

Author SHA1 Message Date
5e608de0ad Add public kos32-export-env-vars 2026-02-25 17:14:29 -05:00
2 changed files with 79 additions and 3 deletions

View File

@@ -142,7 +142,7 @@ jobs:
- name: (en_US) Build KolibriOS
run: |
export PATH=/home/autobuild/tools/win32/bin:$PATH
source kos32-export-env-vars ${{ gitea.workspace }}
source "${{ gitea.workspace }}/.gitea/workflows/kos32-export-env-vars" "${{ gitea.workspace }}"
tup build-en_US
- name: (en_US) Upload floppy image
@@ -167,7 +167,7 @@ jobs:
- name: (ru_RU) Build KolibriOS
run: |
export PATH=/home/autobuild/tools/win32/bin:$PATH
source kos32-export-env-vars ${{ gitea.workspace }}
source "${{ gitea.workspace }}/.gitea/workflows/kos32-export-env-vars" "${{ gitea.workspace }}"
tup build-ru_RU
- name: (ru_RU) Upload floppy image
@@ -192,7 +192,7 @@ jobs:
- name: (es_ES) Build KolibriOS
run: |
export PATH=/home/autobuild/tools/win32/bin:$PATH
source kos32-export-env-vars ${{ gitea.workspace }}
source "${{ gitea.workspace }}/.gitea/workflows/kos32-export-env-vars" "${{ gitea.workspace }}"
tup build-es_ES
- name: (es_ES) Upload floppy image

View File

@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-only
# SPDX-FileCopyrightText: 2025 KolibriOS team
_kos32_export_env_vars() {
local repo_root prev_pwd cmtid latest_tag offset
repo_root="${1:-}"
if [ -z "${repo_root}" ]; then
echo "kos32-export-env-vars: repository path argument is required" >&2
return 1
fi
if [ ! -d "${repo_root}" ]; then
echo "kos32-export-env-vars: path does not exist: ${repo_root}" >&2
return 1
fi
if ! command -v git >/dev/null 2>&1; then
echo "kos32-export-env-vars: git is required but not found in PATH" >&2
return 1
fi
if ! git -C "${repo_root}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "kos32-export-env-vars: not a git repository: ${repo_root}" >&2
return 1
fi
prev_pwd="${PWD}"
if ! cd "${repo_root}"; then
echo "kos32-export-env-vars: unable to enter repository: ${repo_root}" >&2
return 1
fi
cmtid="$(git rev-parse --short=8 HEAD 2>/dev/null)" || {
cd "${prev_pwd}" || true
echo "kos32-export-env-vars: failed to resolve HEAD commit id" >&2
return 1
}
if ! printf '%s' "${cmtid}" | grep -Eq '^[0-9a-fA-F]{8}$'; then
cd "${prev_pwd}" || true
echo "kos32-export-env-vars: unexpected commit id format: ${cmtid}" >&2
return 1
fi
latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || true)"
if [ -n "${latest_tag}" ]; then
offset="$(git rev-list --count "${latest_tag}..HEAD" 2>/dev/null)" || {
cd "${prev_pwd}" || true
echo "kos32-export-env-vars: failed to compute commit offset from tag ${latest_tag}" >&2
return 1
}
else
offset="0"
fi
if ! printf '%s' "${offset}" | grep -Eq '^[0-9]+$'; then
cd "${prev_pwd}" || true
echo "kos32-export-env-vars: unexpected commit offset format: ${offset}" >&2
return 1
fi
if ! cd "${prev_pwd}"; then
echo "kos32-export-env-vars: failed to restore previous working directory: ${prev_pwd}" >&2
return 1
fi
export KOLIBRIOS_BUILD_CMTID="0x$(printf '%s' "${cmtid}" | tr '[:upper:]' '[:lower:]')"
export KOLIBRIOS_BUILD_OFFSET="${offset}"
if [ -z "${KOLIBRIOS_BUILD_DBGTAG+x}" ] || [ -z "${KOLIBRIOS_BUILD_DBGTAG}" ]; then
export KOLIBRIOS_BUILD_DBGTAG=0
fi
}
_kos32_export_env_vars "${1:-}" || return 1 2>/dev/null || exit 1
unset -f _kos32_export_env_vars