File generate_dependency_archive.sh of Package dart
#!/bin/bash
set -euxo pipefail
DIR_SCRIPT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
DIR_TMP="${DIR_SCRIPT}/tmp.archive_generation"
DIR_DART="${DIR_TMP}/sdk"
DIR_DEPOT_TOOLS="${DIR_TMP}/depot_tools"
DIR_DEPOT_TOOLS_SYMLINK="/tmp/tmp.depot_tools_link"
DEPOT_TOOLS_COMMIT_HASH="$(grep 'define depot_tools_commit_hash' "${DIR_SCRIPT}/dart.spec" | sed 's/%define depot_tools_commit_hash //g')"
DART_VERSION="$(rpmspec -q "${DIR_SCRIPT}/dart.spec" --srpm --qf="%{version}")"
ARCHIVE_DEPOT_TOOLS="depot_tools-${DEPOT_TOOLS_COMMIT_HASH}.tar.gz"
#rm -rf "$DIR_TMP"
mkdir -p "$DIR_TMP"
cat > "${DIR_TMP}/.gclient" <<EOF
solutions = [
{
"name": "sdk",
"url": "file://${DIR_DART}",
"deps_file": "DEPS",
"managed": False,
"custom_deps": {},
"custom_vars": {},
},
]
EOF
if [[ ! -d "${DIR_DART}/.git" ]] || [[ "$(cd "$DIR_DART" && git describe --tags --exact-match)" != "$DART_VERSION" ]]; then
rm -rf "$DIR_DART"
git clone https://github.com/dart-lang/sdk --branch "$DART_VERSION" --depth 1 "$DIR_DART"
fi
mkdir -p "$DIR_DEPOT_TOOLS"
tar xf "$ARCHIVE_DEPOT_TOOLS" -C "$DIR_DEPOT_TOOLS"
if [[ "$DIR_DEPOT_TOOLS" == *:* ]]; then
ln -fs "$DIR_DEPOT_TOOLS" "$DIR_DEPOT_TOOLS_SYMLINK"
ACTUAL_DEPOT_TOOLS_DIR="$DIR_DEPOT_TOOLS_SYMLINK"
else
ACTUAL_DEPOT_TOOLS_DIR="$DIR_DEPOT_TOOLS"
fi
cd "$DIR_DART"
patch -Np 1 --no-backup-if-mismatch --input=../../DEPS.patch
DART_COMMIT_TIME="$(git show --no-patch --format=%ci "$DART_VERSION" | tail -n1)"
export DEPOT_TOOLS_UPDATE=0
export PATH="${PATH}:${ACTUAL_DEPOT_TOOLS_DIR}"
python3 "${ACTUAL_DEPOT_TOOLS_DIR}/gclient.py" sync \
-D \
--nohooks \
--no-history \
--shallow \
--force
#-r "$(git rev-parse HEAD)"
"${DIR_DART}/tools/sdks/dart-sdk/bin/dart" "${DIR_DART}/tools/generate_package_config.dart"
python3 "${DIR_DART}/tools/generate_sdk_version_file.py"
git restore DEPS
git switch --orphan build_branch_for_archiving
tar czf "${DIR_SCRIPT}/gclient_sync_tools.tar.gz" -C "$DIR_TMP" --mtime="$DART_COMMIT_TIME" sdk/tools
tar czf "${DIR_SCRIPT}/gclient_sync.tar.gz" -C "$DIR_TMP" --mtime="$DART_COMMIT_TIME" --exclude="sdk/.git" --exclude="sdk/tools" sdk sdk/.git/log/HEAD
git checkout "$DART_VERSION"