Skip to content

Commit ca46f86

Browse files
committed
artifacts: download-artifact CLI. makes sure to only used local .deb, or download from OCI, never build
1 parent 1fa54e0 commit ca46f86

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

compile.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ logging_init
4444
traps_init
4545

4646
# make sure git considers our build system dir as a safe dir (only if actually building)
47-
[[ "${CONFIG_DEFS_ONLY}" != "yes" ]] && git_ensure_safe_directory "${SRC}"
47+
[[ "${CONFIG_DEFS_ONLY}" != "yes" && "${PRE_PREPARED_HOST}" != "yes" ]] && git_ensure_safe_directory "${SRC}"
4848

4949
# Execute the main CLI entrypoint.
5050
cli_entrypoint "$@"

lib/functions/cli/cli-artifact.sh

+37-16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
# https://github.com/armbian/build/
99

1010
function cli_artifact_pre_run() {
11+
case "${ARMBIAN_COMMAND}" in
12+
download-artifact)
13+
display_alert "download-only mode:" "won't build '${WHAT}'" "info"
14+
DONT_BUILD_ARTIFACTS="${WHAT}"
15+
;;
16+
esac
17+
1118
initialize_artifact "${WHAT}"
1219
# Run the pre run adapter
1320
artifact_cli_adapter_pre_run
@@ -45,31 +52,45 @@ function cli_artifact_run() {
4552
declare ignore_local_cache="${ignore_local_cache:-"${default_update_remote_only}"}"
4653
declare deploy_to_remote="${deploy_to_remote:-"${default_update_remote_only}"}"
4754

48-
# If OCI_TARGET_BASE is explicitly set, ignore local, skip if found in remote, and deploy to remote after build.
49-
if [[ -n "${OCI_TARGET_BASE}" ]]; then
50-
skip_unpack_if_found_in_caches="yes"
51-
ignore_local_cache="yes"
52-
deploy_to_remote="yes"
53-
54-
# Pass ARTIFACT_USE_CACHE=yes to actually use the cache versions, but don't deploy to remote.
55-
# @TODO this is confusing. each op should be individually controlled...
56-
# what we want is:
57-
# 1: - check remote, if not found, check local, if not found, build, then deploy to remote
58-
# - if remote found, do nothing.
59-
# - if local found, deploy it to remote (for switching targets)
60-
# 2: - get from remote -> get local -> build, then DON'T deploy to remote
61-
if [[ "${ARTIFACT_USE_CACHE}" == "yes" ]]; then
55+
case "${ARMBIAN_COMMAND}" in
56+
download-artifact)
57+
display_alert "Running in download-artifact mode" "download-artifact" "ext"
6258
skip_unpack_if_found_in_caches="no"
6359
ignore_local_cache="no"
6460
deploy_to_remote="no"
65-
fi
66-
fi
61+
;;
62+
*)
63+
# @TODO: rpardini: i'm braindead. I really can't make sense of my own code!
64+
# If OCI_TARGET_BASE is explicitly set, ignore local, skip if found in remote, and deploy to remote after build.
65+
if [[ -n "${OCI_TARGET_BASE}" ]]; then
66+
skip_unpack_if_found_in_caches="yes"
67+
ignore_local_cache="yes"
68+
deploy_to_remote="yes"
69+
70+
# Pass ARTIFACT_USE_CACHE=yes to actually use the cache versions, but don't deploy to remote.
71+
# @TODO this is confusing. each op should be individually controlled...
72+
# what we want is:
73+
# 1: - check remote, if not found, check local, if not found, build, then deploy to remote
74+
# - if remote found, do nothing.
75+
# - if local found, deploy it to remote (for switching targets)
76+
# 2: - get from remote -> get local -> build, then DON'T deploy to remote
77+
if [[ "${ARTIFACT_USE_CACHE}" == "yes" ]]; then
78+
skip_unpack_if_found_in_caches="no"
79+
ignore_local_cache="no"
80+
deploy_to_remote="no"
81+
fi
82+
fi
83+
;;
84+
esac
6785

6886
# Force artifacts download we need to populate repository
6987
if [[ "${FORCE_ARTIFACTS_DOWNLOAD}" == "yes" ]]; then
7088
skip_unpack_if_found_in_caches="no"
7189
fi
7290

91+
# display a summary of the 3 vars above: skip_unpack_if_found_in_caches, ignore_local_cache, deploy_to_remote
92+
display_alert "CLI Artifact summary" "skip_unpack_if_found_in_caches=${skip_unpack_if_found_in_caches}, ignore_local_cache=${ignore_local_cache}, deploy_to_remote=${deploy_to_remote}" "info"
93+
7394
if [[ "${ARTIFACT_BUILD_INTERACTIVE}" == "yes" ]]; then # Set by `kernel-config`, `kernel-patch`, `uboot-config`, `uboot-patch`, etc.
7495
display_alert "Running artifact build in interactive mode" "log file will be incomplete" "info"
7596
do_with_default_build obtain_complete_artifact

lib/functions/cli/commands.sh

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function armbian_register_commands() {
4343
# all-around artifact wrapper
4444
["artifact"]="artifact" # implemented in cli_artifact_pre_run and cli_artifact_run
4545
["artifact-config-dump-json"]="artifact" # implemented in cli_artifact_pre_run and cli_artifact_run
46+
["download-artifact"]="artifact" # implemented in cli_artifact_pre_run and cli_artifact_run
4647

4748
# shortcuts, see vars set below. the use legacy single build, and try to control it via variables
4849
["rootfs"]="artifact"

0 commit comments

Comments
 (0)