From 698c32be9f6a3729d375e98cbdd9648fe83ffd9e Mon Sep 17 00:00:00 2001 From: plowsof Date: Mon, 23 Sep 2024 20:09:37 +0100 Subject: [PATCH] handle submodule init + special cases --- Dockerfile.linux | 25 +--- shared_functions.sh | 302 ++++++++++++++++++++++++++------------------ 2 files changed, 181 insertions(+), 146 deletions(-) diff --git a/Dockerfile.linux b/Dockerfile.linux index bf0c031745..2c55bc924d 100644 --- a/Dockerfile.linux +++ b/Dockerfile.linux @@ -35,23 +35,6 @@ RUN chmod +x shared_functions.sh RUN /bin/bash -c "source shared_functions.sh && get_debs_gitcloner && install_debs_gitcloner && clone_git_repos" -#todo: none of these have commit hashes -RUN git clone git://code.qt.io/qt/qt5.git -b ${QT_VERSION} --depth 1 && \ - cd qt5 && \ - git clone git://code.qt.io/qt/qtbase.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtdeclarative.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtgraphicaleffects.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtimageformats.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtmultimedia.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtquickcontrols.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtquickcontrols2.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtsvg.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qttools.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qttranslations.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtx11extras.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtxmlpatterns.git -b ${QT_VERSION} --depth 1 && \ - cd .. - # Stage 3: Builder FROM ubuntu:16.04@sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6 as builder @@ -65,10 +48,4 @@ COPY shared_functions.sh shared_functions.sh RUN chmod +x shared_functions.sh # Single CMD with multiple build steps -RUN /bin/bash -c "source shared_functions.sh && \ - install_debs_downloader && \ - build_standard_projects && \ - build_special_case libxcb && \ - build_special_case boost_1_80_0 && \ - build_special_case openssl-1.1.1u && \ - build_special_case qt5" \ No newline at end of file +RUN /bin/bash -c "source shared_functions.sh && build_all" \ No newline at end of file diff --git a/shared_functions.sh b/shared_functions.sh index 66543b4b15..9e8530e9f8 100755 --- a/shared_functions.sh +++ b/shared_functions.sh @@ -269,11 +269,11 @@ gitrepo_list=( "https://gitlab.freedesktop.org/xorg/proto/xcbproto" "1.12" "6398e42131eedddde0d98759067dde933191f049" "https://gitlab.freedesktop.org/xorg/lib/libxau" "libXau-1.0.9" "d9443b2c57b512cfb250b35707378654d86c7dea" "https://gitlab.freedesktop.org/xorg/lib/libxcb" "1.12" "d34785a34f28fa6a00f8ce00d87e3132ff0f6467" - "https://gitlab.freedesktop.org/xorg/lib/libxcb-util" "0.4.0" "acf790d7752f36e450d476ad79807d4012ec863b" - "https://gitlab.freedesktop.org/xorg/lib/libxcb-image" "0.4.0" "d882052fb2ce439c6483fce944ba8f16f7294639" - "https://gitlab.freedesktop.org/xorg/lib/libxcb-keysyms" "0.4.0" "0e51ee5570a6a80bdf98770b975dfe8a57f4eeb1" - "https://gitlab.freedesktop.org/xorg/lib/libxcb-render-util" "0.3.9" "0317caf63de532fd7a0493ed6afa871a67253747" - "https://gitlab.freedesktop.org/xorg/lib/libxcb-wm" "0.4.1" "24eb17df2e1245885e72c9d4bbb0a0f69f0700f2" + "https://gitlab.freedesktop.org/xorg/lib/libxcb-util" "0.4.0" "acf790d7752f36e450d476ad79807d4012ec863b" "true" + "https://gitlab.freedesktop.org/xorg/lib/libxcb-image" "0.4.0" "d882052fb2ce439c6483fce944ba8f16f7294639" "true" + "https://gitlab.freedesktop.org/xorg/lib/libxcb-keysyms" "0.4.0" "0e51ee5570a6a80bdf98770b975dfe8a57f4eeb1" "true" + "https://gitlab.freedesktop.org/xorg/lib/libxcb-render-util" "0.3.9" "0317caf63de532fd7a0493ed6afa871a67253747" "true" + "https://gitlab.freedesktop.org/xorg/lib/libxcb-wm" "0.4.1" "24eb17df2e1245885e72c9d4bbb0a0f69f0700f2" "true" "https://github.com/xkbcommon/libxkbcommon" "xkbcommon-0.5.0" "c43c3c866eb9d52cd8f61e75cbef1c30d07f3a28" "https://github.com/madler/zlib" "v1.3" "09155eaa2f9270dc4ed1fa13e2b4b2613e6e4851" "https://git.savannah.gnu.org/git/freetype/freetype2.git" "VER-2-10-2" "132f19b779828b194b3fede187cee719785db4d8" @@ -454,21 +454,23 @@ get_debs() { done } -get_repos() { - local -a repo_list=("$@") +# Function to clone, reset, and optionally initialize submodules +git_clone_reset() { + local repo=$1 + local branch=$2 + local commit=$3 + local init_submodules=$4 - for ((i=0; i<${#repo_list[@]}; i+=3)); do - local repo_url="${repo_list[i]}" - local branch_or_tag="${repo_list[i+1]}" - local commit_hash="${repo_list[i+2]}" - - echo "Cloning $(basename "$repo_url")" - - git clone -b "$branch_or_tag" --depth 1 "$repo_url" && \ - cd "$(basename "$repo_url" .git)" && \ - git reset --hard "$commit_hash" && \ - cd .. - done + git clone -b $branch --depth 1 $repo + cd $(basename $repo .git) + git reset --hard $commit + + if [ "$init_submodules" = true ]; then + git submodule init + git clone --depth 1 https://gitlab.freedesktop.org/xorg/util/xcb-util-m4 m4 + git -C m4 reset --hard c617eee22ae5c285e79e81ec39ce96862fd3262f + fi + cd .. } dpkg_ordered() { @@ -498,114 +500,170 @@ install_debs_gitcloner() { } clone_git_repos() { - get_repos "${gitrepo_list[@]}" + git_clone_reset "${gitrepo_list[@]}" + #Qt5 special case todo: commit hashes + git clone git://code.qt.io/qt/qt5.git -b ${QT_VERSION} --depth 1 + cd qt5 + git clone git://code.qt.io/qt/qtbase.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtdeclarative.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtgraphicaleffects.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtimageformats.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtmultimedia.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtquickcontrols.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtquickcontrols2.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtsvg.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qttools.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qttranslations.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtx11extras.git -b ${QT_VERSION} --depth 1 + git clone git://code.qt.io/qt/qtxmlpatterns.git -b ${QT_VERSION} --depth 1 + cd .. } -build_project() { - cd $1 - #pop the first value - shift - if [ -f "./bootstrap" ]; then - ./bootstrap $@; - elif [ -f "./bootstrap.sh" ]; then - ./bootstrap.sh $@; - elif [ -f "./autogen.sh" ]; then - ./autogen.sh $@; - elif [ -f "./configure" ]; then - ./configure $@; - else - echo "No recognized build script found for $1"; - return 1; - fi - make -j$THREADS - make install - cd .. - rm -rf -} +# Function to build and install a project +build_and_install() { + local dir=$1 + local configure_cmd=$2 + local make_cmd=${3:-"make -j$THREADS"} + local install_cmd=${4:-"make -j$THREADS install"} -build_standard_projects() { - build_project xorgproto - build_project xcbproto - build_project libxau --enable-shared --disable-static - build_project libxcb-util --enable-shared --disable-static - build_project libxcb-image --enable-shared --disable-static - build_project libxcb-keysyms --enable-shared --disable-static - build_project libxcb-render-util --enable-shared --disable-static - build_project libxcb-wm --enable-shared --disable-static - build_project libxkbcommon --prefix=/usr --enable-shared --disable-static --enable-x11 --disable-docs - build_project zlib --static - build_project freetype2 --disable-shared --enable-static --with-zlib=no - build_project expat-2.4.8 --enable-static --disable-shared --prefix=/usr - build_project fontconfig --disable-shared --enable-static --sysconfdir=/etc --localstatedir=/var - build_project icu/icu4c/source --disable-shared --enable-static --disable-tests --disable-samples - build_project libusb --disable-shared --enable-static - build_project hidapi --disable-shared --enable-static - build_project libzmq --disable-shared --enable-static --disable-libunwind --with-libsodium - build_project libgpg-error --disable-shared --enable-static --disable-doc --disable-tests - build_project libgcrypt --disable-shared --enable-static --disable-doc - build_project protobuf --enable-static --disable-shared - build_project CMake + cd $dir + eval $configure_cmd + eval $make_cmd + eval $install_cmd + cd .. + rm -rf $dir } -build_special_case() { - local project_dir=$1 - shift - - case "$project_dir" in - "libxcb") - cd "$project_dir" - ./autogen.sh --enable-shared --disable-static - make -j$THREADS - make install - make clean - rm /usr/local/lib/libxcb-xinerama.so - ./autogen.sh --disable-shared --enable-static - make -j$THREADS - cp src/.libs/libxcb-xinerama.a /usr/local/lib/ - cd .. - rm -rf "$project_dir" - ;; - - "boost_1_80_0") - cd "$project_dir" - ./bootstrap.sh - ./b2 --with-atomic --with-system --with-filesystem --with-thread --with-date_time --with-chrono --with-regex --with-serialization --with-program_options --with-locale variant=release link=static runtime-link=static cflags="${CFLAGS}" cxxflags="${CXXFLAGS}" install -a --prefix=/usr - cd .. - rm -rf "$project_dir" - ;; - - "openssl-1.1.1u") - cd "$project_dir" - ./config no-shared no-zlib-dynamic --prefix=/usr --openssldir=/usr - make -j$THREADS - make install - cd .. - rm -rf "$project_dir" - ;; - - "qt5") - cd "$project_dir" - sed -ri 's/(Libs:.*)/\1 -lexpat/' /usr/local/lib/pkgconfig/fontconfig.pc - sed -ri 's/(Libs:.*)/\1 -lz/' /usr/local/lib/pkgconfig/freetype2.pc - sed -ri 's/(Libs:.*)/\1 -lXau/' /usr/local/lib/pkgconfig/xcb.pc - sed -i 's/\/usr\/X11R6\/lib64/\/usr\/local\/lib/' qtbase/mkspecs/linux-g++-64/qmake.conf - ./configure --prefix=/usr -platform linux-g++-64 -opensource -confirm-license -release -static -no-avx -opengl desktop -qpa xcb -xcb -xcb-xlib -feature-xlib -system-freetype -fontconfig -glib -no-dbus -no-feature-qml-worker-script -no-linuxfb -no-openssl -no-sql-sqlite -no-kms -no-use-gold-linker -qt-harfbuzz -qt-libjpeg -qt-libpng -qt-pcre -qt-zlib -skip qt3d -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtlocation -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttools -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtwinextras -skip qtx11extras -skip gamepad -skip serialbus -skip location -skip webengine -nomake examples -nomake tests -nomake tools - make -j$THREADS - make install - cd qttools/src/linguist/lrelease - ../../../../qtbase/bin/qmake - make -j$THREADS - make install - cd ../../../.. - cd .. - rm -rf "$project_dir" - ;; - - *) - echo "No special case defined for $project_dir" - build_project "$project_dir" "$@" - ;; - esac + +build_all() { + # xorgproto + build_and_install xorgproto "./autogen.sh" + + # xcbproto + build_and_install xcbproto "./autogen.sh" + + # libxau + build_and_install libxau "./autogen.sh --enable-shared --disable-static" + + # libxcb + build_and_install libxcb " + ./autogen.sh --enable-shared --disable-static && + make -j$THREADS && + make -j$THREADS install && + make -j$THREADS clean && + rm /usr/local/lib/libxcb-xinerama.so && + ./autogen.sh --disable-shared --enable-static && + make -j$THREADS && + cp src/.libs/libxcb-xinerama.a /usr/local/lib/ + " + + # libxcb-util + build_and_install libxcb-util "./autogen.sh --enable-shared --disable-static" + + # libxcb-image + build_and_install libxcb-image "./autogen.sh --enable-shared --disable-static" + + # libxcb-keysyms + build_and_install libxcb-keysyms "./autogen.sh --enable-shared --disable-static" + + # libxcb-render-util + build_and_install libxcb-render-util "./autogen.sh --enable-shared --disable-static" + + # libxcb-wm + build_and_install libxcb-wm "./autogen.sh --enable-shared --disable-static" + + # libxkbcommon + build_and_install libxkbcommon "./autogen.sh --prefix=/usr --enable-shared --disable-static --enable-x11 --disable-docs" + + # zlib + build_and_install zlib "./configure --static" + + # freetype2 + build_and_install freetype2 "./autogen.sh && ./configure --disable-shared --enable-static --with-zlib=no" + + # expat + #wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2 + #echo "a247a7f6bbb21cf2ca81ea4cbb916bfb9717ca523631675f99b3d4a5678dcd16 expat-2.4.8.tar.bz2" | sha256sum -c + #tar -xf expat-2.4.8.tar.bz2 + #rm expat-2.4.8.tar.bz2 + build_and_install expat-2.4.8 "./configure --enable-static --disable-shared --prefix=/usr" + + # fontconfig + build_and_install fontconfig "./autogen.sh --disable-shared --enable-static --sysconfdir=/etc --localstatedir=/var" + + # icu + build_and_install icu/icu4c/source "./configure --disable-shared --enable-static --disable-tests --disable-samples" + + # boost + #wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz + #echo "4b2136f98bdd1f5857f1c3dea9ac2018effe65286cf251534b6ae20cc45e1847 boost_1_80_0.tar.gz" | sha256sum -c + #tar -xzf boost_1_80_0.tar.gz + #rm boost_1_80_0.tar.gz + cd boost_1_80_0 + ./bootstrap.sh + ./b2 --with-atomic --with-system --with-filesystem --with-thread --with-date_time --with-chrono --with-regex --with-serialization --with-program_options --with-locale variant=release link=static runtime-link=static cflags="${CFLAGS}" cxxflags="${CXXFLAGS}" install -a --prefix=/usr + cd .. + rm -rf boost_1_80_0 + + # openssl + #wget https://www.openssl.org/source/openssl-1.1.1u.tar.gz + #echo "e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6 openssl-1.1.1u.tar.gz" | sha256sum -c + #tar -xzf openssl-1.1.1u.tar.gz + #rm openssl-1.1.1u.tar.gz + build_and_install openssl-1.1.1u "./config no-shared no-zlib-dynamic --prefix=/usr --openssldir=/usr" + + # unbound + #wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.16.2.tar.gz + #echo "2e32f283820c24c51ca1dd8afecfdb747c7385a137abe865c99db4b257403581 unbound-1.16.2.tar.gz" | sha256sum -c + #tar -xzf unbound-1.16.2.tar.gz + #rm unbound-1.16.2.tar.gz + build_and_install unbound-1.16.2 "./configure --disable-shared --enable-static --without-pyunbound --with-libexpat=/usr --with-ssl=/usr --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only --with-pic" + + # Remove existing libraries + rm /usr/lib/x86_64-linux-gnu/libX11.a + rm /usr/lib/x86_64-linux-gnu/libXext.a + rm /usr/lib/x86_64-linux-gnu/libX11-xcb.a + + # Qt5 + cd qt5 + sed -ri s/\(Libs:.*\)/\\1\ -lexpat/ /usr/local/lib/pkgconfig/fontconfig.pc + sed -ri s/\(Libs:.*\)/\\1\ -lz/ /usr/local/lib/pkgconfig/freetype2.pc + sed -ri s/\(Libs:.*\)/\\1\ -lXau/ /usr/local/lib/pkgconfig/xcb.pc + sed -i s/\\/usr\\/X11R6\\/lib64/\\/usr\\/local\\/lib/ qtbase/mkspecs/linux-g++-64/qmake.conf + ./configure --prefix=/usr -platform linux-g++-64 -opensource -confirm-license -release -static -no-avx \ + -opengl desktop -qpa xcb -xcb -xcb-xlib -feature-xlib -system-freetype -fontconfig -glib \ + -no-dbus -no-feature-qml-worker-script -no-linuxfb -no-openssl -no-sql-sqlite -no-kms -no-use-gold-linker \ + -qt-harfbuzz -qt-libjpeg -qt-libpng -qt-pcre -qt-zlib \ + -skip qt3d -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d \ + -skip qtdoc -skip qtgamepad -skip qtlocation -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing \ + -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttools \ + -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview \ + -skip qtwinextras -skip qtx11extras -skip gamepad -skip serialbus -skip location -skip webengine \ + -nomake examples -nomake tests -nomake tools + make -j$THREADS + make -j$THREADS install + cd qttools/src/linguist/lrelease + ../../../../qtbase/bin/qmake + make -j$THREADS + make -j$THREADS install + cd ../../../.. + cd .. + rm -rf qt5 + + # libusb + build_and_install libusb "./autogen.sh --disable-shared --enable-static" + # hidapi + build_and_install hidapi "./bootstrap && ./configure --disable-shared --enable-static" + # libzmq + build_and_install libzmq "./autogen.sh && ./configure --disable-shared --enable-static --disable-libunwind --with-libsodium" + # libgpg-error + build_and_install libgpg-error "./autogen.sh && ./configure --disable-shared --enable-static --disable-doc --disable-tests" + # libgcrypt + build_and_install libgcrypt "./autogen.sh && ./configure --disable-shared --enable-static --disable-doc" + # protobuf + build_and_install protobuf "./autogen.sh && ./configure --enable-static --disable-shared" + # CMake + build_and_install CMake "./bootstrap" } #downloader container