Compare commits

...

7 Commits

4 changed files with 114 additions and 5 deletions

View File

@@ -16,10 +16,22 @@
installPhase = ''
mkdir -p $out/bin
install --mode 555 src/flutter-build.sh $out/bin/flutter-build
install --mode 555 src/flutter/build.sh $out/bin/flutter-build
'';
};
flutter-build-raw = pkgs.callPackage flutterBuildRaw {};
checkPr = {stdenv}: stdenv.mkDerivation {
pname = "check-pr";
version = "0.1.0";
src = ./.;
installPhase = ''
mkdir -p $out/bin
install --mode 555 src/flutter/check-pr.sh $out/bin/check-pr
'';
};
in {
packages = {
# The raw flutter-build script
@@ -31,6 +43,9 @@
--notify-send ${pkgs.libnotify}/bin/notify-send \
$@
'';
# A script for checking if a PR is okay
checkPr = pkgs.callPackage checkPr {};
};
});
}

View File

@@ -0,0 +1,49 @@
#!/bin/bash
# I keep forgetting how to extract the boot.img from an Android OTA update
# for patching by Magisk.
set -e
while [[ $# -gt 0 ]]; do
case $1 in
--payload-dumper)
# Specify the path to the payload_dumper binary
PAYLOAD_DUMPER=$2
shift
shift
;;
--diff)
PAYLOAD_DUMPER_EXTRA_ARGS="${PAYLOAD_DUMPER_EXTRA_ARGS} --diff"
shift
;;
*)
# The last argument is the file
UPDATE_FILE=$1
shift
;;
esac
done
if [[ ! -f "$UPDATE_FILE" ]]; then
echo "Android update file $UPDATE_FILE does not exist"
exit 1
fi
out_dir=./payload-dumper-output
if [[ -d "$out_dir" ]]; then
echo "Output path $out_dir already exists. Refusing to work!"
exit 1
fi
mkdir "$out_dir"
# Print some basic info
PAYLOAD_DUMPER=${PAYLOAD_DUMPER:-payload_dumper}
echo "INFO: payload_dumper: $PAYLOAD_DUMPER"
echo
# Extract only the payload.bin file
echo "Extracting payload..."
unzip -q -C "$UPDATE_FILE" -d "$out_dir" payload.bin
# Use payload_dumper to get to the boot.img
echo "Dumping data from payload..."
${PAYLOAD_DUMPER} ${PAYLOAD_DUMPER_EXTRA_ARGS} --out "$out_dir" "${out_dir}/payload.bin"

View File

@@ -80,6 +80,18 @@ while [[ $# -gt 0 ]]; do
SEND_NOTIFICATION=n
shift
;;
--pigeon)
# Specifies to run `dart run pigeon --input $2`
PIGEON_FILES="$PIGEON_FILES $2"
shift
shift
;;
--flutter)
# Specifies the path to the flutter binary
FLUTTER=$2
shift
shift
;;
*)
echo "Unknown argument: $1"
shift
@@ -101,6 +113,7 @@ CLEAN_BUILD=${CLEAN_BUILD:-y}
SKIP_BUILD=${SKIP_BUILD:-n}
NOTIFY_SEND=${NOTIFY_SEND:-notify-send}
SEND_NOTIFICATION=${SEND_NOTIFICATION:-y}
FLUTTER=${FLUTTER:-flutter}
# Parse version info
version=$(grep -E "^version: " pubspec.yaml | cut -b 10-)
@@ -112,7 +125,9 @@ release_dir="./release-${version}"
echo "===== ${NAME} ====="
echo "Building version ${version}"
echo "Moving APKs into ${release_dir} after build"
echo "Flutter: ${FLUTTER}"
echo "Clean build: ${CLEAN_BUILD}"
echo "Pigeons to build: ${PIGEON_FILES}"
echo "Skipping build: ${SKIP_BUILD}"
echo "Sending notification: ${SEND_NOTIFICATION}"
echo "APKs already signed: ${ALREADY_SIGNED}"
@@ -146,17 +161,22 @@ else
if [[ "${CLEAN_BUILD}" = "y" ]]; then
# Clean flutter build
flutter clean
$FLUTTER clean
fi
# Get dependencies
flutter pub get
$FLUTTER pub get
# Build everything again
flutter pub run build_runner build --delete-conflicting-outputs
$FLUTTER pub run build_runner build --delete-conflicting-outputs
# Build pigeons
for pigeon in $PIGEON_FILES; do
$FLUTTER pub run pigeon --input $pigeon
done
# Build the release apk
flutter build apk \
$FLUTTER build apk \
--release \
--split-per-abi \
--split-debug-info="${release_dir}/debug-info"

25
src/flutter/check-pr.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Run before merging a PR. Checks if the formatting is correct.
# Check if there are any formatting issues
echo "Checking formatting..."
dart_format_result=$(dart format --output none --set-exit-if-changed .)
if [[ ! "$?" = "0" ]]; then
echo "Error: dart format indicates that format the code is not formatted properly"
echo
echo "dart format output:"
echo "$dart_format_result"
exit 1
fi
# Check if the linter has any issues
echo "Checking linter..."
flutter_analyze_result=$(flutter analyze)
if [[ ! "$?" = "0" ]]; then
echo "Error: flutter analyze indicates that there are lint issues"
echo
echo "flutter analyze output:"
echo "${flutter_analyze_result}"
exit 1
fi
echo "PR looks good!"