1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Add Dockerfiles for build images of CDT project

This is the state of the files as of cdt-infra
commit 497e7b2a643ff6ea12a56a21c17dd2d170e918c8 with
the Readme updated for the new locations
This commit is contained in:
Jonah Graham 2024-04-26 10:43:40 -04:00
parent 88355ecc48
commit 9fb6260b6a
19 changed files with 971 additions and 0 deletions

1
docker/.dockerignore Normal file
View file

@ -0,0 +1 @@
build-images.sh

33
docker/Readme.md Normal file
View file

@ -0,0 +1,33 @@
Dockerfiles
============
The docker images for Eclipse CDT's [Jenkins instance](https://ci.eclipse.org/cdt/) are stored at [quay.io](https://quay.io/organization/eclipse-cdt)
and built using the following scripts. The individual directories below this one contain Dockerfiles which contain a little more information. Note that
the split between the Dockerfiles is somewhat arbitrary and historical. Only the cdt-infra-eclipse-full image is known to be referenced outside
of the cdt repo.
build-images.sh
===============
Builds the images locally. A download of [Xcode_9.4.1.xip](https://download.developer.apple.com/Developer_Tools/Xcode_9.4.1/Xcode_9.4.1.xip) (visit [here](https://developer.apple.com/download/more/) first to logon to Apple if needed) is needed to do a complete build. To save on rebuild times, the xip can be removed from the directory to use the cached cdt-infra-build-macos-sdk image.
deploy-images.sh
================
Builds images (from cache), uploads them to quay.io/eclipse-cdt namespace and then
updates all the Jenkinsfile and yaml files to refer to these new images.
Using the docker images
=======================
The docker images exist mostly for use in Jenkins, see the [pod templates](https://github.com/eclipse-cdt/cdt/blob/main/jenkins/pod-templates).
They can be used to recreate a consistent environment in other cases too. For example, you can run a full build on a machine that does not already have the tools by using docker:
```
docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest COMMAND HERE
```
For examples of the above in practice, see [cdt-gdb-adapter's integration tests readme](https://github.com/eclipse-cdt/cdt-gdb-adapter/blob/master/src/integration-tests/README.md) and the native section of [CDT's readme](https://github.com/eclipse-cdt/cdt/blob/main/BUILDING.md#native)

16
docker/build-images.sh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eux
# Xcode_13.1.xip is needed to build the OSx cross compiler image from https://developer.apple.com/download/all/?q=xcode
# As an optimization for the rebuild times, the image is only built if the xip is present.
if [ -f Xcode_13.1.xip ]; then
docker build --rm --build-arg Xcodexip=Xcode_13.1.xip -f cdt-infra-build-macos-sdk/ubuntu-18.04/Dockerfile -t cdt-infra-build-macos-sdk:ubuntu-18.04 .
else
echo "MacOSX SDK & Toolchain build is being skipped"
fi
docker build --rm -f cdt-infra-base/ubuntu-18.04/Dockerfile -t cdt-infra-base:ubuntu-18.04 .
docker build --rm -f cdt-infra-all-gdbs/ubuntu-18.04/Dockerfile -t cdt-infra-all-gdbs:ubuntu-18.04 .
docker build --rm -f cdt-infra-eclipse-full/ubuntu-18.04/Dockerfile -t cdt-infra-eclipse-full:ubuntu-18.04 .
docker build --rm -f cdt-infra-plus-eclipse-install/ubuntu-18.04/Dockerfile -t cdt-infra-plus-eclipse-install:ubuntu-18.04 .

View file

@ -0,0 +1,26 @@
Building GDBs in a separate image
=================================
The GDBs take a long time to build and it is very inconvenient to have to build them
because something else in a Docker file has changed. Therefore, this image *only*
builds the GDBs using the download-build-gdb.sh script.
Other images can then use these prebuilt GDBs by copying them to their image.
For example, to copy all the GDBs use this line:
```
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all /shared/common/gdb/gdb-all
```
Or, to copy a specific version only, do this:
```
# Copy install directory
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/install/gdb-8.2.1 /shared/common/gdb/gdb-all/install/gdb-8.2.1
# Copy versioned links
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdb.8.2 /shared/common/gdb/gdb-all/bin/gdb.8.2
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdb.8.2.1 /shared/common/gdb/gdb-all/bin/gdb.8.2.1
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdbserver.8.2 /shared/common/gdb/gdb-all/bin/gdbserver.8.2
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdbserver.8.2.1 /shared/common/gdb/gdb-all/bin/gdbserver.8.2.1
```

View file

@ -0,0 +1,42 @@
FROM ubuntu:18.04
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
gnupg \
openssh-client \
pkg-config \
wget \
zip \
locales \
build-essential \
bison \
flex \
libgmp-dev \
libexpat1-dev \
libmpfr-dev \
libncurses-dev \
pkg-config \
zlib1g-dev \
texinfo \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8
# Need locale to be UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Build GDB
COPY scripts/download-build-gdb.sh /opt/scripts/download-build-gdb.sh
ENV GDB_BASE /shared/common/gdb/gdb-all
ENV GDB_VERSIONS all
# build without debug info to reduce size
ENV CFLAGS -g0
ENV CXXFLAGS -g0
RUN chmod u+x /opt/scripts/download-build-gdb.sh && mkdir -p /shared/common/gdb/gdb-all && /opt/scripts/download-build-gdb.sh -b $GDB_BASE $GDB_VERSIONS \
&& rm -rf $GDB_BASE/download && rm -rf $GDB_BASE/build

View file

@ -0,0 +1,2 @@
This directory contains dockerfiles for CDT Infra to provide a basic Java environment.

View file

@ -0,0 +1,139 @@
# This file is derived from:
# - https://github.com/eclipse-cbi/dockerfiles/blob/bf1f1a18f4910d007de67765f8df083102150a7c/distros/Dockerfile
# - https://github.com/eclipse-cbi/dockerfiles/blob/bf1f1a18f4910d007de67765f8df083102150a7c/gtk3-wm/ubuntu-metacity/18.04/Dockerfile
# Consult https://github.com/eclipse-cbi/dockerfiles for possible updates
# differences from source are commented
FROM ubuntu:18.04
### user name recognition at runtime w/ an arbitrary uid - for OpenShift deployments
COPY scripts/uid_entrypoint /usr/local/bin/uid_entrypoint
RUN chmod u+x /usr/local/bin/uid_entrypoint && \
chgrp 0 /usr/local/bin/uid_entrypoint && \
chmod g=u /usr/local/bin/uid_entrypoint /etc/passwd
# Add dumb-init entry point: https://github.com/eclipse-cdt/cdt-infra/pull/26
RUN apt-get update && apt-get install -y --no-install-recommends \
dumb-init \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "uid_entrypoint", "dumb-init" ]
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libgtk-3-0 \
tigervnc-standalone-server \
tigervnc-common \
metacity \
x11-xserver-utils \
libgl1-mesa-dri \
xfonts-base \
xfonts-scalable \
xfonts-100dpi \
xfonts-75dpi \
fonts-liberation \
fonts-liberation2 \
fonts-freefont-ttf \
fonts-dejavu \
fonts-dejavu-core \
fonts-dejavu-extra \
&& rm -rf /var/lib/apt/lists/*
ENV HOME=/home/vnc
ENV DISPLAY :0
RUN mkdir -p ${HOME}/.vnc && chmod -R 775 ${HOME} \
&& echo "123456" | vncpasswd -f > ${HOME}/.vnc/passwd \
&& chmod 600 ${HOME}/.vnc/passwd
# In addition to metacity in upstream version, provide icewm and mutter manager scripts
# and use icewm as default (experiments showed that on 16.04 metacity was more reliable,
# but on 18.04 icewm is more reliable when running tests)
COPY scripts/xstartup_*.sh ${HOME}/.vnc/
COPY scripts/xstartup_metacity.sh ${HOME}/.vnc/xstartup.sh
RUN chmod 755 ${HOME}/.vnc/xstartup*.sh
####
# From this point forward is the extra standard tools for CDT
# git and other tools
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
openssh-client \
wget \
zip \
unzip \
gnupg \
locales \
libxtst6 \
&& rm -rf /var/lib/apt/lists/*
RUN locale-gen en_US.UTF-8
# Need locale to be UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Get release versions from Adoptium API: https://api.adoptium.net/q/swagger-ui/#/Release%20Info/getReleaseNames
ENV JDK17_VERSION jdk-17.0.11+9
ENV JDK21_VERSION jdk-21.0.3+9
ENV JAVA17_HOME /usr/lib/jvm/${JDK17_VERSION}
ENV JAVA21_HOME /usr/lib/jvm/${JDK21_VERSION}
# Get Java from adoptium + header files for win32 & mac for cross compiling JNI libraries on Java 8, 11, 17
# TODO: Move these runs into a script, the only difference between each invocation is the env variables
RUN export JVERSION=${JDK17_VERSION} \
&& export JHOME=${JAVA17_HOME} \
&& mkdir /tmp/x && mkdir -p /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/linux/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-linux.tar.gz \
&& mkdir /tmp/x/linux && cd /tmp/x/linux && tar xvf /tmp/x/openjdk-linux.tar.gz \
&& mv /tmp/x/linux/${JVERSION} /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-win32.zip \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/mac/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-mac.tar.gz \
&& mkdir /tmp/x/win32 && cd /tmp/x/win32 && unzip /tmp/x/openjdk-win32.zip \
&& mkdir /tmp/x/mac && cd /tmp/x/mac && tar xvf /tmp/x/openjdk-mac.tar.gz \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/win32/${JVERSION}/include/$i ; done \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/mac/${JVERSION}/Contents/Home/include/$i ; done \
&& mv /tmp/x/win32/${JVERSION}/include/win32 $JHOME/include \
&& mv /tmp/x/mac/${JVERSION}/Contents/Home/include/darwin $JHOME/include \
&& find $JHOME/include \
&& rm -rf /tmp/x
RUN export JVERSION=${JDK21_VERSION} \
&& export JHOME=${JAVA21_HOME} \
&& mkdir /tmp/x && mkdir -p /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/linux/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-linux.tar.gz \
&& mkdir /tmp/x/linux && cd /tmp/x/linux && tar xvf /tmp/x/openjdk-linux.tar.gz \
&& mv /tmp/x/linux/${JVERSION} /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-win32.zip \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/mac/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-mac.tar.gz \
&& mkdir /tmp/x/win32 && cd /tmp/x/win32 && unzip /tmp/x/openjdk-win32.zip \
&& mkdir /tmp/x/mac && cd /tmp/x/mac && tar xvf /tmp/x/openjdk-mac.tar.gz \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/win32/${JVERSION}/include/$i ; done \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/mac/${JVERSION}/Contents/Home/include/$i ; done \
&& mv /tmp/x/win32/${JVERSION}/include/win32 $JHOME/include \
&& mv /tmp/x/mac/${JVERSION}/Contents/Home/include/darwin $JHOME/include \
&& find $JHOME/include \
&& rm -rf /tmp/x
# Default to JAVA21 being in use
ENV PATH="${JAVA21_HOME}/bin:${PATH}"
ENV JAVA_HOME ${JAVA21_HOME}
# Maven - Note that this is the default, but the Jenkinsfile may override it with JIPP version
ENV MAVEN_VERSION 3.9.6
RUN curl -fsSL https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /usr/share \
&& mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
#Fix permissions for OpenShift & standard k8s
RUN chown -R 1000:0 ${HOME} \
&& chmod -R g+rwX ${HOME}
ENV USER_NAME vnc
USER 1000
WORKDIR ${HOME}

View file

@ -0,0 +1,3 @@
This directory contains dockerfiles to build a Cross platform MacOS SDK.
A download of [Xcode_13.1.xip](https://developer.apple.com/download/all/?q=xcode) (visit [here](https://developer.apple.com/download/more/) first to logon to Apple if needed) is needed to build this image.

View file

@ -0,0 +1,25 @@
# This dockerfile is used to build the MacOSX SDK
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y clang make build-essential
RUN apt-get install -y libssl-dev lzma-dev liblzma-dev libxml2-dev git cmake patch python cpio bzip2 xz-utils libbz2-dev
# Xcode_13.1.xip needs to be downloaded from
# https://developer.apple.com/download/all/?q=xcode - specically:
ARG Xcodexip=Xcode_13.1.xip
WORKDIR /opt
COPY ${Xcodexip} /opt/${Xcodexip}
RUN git clone https://github.com/tpoechtrager/osxcross.git
RUN cd /opt/osxcross && ./tools/gen_sdk_package_pbzx.sh /opt/${Xcodexip}
RUN mv /opt/osxcross/*.xz /opt/osxcross/tarballs
ENV UNATTENDED=1
RUN cd /opt/osxcross && ./build.sh
# Start next stage build
FROM ubuntu:18.04
COPY --from=0 /opt/osxcross/target /opt/osxcross/target
ENV PATH="/opt/osxcross/target/bin:${PATH}"
# At this point the osxcross toolchain is not usable,
# it needs to be copied into another container and that
# container needs clang & llvm installed too.

View file

@ -0,0 +1 @@
This directory contains dockerfiles for complete CDT Infra to build everything for Eclipse CDT

View file

@ -0,0 +1,57 @@
FROM cdt-infra-base:ubuntu-18.04
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
gdb \
libgmp-dev \
libexpat1-dev \
libipt1 \
libmpfr-dev \
libncurses-dev \
ninja-build \
pkg-config \
python3-all-dev python3-pip python3-setuptools \
zlib1g-dev \
gdbserver \
gcc-mingw-w64-x86-64 \
g++-mingw-w64-x86-64 \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
gcc-powerpc64le-linux-gnu \
g++-powerpc64le-linux-gnu \
clang \
libxml2-utils \
gettext-base \
xserver-xephyr \
&& apt-get install -y llvm \
&& apt-get install -y --no-install-recommends texinfo bison flex \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --upgrade pip
#Specifc CDT deps
#Meson
RUN pip3 install meson
# GDB pre-built in a different image
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all /shared/common/gdb/gdb-all
ENV PATH="/shared/common/gdb/gdb-all/bin:${PATH}"
# Get pre-built MacOSX toolchain from other image (this also
# requires clang to be listed in the installs above)
COPY --from=cdt-infra-build-macos-sdk:ubuntu-18.04 /opt/osxcross/target /opt/osxcross/target
ENV PATH="/opt/osxcross/target/bin:${PATH}"
#Fix permissions for OpenShift & standard k8s
RUN chown -R 1000:0 ${HOME} \
&& chmod -R g+rwX ${HOME}
ENV USER_NAME vnc
USER 1000
WORKDIR ${HOME}
CMD ["/home/vnc/.vnc/xstartup.sh"]

View file

@ -0,0 +1 @@
This directory contains dockerfiles for complete CDT Infra + Eclipse Installations.

View file

@ -0,0 +1,27 @@
FROM ubuntu:18.04
ENV HOME=/home/vnc
RUN apt-get update
RUN apt-get install -y curl tar gzip
#Eclipse SDK & Fix permissions for OpenShift & standard k8s
RUN mkdir -p ${HOME}/buildtools && cd ${HOME}/buildtools \
&& curl -sL https://download.eclipse.org/eclipse/downloads/drops4/R-4.23-202203080310/eclipse-SDK-4.23-linux-gtk-x86_64.tar.gz | tar xvz \
&& mv eclipse eclipse-SDK-4.23 \
&& curl -sL https://download.eclipse.org/eclipse/downloads/drops4/R-4.31-202402290520/eclipse-SDK-4.31-linux-gtk-x86_64.tar.gz | tar xvz \
&& mv eclipse eclipse-SDK-4.31 \
&& chown -R 1000:0 ${HOME} \
&& chmod -R g+rwX ${HOME}
FROM cdt-infra-eclipse-full:ubuntu-18.04
USER root
COPY --from=0 ${HOME}/buildtools ${HOME}/buildtools
RUN apt-get update \
&& apt-get install -y clang-format \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update
RUN apt-get install -y ssh-askpass
USER 1000
CMD ["/home/vnc/.vnc/xstartup.sh"]

38
docker/deploy-images.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -eux
if ! git diff-index HEAD --quiet; then
echo "git tree is dirty, please commit changes before deploying images"
exit 1
fi
namespace=${1:-quay.io/eclipse-cdt}
shorthash=$(git rev-parse --short HEAD)
toplevel=$(git rev-parse --show-toplevel)
images="cdt-infra-eclipse-full:ubuntu-18.04 cdt-infra-plus-eclipse-install:ubuntu-18.04"
$toplevel/docker/build-images.sh
for image in $images; do
docker tag $image ${namespace}/${image}-${shorthash}
docker push ${namespace}/${image}-${shorthash}
nameonly=$(echo $image | sed -es,:.*,,)
docker tag $image ${namespace}/${nameonly}:latest
docker push ${namespace}/${nameonly}:latest
done
echo "The following images have been pushed."
for image in $images; do
hashname=$(docker inspect --format='{{index .RepoDigests 0}}' $image)
echo $image "-->" $hashname
nameonly=$(echo $image | sed -es,:.*,,)
find $toplevel -name \*\.Jenkinsfile -or -name \*\.yaml | while read file; do
sed -i "s#image: $namespace/$nameonly[:@].*#image: $hashname#" $file
git add $file
done
done
echo "Finished pushing to $namespace with tag hash $shorthash"
git commit -m"Update images to Dockerfiles from commit $shorthash"
echo "The .yaml and .Jenkinsfiles have been updated to new image and committed, now Push!"

View file

@ -0,0 +1,520 @@
#!/usr/bin/env bash
# * Copyright (c) 2015, 2021 Ericsson and others.
# * This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License 2.0
# * which accompanies this distribution, and is available at
# * https://www.eclipse.org/legal/epl-2.0/
# *
# * SPDX-License-Identifier: EPL-2.0
# *
# * Contributors:
# * Simon Marchi (Ericsson) - Initial implementation
# Stop the script if any command fails
set -o errexit
# Consider using an unset variable as an error
set -o nounset
# Make sure getopt is the command and not the bash built-in
if [[ $(getopt --version) != *"getopt"* ]]; then
echo "getopt command not found."
exit 1
fi
# Our work directory
default_base_dir="$HOME/gdb-all"
base_dir="${default_base_dir}"
# Passed to make's -j
default_jlevel="12"
jlevel="${default_jlevel}"
# Supported versions
# Note starting in GDB 9.x the .x is the patch release, so for example we have 9.2 in this list, but not 9.1.
default_versions="12.1 11.2 10.2 9.2 8.3.1 8.2.1 8.1.1 8.0.1 7.12.1 7.11.1 7.10.1 7.9.1 7.8.2 7.7.1 7.6.2 7.5.1 7.4.1 7.3.1 7.2 7.1 7.0.1 6.8 6.7.1 6.6"
# Is set to "echo" if we are doing a dry-run.
dryrun=""
# Is set to "yes" to download only
download_only="no"
# Print help and exit with the specified exit code.
#
# $1: The value to pass to exit
function help_and_exit() {
echo "Usage:"
echo " download-build-gdb.sh [OPTIONS] [VERSIONS|all]"
echo ""
echo "Description:"
echo " This script downloads, builds and installs the given versions of gdb."
echo " Passing \"all\" to the script is the same as passing all the supported versions."
echo ""
echo "Options:"
echo " -b, --base-dir PATH Set the base directory for downloading, building and "
echo " installing the gdbs (default: ${default_base_dir})."
echo " -d, --dry-run Make a dry-run: print the commands instead of executing"
echo " them."
echo " --download Download, but do not build."
echo " -h, --help Print this help message and exit."
echo " -j, --jobs N Number of parallel jobs while making. N is passed"
echo " directly to make's -j (default: ${default_jlevel})."
echo ""
echo "Supported versions:"
echo " ${default_versions}"
echo ""
echo "Examples:"
echo " Build versions 7.7.1 and 7.8.2:"
echo " $ $0 7.7.1 7.8.2"
echo " Build all supported versions:"
echo " $ $0 all"
echo ""
exit "$1"
}
# Output a visible header
#
# $1: Text to display
function echo_header() {
echo -e "\e[1m\e[7m>>> $1\e[0m"
}
# Check that the version passed is supported by the script.
#
# $1: version number
function check_supported() {
local supported_pattern="@(${default_versions// /|})"
local version="$1"
shopt -s extglob
case "$version" in
${supported_pattern})
# Supported, do nothing.
;;
*)
echo "Error: version ${version} is not supported by this script."
echo ""
help_and_exit 1
;;
esac
}
# Download the tarball of the given release of gdb.
#
# $1: version number
function download_gdb() {
local baseaddr="https://ftp.gnu.org/gnu/gdb"
local version="$1"
case "$version" in
"6.6"|"6.7.1"|"6.8"|"7.0.1"|"7.1"|"7.2")
version="${version}a"
;;
esac
echo_header "Downloading gdb $version to ${download_dir}"
${dryrun} wget --timestamping --directory-prefix "${download_dir}" "${baseaddr}/gdb-${version}.tar.gz"
}
# Extract the gdb tarball.
#
# $1: version number
function extract_gdb() {
local version="$1"
case "$version" in
"6.6"|"6.7.1"|"6.8"|"7.0.1"|"7.1"|"7.2")
version="${version}a"
;;
esac
local archive="${download_dir}/gdb-${version}.tar.gz"
echo_header "Extracting ${archive} to ${src_dir}"
${dryrun} mkdir -p "${src_dir}"
${dryrun} tar -xf "${archive}" -C "${src_dir}"
}
# Make necessary fixes to build an "old" release on a "modern" system.
#
# $1: version number
function fixup_gdb() {
local version="$1"
local build="${src_dir}/gdb-${version}"
echo_header "Fixing up gdb ${version}"
case "$version" in
# glibc or the kernel changed the signal API at some point
"7.4.1"|"7.3.1"|"7.2"|"7.1"|"7.0.1"|"6.8"|"6.7.1"|"6.6")
${dryrun} find "${build}/gdb" -type f -exec sed -i -e 's/struct siginfo;/#include <signal.h>/g' {} \;
${dryrun} find "${build}/gdb" -type f -exec sed -i -e 's/struct siginfo/siginfo_t/g' {} \;
;;
esac
case "$version" in
# paddr_t was a typo a long time ago that slowly got fixed/removed from sources/headers
"6.6")
${dryrun} find "${build}/gdb" -type f -exec sed -i -e 's/paddr_t/psaddr_t/g' {} \;
;;
esac
case "$version" in
# glibc or the kernel changed the proc-service API at some point (original GDB fix: https://sourceware.org/ml/gdb-patches/2015-02/msg00210.html)
"7.9.1"|"7.8.2"|"7.7.1"|"7.6.2"|"7.5.1"|"7.4.1"|"7.3.1"|"7.2"|"7.1"|"7.0.1"|"6.8"|"6.7.1"|"6.6")
${dryrun} sed -i -e 's/ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void \*fpregset)/ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prfpregset_t *fpregset)/g' "${build}/gdb/gdbserver/proc-service.c"
${dryrun} sed -i -e 's/ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void \*fpregset)/ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prfpregset_t *fpregset)/g' "${build}/gdb/gdbserver/proc-service.c"
;;
esac
# gdb commit 5a6c3296a7a90694ad4042f6256f3da6d4fa4ee8 - Fix ia64 defining TRAP_HWBKPT before including gdb_wait.h
case "$version" in
"8.1.1"|"8.0.1")
${dryrun} patch --directory=${build} --strip 1 <<END
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 5c4ddc95909..1f21ef03a39 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -21,8 +21,6 @@
#include "linux-procfs.h"
#include "linux-waitpid.h"
#include "buffer.h"
-#include "gdb_wait.h"
-#include "gdb_ptrace.h"
#ifdef HAVE_SYS_PROCFS_H
#include <sys/procfs.h>
#endif
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 60967a3b6aa..dc180fbf82a 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -21,6 +21,7 @@
struct buffer;
#include "nat/gdb_ptrace.h"
+#include "gdb_wait.h"
#ifdef __UCLIBC__
#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
END
;;
"7.12.1")
${dryrun} patch --directory=${build} --strip 1 <<END
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 3447e0716c1..dd3310eecbf 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -21,8 +21,6 @@
#include "linux-procfs.h"
#include "linux-waitpid.h"
#include "buffer.h"
-#include "gdb_wait.h"
-#include "gdb_ptrace.h"
#include <sys/procfs.h>
/* Stores the ptrace options supported by the running kernel.
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 59549452c09..6faa89b22a0 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -21,6 +21,7 @@
struct buffer;
#include "nat/gdb_ptrace.h"
+#include "gdb_wait.h"
#ifdef __UCLIBC__
#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
END
;;
"7.11.1")
${dryrun} patch --directory=${build} --strip 1 <<END
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 0eaf9a30ff4..446d5ba94b5 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -21,8 +21,6 @@
#include "linux-procfs.h"
#include "linux-waitpid.h"
#include "buffer.h"
-#include "gdb_wait.h"
-#include "gdb_ptrace.h"
/* Stores the ptrace options supported by the running kernel.
A value of -1 means we did not check for features yet. A value
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 0a23bcb0fc4..d84114b4881 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -21,6 +21,7 @@
struct buffer;
#include "nat/gdb_ptrace.h"
+#include "gdb_wait.h"
#ifdef __UCLIBC__
#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
END
;;
"7.10.1")
${dryrun} patch --directory=${build} --strip 1 <<END
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 1a926f93156..43d5fbfc731 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -21,7 +21,6 @@
#include "linux-procfs.h"
#include "linux-waitpid.h"
#include "buffer.h"
-#include "gdb_wait.h"
/* Stores the ptrace options supported by the running kernel.
A value of -1 means we did not check for features yet. A value
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index be6c39528c9..681b1663f62 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -21,6 +21,7 @@
struct buffer;
#include <sys/ptrace.h>
+#include "gdb_wait.h"
#ifdef __UCLIBC__
#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
END
;;
esac
# Fix wrong include on Mac
${dryrun} find "${build}" -name "darwin-nat.c" -type f -exec sed -i -e "s/machine\/setjmp.h/setjmp.h/g" {} \;
# Fix change in const: https://sourceware.org/bugzilla/show_bug.cgi?id=20491
${dryrun} find "${build}/gdb" -type f '(' -name '*.c' -or -name '*.h' ')' -exec sed -i -e 's/ps_get_thread_area (const struct ps_prochandle/ps_get_thread_area (struct ps_prochandle/g' {} \;
}
# Run ./configure.
#
# $1: version number
function configure_gdb() {
local version="$1"
local src="${src_dir}/gdb-${version}"
local build="${build_dir}/gdb-${version}"
local cflags="-Wno-error -g3 -O0"
local cxxflags="-Wno-error -g3 -O0"
echo_header "Configuring ${src} in ${build}"
${dryrun} mkdir -p "${build}"
${dryrun} pushd "${build}"
case "${version}" in
"6.7.1"|"6.8")
cflags="${cflags} -Wno-error=enum-compare"
;;
esac
# If there is already some CFLAGS/CXXFLAGS in the environment, add them to the mix.
cflags="${cflags} ${CFLAGS:-}"
cxxflags="${cxxflags} ${CXXFLAGS:-}"
# Need to use eval to allow the ${dryrun} trick to work with the env var command at the start.
eval ${dryrun} 'CFLAGS="${cflags}" CXXFLAGS="${cxxflags}" ${src}/configure --prefix="${install_dir}/gdb-${version}" --enable-werror=no'
${dryrun} popd
}
# Build gdb.
#
# $1: version number
function make_gdb() {
local version="$1"
local build="${build_dir}/gdb-${version}"
echo_header "Making in ${build}"
${dryrun} pushd "${build}"
${dryrun} make -j "${jlevel}"
${dryrun} popd
}
# Run make install.
#
# $1: version number
function make_install_gdb() {
local version="$1"
# Only install gdb and gdbserver (if present for GDB 10.1+), not the whole binutils-gdb
local install_gdb="${build_dir}/gdb-${version}/gdb"
local install_gdbserver="${build_dir}/gdb-${version}/gdbserver"
echo_header "Make installing in ${install_gdb}"
${dryrun} pushd "${install_gdb}"
# Disable building of the doc, which fails anyway with older gdbs and
# newer makeinfos.
${dryrun} make install MAKEINFO=true
${dryrun} popd
# XX this does not dryrun properly as the directory won't exist until it is built
if [ -e ${install_gdbserver} ]; then
echo_header "Make installing in ${install_gdbserver}"
${dryrun} pushd "${install_gdbserver}"
# Disable building of the doc, which fails anyway with older gdbs and
# newer makeinfos.
${dryrun} make install MAKEINFO=true
${dryrun} popd
fi
}
# Create symlinks in "bin" directory.
#
# $1: version number
function symlink_gdb() {
local version="$1"
echo_header "Creating symlinks for gdb ${version} in ${symlinks_dir}"
${dryrun} mkdir -p "${symlinks_dir}"
${dryrun} ln -sf "${install_dir}/gdb-${version}/bin/gdb" "${symlinks_dir}/gdb.${version}"
${dryrun} ln -sf "${install_dir}/gdb-${version}/bin/gdbserver" "${symlinks_dir}/gdbserver.${version}"
# If the version is a triplet (x.y.z), also create a symlink with just
# the first two numbers (x.y).
if [[ "$version" =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
local short_version="${version%.[0-9]}"
${dryrun} ln -sf "${install_dir}/gdb-${version}/bin/gdb" "${symlinks_dir}/gdb.${short_version}"
${dryrun} ln -sf "${install_dir}/gdb-${version}/bin/gdbserver" "${symlinks_dir}/gdbserver.${short_version}"
fi
# If the version is > 9.x, then make a symlink based on GDB new numbering scheme which is MAJOR.PATCH
local maybe_major_version="${version%.[0-9]}"
local major_version="${maybe_major_version%.[0-9]}"
if (( "$major_version" >= 9 )) ; then
${dryrun} ln -sf "${install_dir}/gdb-${version}/bin/gdb" "${symlinks_dir}/gdb.${major_version}"
${dryrun} ln -sf "${install_dir}/gdb-${version}/bin/gdbserver" "${symlinks_dir}/gdbserver.${major_version}"
fi
}
# Start argument parsing. The script will exit (thanks to errexit) if bad arguments are passed.
args=$(getopt -o b:dhj: -l "base-dir:,dry-run,help,jobs" -n "$0" -- "$@");
eval set -- "$args"
while true; do
case "$1" in
-b|--base-dir)
shift
base_dir="$1"
shift
;;
-d|--dry-run)
dryrun="echo"
shift
;;
--download)
download_only="yes"
shift
;;
-h|--help)
help_and_exit 0
break
;;
-j|--jobs)
shift
jlevel="$1"
shift
;;
--)
shift;
break;
;;
esac
done
abs_base_dir=$(readlink -f "${base_dir}")
# Where we download the tarballs
download_dir="${base_dir}/download"
# Where we extract the tarballs and build
src_dir="${base_dir}/src"
# Where we build
build_dir="${base_dir}/build"
# Where we make install to
install_dir="${abs_base_dir}/install"
# Where we will create symlinks to all gdb versions (in the form gdb.x.y)
# (Hint: this is so you can add this directory to your PATH and have all
# versions available quickly.)
symlinks_dir="${base_dir}/bin"
if [ $# -eq 0 ]; then
echo "Error: you need to specify at least one gdb version or \"all\"."
echo ""
help_and_exit 1
fi
versions=$*
if [ "$versions" = "all" ]; then
versions="${default_versions}"
fi
# End argument parsing
for version in $versions; do
check_supported "$version"
done
for version in $versions; do
download_gdb "$version"
if [ "$download_only" = "no" ]; then
extract_gdb "$version"
fixup_gdb "$version"
configure_gdb "$version"
make_gdb "$version"
make_install_gdb "$version"
symlink_gdb "$version"
fi
done
echo_header "Done!"
echo ""
if [ "$download_only" = "no" ]; then
echo "gdb versions built:"
echo " ${versions}"
echo ""
echo "Symbolic links to binaries have been created in:"
echo " ${symlinks_dir}"
echo ""
echo "You can add this path to your \$PATH to access them easily."
echo ""
fi

View file

@ -0,0 +1,7 @@
#!/usr/bin/env sh
if ! whoami > /dev/null 2>&1; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
fi
fi
exec "$@"

View file

@ -0,0 +1,11 @@
#!/usr/bin/env /bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r ${HOME}/.Xresources ] && xrdb ${HOME}/.Xresources
Xvnc ${DISPLAY} -geometry 1440x900 -depth 16 -dpi 100 -PasswordFile ${HOME}/.vnc/passwd &
sleep 2
xsetroot -solid grey
vncconfig -iconic &
xhost +
icewm --replace --sm-disable --display=${DISPLAY} &

View file

@ -0,0 +1,11 @@
#!/usr/bin/env /bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r ${HOME}/.Xresources ] && xrdb ${HOME}/.Xresources
Xvnc ${DISPLAY} -geometry 1440x900 -depth 16 -dpi 100 -PasswordFile ${HOME}/.vnc/passwd &
sleep 2
xsetroot -solid grey
vncconfig -iconic &
xhost +
metacity --replace --sm-disable --display=${DISPLAY} &

View file

@ -0,0 +1,11 @@
#!/usr/bin/env /bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r ${HOME}/.Xresources ] && xrdb ${HOME}/.Xresources
Xvnc ${DISPLAY} -geometry 1440x900 -depth 16 -dpi 100 -PasswordFile ${HOME}/.vnc/passwd &
sleep 2
xsetroot -solid grey
vncconfig -iconic &
xhost +
mutter --replace --sm-disable --display=${DISPLAY} &