fix resource name
Build Futon with Niadd patch / Build Futon Niadd debug APK (push) Failing after 12m44s
Build Futon with Niadd patch / Build Futon Niadd debug APK (push) Failing after 12m44s
This commit is contained in:
2 files changed
+99
-42
No files matched your search
+32
-13
@@ -113,34 +113,53 @@ jobs:
|
|||||||
python3 scripts/patch_futon_niadd.py \
|
python3 scripts/patch_futon_niadd.py \
|
||||||
work/Futon
|
work/Futon
|
||||||
|
|
||||||
echo "=== Verify Futon build.gradle modification ==="
|
echo "=== Verify applicationId suffix ==="
|
||||||
|
|
||||||
grep -F "applicationIdSuffix = '.niadd'" \
|
grep -F "applicationIdSuffix = '.niadd'" \
|
||||||
work/Futon/app/build.gradle
|
work/Futon/app/build.gradle
|
||||||
|
|
||||||
echo "=== Verify Niadd resource overlay ==="
|
echo "=== Verify application name ==="
|
||||||
|
|
||||||
NIADD_RESOURCES="work/Futon/app/src/debug/res/values/niadd.xml"
|
grep -F '>Futon Niadd</string>' \
|
||||||
|
work/Futon/app/src/debug/res/values/strings.xml
|
||||||
|
|
||||||
test -f "${NIADD_RESOURCES}"
|
echo "=== Verify Niadd sync identifiers ==="
|
||||||
|
|
||||||
grep -F "Futon Niadd" \
|
grep -F 'io.github.landwarderer.futon.niadd.sync' \
|
||||||
"${NIADD_RESOURCES}"
|
work/Futon/app/src/debug/res/values/constants.xml
|
||||||
|
|
||||||
grep -F "io.github.landwarderer.futon.niadd.sync" \
|
grep -F 'io.github.landwarderer.futon.niadd.history' \
|
||||||
"${NIADD_RESOURCES}"
|
work/Futon/app/src/debug/res/values/constants.xml
|
||||||
|
|
||||||
grep -F "io.github.landwarderer.futon.niadd.history" \
|
grep -F 'io.github.landwarderer.futon.niadd.favourites' \
|
||||||
"${NIADD_RESOURCES}"
|
work/Futon/app/src/debug/res/values/constants.xml
|
||||||
|
|
||||||
grep -F "io.github.landwarderer.futon.niadd.favourites" \
|
echo "=== Ensure old debug identifiers are gone ==="
|
||||||
"${NIADD_RESOURCES}"
|
|
||||||
|
if grep -F 'org.futon.debug.sync' \
|
||||||
|
work/Futon/app/src/debug/res/values/constants.xml; then
|
||||||
|
echo "ERROR: old debug sync account type is still present"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -F 'org.koitharu.futon.debug.history' \
|
||||||
|
work/Futon/app/src/debug/res/values/constants.xml; then
|
||||||
|
echo "ERROR: old debug history authority is still present"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -F 'org.koitharu.futon.debug.favourites' \
|
||||||
|
work/Futon/app/src/debug/res/values/constants.xml; then
|
||||||
|
echo "ERROR: old debug favourites authority is still present"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== Futon resulting diff ==="
|
echo "=== Futon resulting diff ==="
|
||||||
|
|
||||||
git -C work/Futon diff -- \
|
git -C work/Futon diff -- \
|
||||||
app/build.gradle \
|
app/build.gradle \
|
||||||
app/src/debug/res/values/niadd.xml
|
app/src/debug/res/values/strings.xml \
|
||||||
|
app/src/debug/res/values/constants.xml
|
||||||
|
|
||||||
git -C work/Futon diff --check
|
git -C work/Futon diff --check
|
||||||
|
|
||||||
|
|||||||
@@ -12,36 +12,57 @@ if len(sys.argv) != 2:
|
|||||||
repo_dir = Path(sys.argv[1]).resolve()
|
repo_dir = Path(sys.argv[1]).resolve()
|
||||||
|
|
||||||
build_gradle = repo_dir / "app/build.gradle"
|
build_gradle = repo_dir / "app/build.gradle"
|
||||||
|
debug_strings = repo_dir / "app/src/debug/res/values/strings.xml"
|
||||||
|
debug_constants = repo_dir / "app/src/debug/res/values/constants.xml"
|
||||||
|
|
||||||
if not build_gradle.is_file():
|
|
||||||
print(f"ERROR: build.gradle not found: {build_gradle}", file=sys.stderr)
|
for file_path in (
|
||||||
|
build_gradle,
|
||||||
|
debug_strings,
|
||||||
|
debug_constants,
|
||||||
|
):
|
||||||
|
if not file_path.is_file():
|
||||||
|
print(
|
||||||
|
f"ERROR: required Futon file not found: {file_path}",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
text = build_gradle.read_text(encoding="utf-8")
|
def replace_exact(
|
||||||
|
file_path: Path,
|
||||||
|
name: str,
|
||||||
def replace_exact(name: str, old: str, new: str) -> None:
|
old: str,
|
||||||
global text
|
new: str,
|
||||||
|
) -> None:
|
||||||
|
text = file_path.read_text(encoding="utf-8")
|
||||||
|
|
||||||
count = text.count(old)
|
count = text.count(old)
|
||||||
|
|
||||||
if count != 1:
|
if count != 1:
|
||||||
print(
|
print(
|
||||||
f"ERROR: modification '{name}' expected exactly 1 match, found {count}",
|
f"ERROR: modification '{name}' expected exactly 1 match "
|
||||||
|
f"in {file_path}, found {count}",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
"Upstream Futon build.gradle has probably changed.",
|
"Upstream Futon has probably changed.",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
text = text.replace(old, new, 1)
|
text = text.replace(old, new, 1)
|
||||||
|
|
||||||
|
file_path.write_text(
|
||||||
|
text,
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
|
||||||
print(f"[OK] {name}")
|
print(f"[OK] {name}")
|
||||||
|
|
||||||
|
|
||||||
replace_exact(
|
replace_exact(
|
||||||
|
build_gradle,
|
||||||
"Niadd applicationId suffix",
|
"Niadd applicationId suffix",
|
||||||
"""\t\tdebug {
|
"""\t\tdebug {
|
||||||
\t\t\tapplicationIdSuffix = '.debug'
|
\t\t\tapplicationIdSuffix = '.debug'
|
||||||
@@ -57,34 +78,51 @@ replace_exact(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
build_gradle.write_text(text, encoding="utf-8")
|
replace_exact(
|
||||||
|
debug_strings,
|
||||||
|
"Niadd application name",
|
||||||
|
"""\t<string name="app_name" translatable="false">Futon Dev</string>""",
|
||||||
|
"""\t<string name="app_name" translatable="false">Futon Niadd</string>""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
values_dir = repo_dir / "app/src/debug/res/values"
|
replace_exact(
|
||||||
values_dir.mkdir(parents=True, exist_ok=True)
|
debug_constants,
|
||||||
|
"Niadd sync account type",
|
||||||
|
"""\t<string name="account_type_sync" translatable="false">org.futon.debug.sync</string>""",
|
||||||
|
"""\t<string name="account_type_sync" translatable="false">io.github.landwarderer.futon.niadd.sync</string>""",
|
||||||
|
)
|
||||||
|
|
||||||
niadd_resources = values_dir / "niadd.xml"
|
|
||||||
|
|
||||||
niadd_resources.write_text(
|
replace_exact(
|
||||||
"""<?xml version="1.0" encoding="utf-8"?>
|
debug_constants,
|
||||||
<resources>
|
"Niadd history authority",
|
||||||
<string name="app_name" translatable="false">Futon Niadd</string>
|
"""\t<string name="sync_authority_history" translatable="false">org.koitharu.futon.debug.history</string>""",
|
||||||
|
"""\t<string name="sync_authority_history" translatable="false">io.github.landwarderer.futon.niadd.history</string>""",
|
||||||
|
)
|
||||||
|
|
||||||
<string name="account_type_sync" translatable="false">io.github.landwarderer.futon.niadd.sync</string>
|
|
||||||
|
|
||||||
<string name="sync_authority_history" translatable="false">io.github.landwarderer.futon.niadd.history</string>
|
replace_exact(
|
||||||
|
debug_constants,
|
||||||
<string name="sync_authority_favourites" translatable="false">io.github.landwarderer.futon.niadd.favourites</string>
|
"Niadd favourites authority",
|
||||||
</resources>
|
"""\t<string name="sync_authority_favourites" translatable="false">org.koitharu.futon.debug.favourites</string>""",
|
||||||
""",
|
"""\t<string name="sync_authority_favourites" translatable="false">io.github.landwarderer.futon.niadd.favourites</string>""",
|
||||||
encoding="utf-8",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("[OK] Futon Niadd application variant configured")
|
print("[OK] Futon Niadd application variant configured")
|
||||||
print("[OK] applicationId: io.github.landwarderer.futon.niadd")
|
print()
|
||||||
print("[OK] app name: Futon Niadd")
|
print("Application ID:")
|
||||||
print("[OK] account type: io.github.landwarderer.futon.niadd.sync")
|
print(" io.github.landwarderer.futon.niadd")
|
||||||
print("[OK] history authority: io.github.landwarderer.futon.niadd.history")
|
print()
|
||||||
print("[OK] favourites authority: io.github.landwarderer.futon.niadd.favourites")
|
print("Application name:")
|
||||||
|
print(" Futon Niadd")
|
||||||
|
print()
|
||||||
|
print()
|
||||||
|
print("Sync account type:")
|
||||||
|
print(" io.github.landwarderer.futon.niadd.sync")
|
||||||
|
print()
|
||||||
|
print("Sync authorities:")
|
||||||
|
print(" io.github.landwarderer.futon.niadd.history")
|
||||||
|
print(" io.github.landwarderer.futon.niadd.favourites")
|
||||||
Reference in new issue
Block a user