From: yzewei <[email protected]>

This patch combines previous v1 and v2 patches, Please ignore previous patches 
v1 and v2.

- Remove obsolete RISC-V ports setup for Debian 13+
  Debian 13 and later officially support riscv64, so the old
  debian-ports archive keyring and sources.list configuration
  are no longer necessary.

- Add validation to forbid RISC-V cross compilation on Debian < 13
  Ensures that cross compiling for riscv64 on unsupported Debian
  releases fails early with a clear error message.

Signed-off-by: yzewei <[email protected]>
---
 lcitool/formatters.py | 15 ---------------
 lcitool/projects.py   |  2 +-
 lcitool/util.py       |  4 +++-
 3 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/lcitool/formatters.py b/lcitool/formatters.py
index c26cf22a..af171fae 100644
--- a/lcitool/formatters.py
+++ b/lcitool/formatters.py
@@ -456,21 +456,6 @@ class BuildEnvFormatter(Formatter):
                     "dpkg --add-architecture {cross_arch_deb}",
                 ]
             )
-            if target.cross_arch == "riscv64":
-                cross_commands.extend(
-                    [
-                        "{nosync}{packaging_command} install 
debian-ports-archive-keyring",
-                        "{nosync}echo 'deb 
http://ftp.ports.debian.org/debian-ports/ sid main' > 
/etc/apt/sources.list.d/ports.list",
-                        "{nosync}echo 'deb 
http://ftp.ports.debian.org/debian-ports/ unreleased main' >> 
/etc/apt/sources.list.d/ports.list",
-                    ]
-                )
-            cross_commands.extend(
-                [
-                    "{nosync}{packaging_command} update",
-                    "{nosync}{packaging_command} dist-upgrade -y",
-                    "{nosync}{packaging_command} install 
--no-install-recommends -y dpkg-dev",
-                ]
-            )
             if varmap["cross_pkgs"]:
                 cross_commands.extend(
                     [
diff --git a/lcitool/projects.py b/lcitool/projects.py
index f1187cb2..0324f21a 100644
--- a/lcitool/projects.py
+++ b/lcitool/projects.py
@@ -270,7 +270,7 @@ class Project:
             target_name = f"{target_name}"
         else:
             try:
-                util.validate_cross_platform(target.cross_arch, osname)
+                util.validate_cross_platform(target.cross_arch, osname, 
osversion)
             except ValueError as ex:
                 raise ProjectError(str(ex))
             target_name = f"{target_name}-{target.cross_arch}-cross"
diff --git a/lcitool/util.py b/lcitool/util.py
index 3f5cb870..aedf3882 100644
--- a/lcitool/util.py
+++ b/lcitool/util.py
@@ -409,10 +409,12 @@ class DataDir:
         return result
 
 
-def validate_cross_platform(cross_arch: str, osname: str) -> None:
+def validate_cross_platform(cross_arch: str, osname: str, osversion: str) -> 
None:
     if osname not in ["Debian", "Fedora"]:
         raise ValueError(f"Cannot cross compile on {osname}")
     if osname == "Debian" and cross_arch.startswith("mingw"):
         raise ValueError(f"Cannot cross compile for {cross_arch} on {osname}")
     if osname == "Fedora" and not cross_arch.startswith("mingw"):
         raise ValueError(f"Cannot cross compile for {cross_arch} on {osname}")
+    if osname == "Debian" and cross_arch == "riscv64" and 
int(osversion.split('.')[0]) < 13:
+        raise ValueError(f"Cross compiling for {cross_arch} is not supported 
on Debian < 13")
-- 
2.43.0

Reply via email to