Skip to content

Commit c928dfb

Browse files
committed
initial commit
0 parents commit c928dfb

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
debian.tgz
2+
package

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM scratch
2+
ADD debian.tgz /
3+
4+
RUN apt-get update \
5+
&& apt-get install -qq -y --no-install-recommends \
6+
software-properties-common \
7+
autoconf \
8+
build-essential \
9+
curl \
10+
file \
11+
git \
12+
libasound2-dev \
13+
libcups2-dev \
14+
libfontconfig1-dev \
15+
libx11-dev \
16+
libxext-dev \
17+
libxrandr-dev \
18+
libxrender-dev \
19+
libxt-dev \
20+
libxtst-dev \
21+
unzip \
22+
wget \
23+
zip \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
RUN mkdir -p /openjdk-linux-x86 \
27+
&& useradd -ms /bin/bash build \
28+
&& chown build /openjdk-linux-x86
29+
30+
USER build
31+
WORKDIR /openjdk-linux-x86
32+
RUN git clone https://github.com/OpenIndex/openjdk-linux-x86.git /openjdk-linux-x86 \
33+
&& git checkout jdk11
34+
35+
ENTRYPOINT ["/usr/bin/linux32", "--", "/openjdk-linux-x86/build.sh"]

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This repository contains an example about how to build OpenJDK 11 for Linux x86 (IA-32) on a Linux x86-64 system with [Docker](https://www.docker.com/).
2+
3+
In the first step run `sudo build-image.sh` in order to create a Debian i386 root filesystem. You might use other already existing images from [Docker Hub](https://hub.docker.com/) as well and update the `Dockerfile` accordingly. But I did not test this yet.
4+
5+
Afterwards execute `build-openjdk.sh` in order to start the build process. If everything went fine, the created OpenJDK packages are stored in the newly created `package` folder.

build-image.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
### Build a docker image for debian i386.
3+
4+
### settings
5+
arch=i386
6+
suite=${1:-stretch}
7+
chroot_dir="/var/chroot/$suite"
8+
apt_mirror="http://http.debian.net/debian"
9+
docker_image="32bit/debian-i386:$suite"
10+
11+
### make sure that the required tools are installed
12+
#apt-get install -y docker.io debootstrap dchroot
13+
14+
### install a minbase system with debootstrap
15+
export DEBIAN_FRONTEND=noninteractive
16+
debootstrap --arch $arch $suite $chroot_dir $apt_mirror
17+
18+
### update the list of package sources
19+
cat <<EOF > $chroot_dir/etc/apt/sources.list
20+
deb $apt_mirror $suite main contrib non-free
21+
deb $apt_mirror $suite-updates main contrib non-free
22+
deb http://security.debian.org/ $suite/updates main contrib non-free
23+
EOF
24+
25+
### upgrade packages
26+
chroot $chroot_dir apt-get update
27+
chroot $chroot_dir apt-get upgrade -y
28+
29+
### cleanup
30+
chroot $chroot_dir apt-get autoclean
31+
chroot $chroot_dir apt-get clean
32+
chroot $chroot_dir apt-get autoremove
33+
34+
### create a tar archive from the chroot directory
35+
tar cfz debian.tgz -C $chroot_dir .
36+
37+
### import this tar archive into a docker image:
38+
#cat debian.tgz | docker import - $docker_image
39+
40+
# ### push image to Docker Hub
41+
# docker push $docker_image
42+
43+
### cleanup
44+
#rm debian.tgz
45+
rm -rf $chroot_dir

build-openjdk.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
DOCKER_IMAGE="openjdk11-linux-x86"
3+
DOCKER_CONTAINER="build-openjdk11-linux-x86"
4+
5+
set -e
6+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
cd "$DIR"
8+
9+
DOCKER_IMAGE_ID="$(docker images -q "$DOCKER_IMAGE")"
10+
if [[ -z "$DOCKER_IMAGE_ID" ]]; then
11+
echo ""
12+
echo -e "\e[1m\e[92m=================================================\e[0m"
13+
echo -e "\e[1m\e[92m build docker image\e[0m"
14+
echo -e "\e[1m\e[92m=================================================\e[0m"
15+
echo ""
16+
docker build --tag "$DOCKER_IMAGE" .
17+
fi
18+
19+
echo ""
20+
echo -e "\e[1m\e[92m=================================================\e[0m"
21+
echo -e "\e[1m\e[92m run docker image\e[0m"
22+
echo -e "\e[1m\e[92m=================================================\e[0m"
23+
echo ""
24+
docker run --name "$DOCKER_CONTAINER" "$DOCKER_IMAGE"
25+
26+
echo ""
27+
echo -e "\e[1m\e[92m=================================================\e[0m"
28+
echo -e "\e[1m\e[92m export packages\e[0m"
29+
echo -e "\e[1m\e[92m=================================================\e[0m"
30+
echo ""
31+
rm -Rf package
32+
DOCKER_CONTAINER_ID="$(docker ps -aqf "name=$DOCKER_CONTAINER")"
33+
docker cp "$DOCKER_CONTAINER_ID":/openjdk-linux-x86/package .
34+
35+
echo ""
36+
echo -e "\e[1m\e[92m=================================================\e[0m"
37+
echo -e "\e[1m\e[92m remove docker container\e[0m"
38+
echo -e "\e[1m\e[92m=================================================\e[0m"
39+
echo ""
40+
docker container rm -f "$DOCKER_CONTAINER_ID"

0 commit comments

Comments
 (0)