mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
git/docker: bsp-cli: fix BUILD_REPOSITORY_URL and BUILD_REPOSITORY_COMMIT under Docker; fixes AR-1750
This commit is contained in:
committed by
igorpecovnik
parent
03810833ef
commit
52710b3363
@@ -179,6 +179,10 @@ function compile_armbian-bsp-cli() {
|
||||
find "${destination}" -print0 2> /dev/null | xargs -0r chown --no-dereference 0:0
|
||||
find "${destination}" ! -type l -print0 2> /dev/null | xargs -0r chmod 'go=rX,u+rw,a-s'
|
||||
|
||||
if [[ "${SHOW_DEBUG}" == "yes" ]]; then
|
||||
run_tool_batcat --file-name "/etc/armbian-release.sh" "${destination}"/etc/armbian-release
|
||||
fi
|
||||
|
||||
# Build / close the package. This will run shellcheck / show the generated files if debugging
|
||||
fakeroot_dpkg_deb_build "${destination}" "${DEB_STORAGE}/"
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ function cli_docker_run() {
|
||||
declare -g GIT_INFO_ANSI
|
||||
GIT_INFO_ANSI="$(prepare_ansi_git_info_log_header)"
|
||||
|
||||
# Same stuff for BUILD_REPOSITORY_URL and BUILD_REPOSITORY_COMMIT.
|
||||
if [[ -d "${SRC}/.git" && "${CONFIG_DEFS_ONLY}" != "yes" ]]; then # don't waste time if only gathering config defs
|
||||
set_git_build_repo_url_and_commit_vars "docker launcher"
|
||||
fi
|
||||
|
||||
LOG_SECTION="docker_cli_prepare" do_with_logging docker_cli_prepare
|
||||
|
||||
# @TODO: and can be very well said that in CI, we always want FAST_DOCKER=yes, unless we're building the Docker image itself.
|
||||
|
||||
@@ -70,9 +70,10 @@ function do_main_configuration() {
|
||||
[[ -z "${CHROOT_CACHE_VERSION}" ]] && CHROOT_CACHE_VERSION=7
|
||||
|
||||
if [[ -d "${SRC}/.git" && "${CONFIG_DEFS_ONLY}" != "yes" ]]; then # don't waste time if only gathering config defs
|
||||
display_alert "Getting git info for repo" "${SRC}" "debug"
|
||||
BUILD_REPOSITORY_URL="$(git remote get-url "$(git remote | grep origin || true)" || true)" # ignore all errors
|
||||
BUILD_REPOSITORY_COMMIT="$(git describe --match=d_e_a_d_b_e_e_f --always --dirty || true)" # ignore error
|
||||
# The docker launcher will have passed these as environment variables. If not, try again here.
|
||||
if [[ -z "${BUILD_REPOSITORY_URL}" || -z "${BUILD_REPOSITORY_COMMIT}" ]]; then
|
||||
set_git_build_repo_url_and_commit_vars "main configuration"
|
||||
fi
|
||||
fi
|
||||
|
||||
ROOTFS_CACHE_MAX=200 # max number of rootfs cache, older ones will be cleaned up
|
||||
@@ -500,3 +501,13 @@ function source_family_config_and_arch() {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function set_git_build_repo_url_and_commit_vars() {
|
||||
display_alert "Getting git info for repo, during ${1}..." "${SRC}" "debug"
|
||||
declare -g BUILD_REPOSITORY_URL BUILD_REPOSITORY_COMMIT
|
||||
BUILD_REPOSITORY_URL="$(git -C "${SRC}" remote get-url "$(git -C "${SRC}" remote | grep origin || true)" || true)" # ignore all errors
|
||||
BUILD_REPOSITORY_COMMIT="$(git -C "${SRC}" describe --match=d_e_a_d_b_e_e_f --always --dirty || true)" # ignore error
|
||||
display_alert "BUILD_REPOSITORY_URL set during ${1}" "${BUILD_REPOSITORY_URL}" "debug"
|
||||
display_alert "BUILD_REPOSITORY_COMMIT set during ${1}" "${BUILD_REPOSITORY_COMMIT}" "debug"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -420,6 +420,16 @@ function docker_cli_prepare_launch() {
|
||||
DOCKER_ARGS+=("--env" "GIT_INFO_ANSI=${GIT_INFO_ANSI}")
|
||||
fi
|
||||
|
||||
if [[ -n "${BUILD_REPOSITORY_URL}" ]]; then
|
||||
display_alert "Git info" "Passing down BUILD_REPOSITORY_URL as an env var..." "debug"
|
||||
DOCKER_ARGS+=("--env" "BUILD_REPOSITORY_URL=${BUILD_REPOSITORY_URL}")
|
||||
fi
|
||||
|
||||
if [[ -n "${BUILD_REPOSITORY_COMMIT}" ]]; then
|
||||
display_alert "Git info" "Passing down BUILD_REPOSITORY_COMMIT as an env var..." "debug"
|
||||
DOCKER_ARGS+=("--env" "BUILD_REPOSITORY_COMMIT=${BUILD_REPOSITORY_COMMIT}")
|
||||
fi
|
||||
|
||||
if [[ "${DOCKER_PASS_SSH_AGENT}" == "yes" ]]; then
|
||||
declare ssh_socket_path="${SSH_AUTH_SOCK}"
|
||||
if [[ "${OSTYPE}" == "darwin"* ]]; then # but probably only Docker Inc, not Rancher...
|
||||
|
||||
Reference in New Issue
Block a user