Skip to content

Commit

Permalink
sq: update gcc/static
Browse files Browse the repository at this point in the history
--
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
  • Loading branch information
sam#gemmi-win10 committed Oct 17, 2023
1 parent e54dbaa commit 008b1f1
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 40 deletions.
11 changes: 8 additions & 3 deletions ubt-core/src/gcc/static/Dockerfile.xx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@

ARG BUILDPLATFORM=linux/amd64
FROM --platform=$BUILDPLATFORM 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/tonistiigi-xx AS xx
FROM registry.cn-shenzhen.aliyuncs.com/infrasync/tonistiigi-xx AS xx

FROM --platform=$BUILDPLATFORM registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15 AS upx
# 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
Expand Down
90 changes: 89 additions & 1 deletion ubt-core/src/gcc/static/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,92 @@

## 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
Expand All @@ -21,4 +109,4 @@
- '{ "tag_prefix": "ubuntu-22.04", "baseimage": "jlesage/baseimage:ubuntu-22.04-v3.4.7", "platforms": "linux/amd64,linux/arm/v7,linux/arm64/v8" }'


```
```
71 changes: 67 additions & 4 deletions ubt-core/src/gcc/static/alpine-build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +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

img=registry.cn-shenzhen.aliyuncs.com/infrasync/alpine:3.15-xx
docker build -t $img -f Dockerfile.xx . #xx
repoHub=docker.io
echo "${DOCKER_REGISTRY_PW_dockerhub}" |docker login --username=${DOCKER_REGISTRY_USER_dockerhub} --password-stdin $repoHub

# ./Dockerfile: err docker-1806/1903--alpine--make--noPermition
docker run -it --rm --privileged \
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 <<EOF
FROM alpine:3.15
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
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 .
62 changes: 48 additions & 14 deletions ubt-core/src/gcc/static/dfile.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# $ARG export BASEIMAGE=unknown
$ARG export BASEIMAGE=ubuntu:20.04
$ARG export BUILDPLATFORM=linux/amd64
# # $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
Expand All @@ -20,6 +20,15 @@ $ARG export DEBIAN_PKGS="\

# 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
Expand All @@ -34,14 +43,22 @@ ping -c 2 qq.com
# 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 && \
pwd; ls -lah
mkdir /tmp/upx && \
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 -lah
# 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
Expand All @@ -50,13 +67,18 @@ ping -c 2 qq.com
# 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
Expand All @@ -65,8 +87,13 @@ $RUN upx /tmp/tigervnc-install/usr/bin/vncpasswd
# 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.
Expand All @@ -76,14 +103,19 @@ $RUN sh /tmp/build-fontconfig.sh
# echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories
# $ARG export TARGETPLATFORM
# COPY --from=xx / /
\cp -a src/xdpyprobe /tmp/xdpyprobe
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}
Expand Down Expand Up @@ -122,13 +154,15 @@ $RUN upx /tmp/xdpyprobe/xdpyprobe
# # COPY --from=dhparam /tmp/dhparam.pem /defaults/
# # COPY --from=noVNC /opt/noVNC /opt/noVNC

mkdir -p /mnt/rootfs/opt/base/bin/ /mnt/rootfs/opt/base/share/X11/
\cp -a /tmp/tigervnc-install/usr/bin/Xvnc /mnt/rootfs/opt/base/bin/
\cp -a /tmp/tigervnc-install/usr/bin/vncpasswd /mnt/rootfs/opt/base/bin/
\cp -a /tmp/xkb-install/usr/share/X11/xkb /mnt/rootfs/opt/base/share/X11/xkb
\cp -a /tmp/xkbcomp-install/usr/bin/xkbcomp /mnt/rootfs/opt/base/bin/
\cp -a /tmp/fontconfig-install/opt /mnt/rootfs/opt
\cp -a /tmp/xdpyprobe/xdpyprobe /mnt/rootfs/opt/base/bin/
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 \
Expand Down
24 changes: 16 additions & 8 deletions ubt-core/src/gcc/static/src/fontconfig/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ 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"
Expand Down Expand Up @@ -55,10 +63,10 @@ function log {
# Only the fonts used by JWM are installed.
#
log "Installing Noto fonts..."
mkdir -p /tmp/fontconfig-install/opt/base/share/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/opt/base/share/fonts/
\cp -v /usr/share/fonts/noto/$FONT.ttf /tmp/fontconfig-install${targetDir}/share/fonts/
done

#
Expand All @@ -69,20 +77,20 @@ done
# dependent. Thus, we won't generate one, but it's not a problem since
# we have very few fonts installed.
#
mkdir /tmp/fontconfig
mkdir -p /tmp/fontconfig
log "Downloading fontconfig..."
curl -# -L -f ${FONTCONFIG_URL} | tar -xz --strip 1 -C /tmp/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=/opt/base/share/fonts \
--with-baseconfigdir=/opt/base/share/fontconfig \
--with-configdir=/opt/base/share/fontconfig/conf.d \
--with-templatedir=/opt/base/share/fontconfig/conf.avail \
--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 \
Expand Down
Loading

0 comments on commit 008b1f1

Please sign in to comment.