This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split arch-unspecific data to save space and bandwidth (#34)
- Loading branch information
1 parent
b5700da
commit 4db1c22
Showing
15 changed files
with
222 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
|
||
plugins = { | ||
"x86_64": {}, | ||
"arm64": {} | ||
} | ||
|
||
for arch in ("arm64", "x86_64"): | ||
with open(f"meta-{arch}.json") as f: | ||
meta = json.load(f) | ||
for plugin in meta["plugins"]: | ||
plugins[arch][plugin["name"]] = plugin | ||
|
||
all_plugins = sorted(set(plugins["x86_64"].keys()) | set(plugins["arm64"].keys())) | ||
|
||
print("## Arch comparison") | ||
print("-|x86_64|arm64|any") | ||
print("-|-|-|-") | ||
for plugin in all_plugins: | ||
x86_64 = plugins["x86_64"].get(plugin) | ||
arm64 = plugins["arm64"].get(plugin) | ||
if not x86_64: | ||
(x, a, d) = ("💀️", "❌", "❌") | ||
elif not arm64: | ||
(x, a, d) = ("❌", "💀️", "❌") | ||
else: | ||
if "version" in x86_64: | ||
x = "✅" | ||
else: | ||
x = "❌" | ||
if "version" in arm64: | ||
a = "✅" | ||
else: | ||
a = "❌" | ||
if "data_version" not in x86_64 or "data_version" not in arm64: | ||
d = "💀️" | ||
elif x86_64["data_version"] != arm64["data_version"]: | ||
d = "❌" | ||
else: | ||
d = "✅" | ||
print(f"{plugin}|{x}|{a}|{d}") | ||
|
||
print(f"\n{len(all_plugins)} plugins in total.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
import json | ||
import os | ||
import subprocess | ||
import sys | ||
from dirhash import dirhash | ||
|
||
input_methods = sys.argv[1:] | ||
|
||
cwd = os.getcwd() | ||
data_dir = f"{cwd}/../data" | ||
plugin = cwd.split("/")[-3] # /path/to/rime/tmp/fcitx5 | ||
files: list[str] = [] | ||
|
||
for dirpath, _, filenames in os.walk(cwd): | ||
if dirpath == "plugin": | ||
continue | ||
for filename in filenames: | ||
files.append(f"{dirpath[len(cwd) + 1:]}/{filename}") | ||
for wd in (cwd, data_dir): | ||
for dirpath, _, filenames in os.walk(wd): | ||
if dirpath == f"{wd}/plugin": | ||
continue | ||
for filename in filenames: | ||
files.append(f"{dirpath[len(wd) + 1:]}/{filename}") | ||
|
||
try: | ||
version = dirhash(cwd, "md5", ignore=["plugin"]) | ||
except: | ||
# pure data plugin | ||
version = None | ||
|
||
def getVersion(): | ||
# XXX: it causes unnecessary update when the plugin is not changed | ||
result = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, text=True) | ||
return result.stdout.strip() | ||
data_version = dirhash(data_dir, "md5") | ||
|
||
plugin_dir = f"{data_dir}/plugin" | ||
|
||
version = getVersion() | ||
|
||
os.makedirs("plugin", exist_ok=True) | ||
with open(f"plugin/{plugin}.json", "w") as f: | ||
os.makedirs(plugin_dir, exist_ok=True) | ||
with open(f"{plugin_dir}/{plugin}.json", "w") as f: | ||
descriptor = { | ||
"version": version, | ||
"data_version": data_version, | ||
"files": files | ||
} | ||
if version: | ||
descriptor["version"] = version | ||
if input_methods: | ||
descriptor["input_methods"] = input_methods | ||
json.dump(descriptor, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
|
||
plugins = { | ||
"array": [ | ||
"array30", | ||
"array30-large", | ||
], | ||
"boshiamy": [ | ||
"boshiamy" | ||
], | ||
"cangjie": [ | ||
"cangjie5", | ||
"cangjie3", | ||
"cangjie-large", | ||
"scj6" | ||
], | ||
"cantonese": [ | ||
"cantonese", | ||
"cantonhk", | ||
"jyutping-table" | ||
], | ||
"quick": [ | ||
"quick5", | ||
"quick3", | ||
"quick-classic", | ||
"easy-large" | ||
], | ||
"stroke": [ | ||
"t9", | ||
"stroke5" | ||
], | ||
"wu": [ | ||
"wu" | ||
], | ||
"wubi86": [ | ||
"wubi-large" | ||
], | ||
"wubi98": [ | ||
"wubi98", | ||
"wubi98-single", | ||
"wubi98-large", | ||
"wubi98-pinyin" | ||
], | ||
"zhengma": [ | ||
"zhengma", | ||
"zhengma-large", | ||
"zhengma-pinyin" | ||
] | ||
} | ||
|
||
|
||
def ensure(command: str): | ||
if os.system(command) != 0: | ||
exit(1) | ||
|
||
|
||
build_dir = os.getcwd() | ||
|
||
# split table-extra to plugins and keep directory structures so the package script can be reused | ||
for plugin, ims in plugins.items(): | ||
ensure(f"rm -rf {plugin}") | ||
ensure(f"mkdir -p {plugin}/" + "tmp/data/share/fcitx5/{inputmethod,table}") | ||
ensure(f"mkdir -p {plugin}/tmp/fcitx5") | ||
|
||
# equivalent to f5m_split_data | ||
for im in ims: | ||
ensure(f"mv table-extra/tmp/fcitx5/share/fcitx5/inputmethod/{im}.conf {plugin}/tmp/data/share/fcitx5/inputmethod") | ||
ensure(f"mv table-extra/tmp/fcitx5/share/fcitx5/table/{im}.main.dict {plugin}/tmp/data/share/fcitx5/table") | ||
|
||
os.chdir(f"{plugin}/tmp/fcitx5") | ||
ensure(f"python {build_dir}/../generate-descriptor.py {ims[0]}") | ||
os.chdir("../data") | ||
ensure(f"tar cjvf {build_dir}/{plugin}-any.tar.bz2 *") | ||
os.chdir(build_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ install_deps libthai | |
f5m_configure | ||
f5m_build | ||
f5m_install | ||
f5m_split_data | ||
f5m_make_tarball libthai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters