Files
buildroot/package/flutter-engine/gen-tarball
Adam Duskett 1956e4e434 package/flutter-engine: bump to version 3.29.2
As of Flutter 3.27.4, the flutter-engine github repository is archived, and the
flutter-engine source code now resides at https://github.com/flutter/flutter/.

Because of the above, the following changes must occure:

- Paths are now prefixed with engine/src.

- The "name" field in the dot-gclient file is now "./", and the gen-tarball
  script:
   - Makes the dl-tmp/src dir
   - Copies the dot-gclient file to the dl-tmp/src dir
   - Runs gclient.py inside of the dl-tmp/src dir

Without these changes, gclient creates two directores:
dl-tmp/src/flutter and dl-tmp/src/engine, and cloning fails with the following
error:

```
python3: can't open file 'dl-tmp/src/engine/src/flutter/tools/pub_get_offline.py':
[Errno 2] No such file or directory
```

because the file resides at src/flutter/engine/src/flutter/tools.
Changing the name from src/flutter to ./ and running gclient.py directly in
the src directory creates a proper directory structure suitable for compiling.

Of course, this also means there is a new pushd in the gen_tarball method to
move to ${SCRATCH_DIR} to ensure the tarball is generated outside of the
source directory.

Tested with run-tests tests.package.test_flutter.TestFlutter.test_run.

The license file has changed, but it's still BSD-3-Clause.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2025-04-21 23:19:59 +02:00

96 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Call gclient and generate a flutter-engine source tarball if one does not
# already exist.
set -eu
DL_DIR=
DOT_GCLIENT=
JOBS=
SCRATCH_DIR=
TARBALL_DL_PATH=
VERSION=
TARBALL_NAME=
term_bold="$(tput smso 2>/dev/null || true)"
term_reset="$(tput rmso 2>/dev/null || true)"
# Print status messages in the same style Buildroot prints.
message() {
printf "%s>>> flutter-engine %s %s%s\n" "${term_bold}" "${VERSION}" "${1}" "${term_reset}"
}
parse_opts() {
local o O opts
o='d:j:s:t:v:'
O='dot-gclient:,jobs:,scratch-dir:,tarball-dl-path:,version:'
opts="$(getopt -o "${o}" -l "${O}" -- "${@}")"
eval set -- "${opts}"
while [ ${#} -gt 0 ]; do
case "${1}" in
(-d|--dot-gclient) DOT_GCLIENT="${2}"; shift 2;;
(-j|--jobs) JOBS="${2}"; shift 2;;
(-s|--scratch-dir) SCRATCH_DIR="${2}"; shift 2;;
(-t|--tarball-dl-path) DL_DIR=$(dirname "${2}"); TARBALL_DL_PATH="${2}"; shift 2;;
(-v|--version) VERSION="${2}"; TARBALL_NAME=flutter-"${VERSION}".tar.gz; shift 2;;
(--) shift; break;;
esac
done
}
prepare() {
rm -rf "${SCRATCH_DIR}"
mkdir -p "${SCRATCH_DIR}"/src
pushd "${SCRATCH_DIR}"/src >/dev/null
}
copy_dot_gclient() {
sed "s%!FLUTTER_VERSION!%${VERSION}%g" "${DOT_GCLIENT}" >.gclient
}
run_gclient() {
message "Downloading"
gclient.py \
sync \
--delete_unversioned_trees \
--no-history \
--reset \
--shallow \
-j"${JOBS}"
}
gen_tarball() {
message "Generating tarball"
mkdir -p "${DL_DIR}"
pushd "${SCRATCH_DIR}" >/dev/null
# There are two issues with the flutter-engine buildsystem:
# - it expects empty directories created by gclient.py to be present; that
# means we can't use the mk_tar_gz helper method from support/download/helpers,
# because it does not include empty directories;
# - it insists on having a full git repositoy, with .git et al., which means
# we can't generate a reproducible archive anyway.
# So we just create a plain tarball.
${TAR} -C "${SCRATCH_DIR}"/src -czf "${TARBALL_NAME}" .
mv "${TARBALL_NAME}" "${TARBALL_DL_PATH}"
popd >/dev/null
}
cleanup() {
popd >/dev/null
rm -rf "${SCRATCH_DIR}"
}
main() {
parse_opts "${@}"
if [[ ! -e "${TARBALL_DL_PATH}" ]]; then
prepare
copy_dot_gclient
run_gclient
gen_tarball
cleanup
fi
}
main "${@}"