This commit is contained in:
2 files changed
+321
-15
No files matched your search
@@ -0,0 +1,90 @@
|
||||
#!/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"
|
||||
|
||||
if not build_gradle.is_file():
|
||||
print(f"ERROR: build.gradle not found: {build_gradle}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
text = build_gradle.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def replace_exact(name: str, old: str, new: str) -> None:
|
||||
global text
|
||||
|
||||
count = text.count(old)
|
||||
|
||||
if count != 1:
|
||||
print(
|
||||
f"ERROR: modification '{name}' expected exactly 1 match, found {count}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
"Upstream Futon build.gradle has probably changed.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
text = text.replace(old, new, 1)
|
||||
print(f"[OK] {name}")
|
||||
|
||||
|
||||
replace_exact(
|
||||
"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}
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
build_gradle.write_text(text, encoding="utf-8")
|
||||
|
||||
|
||||
values_dir = repo_dir / "app/src/debug/res/values"
|
||||
values_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
niadd_resources = values_dir / "niadd.xml"
|
||||
|
||||
niadd_resources.write_text(
|
||||
"""<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name" translatable="false">Futon Niadd</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>
|
||||
|
||||
<string name="sync_authority_favourites" translatable="false">io.github.landwarderer.futon.niadd.favourites</string>
|
||||
</resources>
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
print()
|
||||
print("[OK] Futon Niadd application variant configured")
|
||||
print("[OK] applicationId: io.github.landwarderer.futon.niadd")
|
||||
print("[OK] app name: Futon Niadd")
|
||||
print("[OK] account type: io.github.landwarderer.futon.niadd.sync")
|
||||
print("[OK] history authority: io.github.landwarderer.futon.niadd.history")
|
||||
print("[OK] favourites authority: io.github.landwarderer.futon.niadd.favourites")
|
||||
Reference in new issue
Block a user