Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ubuntu jammy, noble, and oracular with their appropriate qt #791

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kiwixbuild/buildenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def __init__(self, dummy_run):
def detect_platform(self):
_platform = platform.system()
self.distname = _platform
self.codename = ""
if _platform == "Linux":
self.distname = distro.id()
if self.distname == "ubuntu":
self.distname = "debian"
self.codename = distro.codename()

def download(self, what, where=None):
where = where or self.archive_dir
Expand Down
23 changes: 22 additions & 1 deletion kiwixbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,23 @@ def build(self):
def _get_packages(self):
packages_list = []
for config in ConfigInfo.all_running_configs.values():
# get {host}_{config} packages
mapper_name = "{host}_{config}".format(
host=neutralEnv("distname"), config=config
)
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
packages_list += package_name_mapper.get("COMMON", [])
# get {host}_{codename}_{config} packages
mapper_name = "{host}_{codename}_{config}".format(
host=neutralEnv("distname"), codename=neutralEnv("codename"), config=config
)
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
packages_list += package_name_mapper.get("COMMON", [])

Comment on lines 127 to 140
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the code duplication introduced here and in the other change in this (_get_packages()) function.

You can avoid it with the help of an auxiliary function _get_mapper_names_for_config(config):

def _get_mapper_names_for_config(config):
    host = neutralEnv("distname")
    codename = neutralEnv("codename")
    return ( f"{host}_{config}", f"{host}_{codename}_{config}" )

Then your code here will turn into:

        for config in ConfigInfo.all_running_configs.values():
            for mapper_name in _get_mapper_names_for_config(config):
                package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
                packages_list += package_name_mapper.get("COMMON", [])

to_drop = []
for builderDef in self._targets:
configName, builderName = builderDef
# get {host}_{config} packages
mapper_name = "{host}_{config}".format(
host=neutralEnv("distname"), config=configName
)
Expand All @@ -144,6 +152,19 @@ def _get_packages(self):
if packages is not True:
# True means "assume the dependency is install but do not try to install anything for it"
packages_list += packages

# get {host}_{codename}_{config} packages
mapper_name = "{host}_{codename}_{config}".format(
host=neutralEnv("distname"), codename=neutralEnv("codename"), config=configName
)
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
packages = package_name_mapper.get(builderName)
if packages:
to_drop.append(builderDef)
if packages is not True:
# True means "assume the dependency is install but do not try to install anything for it"
packages_list += packages

Comment on lines +155 to +167
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of this code duplication taking advantage of _get_mapper_names_for_config() like proposed in the previous comment.

for dep in to_drop:
del self._targets[dep]
return packages_list
Expand All @@ -160,7 +181,7 @@ def install_packages(self):
if distname in ("fedora", "redhat", "centos"):
package_installer = "sudo dnf install {}"
package_checker = "rpm -q --quiet {}"
elif distname in ("debian", "Ubuntu"):
elif distname in ("debian", "ubuntu"):
package_installer = "sudo apt-get install {}"
package_checker = 'LANG=C dpkg -s {} 2>&1 | grep Status | grep "ok installed" 1>/dev/null 2>&1'
elif distname == "Darwin":
Expand Down
2 changes: 1 addition & 1 deletion kiwixbuild/configs/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AndroidConfigInfo(ConfigInfo):
build = "android"
static = True
toolchain_names = ["android-ndk"]
compatible_hosts = ["fedora", "debian"]
compatible_hosts = ["fedora", "debian", "ubuntu"]

def __str__(self):
return "android"
Expand Down
2 changes: 1 addition & 1 deletion kiwixbuild/configs/armhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Base config for arm
class ArmConfigInfo(ConfigInfo):
compatible_hosts = ["fedora", "debian", "almalinux"]
compatible_hosts = ["fedora", "debian", "ubuntu", "almalinux"]

def get_cross_config(self):
return {
Expand Down
2 changes: 1 addition & 1 deletion kiwixbuild/configs/flatpak.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FlatpakConfigInfo(ConfigInfo):
build = "flatpak"
static = ""
toolchain_names = ["org.kde", "io.qt.qtwebengine"]
compatible_hosts = ["debian", "fedora"]
compatible_hosts = ["debian", "ubuntu", "fedora"]

def __str__(self):
return "flatpak"
Expand Down
2 changes: 1 addition & 1 deletion kiwixbuild/configs/i586.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class I586ConfigInfo(ConfigInfo):
build = "i586"
arch_full = "i586-linux-gnu"
compatible_hosts = ["fedora", "debian"]
compatible_hosts = ["fedora", "debian", "ubuntu"]

def get_cross_config(self):
return {
Expand Down
2 changes: 1 addition & 1 deletion kiwixbuild/configs/musl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class MuslConfigInfo(ConfigInfo):
compatible_hosts = ["fedora", "debian"]
compatible_hosts = ["fedora", "debian", "ubuntu"]

def get_cross_config(self):
return {
Expand Down
6 changes: 3 additions & 3 deletions kiwixbuild/configs/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def arch_name(self):
class NativeDyn(NativeConfigInfo):
name = "native_dyn"
static = False
compatible_hosts = ["fedora", "debian", "Darwin", "almalinux", "Windows"]
compatible_hosts = ["fedora", "debian", "ubuntu", "Darwin", "almalinux", "Windows"]


class NativeStatic(NativeConfigInfo):
name = "native_static"
static = True
compatible_hosts = ["fedora", "debian", "Darwin", "almalinux", "Windows"]
compatible_hosts = ["fedora", "debian", "ubuntu", "Darwin", "almalinux", "Windows"]


class NativeMixed(MixedMixin("native_static"), NativeConfigInfo):
name = "native_mixed"
static = False
compatible_hosts = ["fedora", "debian", "Darwin", "almalinux", "Windows"]
compatible_hosts = ["fedora", "debian", "ubuntu", "Darwin", "almalinux", "Windows"]
2 changes: 1 addition & 1 deletion kiwixbuild/configs/neutral.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class NeutralConfigInfo(ConfigInfo):
name = "neutral"
arch_name = "neutral"
static = ""
compatible_hosts = ["fedora", "debian", "Darwin"]
compatible_hosts = ["fedora", "debian", "ubuntu", "Darwin"]

def __str__(self):
return "neutral"
2 changes: 1 addition & 1 deletion kiwixbuild/configs/wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class WasmConfigInfo(ConfigInfo):
libdir = "lib"
# arch_full = 'wasm64-linux'
toolchain_names = ["emsdk"]
compatible_hosts = ["fedora", "debian"]
compatible_hosts = ["fedora", "debian", "ubuntu"]
exe_wrapper_def = ""

def get_cross_config(self):
Expand Down
2 changes: 1 addition & 1 deletion kiwixbuild/configs/win64.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Win64ConfigInfo(ConfigInfo):
"-lkernel32",
]
build = "win64"
compatible_hosts = ["fedora", "debian"]
compatible_hosts = ["fedora", "debian", "ubuntu"]
arch_full = "x86_64-w64-mingw32"

def get_cross_config(self):
Expand Down
30 changes: 30 additions & 0 deletions kiwixbuild/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,36 @@
"debian_android": {
"COMMON": _debian_common,
},
"ubuntu_jammy_native_dyn": {
"COMMON": _debian_common,
"zlib": ["zlib1g-dev"],
"uuid": ["uuid-dev"],
"libmicrohttpd": ["libmicrohttpd-dev", "ccache"],
"qt": ["libqt5gui5", "qtbase5-dev", "libqt5svg5-dev", "qt5-image-formats-plugins"],
"qtwebengine": ["qtwebengine5-dev"],
"aria2": ["aria2"],
},
"ubuntu_noble_native_dyn": {
"COMMON": _debian_common,
"zlib": ["zlib1g-dev"],
"uuid": ["uuid-dev"],
"libmicrohttpd": ["libmicrohttpd-dev", "ccache"],
"qt": ["qt6-base-dev", "qt6-base-dev-tools", "libqt6webenginecore6-bin", "libqt6svg6", "qtchooser"],
"qtwebengine": ["qt6-webengine-dev"],
"aria2": ["aria2"],
},
"ubuntu_oracular_native_dyn": {
"COMMON": _debian_common,
"zlib": ["zlib1g-dev"],
"uuid": ["uuid-dev"],
"libmicrohttpd": ["libmicrohttpd-dev", "ccache"],
"qt": ["qt6-base-dev", "qt6-base-dev-tools", "libqt6webenginecore6-bin", "libqt6svg6", "qtchooser"],
"qtwebengine": ["qt6-webengine-dev"],
"aria2": ["aria2"],
},
"ubuntu_native_static": {
"COMMON": _debian_common + ["libbz2-dev", "libmagic-dev"],
},
"Darwin_native_dyn": {
"COMMON": ["autoconf", "automake", "libtool", "cmake", "pkg-config"],
"file": ["libmagic"],
Expand Down
Loading