build: Add sysroot creator script

This commit is contained in:
klzgrad 2019-10-05 15:52:34 +08:00
parent 72807d15b1
commit 716e2a83ba
4 changed files with 41 additions and 434 deletions

View File

@ -9,8 +9,14 @@ set -o errexit
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
KEYS=( KEYS=(
# Debian Ports Archive Automatic Signing Key (2023)
"B523E5F3FC4E5F2C"
# Debian Ports Archive Automatic Signing Key (2024)
"8D69674688B6CB36"
# Debian Archive Automatic Signing Key (12/bookworm) # Debian Archive Automatic Signing Key (12/bookworm)
"6ED0E7B82643E131" "B7C5D7D6350947F8"
# Debian Security Archive Automatic Signing Key (12/bookworm)
"254CF3B5AEC0A8F0"
# Debian Stable Release Key (12/bookworm) # Debian Stable Release Key (12/bookworm)
"F8D2585B8783D481" "F8D2585B8783D481"
# Debian Archive Automatic Signing Key (11/bullseye) # Debian Archive Automatic Signing Key (11/bullseye)

View File

@ -35,7 +35,7 @@ from urllib.request import urlopen
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPT_DIR))) SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPT_DIR)))
VALID_ARCHS = ('amd64', 'i386', 'armhf', 'arm64', 'armel', 'mipsel', 'mips64el') VALID_ARCHS = ('amd64', 'i386', 'armhf', 'arm64', 'armel', 'mipsel', 'mips64el', 'riscv64')
ARCH_TRANSLATIONS = { ARCH_TRANSLATIONS = {
'x64': 'amd64', 'x64': 'amd64',

View File

@ -39,10 +39,6 @@ ARCHIVE_TIMESTAMP = "20230611T210420Z"
ARCHIVE_URL = f"https://snapshot.debian.org/archive/debian/{ARCHIVE_TIMESTAMP}/" ARCHIVE_URL = f"https://snapshot.debian.org/archive/debian/{ARCHIVE_TIMESTAMP}/"
APT_SOURCES_LIST = [ APT_SOURCES_LIST = [
# Debian 12 (Bookworm) is needed for GTK4. It should be kept before
# bullseye so that bullseye takes precedence.
("bookworm", ["main"]),
("bookworm-updates", ["main"]),
# This mimics a sources.list from bullseye. # This mimics a sources.list from bullseye.
("bullseye", ["main", "contrib", "non-free"]), ("bullseye", ["main", "contrib", "non-free"]),
("bullseye-updates", ["main", "contrib", "non-free"]), ("bullseye-updates", ["main", "contrib", "non-free"]),
@ -57,6 +53,7 @@ TRIPLES = {
"armel": "arm-linux-gnueabi", "armel": "arm-linux-gnueabi",
"mipsel": "mipsel-linux-gnu", "mipsel": "mipsel-linux-gnu",
"mips64el": "mips64el-linux-gnuabi64", "mips64el": "mips64el-linux-gnuabi64",
"riscv64": "riscv64-linux-gnu",
} }
REQUIRED_TOOLS = [ REQUIRED_TOOLS = [
@ -75,463 +72,52 @@ RELEASE_FILE_GPG = "Release.gpg"
# Packages common to all architectures. # Packages common to all architectures.
DEBIAN_PACKAGES = [ DEBIAN_PACKAGES = [
"comerr-dev",
"krb5-multidev",
"libasound2",
"libasound2-dev",
"libasyncns0",
"libatk-bridge2.0-0",
"libatk-bridge2.0-dev",
"libatk1.0-0",
"libatk1.0-dev",
"libatomic1", "libatomic1",
"libatspi2.0-0",
"libatspi2.0-dev",
"libattr1",
"libaudit1",
"libavahi-client3",
"libavahi-common3",
"libb2-1",
"libblkid-dev",
"libblkid1",
"libbluetooth-dev",
"libbluetooth3",
"libbrotli-dev",
"libbrotli1",
"libbsd0",
"libc6", "libc6",
"libc6-dev", "libc6-dev",
"libcairo-gobject2",
"libcairo-script-interpreter2",
"libcairo2",
"libcairo2-dev",
"libcap-dev",
"libcap-ng0",
"libcap2",
"libcloudproviders0",
"libcolord2",
"libcom-err2",
"libcrypt-dev",
"libcrypt1", "libcrypt1",
"libcups2",
"libcups2-dev",
"libcupsimage2",
"libcupsimage2-dev",
"libcurl3-gnutls",
"libcurl4-gnutls-dev",
"libdatrie-dev",
"libdatrie1",
"libdb5.3",
"libdbus-1-3",
"libdbus-1-dev",
"libdbus-glib-1-2",
"libdbusmenu-glib-dev",
"libdbusmenu-glib4",
"libdbusmenu-gtk3-4",
"libdbusmenu-gtk4",
"libdeflate-dev",
"libdeflate0",
"libdouble-conversion3",
"libdrm-amdgpu1",
"libdrm-dev",
"libdrm-nouveau2",
"libdrm-radeon1",
"libdrm2",
"libegl-dev",
"libegl1",
"libegl1-mesa",
"libegl1-mesa-dev",
"libelf-dev",
"libelf1",
"libepoxy-dev",
"libepoxy0",
"libevdev-dev",
"libevdev2",
"libevent-2.1-7",
"libexpat1",
"libexpat1-dev",
"libffi-dev",
"libffi7",
"libflac-dev",
"libflac8",
"libfontconfig-dev",
"libfontconfig1",
"libfreetype-dev",
"libfreetype6",
"libfribidi-dev",
"libfribidi0",
"libgbm-dev",
"libgbm1",
"libgcc-10-dev", "libgcc-10-dev",
"libgcc-s1", "libgcc-s1",
"libgcrypt20",
"libgcrypt20-dev",
"libgdk-pixbuf-2.0-0",
"libgdk-pixbuf-2.0-dev",
"libgl-dev",
"libgl1",
"libgl1-mesa-dev",
"libgl1-mesa-glx",
"libglapi-mesa",
"libgles-dev",
"libgles1",
"libgles2",
"libglib2.0-0",
"libglib2.0-dev",
"libglvnd-dev",
"libglvnd0",
"libglx-dev",
"libglx0",
"libgmp10",
"libgnutls-dane0",
"libgnutls-openssl27",
"libgnutls28-dev",
"libgnutls30",
"libgnutlsxx28",
"libgomp1", "libgomp1",
"libgpg-error-dev",
"libgpg-error0",
"libgraphene-1.0-0",
"libgraphene-1.0-dev",
"libgraphite2-3",
"libgraphite2-dev",
"libgssapi-krb5-2",
"libgssrpc4",
"libgtk-3-0",
"libgtk-3-dev",
"libgtk-4-1",
"libgtk-4-dev",
"libgtk2.0-0",
"libgudev-1.0-0",
"libharfbuzz-dev",
"libharfbuzz-gobject0",
"libharfbuzz-icu0",
"libharfbuzz0b",
"libhogweed6",
"libice6",
"libicu-le-hb0",
"libicu67",
"libidl-2-0",
"libidn11",
"libidn2-0",
"libinput-dev",
"libinput10",
"libjbig-dev",
"libjbig0",
"libjpeg62-turbo",
"libjpeg62-turbo-dev",
"libjson-glib-1.0-0",
"libjsoncpp-dev",
"libjsoncpp24",
"libk5crypto3",
"libkadm5clnt-mit12",
"libkadm5srv-mit12",
"libkdb5-10",
"libkeyutils1",
"libkrb5-3",
"libkrb5-dev",
"libkrb5support0",
"liblcms2-2",
"libldap-2.4-2",
"liblerc4",
"libltdl7",
"liblz4-1",
"liblzma5",
"liblzo2-2",
"libmd0",
"libmd4c0",
"libminizip-dev",
"libminizip1",
"libmount-dev",
"libmount1",
"libmtdev1",
"libncurses-dev",
"libncurses6",
"libncursesw6",
"libnettle8",
"libnghttp2-14",
"libnsl2",
"libnspr4",
"libnspr4-dev",
"libnss-db",
"libnss3",
"libnss3-dev",
"libogg-dev",
"libogg0",
"libopengl0",
"libopus-dev",
"libopus0",
"libp11-kit0",
"libpam0g",
"libpam0g-dev",
"libpango-1.0-0",
"libpango1.0-dev",
"libpangocairo-1.0-0",
"libpangoft2-1.0-0",
"libpangox-1.0-0",
"libpangoxft-1.0-0",
"libpci-dev",
"libpci3",
"libpciaccess0",
"libpcre16-3",
"libpcre2-16-0",
"libpcre2-32-0",
"libpcre2-8-0",
"libpcre2-dev",
"libpcre2-posix2",
"libpcre3",
"libpcre3-dev",
"libpcre32-3",
"libpcrecpp0v5",
"libpipewire-0.3-0",
"libpipewire-0.3-dev",
"libpixman-1-0",
"libpixman-1-dev",
"libpng-dev",
"libpng16-16",
"libproxy1v5",
"libpsl5",
"libpthread-stubs0-dev",
"libpulse-dev",
"libpulse-mainloop-glib0",
"libpulse0",
"libqt5concurrent5",
"libqt5core5a",
"libqt5dbus5",
"libqt5gui5",
"libqt5network5",
"libqt5printsupport5",
"libqt5sql5",
"libqt5test5",
"libqt5widgets5",
"libqt5xml5",
"libqt6concurrent6",
"libqt6core6",
"libqt6dbus6",
"libqt6gui6",
"libqt6network6",
"libqt6opengl6",
"libqt6openglwidgets6",
"libqt6printsupport6",
"libqt6sql6",
"libqt6test6",
"libqt6widgets6",
"libqt6xml6",
"libre2-9",
"libre2-dev",
"librest-0.7-0",
"librtmp1",
"libsasl2-2",
"libselinux1",
"libselinux1-dev",
"libsepol1",
"libsepol1-dev",
"libsm6",
"libsnappy-dev",
"libsnappy1v5",
"libsndfile1",
"libsoup-gnome2.4-1",
"libsoup2.4-1",
"libspa-0.2-dev",
"libspeechd-dev",
"libspeechd2",
"libsqlite3-0",
"libssh2-1",
"libssl-dev",
"libssl1.1",
"libstdc++-10-dev", "libstdc++-10-dev",
"libstdc++6", "libstdc++6",
"libsystemd-dev",
"libsystemd0",
"libtasn1-6",
"libthai-dev",
"libthai0",
"libtiff-dev",
"libtiff5",
"libtiff6",
"libtiffxx5",
"libtinfo6",
"libtirpc3",
"libts0",
"libudev-dev",
"libudev1",
"libunbound8",
"libunistring2",
"libutempter-dev",
"libutempter0",
"libuuid1",
"libva-dev",
"libva-drm2",
"libva-glx2",
"libva-wayland2",
"libva-x11-2",
"libva2",
"libvorbis0a",
"libvorbisenc2",
"libvulkan-dev",
"libvulkan1",
"libwacom2",
"libwayland-bin",
"libwayland-client0",
"libwayland-cursor0",
"libwayland-dev",
"libwayland-egl-backend-dev",
"libwayland-egl1",
"libwayland-egl1-mesa",
"libwayland-server0",
"libwebp-dev",
"libwebp6",
"libwebp7",
"libwebpdemux2",
"libwebpmux3",
"libwrap0",
"libx11-6",
"libx11-dev",
"libx11-xcb-dev",
"libx11-xcb1",
"libxau-dev",
"libxau6",
"libxcb-dri2-0",
"libxcb-dri2-0-dev",
"libxcb-dri3-0",
"libxcb-dri3-dev",
"libxcb-glx0",
"libxcb-glx0-dev",
"libxcb-icccm4",
"libxcb-image0",
"libxcb-image0-dev",
"libxcb-keysyms1",
"libxcb-present-dev",
"libxcb-present0",
"libxcb-randr0",
"libxcb-randr0-dev",
"libxcb-render-util0",
"libxcb-render-util0-dev",
"libxcb-render0",
"libxcb-render0-dev",
"libxcb-shape0",
"libxcb-shape0-dev",
"libxcb-shm0",
"libxcb-shm0-dev",
"libxcb-sync-dev",
"libxcb-sync1",
"libxcb-util-dev",
"libxcb-util1",
"libxcb-xfixes0",
"libxcb-xfixes0-dev",
"libxcb-xinerama0",
"libxcb-xinput0",
"libxcb-xkb1",
"libxcb1",
"libxcb1-dev",
"libxcomposite-dev",
"libxcomposite1",
"libxcursor-dev",
"libxcursor1",
"libxdamage-dev",
"libxdamage1",
"libxdmcp-dev",
"libxdmcp6",
"libxext-dev",
"libxext6",
"libxfixes-dev",
"libxfixes3",
"libxft-dev",
"libxft2",
"libxi-dev",
"libxi6",
"libxinerama-dev",
"libxinerama1",
"libxkbcommon-dev",
"libxkbcommon-x11-0",
"libxkbcommon0",
"libxml2",
"libxml2-dev",
"libxrandr-dev",
"libxrandr2",
"libxrender-dev",
"libxrender1",
"libxshmfence-dev",
"libxshmfence1",
"libxslt1-dev",
"libxslt1.1",
"libxss-dev",
"libxss1",
"libxt-dev",
"libxt6",
"libxtst-dev",
"libxtst6",
"libxxf86vm-dev",
"libxxf86vm1",
"libzstd1",
"linux-libc-dev", "linux-libc-dev",
"mesa-common-dev",
"qt6-base-dev",
"qt6-base-dev-tools",
"qtbase5-dev",
"qtbase5-dev-tools",
"shared-mime-info",
"uuid-dev",
"wayland-protocols",
"x11proto-dev",
"zlib1g",
"zlib1g-dev",
] ]
DEBIAN_PACKAGES_ARCH = { DEBIAN_PACKAGES_ARCH = {
"amd64": [ "amd64": [
"libasan6", "libasan6",
"libdrm-intel1",
"libitm1", "libitm1",
"liblsan0", "liblsan0",
"libquadmath0", "libquadmath0",
"libtsan0", "libtsan0",
"libubsan1", "libubsan1",
"valgrind",
], ],
"i386": [ "i386": [
"libasan6", "libasan6",
"libdrm-intel1",
"libitm1", "libitm1",
"libquadmath0", "libquadmath0",
"libubsan1", "libubsan1",
"valgrind",
], ],
"armhf": [ "armhf": [
"libasan6", "libasan6",
"libdrm-etnaviv1",
"libdrm-exynos1",
"libdrm-freedreno1",
"libdrm-omap1",
"libdrm-tegra0",
"libubsan1", "libubsan1",
"valgrind",
], ],
"arm64": [ "arm64": [
"libasan6", "libasan6",
"libdrm-etnaviv1",
"libdrm-freedreno1",
"libdrm-tegra0",
"libgmp10", "libgmp10",
"libitm1", "libitm1",
"liblsan0", "liblsan0",
"libthai0",
"libtsan0", "libtsan0",
"libubsan1", "libubsan1",
"valgrind",
], ],
"armel": [ "armel": [
"libasan6", "libasan6",
"libdrm-exynos1",
"libdrm-freedreno1",
"libdrm-omap1",
"libdrm-tegra0",
"libubsan1", "libubsan1",
], ],
"mipsel": [], "mipsel": [],
"mips64el": [ "mips64el": [],
"valgrind", "riscv64": [],
],
} }
@ -673,11 +259,13 @@ def generate_package_list_dist_repo(arch: str, dist: str,
download_or_copy_non_unique_filename(package_list_arch, package_list) download_or_copy_non_unique_filename(package_list_arch, package_list)
verify_package_listing(package_file_arch, package_list, dist) verify_package_listing(package_file_arch, package_list, dist)
# `not line.endswith(":")` is added here to handle the case of
# "X-Cargo-Built-Using:\n rust-adler (= 1.0.2-2), ..."
with lzma.open(package_list, "rt") as src: with lzma.open(package_list, "rt") as src:
return [ return [
dict( dict(
line.split(": ", 1) for line in package_meta.splitlines() line.split(": ", 1) for line in package_meta.splitlines()
if not line.startswith(" ")) if not line.startswith(" ") and not line.endswith(":"))
for package_meta in src.read().split("\n\n") if package_meta for package_meta in src.read().split("\n\n") if package_meta
] ]
@ -719,13 +307,6 @@ def hacks_and_patches(install_root: str, script_dir: str, arch: str) -> None:
if os.path.exists(qtchooser_conf): if os.path.exists(qtchooser_conf):
os.remove(qtchooser_conf) os.remove(qtchooser_conf)
# libxcomposite1 is missing a symbols file.
atomic_copyfile(
os.path.join(script_dir, "libxcomposite1-symbols"),
os.path.join(install_root, "debian", "libxcomposite1", "DEBIAN",
"symbols"),
)
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the # __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
# earliest supported version of glibc (2.26). # earliest supported version of glibc (2.26).
features_h = os.path.join(install_root, "usr", "include", "features.h") features_h = os.path.join(install_root, "usr", "include", "features.h")
@ -763,6 +344,10 @@ def hacks_and_patches(install_root: str, script_dir: str, arch: str) -> None:
# Avoid requiring unsupported glibc versions. # Avoid requiring unsupported glibc versions.
for lib in ["libc.so.6", "libm.so.6", "libcrypt.so.1"]: for lib in ["libc.so.6", "libm.so.6", "libcrypt.so.1"]:
# RISCV64 is new and has no backward compatibility.
# Reversioning would remove necessary symbols and cause linking failures.
if arch == "riscv64":
continue
lib_path = os.path.join(install_root, "lib", TRIPLES[arch], lib) lib_path = os.path.join(install_root, "lib", TRIPLES[arch], lib)
reversion_glibc.reversion_glibc(lib_path) reversion_glibc.reversion_glibc(lib_path)
@ -858,15 +443,20 @@ def cleanup_jail_symlinks(install_root: str) -> None:
# Check if the symlink is absolute and points inside the # Check if the symlink is absolute and points inside the
# install_root. # install_root.
if os.path.isabs(target_path) and target_path.startswith( if os.path.isabs(target_path):
install_root): # Compute the relative path from the symlink to the target.
# Compute the relative path from the symlink to the target relative_path = os.path.relpath(
relative_path = os.path.relpath(target_path, os.path.join(install_root, target_path.strip("/")),
os.path.dirname(full_path)) os.path.dirname(full_path))
# Verify that the target exists inside the install_root.
joined_path = os.path.join(os.path.dirname(full_path),
relative_path)
if not os.path.exists(joined_path):
raise Exception(
f"Link target doesn't exist: {joined_path}")
os.remove(full_path) os.remove(full_path)
os.symlink(relative_path, full_path) os.symlink(relative_path, full_path)
def verify_library_deps(install_root: str) -> None: def verify_library_deps(install_root: str) -> None:
""" """
Verifies if all required libraries are present in the sysroot environment. Verifies if all required libraries are present in the sysroot environment.
@ -908,7 +498,6 @@ def build_sysroot(arch: str) -> None:
hacks_and_patches(install_root, SCRIPT_DIR, arch) hacks_and_patches(install_root, SCRIPT_DIR, arch)
cleanup_jail_symlinks(install_root) cleanup_jail_symlinks(install_root)
verify_library_deps(install_root) verify_library_deps(install_root)
create_tarball(install_root, arch)
def upload_sysroot(arch: str) -> None: def upload_sysroot(arch: str) -> None:
@ -975,6 +564,12 @@ def main():
sanity_check() sanity_check()
# RISCV64 only has support in debian-ports, no support in bookworm.
if args.architecture == "riscv64":
global ARCHIVE_URL, APT_SOURCES_LIST
ARCHIVE_URL = "https://snapshot.debian.org/archive/debian-ports/20230724T141507Z/"
APT_SOURCES_LIST = [("sid", ["main"])]
if args.command == "build": if args.command == "build":
build_sysroot(args.architecture) build_sysroot(args.architecture)
elif args.command == "upload": elif args.command == "upload":

View File

@ -47,5 +47,11 @@
"SysrootDir": "debian_bullseye_mipsel-sysroot", "SysrootDir": "debian_bullseye_mipsel-sysroot",
"Tarball": "debian_bullseye_mipsel_sysroot.tar.xz", "Tarball": "debian_bullseye_mipsel_sysroot.tar.xz",
"URL": "https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain" "URL": "https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain"
},
"bullseye_riscv64": {
"Key": "",
"Sha1Sum": "",
"SysrootDir": "debian_bullseye_riscv64-sysroot",
"Tarball": "debian_bullseye_riscv64_sysroot.tar.xz"
} }
} }