add initial loong64 support

This commit is contained in:
Jianfeng Liu
2025-07-24 09:39:42 +08:00
parent dda6950c34
commit fb363e8829
17 changed files with 5240 additions and 6 deletions

View File

@@ -385,6 +385,7 @@ function kernel_package_callback_linux_headers() {
[[ "${SRC_ARCH}" == "amd64" ]] && SRC_ARCH="x86"
[[ "${SRC_ARCH}" == "armhf" ]] && SRC_ARCH="arm"
[[ "${SRC_ARCH}" == "riscv64" ]] && SRC_ARCH="riscv"
[[ "${SRC_ARCH}" == "loong64" ]] && SRC_ARCH="loongarch"
# @TODO: added KERNEL_SRC_ARCH to each arch'es .config file; let's make sure they're sane. Just use KERNEL_SRC_ARCH after confirmed.
# Lets check and warn if it isn't. If warns don't popup over time we remove and just use ARCHITECTURE later.
if [[ "${SRC_ARCH}" != "${KERNEL_SRC_ARCH}" ]]; then

View File

@@ -318,7 +318,8 @@ function do_main_configuration() {
esac
# enable APA extension for Debian Unstable release
[ "$RELEASE" = "sid" ] && enable_extension "apa"
# loong64 is not supported now
[ "$RELEASE" = "sid" ] && [ "$ARCH" != "loong64" ] && enable_extension "apa"
## Extensions: at this point we've sourced all the config files that will be used,
## and (hopefully) not yet invoked any extension methods. So this is the perfect
@@ -370,6 +371,8 @@ function do_extra_configuration() {
fi
DEBIAN_MIRROR='deb.debian.org/debian'
# loong64 is using debian-ports repo now
[[ "${ARCH}" == "loong64" ]] && DEBIAN_MIRROR='deb.debian.org/debian-ports'
DEBIAN_SECURITY='security.debian.org/'
[[ "${ARCH}" == "amd64" ]] &&
UBUNTU_MIRROR='archive.ubuntu.com/ubuntu/' ||

View File

@@ -39,6 +39,8 @@ function apt_find_upstream_package_version_and_download_url() {
fi
declare base_down_url="http://${mirror_with_slash}pool/main/${first_letter_of_sought_package_name}/${sought_package_name}"
# loong64 is using debian-ports repo, and download from pool-loong64
[[ "${ARCH}" == "loong64" ]] && declare base_down_url="http://${mirror_with_slash}pool-loong64/main/${first_letter_of_sought_package_name}/${sought_package_name}"
# get json with latest pacakge info generated by GHA
case "${GITHUB_MIRROR}" in

View File

@@ -52,6 +52,11 @@ function run_tool_oras() {
ORAS_ARCH="riscv64"
ORAS_VERSION="1.2.0-beta.1" # Only v1.2.0-beta.1+ has risv64 support
;;
*loongarch64*)
ORAS_ARCH="loong64"
ORAS_VERSION="1.3.0-beta.3-loong64" # Only v1.3.0-beta.3-loong64+ has loong64 support
ORAS_REPO="amazingfate" # This is my fork repo, we can delete it if oras releases official loong64 binary in the future
;;
*)
exit_with_error "unknown arch: $MACHINE"
;;
@@ -59,7 +64,7 @@ function run_tool_oras() {
declare ORAS_FN="oras_${ORAS_VERSION}_${ORAS_OS}_${ORAS_ARCH}"
declare ORAS_FN_TARXZ="${ORAS_FN}.tar.gz"
declare DOWN_URL="${GITHUB_SOURCE:-"https://github.com"}/oras-project/oras/releases/download/v${ORAS_VERSION}/${ORAS_FN_TARXZ}"
declare DOWN_URL="${GITHUB_SOURCE:-"https://github.com"}/${ORAS_REPO:-"oras-project"}/oras/releases/download/v${ORAS_VERSION}/${ORAS_FN_TARXZ}"
declare ORAS_BIN="${DIR_ORAS}/${ORAS_FN}"
declare ACTUAL_VERSION

View File

@@ -92,6 +92,11 @@ function run_tool_shellcheck() {
display_alert "No RISC-V riscv64 support for SHELLCHECK" "SHELLCHECK will not run" "wrn"
return 0
;;
*loongarch64*)
# check https://github.com/koalaman/shellcheck in the future, build might be possible
display_alert "No LoongArch support for SHELLCHECK" "SHELLCHECK will not run" "wrn"
return 0
;;
*)
exit_with_error "unknown arch: $MACHINE"
;;

View File

@@ -18,7 +18,7 @@ function obtain_and_check_host_release_and_arch() {
case "${HOSTARCH}" in
amd64 | arm64) ;; # officially supported
armhf | riscv64) # experimental
armhf | riscv64 | loong64) # experimental
display_alert "EXPERIMENTAL build host support" "${HOSTARCH}" "wrn"
;;
*)

View File

@@ -269,6 +269,11 @@ function adaptative_prepare_host_dependencies() {
host_dependencies+=("debian-archive-keyring")
fi
if [[ "${wanted_arch}" == "loong64" || "${wanted_arch}" == "all" ]]; then
host_dependencies+=("gcc-loongarch64-linux-gnu") # crossbuild-essential-loongarch64 is not even available "yet"
host_dependencies+=("debian-ports-archive-keyring")
fi
if [[ "${wanted_arch}" != "amd64" ]]; then
host_dependencies+=("libc6-amd64-cross") # Support for running x86 binaries (under qemu on other arches)
fi

View File

@@ -121,13 +121,19 @@ function create_sources_list_and_deploy_repo_key() {
sid | unstable)
distro="debian"
if [[ "${ARCH}" == loong64 ]]; then
# loong64 is using debian-ports repo, we can change it to default after debian supports it officially
keyring_filename=/usr/share/keyrings/debian-ports-archive-keyring.gpg
else
keyring_filename=/usr/share/keyrings/debian-archive-keyring.gpg
fi
# sid is permanent unstable development and has no such thing as updates or security
cat <<- EOF > "${basedir}/etc/apt/sources.list.d/${distro}.sources"
Types: deb
URIs: http://${DEBIAN_MIRROR}
Suites: ${release}
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Signed-By: ${keyring_filename}
EOF
# Required for some packages on riscv64.

View File

@@ -98,6 +98,8 @@ function create_new_rootfs_cache_via_debootstrap() {
"'--components=${AGGREGATED_DEBOOTSTRAP_COMPONENTS_COMMA}'" # from aggregation.py
)
# This is necessary to debootstrap from a non-official repo
[[ $ARCH == loong64 ]] && deboostrap_arguments+=("--keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg")
# Small detour for local apt caching option.
local_apt_deb_cache_prepare "before debootstrap" # sets LOCAL_APT_CACHE_INFO
if [[ "${LOCAL_APT_CACHE_INFO[USE]}" == "yes" ]]; then