Build Futon with Niadd patch / Build Futon Niadd debug APK (push) Failing after 12m44s
129 lines
3.1 KiB
Python
129 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
|
|
if len(sys.argv) != 2:
|
|
print(f"Usage: {sys.argv[0]} <Futon-dir>", file=sys.stderr)
|
|
sys.exit(2)
|
|
|
|
|
|
repo_dir = Path(sys.argv[1]).resolve()
|
|
|
|
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"
|
|
|
|
|
|
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)
|
|
|
|
|
|
def replace_exact(
|
|
file_path: Path,
|
|
name: str,
|
|
old: str,
|
|
new: str,
|
|
) -> None:
|
|
text = file_path.read_text(encoding="utf-8")
|
|
|
|
count = text.count(old)
|
|
|
|
if count != 1:
|
|
print(
|
|
f"ERROR: modification '{name}' expected exactly 1 match "
|
|
f"in {file_path}, found {count}",
|
|
file=sys.stderr,
|
|
)
|
|
print(
|
|
"Upstream Futon has probably changed.",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
|
|
text = text.replace(old, new, 1)
|
|
|
|
file_path.write_text(
|
|
text,
|
|
encoding="utf-8",
|
|
)
|
|
|
|
print(f"[OK] {name}")
|
|
|
|
|
|
replace_exact(
|
|
build_gradle,
|
|
"Niadd applicationId suffix",
|
|
"""\t\tdebug {
|
|
\t\t\tapplicationIdSuffix = '.debug'
|
|
\t\t\tbuildConfigField "String", "SENTRY_DSN", '""'
|
|
\t\t}
|
|
""",
|
|
"""\t\tdebug {
|
|
\t\t\tapplicationIdSuffix = '.niadd'
|
|
\t\t\tversionNameSuffix = '-Niadd'
|
|
\t\t\tbuildConfigField "String", "SENTRY_DSN", '""'
|
|
\t\t}
|
|
""",
|
|
)
|
|
|
|
|
|
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>""",
|
|
)
|
|
|
|
|
|
replace_exact(
|
|
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>""",
|
|
)
|
|
|
|
|
|
replace_exact(
|
|
debug_constants,
|
|
"Niadd history authority",
|
|
"""\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>""",
|
|
)
|
|
|
|
|
|
replace_exact(
|
|
debug_constants,
|
|
"Niadd favourites authority",
|
|
"""\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>""",
|
|
)
|
|
|
|
|
|
print()
|
|
print("[OK] Futon Niadd application variant configured")
|
|
print()
|
|
print("Application ID:")
|
|
print(" io.github.landwarderer.futon.niadd")
|
|
print()
|
|
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")
|