migrate.sh: add help, add force option, fix on shells without echo -e

This commit is contained in:
Chris Renshaw
2023-12-28 13:19:23 -04:00
committed by osm0sis
parent a3cbed9a4e
commit edcb94e179

View File

@@ -1,7 +1,11 @@
#!/bin/sh
case "$1" in
install) INSTALL=1; shift;;
-h|--help|help) echo "sh migrate.sh [-f] [file]"; exit 0;;
esac;
case "$1" in
-i|--install|install) INSTALL=1; shift;;
*) echo "custom.pif.json migration script \
\n by osm0sis @ xda-developers \n";;
esac;
@@ -11,6 +15,10 @@ die() { [ "$INSTALL" ] || echo "\n\n! $@"; exit 1; }
grep_get_json() { grep "$1" "$DIR/custom.pif.json" | cut -d\" -f4; }
grep_check_json() { grep -q "$1" "$DIR/custom.pif.json" && [ "$(grep_get_json "$1")" ]; }
case "$1" in
-f|--force|force) FORCE=1; shift;;
esac;
if [ -f "$1" ]; then
DIR="$1";
shift;
@@ -24,7 +32,7 @@ DIR=$(dirname "$(readlink -f "$DIR")");
[ -f "$DIR/custom.pif.json" ] || die "No custom.pif.json found";
grep_check_json api_level && die "No migration required";
grep_check_json api_level && [ ! "$FORCE" ] && die "No migration required";
[ "$INSTALL" ] || item "Parsing fields ...";
@@ -81,7 +89,8 @@ echo " // Build Fields";
for FIELD in $ALLFIELDS; do
eval echo '\ \ \ \ \"$FIELD\": \"'\$$FIELD'\",';
done;
echo -e "\n // System Properties";
echo "
// System Properties";
echo ' "*.build.id": "'$ID'",';
echo ' "*.security_patch": "'$SECURITY_PATCH'",';
[ -z "$VNDK_VERSION" ] || echo ' "*.vndk_version": "'$VNDK_VERSION'",';