From 75d0bf40f3cc184ce11ec8b36db55798d6b615fb Mon Sep 17 00:00:00 2001 From: sam#gemmi-win10 Date: Mon, 16 Oct 2023 08:11:37 +0800 Subject: [PATCH] sq: +core/src/gcc/static x4 -- cp init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +src/xdpy +src/fontconfig mv src/tigervnc +gcc/static/README cp cut: Dockerfile sq: +dfile.sh alpine-build.sh; +Dockerfile.xx -- dockerfile.xx sh ig x3 +alpine-build.sh +dfile.sh registry.cn-shenzhen.aliyuncs.com/infrasync/ curl -# -L https://ghproxy.com zh repo TIGERVNC_URL=https://ghproxy.com/ BUILDPLATFORM COPY --link sq: up gcc/static -- fix cp out: /mnt/rootfs/opt/base fix sort notes notes notes out apk pwd; ls -lah /mnt/$file /mnt/$file down_catfile RUN export domain="mirrors.ustc.edu.cn"; \ ping -c 2 qq.com sh buld.sh s s curl -# -k -fSL $RUN export CC=xx-clang \ notes base out base ping -c 2 qq.com fix export f docker build xx sq: update gcc/static -- sort buildOne buildOne apk repo FROM alpine:3.15 img=$ns/docker-headless:compile-alpine-3.15-xx-rootfs-tiger mkdir -p /tmp/xdpyprobe run build # exit 0 without BUILDPLATFORM repo=$1 BUILDPLATFORM=linux/arm notes top PLATFORM export BUILDPLATFORM=linux/arm ls -lhaS ARG BUILDPLATFORM=linux/amd64 ARG TARGETPLATFORM sed -i "s^ARG BUILDPLATFORM=linux/amd64^ARG BUILDPLATFORM^g" Dockerfile.xx.hub \cp -a /usr/bin/upx /mnt/rootfs${targetDir}/bin/ #+upx ns=infrastlabs # it="-it" # buildx-with-cache exact sed # view,validate BUILDPLATFORM sed repo fill drops #opt>usr?? \cp -a src/xdpyprobe/* /tmp/xdpyprobe/ 共历时172秒 clear /mnt/logs # do_fontconfig gawk; 2>&1 pwd; ls -laSh tee -a $logfile print_time_cost $begin_time x4 mkdir -p func; time do_tiger |tee /mnt/logs/do_tiger.log mv down_catfile rm -rf /mnt/rootfs #clear dfile export targetDir=/opt/base; /usr tiger export targetDir=/opt/base export targetDir=/opt/base mkdir -p /tmp/upx mkdir -p / up info format up ## Build ## Built; - xdpyprobe --- ubt-core/src/gcc/static/.gitignore | 3 + ubt-core/src/gcc/static/Dockerfile | 135 ++++++ ubt-core/src/gcc/static/Dockerfile.xx | 99 ++++ ubt-core/src/gcc/static/README.md | 112 +++++ ubt-core/src/gcc/static/alpine-build.sh | 75 +++ ubt-core/src/gcc/static/dfile.sh | 183 ++++++++ .../src/gcc/static/src/fontconfig/build.sh | 106 +++++ ubt-core/src/gcc/static/src/tigervnc/build.sh | 433 ++++++++++++++++++ .../gcc/static/src/tigervnc/disable-pam.patch | 66 +++ .../static/src/tigervnc/static-build.patch | 12 + .../src/tigervnc/vncpasswd-static.patch | 11 + .../src/gcc/static/src/xdpyprobe/Makefile | 22 + .../src/gcc/static/src/xdpyprobe/config.h | 29 ++ .../src/gcc/static/src/xdpyprobe/xdpyprobe.c | 146 ++++++ 14 files changed, 1432 insertions(+) create mode 100644 ubt-core/src/gcc/static/.gitignore create mode 100644 ubt-core/src/gcc/static/Dockerfile create mode 100644 ubt-core/src/gcc/static/Dockerfile.xx create mode 100644 ubt-core/src/gcc/static/README.md create mode 100644 ubt-core/src/gcc/static/alpine-build.sh create mode 100644 ubt-core/src/gcc/static/dfile.sh create mode 100644 ubt-core/src/gcc/static/src/fontconfig/build.sh create mode 100644 ubt-core/src/gcc/static/src/tigervnc/build.sh create mode 100644 ubt-core/src/gcc/static/src/tigervnc/disable-pam.patch create mode 100644 ubt-core/src/gcc/static/src/tigervnc/static-build.patch create mode 100644 ubt-core/src/gcc/static/src/tigervnc/vncpasswd-static.patch create mode 100644 ubt-core/src/gcc/static/src/xdpyprobe/Makefile create mode 100644 ubt-core/src/gcc/static/src/xdpyprobe/config.h create mode 100644 ubt-core/src/gcc/static/src/xdpyprobe/xdpyprobe.c diff --git a/ubt-core/src/gcc/static/.gitignore b/ubt-core/src/gcc/static/.gitignore new file mode 100644 index 0000000..a61f9fb --- /dev/null +++ b/ubt-core/src/gcc/static/.gitignore @@ -0,0 +1,3 @@ +*.tar.gz +*.tar.xz +*.tar.bz2 diff --git a/ubt-core/src/gcc/static/Dockerfile b/ubt-core/src/gcc/static/Dockerfile new file mode 100644 index 0000000..5c36b67 --- /dev/null +++ b/ubt-core/src/gcc/static/Dockerfile @@ -0,0 +1,135 @@ +# ARG BASEIMAGE=unknown +ARG BASEIMAGE=ubuntu:20.04 +ARG BUILDPLATFORM=linux/amd64 +# Define the Alpine packages to be installed into the image. +ARG ALPINE_PKGS="\ + # Needed to generate self-signed certificates + openssl \ + # Needed to use netcat with unix socket. + netcat-openbsd \ +" +# Define the Debian/Ubuntu packages to be installed into the image. +ARG DEBIAN_PKGS="\ + # Used to determine if nginx is ready. + netcat \ + # For ifconfig + net-tools \ + # Needed to generate self-signed certificates + openssl \ +" + +# Get Dockerfile cross-compilation helpers. +FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/tonistiigi-xx AS xx + +# Build UPX. +FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS upx +# https://gitee.com/infrastlabs/alpine-ext/blob/master/src/build.sh +# https://www.jakehu.me/2021/alpine-mirrors/ +# domain="mirrors.ustc.edu.cn" +# domain="mirrors.aliyun.com"; +# mirrors.tuna.tsinghua.edu.cn +RUN domain="mirrors.tuna.tsinghua.edu.cn"; \ + echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ + echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +RUN apk --no-cache add build-base curl make cmake git && \ + mkdir /tmp/upx && \ + curl -# -L https://ghproxy.com/https://github.com/upx/upx/releases/download/v4.0.1/upx-4.0.1-src.tar.xz | tar xJ --strip 1 -C /tmp/upx && \ + make -C /tmp/upx build/release-gcc -j$(nproc) && \ + cp -v /tmp/upx/build/release-gcc/upx /usr/bin/upx + +# Build TigerVNC server. +FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS tigervnc +RUN domain="mirrors.tuna.tsinghua.edu.cn"; \ + echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ + echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +ARG TARGETPLATFORM +COPY --from=xx / / +COPY src/tigervnc /build +RUN /build/build.sh +RUN xx-verify --static /tmp/tigervnc-install/usr/bin/Xvnc +RUN xx-verify --static /tmp/tigervnc-install/usr/bin/vncpasswd +COPY --from=upx /usr/bin/upx /usr/bin/upx +RUN upx /tmp/tigervnc-install/usr/bin/Xvnc +RUN upx /tmp/tigervnc-install/usr/bin/vncpasswd + +# Build Fontconfig. +FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS fontconfig +RUN domain="mirrors.tuna.tsinghua.edu.cn"; \ + echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ + echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +ARG TARGETPLATFORM +COPY --from=xx / / +COPY src/fontconfig/build.sh /tmp/build-fontconfig.sh +RUN /tmp/build-fontconfig.sh + +# Build xdpyprobe. +# Used to determine if the X server (Xvnc) is ready. +FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS xdpyprobe +RUN domain="mirrors.tuna.tsinghua.edu.cn"; \ + echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ + echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +ARG TARGETPLATFORM +COPY --from=xx / / +COPY src/xdpyprobe /tmp/xdpyprobe +RUN apk --no-cache add make clang +RUN xx-apk --no-cache add gcc musl-dev libx11-dev libx11-static libxcb-static +RUN CC=xx-clang \ + make -C /tmp/xdpyprobe +RUN xx-verify --static /tmp/xdpyprobe/xdpyprobe +COPY --from=upx /usr/bin/upx /usr/bin/upx +RUN upx /tmp/xdpyprobe/xdpyprobe + +# Pull base image. +FROM ${BASEIMAGE} +ARG TARGETPLATFORM +RUN export DOMAIN="mirrors.ustc.edu.cn"; \ + test -z "$(echo $TARGETPLATFORM |grep arm)" && target=ubuntu || target=ubuntu-ports; \ + echo "deb http://${DOMAIN}/$target focal main restricted universe multiverse" > /etc/apt/sources.list \ + && echo "deb http://${DOMAIN}/$target focal-updates main restricted universe multiverse">> /etc/apt/sources.list; +WORKDIR /tmp +# Install system packages. +ARG ALPINE_PKGS +ARG DEBIAN_PKGS +RUN \ + if [ -n "$(which apk)" ]; then \ + add-pkg ${ALPINE_PKGS}; \ + else \ + add-pkg ${DEBIAN_PKGS}; \ + fi && \ + # Remove some unneeded stuff. + rm -rf /var/cache/fontconfig/* + +# Add files. +# COPY helpers/* /opt/base/bin/ +# COPY rootfs/ / +# COPY --link +COPY --from=tigervnc /tmp/tigervnc-install/usr/bin/Xvnc /opt/base/bin/ +COPY --from=tigervnc /tmp/tigervnc-install/usr/bin/vncpasswd /opt/base/bin/ +COPY --from=tigervnc /tmp/xkb-install/usr/share/X11/xkb /opt/base/share/X11/xkb +COPY --from=tigervnc /tmp/xkbcomp-install/usr/bin/xkbcomp /opt/base/bin/ +# COPY --from=openbox /tmp/openbox-install/usr/bin/openbox /opt/base/bin/ +# COPY --from=openbox /tmp/openbox-install/usr/bin/obxprop /opt/base/bin/ +COPY --from=fontconfig /tmp/fontconfig-install/opt /opt +COPY --from=xdpyprobe /tmp/xdpyprobe/xdpyprobe /opt/base/bin/ +# COPY --from=yad /tmp/yad-install/usr/bin/yad /opt/base/bin/ +# COPY --from=nginx /tmp/nginx-install /opt/base/ +# COPY --from=dhparam /tmp/dhparam.pem /defaults/ +# COPY --from=noVNC /opt/noVNC /opt/noVNC + +# Set environment variables. +ENV \ + DISPLAY_WIDTH=1920 \ + DISPLAY_HEIGHT=1080 \ + DARK_MODE=0 \ + SECURE_CONNECTION=0 \ + SECURE_CONNECTION_VNC_METHOD=SSL \ + SECURE_CONNECTION_CERTS_CHECK_INTERVAL=60 \ + WEB_LISTENING_PORT=5800 \ + VNC_LISTENING_PORT=5900 \ + VNC_PASSWORD= \ + ENABLE_CJK_FONT=0 + +# Expose ports. +# - 5800: VNC web interface +# - 5900: VNC +EXPOSE 5800 5900 diff --git a/ubt-core/src/gcc/static/Dockerfile.xx b/ubt-core/src/gcc/static/Dockerfile.xx new file mode 100644 index 0000000..01d72f2 --- /dev/null +++ b/ubt-core/src/gcc/static/Dockerfile.xx @@ -0,0 +1,99 @@ + +# ARG BUILDPLATFORM=linux/amd64 +# ARG TARGETPLATFORM +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/tonistiigi-xx AS xx +FROM registry.cn-shenzhen.aliyuncs.com/infrasync/tonistiigi-xx AS xx + +# ARG BUILDPLATFORM=linux/amd64 +# ARG TARGETPLATFORM +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS upx +FROM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS upx +COPY --from=xx / / + +# https://gitee.com/infrastlabs/alpine-ext/blob/master/src/build.sh +# https://www.jakehu.me/2021/alpine-mirrors/ +# domain="mirrors.ustc.edu.cn" +# domain="mirrors.aliyun.com"; +# mirrors.tuna.tsinghua.edu.cn +RUN export domain="mirrors.ustc.edu.cn"; \ + echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ + echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +RUN ping -c 2 qq.com; apk update; \ + apk --no-cache add build-base curl make cmake git + + +###TIGERVNC +# log "Installing required Alpine packages..." +# ping -c 2 qq.com +RUN apk --no-cache add \ + curl \ + build-base \ + clang \ + cmake \ + autoconf \ + automake \ + libtool \ + pkgconf \ + meson \ + util-macros \ + font-util-dev \ + xtrans + +# ping -c 2 qq.com +RUN xx-apk --no-cache --no-scripts add \ + g++ \ + xcb-util-dev \ + pixman-dev \ + libx11-dev \ + libgcrypt-dev \ + libgcrypt-static \ + libgpg-error-static \ + libxkbfile-dev \ + libxfont2-dev \ + libjpeg-turbo-dev \ + nettle-dev \ + libunistring-dev \ + gnutls-dev \ + fltk-dev \ + libxrandr-dev \ + libxtst-dev \ + freetype-dev \ + libfontenc-dev \ + zlib-dev \ + libx11-static \ + libxcb-static \ + zlib-static \ + pixman-static \ + libjpeg-turbo-static \ + freetype-static \ + libpng-static \ + bzip2-static \ + brotli-static \ + libunistring-static \ + nettle-static \ + gettext-static \ + libunistring-dev \ + libbsd-dev + + +###FONTCONFIG +# log "Installing required Alpine packages..." +RUN apk --no-cache add \ + curl \ + build-base \ + clang \ + pkgconfig \ + gperf \ + python3 \ + font-croscore + +RUN xx-apk --no-cache --no-scripts add \ + glib-dev \ + g++ \ + freetype-dev \ + expat-dev + + +###XDPY +RUN xx-apk --no-cache add gcc musl-dev libx11-dev libx11-static libxcb-static + diff --git a/ubt-core/src/gcc/static/README.md b/ubt-core/src/gcc/static/README.md new file mode 100644 index 0000000..fe5ff25 --- /dev/null +++ b/ubt-core/src/gcc/static/README.md @@ -0,0 +1,112 @@ + +## Build + +dfile.sh + +- upx +- tiger/build.sh + - gnutls + - libxfont2 + - libfontenc + - libtasn1 + - libxshmfence + - tigervnc/xorg-server + - common + - unix/common + - unix/passwd + - unix/xserver + - X11/xkb:xkeyboard-config + - xkbcomp +- xdpyprobe/ +- +- fontconfig/build.sh +- openbox +- gtk's yad +- nginx +- novnc + + + +## Built + +```bash +# host-21-60:/_ext/working/_ee/ubt-armv7/ubt-core/src/gcc/static # find rootfs/ |grep -v font +rootfs/ +rootfs/opt +rootfs/opt/opt +rootfs/opt/opt/base +rootfs/opt/opt/base/share +rootfs/opt/base +rootfs/opt/base/bin +rootfs/opt/base/bin/xdpyprobe +rootfs/opt/base/bin/Xvnc +rootfs/opt/base/bin/vncpasswd +rootfs/opt/base/share +rootfs/opt/base/share/X11 + +# host-21-60:/_ext/working/_ee/ubt-armv7/ubt-core/src/gcc/static # ll -Sh +total 23M +-rw-r--r-- 1 root root 9.0M Oct 16 23:39 xorg-server-1.20.14.tar.gz +-rw-r--r-- 1 root root 5.8M Oct 16 23:14 gnutls-3.7.1.tar.xz +-rw-r--r-- 1 root root 1.9M Oct 16 23:21 v1.13.1.tar.gz +-rw-r--r-- 1 root root 1.7M Oct 16 23:45 xkeyboard-config-2.32.tar.bz2 +-rw-r--r-- 1 root root 1.7M Oct 16 23:20 libtasn1-4.18.0.tar.gz +-rw-r--r-- 1 root root 1.2M Oct 16 23:06 upx-4.0.1-src.tar.xz +-rw-r--r-- 1 root root 6.1K Oct 16 23:36 dfile.sh +-rw-r--r-- 1 root root 5.3K Oct 16 22:15 Dockerfile +drwxr-xr-x 2 root root 4.0K Oct 17 00:01 _build #32K +drwxr-xr-x 17 root root 4.0K Oct 17 00:08 _tmp #274M +drwxr-xr-x 3 root root 4.0K Oct 16 23:43 rootfs #6M +drwxr-xr-x 5 root root 4.0K Oct 16 20:54 src +-rw-r--r-- 1 root root 3.1K Oct 17 00:00 README.md +-rw-r--r-- 1 root root 2.2K Oct 16 23:25 Dockerfile.xx +-rw-r--r-- 1 root root 317 Oct 17 00:00 alpine-build.sh +-rw-r--r-- 1 root root 31 Oct 16 23:21 .gitignore +``` + +- xdpyprobe + +```bash +host-21-60:/_ext/working/_ee/ubt-armv7/ubt-core/src/gcc/static # rootfs/opt/base/bin/xdpyprobe -h +Usage: xdpyprobe [OPTIONS] [DISPLAY] +Check connectivity of the X server defined by DISPLAY. +If DISPLAY is not specified, use $DISPLAY environment variable. + +Options: + -q, --quiet do not display any output + -h, --help display help message and exit + -v, --version display version message and exit + +Exit status: + 0 if connection to DISPLAY succeeded; + 1 if connection to DISPLAY failed; + 255 if X server connectivity was not probed (e.g., when + the help message is displayed). +``` + +## Ref + + + +- https://gitee.com/infrastlabs/fk-docker-baseimage-gui/blob/master/.github/workflows/build-baseimage.yml + + +```yml + strategy: + fail-fast: false + matrix: + info: + - '{ "tag_prefix": "alpine-3.14", "baseimage": "jlesage/baseimage:alpine-3.14-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "alpine-3.15", "baseimage": "jlesage/baseimage:alpine-3.15-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "alpine-3.16", "baseimage": "jlesage/baseimage:alpine-3.16-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "alpine-3.17", "baseimage": "jlesage/baseimage:alpine-3.17-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "alpine-3.18", "baseimage": "jlesage/baseimage:alpine-3.18-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "debian-10", "baseimage": "jlesage/baseimage:debian-10-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "debian-11", "baseimage": "jlesage/baseimage:debian-11-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "ubuntu-16.04", "baseimage": "jlesage/baseimage:ubuntu-16.04-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "ubuntu-18.04", "baseimage": "jlesage/baseimage:ubuntu-18.04-v3.4.7", "platforms": "linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "ubuntu-20.04", "baseimage": "jlesage/baseimage:ubuntu-20.04-v3.4.7", "platforms": "linux/amd64,linux/arm/v7,linux/arm64/v8" }' + - '{ "tag_prefix": "ubuntu-22.04", "baseimage": "jlesage/baseimage:ubuntu-22.04-v3.4.7", "platforms": "linux/amd64,linux/arm/v7,linux/arm64/v8" }' + + +``` diff --git a/ubt-core/src/gcc/static/alpine-build.sh b/ubt-core/src/gcc/static/alpine-build.sh new file mode 100644 index 0000000..7a2ab2b --- /dev/null +++ b/ubt-core/src/gcc/static/alpine-build.sh @@ -0,0 +1,75 @@ + +export |grep DOCKER_REG +repo=registry.cn-shenzhen.aliyuncs.com +echo "${DOCKER_REGISTRY_PW_infrastSubUser2}" |docker login --username=${DOCKER_REGISTRY_USER_infrastSubUser2} --password-stdin $repo + +repoHub=docker.io +echo "${DOCKER_REGISTRY_PW_dockerhub}" |docker login --username=${DOCKER_REGISTRY_USER_dockerhub} --password-stdin $repoHub + +ns=infrastlabs +tag=compile-alpine-3.15-xx +img=$ns/docker-headless:$tag +# BUILDPLATFORM=$1; test -z "$BUILDPLATFORM" && BUILDPLATFORM=linux/amd64 +BUILDPLATFORM=linux/amd64 +BUILDPLATFORM=linux/arm64 +BUILDPLATFORM=linux/arm + +repo=$1 +if [ "" != "$repo" ]; then + cat Dockerfile.xx > Dockerfile.xx.hub + sed -i "s^registry.cn-shenzhen.aliyuncs.com/infrasync/alpine^alpine^g" Dockerfile.xx.hub + sed -i "s^registry.cn-shenzhen.aliyuncs.com/infrasync/tonistiigi-xx^tonistiigi/xx^g" Dockerfile.xx.hub + sed -i "s^ARG BUILDPLATFORM=linux/amd64^ARG BUILDPLATFORM^g" Dockerfile.xx.hub + dockerfile=Dockerfile.xx.hub +else + dockerfile=Dockerfile.xx +fi + +# buildimg +# docker build -t $img -f $dockerfile . #xx +# buildx-with-cache + # cache + ali="registry.cn-shenzhen.aliyuncs.com" + cimg="docker-headless-cache:$tag" + cache="--cache-from type=registry,ref=$ali/$ns/$cimg --cache-to type=registry,ref=$ali/$ns/$cimg" + # + plat="--platform linux/amd64,linux/arm64,linux/arm" + # plat="--platform linux/arm" + docker buildx build $cache $plat $args --push -t $img -f $dockerfile . + +# exit 0 +# it="-it" +function buildOne(){ +docker run $it --rm --privileged --platform=$BUILDPLATFORM \ + -v $(pwd):/mnt \ + -v $(pwd)/_build:/build \ + -v $(pwd)/_tmp:/tmp \ + $img sh -c "cd /mnt; sh dfile.sh" + +# view,validate +du -sh rootfs +find rootfs |sort #|grep -v xkb +./rootfs/usr/bin/Xvnc -version +ls -lhaS +} + +# TODO loop: PLAT> buildOne +# rootfs_plat? TODO:multiPlat可并行 +# ./Dockerfile: err docker-1806/1903--alpine--make--noPermition +buildOne + +# +Dockerfile_out +dockerfile=Dockerfile.out +cat > $dockerfile < /etc/apk/repositories; \ + echo "http://\$domain/alpine/v3.15/community" >> /etc/apk/repositories +ADD ./rootfs /rootfs +EOF + +mkdir -p rootfs #test +img=$ns/docker-headless:compile-alpine-3.15-xx-rootfs-tiger +plat="--platform linux/amd64,linux/arm64,linux/arm" +plat="--platform linux/arm" +docker buildx build $cache $plat $args --push -t $img -f $dockerfile . diff --git a/ubt-core/src/gcc/static/dfile.sh b/ubt-core/src/gcc/static/dfile.sh new file mode 100644 index 0000000..4240e53 --- /dev/null +++ b/ubt-core/src/gcc/static/dfile.sh @@ -0,0 +1,183 @@ +# # $ARG export BASEIMAGE=unknown +# $ARG export BASEIMAGE=ubuntu:20.04 +# $ARG export BUILDPLATFORM=linux/amd64 +# Define the Alpine packages to be installed into the image. +$ARG export ALPINE_PKGS="\ + # Needed to generate self-signed certificates + openssl \ + # Needed to use netcat with unix socket. + netcat-openbsd \ +" +# Define the Debian/Ubuntu packages to be installed into the image. +$ARG export DEBIAN_PKGS="\ + # Used to determine if nginx is ready. + netcat \ + # For ifconfig + net-tools \ + # Needed to generate self-signed certificates + openssl \ +" + +# test +ping -c 2 qq.com +apk update; apk add gawk; +function print_time_cost(){ + local begin_time=$1 + gawk 'BEGIN{ + print "本操作从" strftime("%Y年%m月%d日%H:%M:%S",'$begin_time'),"开始 ,", + strftime("到%Y年%m月%d日%H:%M:%S",systime()) ,"结束,", + " 共历时" systime()-'$begin_time' "秒"; + }' 2>&1 | tee -a $logfile +} + +# Get Dockerfile cross-compilation helpers. +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/tonistiigi-xx AS xx +# # Build UPX. +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS upx +# https://gitee.com/infrastlabs/alpine-ext/blob/master/src/build.sh +# https://www.jakehu.me/2021/alpine-mirrors/ +# domain="mirrors.ustc.edu.cn" +# domain="mirrors.aliyun.com"; +# mirrors.tuna.tsinghua.edu.cn +# $RUN export domain="mirrors.tuna.tsinghua.edu.cn"; \ +# echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ +# echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +# $RUN apk --no-cache add build-base curl make cmake git && \ +function do_upx(){ + # pwd; ls -laSh + mkdir -p /tmp/upx && \ + export file=upx-4.0.1-src.tar.xz; \ + test -s /mnt/$file || curl -# -k -fSL https://ghproxy.com/https://github.com/upx/upx/releases/download/v4.0.1/$file > /mnt/$file + # pwd; ls -laSh + cat /mnt/$file | tar xJ --strip 1 -C /tmp/upx && \ + make -C /tmp/upx build/release-gcc -j$(nproc) && \ + cp -v /tmp/upx/build/release-gcc/upx /usr/bin/upx +} +rm -rf /mnt/logs; mkdir -p /mnt/logs +begin_time="`gawk 'BEGIN{print systime()}'`"; export logfile=/mnt/logs/do_upx.log +do_upx 2>&1|tee $logfile; print_time_cost $begin_time + +# export targetDir=/opt/base +export targetDir=/usr + +# Build TigerVNC server. +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS tigervnc +# $RUN export domain="mirrors.tuna.tsinghua.edu.cn"; \ +# echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ +# echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +# $ARG export TARGETPLATFORM +# COPY --from=xx / / +function do_tiger(){ +mkdir -p /build; \cp -a src/tigervnc/* /build/ +$RUN sh /build/build.sh +$RUN xx-verify --static /tmp/tigervnc-install/usr/bin/Xvnc +$RUN xx-verify --static /tmp/tigervnc-install/usr/bin/vncpasswd +# COPY --from=upx /usr/bin/upx /usr/bin/upx +$RUN upx /tmp/tigervnc-install/usr/bin/Xvnc +$RUN upx /tmp/tigervnc-install/usr/bin/vncpasswd +} +begin_time="`gawk 'BEGIN{print systime()}'`"; logfile=/mnt/logs/do_tiger.log +do_tiger 2>&1|tee $logfile; print_time_cost $begin_time + + +# Build Fontconfig. +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS fontconfig +# $RUN export domain="mirrors.tuna.tsinghua.edu.cn"; \ +# echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ +# echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +# $ARG export TARGETPLATFORM +# COPY --from=xx / / +function do_fontconfig(){ +\cp -a src/fontconfig/build.sh /tmp/build-fontconfig.sh +$RUN sh /tmp/build-fontconfig.sh +} +# 共历时172秒 +# begin_time="`gawk 'BEGIN{print systime()}'`"; export logfile=/mnt/logs/do_fontconfig.log +# do_fontconfig 2>&1|tee $logfile; print_time_cost $begin_time + +# Build xdpyprobe. +# Used to determine if the X server (Xvnc) is ready. +# FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS xdpyprobe +# $RUN export domain="mirrors.tuna.tsinghua.edu.cn"; \ +# echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \ +# echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories +# $ARG export TARGETPLATFORM +# COPY --from=xx / / +function do_xdpy(){ +mkdir -p /tmp/xdpyprobe +\cp -a src/xdpyprobe/* /tmp/xdpyprobe/ +# $RUN apk --no-cache add make clang +# $RUN xx-apk --no-cache add gcc musl-dev libx11-dev libx11-static libxcb-static +$RUN export CC=xx-clang; \ + make -C /tmp/xdpyprobe +$RUN xx-verify --static /tmp/xdpyprobe/xdpyprobe +# COPY --from=upx /usr/bin/upx /usr/bin/upx +$RUN upx /tmp/xdpyprobe/xdpyprobe +} +begin_time="`gawk 'BEGIN{print systime()}'`"; export logfile=/mnt/logs/do_xdpy.log +do_xdpy 2>&1|tee $logfile; print_time_cost $begin_time + +# Pull base image. +# FROM ${BASEIMAGE} +# $ARG export TARGETPLATFORM +# $RUN export DOMAIN="mirrors.ustc.edu.cn"; \ +# test -z "$(echo $TARGETPLATFORM |grep arm)" && target=ubuntu || target=ubuntu-ports; \ +# echo "deb http://${DOMAIN}/$target focal main restricted universe multiverse" > /etc/apt/sources.list \ +# && echo "deb http://${DOMAIN}/$target focal-updates main restricted universe multiverse">> /etc/apt/sources.list; +# # WORKDIR /tmp +# # # Install system packages. +# # $ARG export ALPINE_PKGS +# # $ARG export DEBIAN_PKGS +# $RUN \ +# if [ -n "$(which apk)" ]; then \ +# add-pkg ${ALPINE_PKGS}; \ +# else \ +# add-pkg ${DEBIAN_PKGS}; \ +# fi && \ +# # Remove some unneeded stuff. +# rm -rf /var/cache/fontconfig/* + +# Add files. +# # COPY helpers/* /opt/base/bin/ +# # COPY rootfs/ / +# # COPY --link +# COPY --from=tigervnc /tmp/tigervnc-install/usr/bin/Xvnc /opt/base/bin/ +# COPY --from=tigervnc /tmp/tigervnc-install/usr/bin/vncpasswd /opt/base/bin/ +# COPY --from=tigervnc /tmp/xkb-install/usr/share/X11/xkb /opt/base/share/X11/xkb +# COPY --from=tigervnc /tmp/xkbcomp-install/usr/bin/xkbcomp /opt/base/bin/ +# # COPY --from=openbox /tmp/openbox-install/usr/bin/openbox /opt/base/bin/ +# # COPY --from=openbox /tmp/openbox-install/usr/bin/obxprop /opt/base/bin/ +# COPY --from=fontconfig /tmp/fontconfig-install/opt /opt +# COPY --from=xdpyprobe /tmp/xdpyprobe/xdpyprobe /opt/base/bin/ +# # COPY --from=yad /tmp/yad-install/usr/bin/yad /opt/base/bin/ +# # COPY --from=nginx /tmp/nginx-install /opt/base/ +# # COPY --from=dhparam /tmp/dhparam.pem /defaults/ +# # COPY --from=noVNC /opt/noVNC /opt/noVNC + +rm -rf /mnt/rootfs #clear +mkdir -p /mnt/rootfs${targetDir}/bin/ /mnt/rootfs${targetDir}/share/X11/ +\cp -a /usr/bin/upx /mnt/rootfs${targetDir}/bin/ #+upx +\cp -a /tmp/tigervnc-install/usr/bin/Xvnc /mnt/rootfs${targetDir}/bin/ +\cp -a /tmp/tigervnc-install/usr/bin/vncpasswd /mnt/rootfs${targetDir}/bin/ +\cp -a /tmp/xkb-install/usr/share/X11/xkb /mnt/rootfs${targetDir}/share/X11/xkb +\cp -a /tmp/xkbcomp-install/usr/bin/xkbcomp /mnt/rootfs${targetDir}/bin/ +# \cp -a /tmp/fontconfig-install/opt /mnt/rootfs/opt #opt>usr?? +\cp -a /tmp/xdpyprobe/xdpyprobe /mnt/rootfs${targetDir}/bin/ + +# Set environment variables. +# ENV \ +# DISPLAY_WIDTH=1920 \ +# DISPLAY_HEIGHT=1080 \ +# DARK_MODE=0 \ +# SECURE_CONNECTION=0 \ +# SECURE_CONNECTION_VNC_METHOD=SSL \ +# SECURE_CONNECTION_CERTS_CHECK_INTERVAL=60 \ +# WEB_LISTENING_PORT=5800 \ +# VNC_LISTENING_PORT=5900 \ +# VNC_PASSWORD= \ +# ENABLE_CJK_FONT=0 + +# Expose ports. +# - 5800: VNC web interface +# - 5900: VNC +# EXPOSE 5800 5900 diff --git a/ubt-core/src/gcc/static/src/fontconfig/build.sh b/ubt-core/src/gcc/static/src/fontconfig/build.sh new file mode 100644 index 0000000..8c60b07 --- /dev/null +++ b/ubt-core/src/gcc/static/src/fontconfig/build.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# +# Helper script that builds Fontconfig as a static library. +# +# A customized fontconfig library is used. This is required to allows baseimage +# programs (like openbox and yad) to use independant fonts and font configuration +# files. This way, these programs don't depend on distro of the baseimage. +# +# NOTE: This script is expected to be run under Alpine Linux. +# + +set -e # Exit immediately if a command exits with a non-zero status. +set -u # Treat unset variables as an error. + +# Define software versions. +FONTCONFIG_VERSION=2.14.0 + +# Define software download URLs. +FONTCONFIG_URL=https://www.freedesktop.org/software/fontconfig/release/fontconfig-${FONTCONFIG_VERSION}.tar.gz +test -z "$targetDir" && export targetDir=/opt/base +function down_catfile(){ + url=$1 + file=${url##*/} + #curl -# -L -f + test -f /mnt/$file || curl -# -k -fSL $url > /mnt/$file + cat /mnt/$file +} + +# Set same default compilation flags as abuild. +export CFLAGS="-Os -fomit-frame-pointer" +export CXXFLAGS="$CFLAGS" +export CPPFLAGS="$CFLAGS" +export LDFLAGS="-Wl,--strip-all -Wl,--as-needed" + +export CC=xx-clang +export CXX=xx-clang++ + +function log { + echo ">>> $*" +} + +# +# Install required packages. +# +# log "Installing required Alpine packages..." +# apk --no-cache add \ +# curl \ +# build-base \ +# clang \ +# pkgconfig \ +# gperf \ +# python3 \ +# font-croscore \ + +# xx-apk --no-cache --no-scripts add \ +# glib-dev \ +# g++ \ +# freetype-dev \ +# expat-dev \ + +# +# Install Noto fonts. +# Only the fonts used by JWM are installed. +# +log "Installing Noto fonts..." +mkdir -p /tmp/fontconfig-install${targetDir}/share/fonts +for FONT in Arimo-Regular Arimo-Bold +do + \cp -v /usr/share/fonts/noto/$FONT.ttf /tmp/fontconfig-install${targetDir}/share/fonts/ +done + +# +# Build fontconfig. +# The static library will be used by some baseimage programs. We need to +# compile our own version to adjust different paths used by fontconfig. +# Note that the fontconfig cache generated by fc-cache is architecture +# dependent. Thus, we won't generate one, but it's not a problem since +# we have very few fonts installed. +# +mkdir -p /tmp/fontconfig +log "Downloading fontconfig..." +down_catfile ${FONTCONFIG_URL} | tar -xz --strip 1 -C /tmp/fontconfig + +log "Configuring fontconfig..." +( + cd /tmp/fontconfig && ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --with-default-fonts=${targetDir}/share/fonts \ + --with-baseconfigdir=${targetDir}/share/fontconfig \ + --with-configdir=${targetDir}/share/fontconfig/conf.d \ + --with-templatedir=${targetDir}/share/fontconfig/conf.avail \ + --with-cache-dir=/config/xdg/cache/fontconfig \ + --disable-shared \ + --enable-static \ + --disable-docs \ + --disable-nls \ + --disable-cache-build \ +) + +log "Compiling fontconfig..." +make -C /tmp/fontconfig -j$(nproc) + +log "Installing fontconfig..." +make DESTDIR=/tmp/fontconfig-install -C /tmp/fontconfig install diff --git a/ubt-core/src/gcc/static/src/tigervnc/build.sh b/ubt-core/src/gcc/static/src/tigervnc/build.sh new file mode 100644 index 0000000..5fcd620 --- /dev/null +++ b/ubt-core/src/gcc/static/src/tigervnc/build.sh @@ -0,0 +1,433 @@ +#!/bin/sh +# ref: https://gitee.com/infrastlabs/fk-docker-baseimage-gui/raw/master/src/tigervnc/build.sh +# +# Helper script that builds the TigerVNC server as a static binary. +# +# This also builds a customized version of XKeyboard config files and the +# compiler (xkbcomp). By using a different instance/version of XKeyboard, we +# prevent version mismatch issues thay could occur by using packages from the +# distro of the baseimage. +# +# NOTE: This script is expected to be run under Alpine Linux. +# + +set -e # Exit immediately if a command exits with a non-zero status. +set -u # Treat unset variables as an error. + +# Define software versions. +TIGERVNC_VERSION=1.13.1 +XSERVER_VERSION=1.20.14 + +# Use the same versions has Alpine 3.15. +GNUTLS_VERSION=3.7.1 +LIBXFONT2_VERSION=2.0.5 +LIBFONTENC_VERSION=1.1.4 +LIBTASN1_VERSION=4.18.0 +LIBXSHMFENCE_VERSION=1.3 + +# If the XKeyboardConfig version is too recent compared to xorgproto/libX11, +# xkbcomp will complain with warnings like "Could not resolve keysym ...". With +# Alpine 3.15, XKeyboardConfig version 2.32 is the latest version that doesn't +# produces these warnings. +XKEYBOARDCONFIG_VERSION=2.32 +XKBCOMP_VERSION=1.4.5 + +# Define software download URLs. +TIGERVNC_URL=https://ghproxy.com/https://github.com/TigerVNC/tigervnc/archive/v${TIGERVNC_VERSION}.tar.gz +XSERVER_URL=https://www.x.org/releases/individual/xserver/xorg-server-${XSERVER_VERSION}.tar.gz + +GNUTLS_URL=https://www.gnupg.org/ftp/gcrypt/gnutls/v${GNUTLS_VERSION%.*}/gnutls-${GNUTLS_VERSION}.tar.xz +LIBTASN1_URL=https://ftp.gnu.org/gnu/libtasn1/libtasn1-${LIBTASN1_VERSION}.tar.gz +LIBXFONT2_URL=https://www.x.org/pub/individual/lib/libXfont2-${LIBXFONT2_VERSION}.tar.gz +LIBFONTENC_URL=https://www.x.org/releases/individual/lib/libfontenc-${LIBFONTENC_VERSION}.tar.gz +LIBXSHMFENCE_URL=https://www.x.org/releases/individual/lib/libxshmfence-${LIBXSHMFENCE_VERSION}.tar.gz + +XKEYBOARDCONFIG_URL=https://www.x.org/archive/individual/data/xkeyboard-config/xkeyboard-config-${XKEYBOARDCONFIG_VERSION}.tar.bz2 +XKBCOMP_URL=https://www.x.org/releases/individual/app/xkbcomp-${XKBCOMP_VERSION}.tar.bz2 + +test -z "$targetDir" && export targetDir=/opt/base +function down_catfile(){ + url=$1 + file=${url##*/} + #curl -# -L -f + test -f /mnt/$file || curl -# -k -fSL $url > /mnt/$file + cat /mnt/$file +} + +# Set same default compilation flags as abuild. +export CFLAGS="-Os -fomit-frame-pointer" +export CXXFLAGS="$CFLAGS" +export CPPFLAGS="$CFLAGS" +export LDFLAGS="-Wl,--as-needed --static -static -Wl,--strip-all" + +export CC=xx-clang + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +function log { + echo ">>> $*" +} + +# +# Install required packages. +# +# log "Installing required Alpine packages..." +# ping -c 2 qq.com +# apk --no-cache add \ +# curl \ +# build-base \ +# clang \ +# cmake \ +# autoconf \ +# automake \ +# libtool \ +# pkgconf \ +# meson \ +# util-macros \ +# font-util-dev \ +# xtrans \ + +# ping -c 2 qq.com +# xx-apk --no-cache --no-scripts add \ +# g++ \ +# xcb-util-dev \ +# pixman-dev \ +# libx11-dev \ +# libgcrypt-dev \ +# libgcrypt-static \ +# libgpg-error-static \ +# libxkbfile-dev \ +# libxfont2-dev \ +# libjpeg-turbo-dev \ +# nettle-dev \ +# libunistring-dev \ +# gnutls-dev \ +# fltk-dev \ +# libxrandr-dev \ +# libxtst-dev \ +# freetype-dev \ +# libfontenc-dev \ +# zlib-dev \ +# libx11-static \ +# libxcb-static \ +# zlib-static \ +# pixman-static \ +# libjpeg-turbo-static \ +# freetype-static \ +# libpng-static \ +# bzip2-static \ +# brotli-static \ +# libunistring-static \ +# nettle-static \ +# gettext-static \ +# libunistring-dev \ +# libbsd-dev \ + +# +# Build GNU TLS. +# The static library is not provided by Alpine repository, so we need to build +# it ourself. +# +mkdir -p /tmp/gnutls +log "Downloading GNU TLS..." +down_catfile ${GNUTLS_URL} | tar -xJ --strip 1 -C /tmp/gnutls +log "Configuring GNU TLS..." +( + cd /tmp/gnutls && ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --disable-openssl-compatibility \ + --disable-rpath \ + --disable-guile \ + --disable-valgrind-tests \ + --disable-cxx \ + --without-p11-kit \ + --disable-tools \ + --disable-doc \ + --enable-static \ + --disable-shared \ +) +log "Compiling GNU TLS..." +make -C /tmp/gnutls -j$(nproc) +log "Installing GNU TLS..." +make DESTDIR=$(xx-info sysroot) -C /tmp/gnutls install + +# +# Build libXfont2 +# The static library is not provided by Alpine repository, so we need to build +# it ourself. +# +mkdir -p /tmp/libxfont2 +log "Downloading libXfont2..." +down_catfile ${LIBXFONT2_URL} | tar -xz --strip 1 -C /tmp/libxfont2 +log "Configuring libXfont2..." +( + cd /tmp/libxfont2 && ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --without-fop \ + --without-xmlto \ + --disable-devel-docs \ + --enable-static \ + --disable-shared \ +) +log "Compiling libXfont2..." +sed 's/^noinst_PROGRAMS = /#noinst_PROGRAMS = /' -i /tmp/libxfont2/Makefile.in +make -C /tmp/libxfont2 -j$(nproc) +log "Installing libXfont2..." +make DESTDIR=$(xx-info sysroot) -C /tmp/libxfont2 install + +# +# Build libfontenc +# The static library is not provided by Alpine repository, so we need to build +# it ourself. +# +mkdir -p /tmp/libfontenc +log "Downloading libfontenc..." +down_catfile ${LIBFONTENC_URL} | tar -xz --strip 1 -C /tmp/libfontenc +log "Configuring libfontenc..." +( + cd /tmp/libfontenc && ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --with-encodingsdir=/usr/share/fonts/encodings \ + --enable-static \ + --disable-shared \ +) +log "Compiling libfontenc..." +make -C /tmp/libfontenc -j$(nproc) +log "Installing libfontenc..." +make DESTDIR=$(xx-info sysroot) -C /tmp/libfontenc install + +# +# Build libtasn1 +# The static library is not provided by Alpine repository, so we need to build +# it ourself. +# +mkdir -p /tmp/libtasn1 +log "Downloading libtasn1..." +down_catfile ${LIBTASN1_URL} | tar -xz --strip 1 -C /tmp/libtasn1 +log "Configuring libtasn1..." +( + cd /tmp/libtasn1 && CFLAGS="$CFLAGS -Wno-error=inline" ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --enable-static \ + --disable-shared \ +) +log "Compiling libtasn1..." +make -C /tmp/libtasn1 -j$(nproc) +log "Installing libtasn1..." +make DESTDIR=$(xx-info sysroot) -C /tmp/libtasn1 install + +# +# Build libxshmfence +# The static library is not provided by Alpine repository, so we need to build +# it ourself. +# +mkdir -p /tmp/libxshmfence +log "Downloading libxshmfence..." +down_catfile ${LIBXSHMFENCE_URL} | tar -xz --strip 1 -C /tmp/libxshmfence +log "Configuring libxshmfence..." +( + cd /tmp/libxshmfence && ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --enable-static \ + --disable-shared \ + --enable-futex \ +) +log "Compiling libxshmfence..." +make -C /tmp/libxshmfence -j$(nproc) +log "Installing libxshmfence..." +make DESTDIR=$(xx-info sysroot) -C /tmp/libxshmfence install + +# +# Build TigerVNC +# +mkdir -p /tmp/tigervnc +log "Downloading TigerVNC..." +down_catfile ${TIGERVNC_URL} | tar -xz --strip 1 -C /tmp/tigervnc +log "Downloading Xorg server..." +down_catfile ${XSERVER_URL} | tar -xz --strip 1 -C /tmp/tigervnc/unix/xserver + +log "Patching TigerVNC..." +# Apply the TigerVNC patch against the X server. +patch -p1 -d /tmp/tigervnc/unix/xserver < /tmp/tigervnc/unix/xserver120.patch +# Build a static binary of vncpasswd. +patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/vncpasswd-static.patch +# Disable PAM support. +patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/disable-pam.patch +# Fix static build. +patch -p1 -d /tmp/tigervnc < "$SCRIPT_DIR"/static-build.patch + +log "Configuring TigerVNC..." +( + cd /tmp/tigervnc && cmake -G "Unix Makefiles" \ + $(xx-clang --print-cmake-defines) \ + -DCMAKE_FIND_ROOT_PATH=$(xx-info sysroot) \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DINSTALL_SYSTEMD_UNITS=OFF \ + -DENABLE_NLS=OFF \ + -DENABLE_GNUTLS=ON \ + -DENABLE_NETTLE=ON \ + -DBUILD_VIEWER=OFF \ +) + +log "Compiling TigerVNC common libraries and tools..." +make -C /tmp/tigervnc/common -j$(nproc) +make -C /tmp/tigervnc/unix/common -j$(nproc) +make -C /tmp/tigervnc/unix/vncpasswd -j$(nproc) + +log "Configuring TigerVNC server..." +autoreconf -fiv /tmp/tigervnc/unix/xserver +( + cd /tmp/tigervnc/unix/xserver && CFLAGS="$CFLAGS -Wno-implicit-function-declaration" ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ + --sysconfdir=/etc/X11 \ + --localstatedir=/var \ + --with-xkb-path=${targetDir}/share/X11/xkb \ + --with-xkb-output=/var/lib/xkb \ + --with-xkb-bin-directory=${targetDir}/bin \ + --with-default-font-path=/usr/share/fonts/misc,/usr/share/fonts/100dpi:unscaled,/usr/share/fonts/75dpi:unscaled,/usr/share/fonts/TTF,/usr/share/fonts/Type1 \ + --disable-docs \ + --disable-unit-tests \ + --without-dtrace \ + \ + --with-pic \ + --disable-static \ + --disable-shared \ + \ + --disable-listen-tcp \ + --enable-listen-unix \ + --disable-listen-local \ + \ + --disable-dpms \ + \ + --disable-systemd-logind \ + --disable-config-hal \ + --disable-config-udev \ + --disable-xorg \ + --disable-dmx \ + --disable-libdrm \ + --disable-dri \ + --disable-dri2 \ + --disable-dri3 \ + --disable-present \ + --disable-xvfb \ + --disable-glx \ + --disable-xinerama \ + --disable-record \ + --disable-xf86vidmode \ + --disable-xnest \ + --disable-xquartz \ + --disable-xwayland \ + --disable-xwayland-eglstream \ + --disable-standalone-xpbproxy \ + --disable-xwin \ + --disable-glamor \ + --disable-kdrive \ + --disable-xephyr \ +) + +# Remove all automatic dependencies on libraries and manually define them to +# have the correct order. +find /tmp/tigervnc -name "*.la" -exec sed 's/^dependency_libs/#dependency_libs/' -i {} ';' +sed 's/^XSERVER_SYS_LIBS = .*/XSERVER_SYS_LIBS = -lXau -lXdmcp -lpixman-1 -ljpeg -lXfont2 -lfreetype -lfontenc -lpng16 -lbrotlidec -lbrotlicommon -lz -lbz2 -lgnutls -lhogweed -lgmp -lnettle -lunistring -ltasn1 -lbsd -lmd/' -i /tmp/tigervnc/unix/xserver/hw/vnc/Makefile + +log "Compiling TigerVNC server..." +make -C /tmp/tigervnc/unix/xserver -j$(nproc) + +log "Installing TigerVNC server..." +make DESTDIR=/tmp/tigervnc-install -C /tmp/tigervnc/unix/xserver install + +log "Installing TigerVNC vncpasswd tool..." +make DESTDIR=/tmp/tigervnc-install -C /tmp/tigervnc/unix/vncpasswd install + +# +# Build XKeyboardConfig. +# +mkdir -p /tmp/xkb +log "Downloading XKeyboardConfig..." +down_catfile ${XKEYBOARDCONFIG_URL} | tar -xj --strip 1 -C /tmp/xkb +log "Configuring XKeyboardConfig..." +( + cd /tmp/xkb && abuild-meson . build +) +log "Compiling XKeyboardConfig..." +meson compile -C /tmp/xkb/build +log "Installing XKeyboardConfig..." +DESTDIR="/tmp/xkb-install" meson install --no-rebuild -C /tmp/xkb/build + +log "Stripping XKeyboardConfig..." +# We keep only the files needed by Xvnc. +TO_KEEP=" + geometry/pc + symbols/pc + symbols/us + symbols/srvr_ctrl + symbols/keypad + symbols/altwin + symbols/inet + compat/accessx + compat/basic + compat/caps + compat/complete + compat/iso9995 + compat/ledcaps + compat/lednum + compat/ledscroll + compat/level5 + compat/misc + compat/mousekeys + compat/xfree86 + keycodes/evdev + keycodes/aliases + types/basic + types/complete + types/extra + types/iso9995 + types/level5 + types/mousekeys + types/numpad + types/pc + rules/evdev +" +find /tmp/xkb-install/usr/share/X11/xkb -mindepth 2 -maxdepth 2 -type d -print -exec rm -r {} ';' +find /tmp/xkb-install/usr/share/X11/xkb -mindepth 1 ! -type d $(printf "! -wholename /tmp/xkb-install/usr/share/X11/xkb/%s " $(echo "$TO_KEEP")) -print -delete + +# +# Build xkbcomp. +# +mkdir -p /tmp/xkbcomp +log "Downloading xkbcomp..." +down_catfile ${XKBCOMP_URL} | tar -xj --strip 1 -C /tmp/xkbcomp + +log "Configuring xkbcomp..." +( + LDFLAGS="-Wl,--as-needed --static -static -Wl,--strip-all -Wl,--start-group -lX11 -lxcb -lXdmcp -lXau -Wl,--end-group" && \ + cd /tmp/xkbcomp && \ + LDFLAGS="-Wl,--as-needed --static -static -Wl,--strip-all -Wl,--start-group -lX11 -lxcb -lXdmcp -lXau -Wl,--end-group" LIBS="$LDFLAGS" ./configure \ + --build=$(TARGETPLATFORM= xx-clang --print-target-triple) \ + --host=$(xx-clang --print-target-triple) \ + --prefix=/usr \ +) + +log "Compiling xkbcomp..." +make -C /tmp/xkbcomp -j$(nproc) + +log "Installing xkbcomp..." +make DESTDIR=/tmp/xkbcomp-install -C /tmp/xkbcomp install + diff --git a/ubt-core/src/gcc/static/src/tigervnc/disable-pam.patch b/ubt-core/src/gcc/static/src/tigervnc/disable-pam.patch new file mode 100644 index 0000000..8e7bf68 --- /dev/null +++ b/ubt-core/src/gcc/static/src/tigervnc/disable-pam.patch @@ -0,0 +1,66 @@ +--- a/CMakeLists.txt 2023-02-15 13:02:43.460281768 -0500 ++++ b/CMakeLists.txt 2023-02-15 13:07:14.323272704 -0500 +@@ -284,7 +284,7 @@ + endif() + + # Check for PAM library +-if(UNIX AND NOT APPLE) ++if(ENABLE_UNIX_PASSWORD_VALIDATOR) + check_include_files(security/pam_appl.h HAVE_PAM_H) + set(CMAKE_REQUIRED_LIBRARIES -lpam) + check_function_exists(pam_start HAVE_PAM_START) +--- a/common/rfb/CMakeLists.txt 2023-02-15 13:47:44.408913330 -0500 ++++ b/common/rfb/CMakeLists.txt 2023-02-15 13:48:26.906919800 -0500 +@@ -91,7 +91,7 @@ + target_sources(rfb PRIVATE WinPasswdValidator.cxx) + endif(WIN32) + +-if(UNIX AND NOT APPLE) ++if(ENABLE_UNIX_PASSWORD_VALIDATOR) + target_sources(rfb PRIVATE UnixPasswordValidator.cxx pam.c) + target_link_libraries(rfb ${PAM_LIBS}) + endif() +--- a/common/rfb/SSecurityPlain.cxx 2023-02-15 13:08:20.122930689 -0500 ++++ b/common/rfb/SSecurityPlain.cxx 2023-02-15 13:10:03.848414138 -0500 +@@ -25,7 +25,7 @@ + #include + #include + #include +-#if !defined(WIN32) && !defined(__APPLE__) ++#if defined(ENABLE_UNIX_PASSWORD_VALIDATOR) + #include + #endif + #ifdef WIN32 +@@ -68,7 +68,7 @@ + { + #ifdef WIN32 + valid = new WinPasswdValidator(); +-#elif !defined(__APPLE__) ++#elif defined(ENABLE_UNIX_PASSWORD_VALIDATOR) + valid = new UnixPasswordValidator(); + #else + valid = NULL; +--- a/common/rfb/SSecurityRSAAES.cxx 2023-02-18 15:14:38.894594813 -0500 ++++ b/common/rfb/SSecurityRSAAES.cxx 2023-02-18 15:15:29.606928303 -0500 +@@ -39,7 +39,7 @@ + #include + #include + #include +-#if !defined(WIN32) && !defined(__APPLE__) ++#if defined(ENABLE_UNIX_PASSWORD_VALIDATOR) + #include + #endif + #ifdef WIN32 +@@ -554,10 +554,10 @@ + + void SSecurityRSAAES::verifyUserPass() + { +-#ifndef __APPLE__ ++#if defined(WIN32) || defined(ENABLE_UNIX_PASSWORD_VALIDATOR) + #ifdef WIN32 + WinPasswdValidator* valid = new WinPasswdValidator(); +-#elif !defined(__APPLE__) ++#elif defined(ENABLE_UNIX_PASSWORD_VALIDATOR) + UnixPasswordValidator *valid = new UnixPasswordValidator(); + #endif + if (!valid->validate(sc, username.buf, password.buf)) { diff --git a/ubt-core/src/gcc/static/src/tigervnc/static-build.patch b/ubt-core/src/gcc/static/src/tigervnc/static-build.patch new file mode 100644 index 0000000..9177e00 --- /dev/null +++ b/ubt-core/src/gcc/static/src/tigervnc/static-build.patch @@ -0,0 +1,12 @@ +--- a/CMakeLists.txt 2023-02-15 13:02:43.460281768 -0500 ++++ b/CMakeLists.txt 2023-02-18 13:34:01.074642043 -0500 +@@ -69,6 +69,9 @@ + add_definitions(-D_DEBUG) + ENDIF() + ++# Prefer static libraries. ++set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) ++ + # Make sure we get a sane C version + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") + diff --git a/ubt-core/src/gcc/static/src/tigervnc/vncpasswd-static.patch b/ubt-core/src/gcc/static/src/tigervnc/vncpasswd-static.patch new file mode 100644 index 0000000..efffe3a --- /dev/null +++ b/ubt-core/src/gcc/static/src/tigervnc/vncpasswd-static.patch @@ -0,0 +1,11 @@ +--- a/unix/vncpasswd/CMakeLists.txt 2023-02-15 12:59:50.403972755 -0500 ++++ b/unix/vncpasswd/CMakeLists.txt 2023-02-15 13:00:02.040382803 -0500 +@@ -3,7 +3,7 @@ + add_executable(vncpasswd + vncpasswd.cxx) + +-target_link_libraries(vncpasswd tx rfb os) ++target_link_libraries(vncpasswd -static tx rfb os) + + install(TARGETS vncpasswd DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) + install(FILES vncpasswd.man DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man1 RENAME vncpasswd.1) diff --git a/ubt-core/src/gcc/static/src/xdpyprobe/Makefile b/ubt-core/src/gcc/static/src/xdpyprobe/Makefile new file mode 100644 index 0000000..26e2599 --- /dev/null +++ b/ubt-core/src/gcc/static/src/xdpyprobe/Makefile @@ -0,0 +1,22 @@ +TARGET = xdpyprobe + +RM = rm -f + +CPPFLAGS = -MMD +CFLAGS = -Wall -Werror -std=gnu11 -Os -fomit-frame-pointer +LDFLAGS = -static -Wl,--strip-all +LDLIBS = -lX11 -lxcb -lXau -lXdmcp + +SOURCES = xdpyprobe.c +OBJECTS = $(patsubst %.c, %.o, $(SOURCES)) +DEPENDS = $(OBJECTS:.o=.d) + +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@ + +clean: + -$(RM) $(OBJECTS) + -$(RM) $(TARGET) + -$(RM) $(DEPENDS) + +-include $(DEPENDS) diff --git a/ubt-core/src/gcc/static/src/xdpyprobe/config.h b/ubt-core/src/gcc/static/src/xdpyprobe/config.h new file mode 100644 index 0000000..a76c308 --- /dev/null +++ b/ubt-core/src/gcc/static/src/xdpyprobe/config.h @@ -0,0 +1,29 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Year in the copyright message */ +#define COPYRIGHT_YEAR 2016 + +/* Name of package */ +#define PACKAGE "xdpyprobe" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "xdpyprobe" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "xdpyprobe 0.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "xdpyprobe" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.1" + +/* Version number of package */ +#define VERSION "0.1" diff --git a/ubt-core/src/gcc/static/src/xdpyprobe/xdpyprobe.c b/ubt-core/src/gcc/static/src/xdpyprobe/xdpyprobe.c new file mode 100644 index 0000000..470fc58 --- /dev/null +++ b/ubt-core/src/gcc/static/src/xdpyprobe/xdpyprobe.c @@ -0,0 +1,146 @@ +/* +Copyright (C) 2016 Alex Kost + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include +#include +#include + +#include "config.h" + +#define EXIT_DRY_RUN 255 +#define FALSE 0 +#define TRUE (!FALSE) + +typedef int bool; +typedef struct settings_t { + char *display_name; + bool quiet; +} settings_t; + +int main (int argc, char *argv[]); +void usage (void); +void version (void); +void display_message (settings_t *settings, char *value); +void set_defaults (settings_t *settings); +void parse_args (int argc, char *argv[], settings_t *settings); + +int +main (int argc, char *argv[]) +{ + Display *display; + settings_t settings; + + set_defaults(&settings); + parse_args(argc, argv, &settings); + + display = XOpenDisplay(settings.display_name); + if (display) { + XCloseDisplay(display); + display_message(&settings, "yes"); + exit(EXIT_SUCCESS); + } else { + display_message(&settings, "no"); + exit(EXIT_FAILURE); + } +} + +void +usage (void) +{ + printf("Usage: %s [OPTIONS] [DISPLAY]\n", PACKAGE_NAME); + printf("Check connectivity of the X server defined by DISPLAY.\n" + "If DISPLAY is not specified, use $DISPLAY environment variable.\n\n"); + printf("Options:\n" + " -q, --quiet do not display any output\n" + " -h, --help display help message and exit\n" + " -v, --version display version message and exit\n\n"); + printf("Exit status:\n" + " %3d if connection to DISPLAY succeeded;\n" + " %3d if connection to DISPLAY failed;\n" + " %3d if X server connectivity was not probed (e.g., when\n" + " the help message is displayed).\n", + EXIT_SUCCESS, EXIT_FAILURE, EXIT_DRY_RUN); + exit(EXIT_DRY_RUN); +} + +void +version (void) +{ + printf("%s\n", PACKAGE_STRING); + printf("Copyright (C) %d Alex Kost\n" + "License GPLv3+: GNU GPL version 3 or later .\n" + "This is free software: you are free to change and redistribute it.\n" + "There is NO WARRANTY, to the extent permitted by law.\n", + COPYRIGHT_YEAR); + exit(EXIT_DRY_RUN); +} + +void +display_message (settings_t *settings, char *value) +{ + if (!settings->quiet) + printf("DISPLAY '%s' is available? %s\n", + settings->display_name, value); +} + +void +set_defaults(settings_t *settings) +{ + settings->display_name = getenv("DISPLAY"); + settings->quiet = FALSE; +} + +void +parse_args (int argc, char *argv[], settings_t *settings) +{ + int opt; + int opt_index = 0; + + struct option opts[] = { + {"quiet", no_argument, NULL, 'q'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0}, + }; + + while ((opt = getopt_long(argc, argv, "qhv", opts, &opt_index)) != -1) + switch (opt) { + case 'q': + settings->quiet = TRUE; + break; + case 'h': + usage(); + case 'v': + version(); + default: + usage(); + } + + switch (argc - optind) { /* arguments left */ + case 0: + break; + case 1: + settings->display_name = argv[optind]; + break; + default: + fprintf(stderr, "Too many arguments\n"); + usage(); + } +}