Skip to content

Commit ec18275

Browse files
authored
strip iso-codes json and preserve its and xkeyboard-config's locale !windows (#40)
1 parent 26ee13f commit ec18275

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

.github/workflows/harmony.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Install dependencies
2727
run: |
28-
sudo apt install -y ninja-build
28+
sudo apt install -y ninja-build gettext
2929
pip install -r requirements.txt
3030
3131
- name: Install OpenHarmony SDK

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
meson==1.7.0
1+
meson==1.8.4

scripts/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def pre_package(self):
173173

174174
def package(self):
175175
os.chdir(f'{self.dest_dir}{INSTALL_PREFIX}')
176-
ensure('rm', ['-rf', 'share/locale']) # To avoid unpack symlink failure on Windows (f5h).
176+
# We will see if other packages also need locale be packaged.
177+
if self.name not in ('iso-codes', 'xkeyboard-config'):
178+
ensure('rm', ['-rf', 'share/locale'])
177179
ensure(tar, ['cj',
178180
'--sort=name', '--mtime=@0',
179181
'--numeric-owner', '--owner=0', '--group=0', '--mode=go+u,go-w',

scripts/iso-codes.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1-
from common import MakeBuilder
1+
import os
2+
from common import MakeBuilder, ensure
23

3-
MakeBuilder('iso-codes').exec()
4+
NEEDED_JSON = 'iso_639-3.json'
5+
# The only translation we need: language code/name when system doesn't recognize.
6+
# iso_639_3.mo is a symlink to it, which causes extraction error on Windows (f5h).
7+
NEEDED_MO = 'iso_639-3.mo'
8+
9+
class IsoCodesBuilder(MakeBuilder):
10+
def pre_package(self):
11+
# Keep only the needed .json file.
12+
json_path = f'{self.dest_dir}/usr/share/iso-codes/json'
13+
for filename in os.listdir(json_path):
14+
if filename != NEEDED_JSON:
15+
os.remove(f'{json_path}/{filename}')
16+
17+
# Keep only the needed .mo file.
18+
locale_path = f'{self.dest_dir}/usr/share/locale'
19+
for code in os.listdir(locale_path):
20+
code_path = f'{locale_path}/{code}'
21+
lc_messages_path = f'{code_path}/LC_MESSAGES'
22+
filenames = os.listdir(lc_messages_path)
23+
if '@' not in code and NEEDED_MO in filenames:
24+
for mo in filenames:
25+
if mo != NEEDED_MO:
26+
os.remove(f'{lc_messages_path}/{mo}')
27+
else:
28+
ensure('rm', ['-rf', code_path])
29+
30+
IsoCodesBuilder('iso-codes').exec()

0 commit comments

Comments
 (0)