feat: pin all dependencies to git sources (#3381)

This commit is contained in:
cyan
2026-08-18 16:34:01 +02:00
committed by GitHub
parent 1f0f51fec5
commit be694edcc4
64 changed files with 6252 additions and 7159 deletions
+2 -5
View File
@@ -34,7 +34,7 @@ cp -a $APP_LOGO $APP_LOGO_DEST_PATH
cp -a $ANDROID_ICON $ANDROID_ICON_DEST_PATH
cp -a $ANDROID_ICON_SET/. $ANDROID_ICON_SET_DEST_PATH/
set -x
set +x
if [[ $GITHUB_HUH == "yeah" ]]; then
pwd
for file in $(find $CAKE_ROOT/android/app/src/main/res -name "*.png") $APP_LOGO $CAKEWALLET_PATH $ASSETS_DIR/images/cakewallet_logo.png $ASSETS_DIR/images/cakewallet_icon_*.png $(find $CAKEWALLET_ICON_SET_PATH -name "*.png"); do
@@ -42,7 +42,4 @@ if [[ $GITHUB_HUH == "yeah" ]]; then
bash $CAKE_ROOT/scripts/branch_icon.sh ${BRANCH_NAME}-asd $file &> /dev/null
done
fi
set +x
set -x
+2
View File
@@ -3,6 +3,8 @@ FROM --platform=linux/amd64 ${BASE_IMAGE} AS build
RUN mkdir -p /w/scripts/android
COPY pubspec_base.yaml /w/pubspec.yaml
COPY pubspec_overrides.yaml /w/pubspec_overrides.yaml
COPY pubspec_overrides.yaml /w/cw_mweb/pubspec_overrides.yaml
COPY cw_mweb/pubspec.yaml /w/cw_mweb/pubspec.yaml
COPY cw_mweb/ffigen_config.yaml /w/cw_mweb/ffigen_config.yaml
COPY cw_mweb/go /w/cw_mweb/go
+1 -1
View File
@@ -55,7 +55,7 @@ torch_ver="$(tinysha $SCRIPT_DIR/Dockerfile.torch $REPO_ROOT/scripts/prepare_tor
reown_ver=$(tinysha $SCRIPT_DIR/Dockerfile.reown $REPO_ROOT/scripts/prepare_reown.sh $REPO_ROOT/scripts/android/build_reown_deps.sh)
bitbox_ver=$(tinysha $SCRIPT_DIR/Dockerfile.bitbox $REPO_ROOT/scripts/build_bitbox_flutter.sh)
monero_ver=$(tinysha $SCRIPT_DIR/Dockerfile.monero $REPO_ROOT/scripts/prepare_moneroc.sh $REPO_ROOT/scripts/android/build_monero_all.sh)
mwebd_ver=$(tinysha $SCRIPT_DIR/Dockerfile.mwebd $(find $REPO_ROOT/cw_mweb/go -type f))
mwebd_ver=$(tinysha $SCRIPT_DIR/Dockerfile.mwebd $REPO_ROOT/pubspec_overrides.yaml $(find $REPO_ROOT/cw_mweb/go -type f))
zcash_ver=$(tinysha $SCRIPT_DIR/Dockerfile.zcash $REPO_ROOT/scripts/prepare_zcash.sh $REPO_ROOT/scripts/android/build_zcash.sh)
decred_ver=$(tinysha $SCRIPT_DIR/Dockerfile.torch $SCRIPT_DIR/Dockerfile.decred $REPO_ROOT/scripts/android/build_decred.sh $REPO_ROOT/cw_decred/pubspec.yaml)
echo $base_ver $torch_ver $reown_ver $bitbox_ver $monero_ver $mwebd_ver $zcash_ver $decred_ver > /tmp/docker_build_versions
+222
View File
@@ -0,0 +1,222 @@
#!/bin/bash
# usage:
# ./compare_overrides.sh GIT_HASH_A GIT_HASH_B
set -e
cd "$(dirname "$0")/.."
HASH_A=${1:?usage: ./compare_overrides.sh GIT_HASH_A GIT_HASH_B}
HASH_B=${2:?usage: ./compare_overrides.sh GIT_HASH_A GIT_HASH_B}
sdk_git_url=https://github.com/dart-lang/sdk
yq() {
go run github.com/mikefarah/yq/v4@latest "$@"
}
normalize_url() {
echo "$1" | sed 's|\.git$||'
}
repo_cache_dir() {
echo "scripts/.cache/repos/$(normalize_url "$1" | sed 's|https://github.com/||; s|/|_|g')"
}
ensure_repo_clone() {
local url=$1 cache_dir=$2
if [[ -d "${cache_dir}/.git" ]]; then
git -C "$cache_dir" fetch --quiet origin
else
mkdir -p "$(dirname "$cache_dir")"
if [[ "$(normalize_url "$url")" == "$sdk_git_url" ]]; then
git clone --quiet --filter=blob:none "$url" "$cache_dir" || return 1
else
git clone --quiet "$url" "$cache_dir" || return 1
fi
fi
}
normalize_repo_path() {
local path=$1
[[ -z "$path" || "$path" == "-" ]] && return 0
echo "${path#./}"
}
ensure_ref() {
local cache_dir=$1 ref=$2
git -C "$cache_dir" cat-file -e "${ref}^{commit}" 2>/dev/null && return 0
git -C "$cache_dir" fetch --quiet origin "$ref" 2>/dev/null || true
git -C "$cache_dir" cat-file -e "${ref}^{commit}" 2>/dev/null
}
count_lines_at_ref() {
local cache_dir=$1 ref=$2 path=$3
local repo_path file lines total=0
ensure_ref "$cache_dir" "$ref" || return 1
repo_path=$(normalize_repo_path "$path")
while IFS= read -r file; do
[[ -z "$file" ]] && continue
lines=$(git -C "$cache_dir" show "$ref:$file" 2>/dev/null | wc -l | tr -d ' ')
total=$((total + lines))
done < <(
if [[ -n "$repo_path" ]]; then
git -C "$cache_dir" ls-tree -r --name-only "$ref" -- "$repo_path" 2>/dev/null
else
git -C "$cache_dir" ls-tree -r --name-only "$ref" 2>/dev/null
fi
)
echo "$total"
}
print_ref_diff() {
local cache_dir=$1 old_ref=$2 new_ref=$3 old_path=$4 new_path=$5
local repo_path diff_paths=() path
ensure_ref "$cache_dir" "$old_ref" || {
echo " diff (old ref not found: $old_ref)"
return 1
}
ensure_ref "$cache_dir" "$new_ref" || {
echo " diff (new ref not found: $new_ref)"
return 1
}
for path in "$old_path" "$new_path"; do
repo_path=$(normalize_repo_path "$path")
[[ -z "$repo_path" ]] && continue
[[ " ${diff_paths[*]} " == *" $repo_path "* ]] && continue
diff_paths+=("$repo_path")
done
if [[ ${#diff_paths[@]} -eq 0 ]]; then
git -C "$cache_dir" diff --stat "$old_ref" "$new_ref" | sed 's/^/ /'
else
git -C "$cache_dir" diff --stat "$old_ref" "$new_ref" -- "${diff_paths[@]}" | sed 's/^/ /'
fi
}
overrides_json_git() {
git show "${1}:pubspec_overrides.yaml" | yq -o=json '.dependency_overrides // {}'
}
overrides_json_worktree() {
yq -o=json '.dependency_overrides // {}' pubspec_overrides.yaml
}
print_git_fields() {
local pkg=$1 old_url=$2 new_url=$3 old_ref=$4 new_ref=$5 old_path=$6 new_path=$7
echo " $pkg"
echo " url $old_url -> $new_url"
echo " ref $old_ref -> $new_ref"
echo " path $old_path -> $new_path"
}
print_new_repo_stats() {
local new_url=$1 new_ref=$2 new_path=$3 cache_dir loc
[[ "$new_url" == "-" || "$new_ref" == "-" ]] && return 0
cache_dir=$(repo_cache_dir "$new_url")
if ! ensure_repo_clone "$new_url" "$cache_dir"; then
echo " loc (clone failed)"
return 0
fi
if loc=$(count_lines_at_ref "$cache_dir" "$new_ref" "$new_path"); then
echo " loc $loc lines"
else
echo " loc (ref not found: $new_ref)"
fi
}
print_changed_ref_stats() {
local url=$1 old_ref=$2 new_ref=$3 old_path=$4 new_path=$5 cache_dir
[[ "$url" == "-" || "$old_ref" == "-" || "$new_ref" == "-" ]] && return 0
cache_dir=$(repo_cache_dir "$url")
if ! ensure_repo_clone "$url" "$cache_dir"; then
echo " diff (clone failed)"
return 0
fi
print_ref_diff "$cache_dir" "$old_ref" "$new_ref" "$old_path" "$new_path"
}
compare_overrides_jq='
def git($obj; $pkg): $obj[$pkg].git // null;
def fields($obj; $pkg):
git($obj; $pkg) as $g |
[($g.url // ""), ($g.ref // ""), ($g.path // "")];
def dash($v): if $v == "" then "-" else $v end;
'
resolved_a=$(git rev-parse "$HASH_A")
resolved_b=$(git rev-parse "$HASH_B")
resolved_head=$(git rev-parse HEAD)
if [[ "$resolved_a" == "$resolved_b" ]]; then
json_a=$(overrides_json_git "$HASH_A")
json_b=$(overrides_json_git "$HASH_B")
elif [[ "$resolved_b" == "$resolved_head" ]]; then
json_a=$(overrides_json_git "$HASH_A")
json_b=$(overrides_json_worktree)
else
json_a=$(overrides_json_git "$HASH_A")
json_b=$(overrides_json_git "$HASH_B")
fi
new_output=$(
jq -r -n --argjson a "$json_a" --argjson b "$json_b" "$compare_overrides_jq"'
($b | keys[] | select(git($b; .))) as $pkg |
select((git($a; $pkg) | not) or git($a; $pkg).url != git($b; $pkg).url) |
(fields($a; $pkg)) as $old |
(fields($b; $pkg)) as $new |
[
$pkg,
dash($old[0]), dash($new[0]),
dash($old[1]), dash($new[1]),
dash($old[2]), dash($new[2])
] | @tsv
' | while IFS=$'\t' read -r pkg old_url new_url old_ref new_ref old_path new_path; do
print_git_fields "$pkg" "$old_url" "$new_url" "$old_ref" "$new_ref" "$old_path" "$new_path"
print_new_repo_stats "$new_url" "$new_ref" "$new_path"
done
)
changed_output=$(
jq -r -n --argjson a "$json_a" --argjson b "$json_b" "$compare_overrides_jq"'
($b | keys[] | select(git($b; .) and git($a; .))) as $pkg |
select(git($a; $pkg).url == git($b; $pkg).url) |
select((git($a; $pkg).ref // "") != (git($b; $pkg).ref // "")) |
(fields($a; $pkg)) as $old |
(fields($b; $pkg)) as $new |
[
$pkg,
dash($old[0]), dash($new[0]),
dash($old[1]), dash($new[1]),
dash($old[2]), dash($new[2])
] | @tsv
' | while IFS=$'\t' read -r pkg old_url new_url old_ref new_ref old_path new_path; do
print_git_fields "$pkg" "$old_url" "$new_url" "$old_ref" "$new_ref" "$old_path" "$new_path"
print_changed_ref_stats "$new_url" "$old_ref" "$new_ref" "$old_path" "$new_path"
done
)
if [[ -n "$new_output" ]]; then
echo "new git repos:"
echo "$new_output"
fi
if [[ -n "$new_output" && -n "$changed_output" ]]; then
echo
fi
if [[ -n "$changed_output" ]]; then
echo "changed git refs:"
echo "$changed_output"
fi
+624
View File
@@ -0,0 +1,624 @@
#!/bin/bash
# Hello! o/
# If you are think there's a chance that you
# 1) want to update flutter sdk
# 2) want to update some dependency
# 3) want to add some dependency
# 4) are forking a dependency
# 5) something in the build process broke and you want to blame dependency pinning
# 6) the script is failing
#
# In cases 1, 2, 3 you don't need to edit this script at all. Just add the dependency
# to either pubspec_base.yaml or cw_*/pubspec.yaml. and re-run this script.
# In case 4 (or 6), do the same and add the dependency to
# package_repo_redirects - to redirect the dependency to your fork.
# repo_redirects - if the dependency was moved between git repos.
# version_ref_maps / dart_sdk_packages - if the dependency cannot be found upstream.
# In case 5 remove pubspec_overrides.yaml, and just build the app. There is a non-zero
# chance that it won't work. And if it works look for the diff between whatever is on git
# and whatever is published on pub.dev tarball.
# The script is designed in a way in which it is optional (so not using it should
# still result in a working build).
# In case of doubt git blame and ask the author ^^
set -e
cd "$(dirname "$0")/.."
yq() {
go run github.com/mikefarah/yq/v4@latest "$@"
}
lockfile="$(pwd)/pubspec.lock"
pubspec_base="$(pwd)/pubspec_base.yaml"
overrides_file="$(pwd)/pubspec_overrides.yaml"
sdk_git_url=https://github.com/dart-lang/sdk
resolved_git_path=""
resolved_ref=""
git_url=""
override_url=""
override_path=""
version_ref_map_skip_verify=0
# old git url|new git url
repo_redirects=(
"https://github.com/cmdrootaccess/another-flushbar|https://github.com/ideployed/another-flushbar"
"https://github.com/anicdh|https://github.com/MrCyjaneK/bs58check.git"
"https://github.com/MedzikUser/libcrypto-dart|https://github.com/MrCyjaneK/libcrypto.git"
"https://github.com/rive-app/rive-flutter|https://github.com/MrCyjaneK/rive-flutter-no-lfs"
"https://github.com/dart-lang/ffi|https://github.com/dart-lang/native"
)
# package|old git url|new git url (to move only one package out of a shared repo)
package_repo_redirects=(
"rive_common|https://github.com/rive-app/rive-flutter|https://github.com/MrCyjaneK/rive_common"
"fixnum_nanodart|https://github.com/dart-lang/fixnum|https://github.com/MrCyjaneK/fixnum_nanodart"
)
# package-version|git hash (exact match, or package-* to skip version check)
version_ref_maps=(
"ffi-2.1.0|6bd0935f29c7294ebb9aab21c06b47b513def933"
"flutter_rust_bridge-2.11.1|f19087cd0cac019b82d52cfa5153ce81b1b6e902"
)
dart_sdk_ref=$(cat $(dirname $(dirname $(which flutter)))/bin/cache/dart-sdk/revision)
dart_sdk_packages=(
js vm_service
)
# Kept on pub.dev
skip_git_pin_packages=(
_fe_analyzer_shared
analyzer
meta
)
lookup_version_ref_map() {
local pkg=$1 ver=$2 entry key ref sdk_pkg
version_ref_map_skip_verify=0
for sdk_pkg in "${dart_sdk_packages[@]}"; do
[[ "$pkg" == "$sdk_pkg" ]] || continue
version_ref_map_skip_verify=1
echo "$dart_sdk_ref"
return 0
done
for entry in "${version_ref_maps[@]}"; do
key="${entry%%|*}"
ref="${entry#*|}"
if [[ "$key" == "${pkg}-${ver}" ]]; then
echo "$ref"
return 0
fi
if [[ "$key" == "${pkg}-*" ]]; then
version_ref_map_skip_verify=1
echo "$ref"
return 0
fi
done
return 1
}
is_dart_sdk_package() {
local pkg=$1 sdk_pkg
for sdk_pkg in "${dart_sdk_packages[@]}"; do
[[ "$pkg" == "$sdk_pkg" ]] && return 0
done
return 1
}
is_skip_git_pin_package() {
local pkg=$1 skip_pkg
for skip_pkg in "${skip_git_pin_packages[@]}"; do
[[ "$pkg" == "$skip_pkg" ]] && return 0
done
return 1
}
apply_default_overrides() {
[[ -f "$pubspec_base" ]] || return 0
awk '
/^# dependency_overrides:/ {
in_block = 1
print "dependency_overrides:"
next
}
in_block && /^#[[:space:]]/ {
sub(/^#[[:space:]]?/, "")
print
next
}
in_block && /^#/ {
sub(/^#/, "")
print
next
}
in_block { exit }
' "$pubspec_base" > "$overrides_file"
if [[ ! -s "$overrides_file" ]]; then
rm -f "$overrides_file"
return 0
fi
echo "applied default overrides from ${pubspec_base}"
}
normalize_url() {
echo "$1" | sed 's|\.git$||'
}
normalize_git_path() {
local path=$1
[[ -z "$path" || "$path" == "." ]] && return 0
[[ "$path" == ./* ]] && { echo "$path"; return 0; }
echo "./${path}"
}
redirect_git_url() {
local url=$1 package=${2:-} entry rest old new
url=$(normalize_url "$url")
if [[ -n "$package" ]]; then
for entry in "${package_repo_redirects[@]}"; do
[[ "${entry%%|*}" != "$package" ]] && continue
rest="${entry#*|}"
old=$(normalize_url "${rest%%|*}")
new=$(normalize_url "${rest#*|}")
[[ "$url" == "$old" ]] && { echo "$new"; return 0; }
done
fi
for entry in "${repo_redirects[@]}"; do
old=$(normalize_url "${entry%%|*}")
new=$(normalize_url "${entry#*|}")
[[ "$url" == "$old" ]] && { echo "$new"; return 0; }
done
echo "$1"
}
parse_github_repo_url() {
local url=$1
if [[ "$url" =~ github\.com/([^/]+)/([^/?#]+) ]]; then
git_owner="${BASH_REMATCH[1]}"
git_repo="${BASH_REMATCH[2]%.git}"
git_url="https://github.com/${git_owner}/${git_repo}"
if [[ "$url" =~ github\.com/[^/]+/[^/]+/(tree|blob)/[^/]+/(.+) ]]; then
git_path="./${BASH_REMATCH[2]}"
else
git_path=""
fi
return 0
fi
return 1
}
pubdev_cache_file() {
echo "$(pwd)/scripts/.cache/pubdev/${1}/${2}.json"
}
pubdev_repo_url() {
local pkg=$1 ver=$2 cache_file
cache_file=$(pubdev_cache_file "$pkg" "$ver")
if [[ -f "$cache_file" ]]; then
jq -r '.pubspec.repository // .pubspec.homepage // empty' "$cache_file"
return 0
fi
mkdir -p "$(dirname "$cache_file")"
curl -sf "https://pub.dev/api/packages/${pkg}/versions/${ver}" >"$cache_file"
jq -r '.pubspec.repository // .pubspec.homepage // empty' "$cache_file"
}
repo_cache_dir() {
echo "scripts/.cache/repos/$(normalize_url "$1" | sed 's|https://github.com/||; s|/|_|g')"
}
locks_dir="$(pwd)/scripts/.cache/locks"
rm -rf $locks_dir
mkdir -p $locks_dir
repo_lock_file() {
local key=$1
if [[ "$key" == */* || "$key" == scripts/* ]]; then
echo "${locks_dir}/repo-$(basename "$key").lock"
else
echo "${locks_dir}/repo-$(normalize_url "$key" | sed 's|https://github.com/||; s|/|_|g').lock"
fi
}
with_lock() {
local lockpath=$1; shift
mkdir -p "$(dirname "$lockpath")"
while ! mkdir "$lockpath" 2>/dev/null; do
sleep 0.05
done
local rc=0
"$@" || rc=$?
rmdir "$lockpath" 2>/dev/null || true
return "$rc"
}
with_repo_lock() {
with_lock "$(repo_lock_file "$1")" "${@:2}"
}
with_overrides_lock() {
with_lock "${locks_dir}/overrides.lock" "$@"
}
_ensure_repo_clone() {
local url=$1 cache_dir=$2
[[ -d "${cache_dir}/.git" ]] && return 0
mkdir -p "$(dirname "$cache_dir")"
if [[ "$(normalize_url "$url")" == "$sdk_git_url" ]]; then
git clone --quiet --filter=blob:none "$url" "$cache_dir" || return 1
else
git clone --quiet "$url" "$cache_dir" || return 1
fi
}
ensure_repo_clone() {
local url=$1 cache_dir=$2
with_repo_lock "$cache_dir" _ensure_repo_clone "$url" "$cache_dir"
}
_ensure_git_ref() {
local cache_dir=$1 ref=$2
git -C "$cache_dir" cat-file -e "${ref}^{commit}" 2>/dev/null
}
ensure_git_ref() {
with_repo_lock "$1" _ensure_git_ref "$@"
}
pubspec_field() {
local content=$1 field=$2
echo "$content" |
grep -E "^${field}:[[:space:]]*" |
head -1 |
sed "s/^${field}:[[:space:]]*//" |
tr -d "\"'" |
sed 's/[[:space:]]*$//'
}
pubspec_matches() {
local content=$1 package=$2 ver=${3:-}
[[ "$(pubspec_field "$content" name)" == "$package" ]] || return 1
[[ -z "$ver" || "$(pubspec_field "$content" version)" == "$ver" ]]
}
build_path_candidates() {
local url=$1 package=$2 path=$3
local candidate candidates=() seen=""
add_candidate() {
local c=$1
if [[ -z "$c" ]]; then
[[ " $seen " == *" __ROOT__ "* ]] && return
seen="$seen __ROOT__"
candidates+=("")
return
fi
[[ " $seen " == *" $c "* ]] && return
seen="$seen $c"
candidates+=("$c")
}
if [[ -n "$path" ]]; then
local normalized="${path#./}"
normalized="${normalized%/}"
if [[ "$normalized" != "packages" ]]; then
local cache_dir content
cache_dir=$(repo_cache_dir "$url")
if ensure_repo_clone "$url" "$cache_dir"; then
content=$(git -C "$cache_dir" show "HEAD:${normalized}/pubspec.yaml" 2>/dev/null) || content=""
pubspec_matches "$content" "$package" && add_candidate "$normalized"
fi
fi
fi
local cache_dir pubspec_path dir content
cache_dir=$(repo_cache_dir "$url")
if ensure_repo_clone "$url" "$cache_dir"; then
while IFS= read -r pubspec_path; do
dir=$(dirname "$pubspec_path")
content=$(git -C "$cache_dir" show "HEAD:${pubspec_path}" 2>/dev/null) || continue
pubspec_matches "$content" "$package" || continue
add_candidate "$dir"
done < <(git -C "$cache_dir" ls-files | grep '/pubspec.yaml$')
fi
add_candidate "pkgs/${package}"
add_candidate "packages/${package}"
add_candidate "${package}"
add_candidate ""
printf '%s\n' "${candidates[@]}"
}
find_path_at_ref() {
local url=$1 ref=$2 package=$3 ver=$4 hint_path=$5
local cache_dir candidate pubspec_file content
cache_dir=$(repo_cache_dir "$url")
ensure_repo_clone "$url" "$cache_dir" || return 1
ensure_git_ref "$cache_dir" "$ref" || return 1
while IFS= read -r candidate; do
pubspec_file=$([[ -n "$candidate" ]] && echo "${candidate}/pubspec.yaml" || echo "pubspec.yaml")
content=$(git -C "$cache_dir" show "${ref}:${pubspec_file}" 2>/dev/null) || continue
pubspec_matches "$content" "$package" "$ver" || continue
[[ -n "$candidate" ]] && echo "./${candidate}"
return 0
done < <(build_path_candidates "$url" "$package" "$hint_path")
return 1
}
_resolve_tag_ref() {
local url=$1 pkg=$2 ver=$3 cache_dir ref tag
cache_dir=$(repo_cache_dir "$url")
_ensure_repo_clone "$url" "$cache_dir" || return 1
for tag in "${ver}" "v${ver}" "${pkg}-${ver}" "${pkg}-v${ver}"; do
ref=$(git -C "$cache_dir" rev-parse -q "refs/tags/${tag}^{commit}" 2>/dev/null) && {
echo "$ref"
return 0
}
ref=$(git -C "$cache_dir" rev-parse -q "refs/tags/${tag}" 2>/dev/null) && {
echo "$ref"
return 0
}
done
return 1
}
resolve_tag_ref() {
with_repo_lock "$1" _resolve_tag_ref "$@"
}
find_commit_for_package_version() {
local url=$1 package=$2 ver=$3 hint_path=$4
local cache_dir candidate pubspec_file ref content ver_try log_args
local -a version_attempts=("$ver")
[[ "$ver" != *-dev ]] && version_attempts+=("${ver}-dev")
cache_dir=$(repo_cache_dir "$url")
ensure_repo_clone "$url" "$cache_dir" || return 1
while IFS= read -r candidate; do
pubspec_file=$([[ -n "$candidate" ]] && echo "${candidate}/pubspec.yaml" || echo "pubspec.yaml")
for ver_try in "${version_attempts[@]}"; do
[[ "$ver_try" == "$ver" ]] && log_args=(--reverse) || log_args=()
for ref in $(git -C "$cache_dir" log "${log_args[@]}" --format=%H -- "$pubspec_file" 2>/dev/null); do
content=$(git -C "$cache_dir" show "${ref}:${pubspec_file}" 2>/dev/null) || continue
pubspec_matches "$content" "$package" "$ver_try" || continue
resolved_git_path=""
[[ -n "$candidate" ]] && resolved_git_path="./${candidate}"
resolved_ref="$ref"
return 0
done
done
done < <(build_path_candidates "$url" "$package" "$hint_path")
return 1
}
resolve_git_override_for_package() {
local package=$1 version=$2 repo_url=$3
local original_git_url hint_path tag_ref path
repo_url=$(redirect_git_url "$repo_url" "$package")
parse_github_repo_url "$repo_url" || return 1
original_git_url="$git_url"
hint_path="$git_path"
path=$(find_path_at_ref "$git_url" HEAD "$package" "" "$hint_path" || true)
if [[ -n "$path" ]]; then
hint_path="$path"
elif [[ -z "$hint_path" && "$git_url" != "$original_git_url" ]]; then
path=$(find_path_at_ref "$original_git_url" HEAD "$package" "" "" || true)
if [[ -n "$path" ]]; then
git_url="$original_git_url"
hint_path="$path"
fi
fi
resolved_git_path=""
resolved_ref=""
tag_ref=$(resolve_tag_ref "$git_url" "$package" "$version" || true)
if [[ -n "$tag_ref" ]] &&
path=$(find_path_at_ref "$git_url" "$tag_ref" "$package" "$version" "$hint_path"); then
resolved_git_path="$path"
resolved_ref="$tag_ref"
return 0
fi
find_commit_for_package_version "$git_url" "$package" "$version" "$hint_path"
}
resolve_mapped_override() {
local package=$1 version=$2 source=$3 lock_git_url=$4 lock_git_path=$5 mapped_ref=$6
local repo_url path_ver
if is_dart_sdk_package "$package"; then
override_url="$sdk_git_url"
override_path="./pkg/${package}"
return 0
fi
if [[ "$source" == "git" ]]; then
[[ -n "$lock_git_url" ]] || return 1
override_url=$(redirect_git_url "$lock_git_url" "$package")
override_path=$(normalize_git_path "$lock_git_path")
return 0
fi
[[ "$source" == "hosted" ]] || return 1
repo_url=$(pubdev_repo_url "$package" "$version")
[[ -n "$repo_url" ]] || return 1
repo_url=$(redirect_git_url "$repo_url" "$package")
parse_github_repo_url "$repo_url" || return 1
override_url="$git_url"
path_ver="$version"
[[ "$version_ref_map_skip_verify" == 1 ]] && path_ver=""
override_path=$(find_path_at_ref "$git_url" "$mapped_ref" "$package" "$path_ver" "" || true)
[[ -n "$override_path" ]]
}
has_git_override_in_yaml() {
local pkg=$1
[[ -f "$overrides_file" ]] || return 1
yq -e ".dependency_overrides.\"${pkg}\".git" "$overrides_file" >/dev/null 2>&1
}
_add_git_override_to_yaml() {
local pkg=$1 url=$2 path=$3 ref=$4 yq_expr
[[ -f "$overrides_file" ]] || printf 'dependency_overrides: {}\n' > "$overrides_file"
if has_git_override_in_yaml "$pkg"; then
echo "$pkg: OK (default override)"
return 0
fi
yq -i "del(.dependency_overrides.\"${pkg}\")" "$overrides_file"
yq_expr=".dependency_overrides.\"${pkg}\".git.url = \"${url}\" | .dependency_overrides.\"${pkg}\".git.ref = \"${ref}\""
[[ -n "$path" ]] && yq_expr+=" | .dependency_overrides.\"${pkg}\".git.path = \"${path}\""
yq -i "$yq_expr" "$overrides_file" || {
echo "$pkg: failed to update ${overrides_file}" >&2
return 1
}
echo "added to ${overrides_file}:"
echo " ${pkg}:"
echo " git:"
echo " url: ${url}"
[[ -n "$path" ]] && echo " path: ${path}"
echo " ref: ${ref}"
}
add_git_override_to_yaml() {
with_overrides_lock _add_git_override_to_yaml "$@"
}
sort_overrides_yaml() {
yq -i \
'.dependency_overrides = (.dependency_overrides | to_entries | sort_by(.key) | from_entries)' \
"$overrides_file"
}
rm -f "$overrides_file"
apply_default_overrides
./configure_cake_wallet.sh android
flutter pub get
apply_default_overrides
mkdir -p "$locks_dir"
process_package() {
local pkg=$1 package source version git_url git_ref git_path mapped_ref repo_url
eval "$(jq -r '@sh "
package=\(.package)
source=\(.source)
version=\(.version)
git_url=\(.git_url)
git_ref=\(.git_ref)
git_path=\(.git_path)
"' <<< "$pkg")"
if has_git_override_in_yaml "$package"; then
echo "$package: OK (default override)"
return 0
fi
if is_skip_git_pin_package "$package"; then
echo "$package: OK (version pinned, skipped)"
return 0
fi
mapped_ref=$(lookup_version_ref_map "$package" "$version" || true)
if [[ -n "$mapped_ref" ]]; then
if ! resolve_mapped_override "$package" "$version" "$source" "$git_url" "$git_path" "$mapped_ref"; then
echo "$package: NOT OK - could not apply version_ref_maps entry for ${version}" >&2
return 1
fi
add_git_override_to_yaml "$package" "$override_url" "$override_path" "$mapped_ref" || return 1
return 0
fi
case "$source" in
git)
if [[ -z "$git_url" || -z "$git_ref" ]]; then
echo "$package: NOT OK - git dependency missing url or ref in ${lockfile}" >&2
return 1
fi
add_git_override_to_yaml \
"$package" \
"$(redirect_git_url "$git_url" "$package")" \
"$(normalize_git_path "$git_path")" \
"$git_ref" || return 1
;;
sdk)
echo "$package: OK (sdk, skipped)"
;;
hosted)
repo_url=$(pubdev_repo_url "$package" "$version")
if [[ -z "$repo_url" ]]; then
echo "$package: NOT OK - could not find repository or homepage on pub.dev for ${version}"
return 1
fi
if ! resolve_git_override_for_package "$package" "$version" "$repo_url"; then
echo "$package: NOT OK - could not resolve git ref for version ${version} in ${git_url}"
echo "# add manual mapping to version_ref_maps in scripts/create_overrides.sh:"
echo "# \"${package}-${version}|GIT_HASH\""
echo "# repository: ${repo_url}"
return 1
fi
add_git_override_to_yaml "$package" "$git_url" "$resolved_git_path" "$resolved_ref" || return 1
;;
path)
echo "$package: OK (path, skipped)"
;;
*)
echo "$package: NOT OK - source=${source} (cannot auto-generate git override)"
return 1
;;
esac
}
max_jobs=16
failed=0
batch=()
while IFS= read -r pkg; do
process_package "$pkg" &
batch+=($!)
if ((${#batch[@]} >= max_jobs)); then
for pid in "${batch[@]}"; do
wait "$pid" || failed=1
done
batch=()
fi
done < <(
yq -o json '.packages' "$lockfile" | jq -c '
to_entries[] | {
package: .key,
source: (.value.source // ""),
version: (.value.version // ""),
git_url: (if (.value.description | type) == "object" then .value.description.url // "" else "" end),
git_ref: (if (.value.description | type) == "object" then (.value.description["resolved-ref"] // .value.description.ref // "") else "" end),
git_path: (if (.value.description | type) == "object" then .value.description.path // "" else "" end)
}
'
)
for pid in "${batch[@]}"; do
wait "$pid" || failed=1
done
[[ "$failed" -eq 0 ]] || exit 1
sort_overrides_yaml
+1 -1
View File
@@ -6,4 +6,4 @@ cd "$(dirname "$0")"
cd ../torch_dart
# ./build.sh x86_64-linux-gnu
./build.sh x86_64-linux-gnu
+2 -2
View File
@@ -3,8 +3,8 @@ FROM --platform=linux/amd64 ${BASE_IMAGE} AS build
RUN mkdir -p /w/scripts/android
COPY pubspec_base.yaml /w/pubspec.yaml
# COPY pubspec_overrides.yaml /w/pubspec_overrides.yaml
# COPY pubspec_overrides.yaml /w/cw_mweb/pubspec_overrides.yaml
COPY pubspec_overrides.yaml /w/pubspec_overrides.yaml
COPY pubspec_overrides.yaml /w/cw_mweb/pubspec_overrides.yaml
COPY cw_mweb/pubspec.yaml /w/cw_mweb/pubspec.yaml
COPY cw_mweb/ffigen_config.yaml /w/cw_mweb/ffigen_config.yaml
COPY cw_mweb/go /w/cw_mweb/go
+1 -1
View File
@@ -14,7 +14,7 @@ RUN groupadd -g "$GID" "$USER" && \
RUN sudo chown $UID:$GID -R /w /root
USER builder
RUN /w/scripts/prepare_torch.sh
RUN /w/scripts/linux/build_torch.sh && rm -rf /w/scripts/torch_dart/simplybs
FROM --platform=linux/amd64 alpine
COPY --from=build /w /w
+1 -1
View File
@@ -55,7 +55,7 @@ torch_ver="$(tinysha $SCRIPT_DIR/Dockerfile.torch $REPO_ROOT/scripts/prepare_tor
reown_ver=$(tinysha $SCRIPT_DIR/Dockerfile.reown $REPO_ROOT/scripts/prepare_reown.sh $REPO_ROOT/scripts/android/build_reown_deps.sh)
bitbox_ver=$(tinysha $SCRIPT_DIR/Dockerfile.bitbox $REPO_ROOT/scripts/build_bitbox_flutter.sh)
monero_ver=$(tinysha $SCRIPT_DIR/Dockerfile.monero $REPO_ROOT/scripts/prepare_moneroc.sh $REPO_ROOT/scripts/linux/build_monero_all.sh)
mwebd_ver=$(tinysha $SCRIPT_DIR/Dockerfile.mwebd $REPO_ROOT/cw_mweb/pubspec.yaml $(find $REPO_ROOT/cw_mweb/go -type f))
mwebd_ver=$(tinysha $SCRIPT_DIR/Dockerfile.mwebd $REPO_ROOT/pubspec_overrides.yaml $(find $REPO_ROOT/cw_mweb/go -type f))
zcash_ver=$(tinysha $SCRIPT_DIR/Dockerfile.zcash $REPO_ROOT/scripts/prepare_zcash.sh $REPO_ROOT/scripts/linux/build_zcash.sh)
echo $base_ver $torch_ver $reown_ver $bitbox_ver $monero_ver $mwebd_ver $zcash_ver > /tmp/docker_build_versions
final_ver=$(tinysha /tmp/docker_build_versions)