From 4a4c5f1c499527b23da29c274b62d16b2e7948bb Mon Sep 17 00:00:00 2001 From: El Date: Sat, 19 Apr 2025 00:43:29 +0500 Subject: [PATCH] KASM-7194 Refactor build scripts and enable conditional test builds --- CMakeLists.txt | 5 +- builder/build.sh | 129 +++++++++++++++++++++++------------------------ 2 files changed, 66 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22f21dc..537063e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,8 +242,9 @@ if(ENABLE_NLS) add_subdirectory(po) endif() -####add_subdirectory(tests) - +if (TESTS) + add_subdirectory(tests) +endif () include(cmake/BuildPackages.cmake) diff --git a/builder/build.sh b/builder/build.sh index b35f83d..ed481df 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -45,8 +45,10 @@ else XORG_PATCH=$(echo "$XORG_VER" | grep -Po '^\d.\d+' | sed 's#\.##') fi -if [ ! -f xorg-server-"${XORG_VER}".tar.gz ]; then - wget --no-check-certificate https://www.x.org/archive/individual/xserver/xorg-server-"${XORG_VER}".tar.gz +TARBALL="xorg-server-${XORG_VER}.tar.gz" + +if [ ! -f "$TARBALL" ]; then + wget --no-check-certificate https://www.x.org/archive/individual/xserver/"$TARBALL" fi #git clone https://kasmweb@bitbucket.org/kasmtech/kasmvnc.git @@ -54,96 +56,91 @@ fi #git checkout dynjpeg cd /src -# We only want the server, so FLTK and manual tests aren't useful. -# Alternatively, install fltk 1.3 and its dev packages. -sed -i -e '/find_package(FLTK/s@^@#@' \ - -e '/add_subdirectory(tests/s@^@#@' \ - CMakeLists.txt - cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . -DBUILD_VIEWER:BOOL=OFF \ -DENABLE_GNUTLS:BOOL=OFF make -j"$(nproc)" -tar -C unix/xserver -xf /tmp/xorg-server-${XORG_VER}.tar.gz --strip-components=1 +if [ ! -d unix/xserver/include ]; then + tar -C unix/xserver -xf /tmp/"$TARBALL" --strip-components=1 -cd unix/xserver -# Apply patches -patch -Np1 -i ../xserver${XORG_PATCH}.patch -case "$XORG_VER" in - 1.20.*) - patch -s -p0 < ../CVE-2022-2320-v1.20.patch - if [ -f ../xserver120.7.patch ]; then - patch -Np1 -i ../xserver120.7.patch - fi ;; - 1.19.*) - patch -s -p0 < ../CVE-2022-2320-v1.19.patch - ;; -esac + cd unix/xserver + # Apply patches + patch -Np1 -i ../xserver"${XORG_PATCH}".patch + case "$XORG_VER" in + 1.20.*) + patch -s -p0 < ../CVE-2022-2320-v1.20.patch + if [ -f ../xserver120.7.patch ]; then + patch -Np1 -i ../xserver120.7.patch + fi ;; + 1.19.*) + patch -s -p0 < ../CVE-2022-2320-v1.19.patch + ;; + esac -autoreconf -i -# Configuring Xorg is long and has many distro-specific paths. -# The distro paths start after prefix and end with the font path, -# everything after that is based on BUILDING.txt to remove unneeded -# components. -# remove gl check for opensuse -if [ "${KASMVNC_BUILD_OS}" == "opensuse" ] || ([ "${KASMVNC_BUILD_OS}" == "oracle" ] && [ "${KASMVNC_BUILD_OS_CODENAME}" == 9 ]); then - sed -i 's/LIBGL="gl >= 7.1.0"/LIBGL="gl >= 1.1"/g' configure + autoreconf -i + # Configuring Xorg is long and has many distro-specific paths. + # The distro paths start after prefix and end with the font path, + # everything after that is based on BUILDING.txt to remove unneeded + # components. + # remove gl check for opensuse + if [ "${KASMVNC_BUILD_OS}" == "opensuse" ] || ([ "${KASMVNC_BUILD_OS}" == "oracle" ] && [ "${KASMVNC_BUILD_OS_CODENAME}" == 9 ]); then + sed -i 's/LIBGL="gl >= 7.1.0"/LIBGL="gl >= 1.1"/g' configure + fi + + # build X11 + ./configure \ + --disable-config-hal \ + --disable-config-udev \ + --disable-dmx \ + --disable-dri \ + --disable-dri2 \ + --disable-kdrive \ + --disable-static \ + --disable-xephyr \ + --disable-xinerama \ + --disable-xnest \ + --disable-xorg \ + --disable-xvfb \ + --disable-xwayland \ + --disable-xwin \ + --enable-glx \ + --prefix=/opt/kasmweb \ + --with-default-font-path="/usr/share/fonts/X11/misc,/usr/share/fonts/X11/cyrillic,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins" \ + --without-dtrace \ + --with-sha1=libcrypto \ + --with-xkb-bin-directory=/usr/bin \ + --with-xkb-output=/var/lib/xkb \ + --with-xkb-path=/usr/share/X11/xkb "${CONFIG_OPTIONS}" + + # remove array bounds errors for new versions of GCC + find . -name "Makefile" -exec sed -i 's/-Werror=array-bounds//g' {} \; fi -# build X11 -./configure \ - --disable-config-hal \ - --disable-config-udev \ - --disable-dmx \ - --disable-dri \ - --disable-dri2 \ - --disable-kdrive \ - --disable-static \ - --disable-xephyr \ - --disable-xinerama \ - --disable-xnest \ - --disable-xorg \ - --disable-xvfb \ - --disable-xwayland \ - --disable-xwin \ - --enable-glx \ - --prefix=/opt/kasmweb \ - --with-default-font-path="/usr/share/fonts/X11/misc,/usr/share/fonts/X11/cyrillic,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins" \ - --without-dtrace \ - --with-sha1=libcrypto \ - --with-xkb-bin-directory=/usr/bin \ - --with-xkb-output=/var/lib/xkb \ - --with-xkb-path=/usr/share/X11/xkb ${CONFIG_OPTIONS} - -# remove array bounds errors for new versions of GCC -find . -name "Makefile" -exec sed -i 's/-Werror=array-bounds//g' {} \; make -j"$(nproc)" # modifications for the servertarball cd /src mkdir -p xorg.build/bin cd xorg.build/bin/ -ln -sf /src/unix/xserver/hw/vnc/Xvnc Xvnc +ln -sfn /src/unix/xserver/hw/vnc/Xvnc Xvnc cd .. mkdir -p man/man1 touch man/man1/Xserver.1 cp /src/unix/xserver/hw/vnc/Xvnc.man man/man1/Xvnc.1 -if [ ! -d lib ]; then - mkdir lib -fi +mkdir -p lib cd lib if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then - ln -s /usr/lib/x86_64-linux-gnu/dri dri + ln -sfn /usr/lib/x86_64-linux-gnu/dri dri elif [ -d /usr/lib/aarch64-linux-gnu/dri ]; then - ln -s /usr/lib/aarch64-linux-gnu/dri dri + ln -sfn /usr/lib/aarch64-linux-gnu/dri dri elif [ -d /usr/lib/arm-linux-gnueabihf/dri ]; then - ln -s /usr/lib/arm-linux-gnueabihf/dri dri + ln -sfn /usr/lib/arm-linux-gnueabihf/dri dri elif [ -d /usr/lib/xorg/modules/dri ]; then - ln -s /usr/lib/xorg/modules/dri dri + ln -sfn /usr/lib/xorg/modules/dri dri else - ln -s /usr/lib64/dri dri + ln -sfn /usr/lib64/dri dri fi cd /src