Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

[WIP] creation of an x86_64 build environment #2

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9f5d165
enh: create Dockerfile based on Slackware 14.1 for x86_64 builds
jopasserat Nov 17, 2016
4ef0c69
enh: add basic docker commands to README
jopasserat Nov 17, 2016
063edcf
enh: bump care and proot versions (integrate fix loader patch)
jopasserat Nov 17, 2016
3312688
Merge branch 'build_environment' of github.com:proot-me/proot-static-…
jopasserat Nov 17, 2016
b49b8de
Cleaner dockerfile based on debian jessie.
romainreuillon Nov 27, 2016
05dc96e
Merge pull request #3 from romainreuillon/build_environment
jopasserat Nov 28, 2016
8807e32
enh: specify jessie as Debian version and clean comments
jopasserat Nov 28, 2016
0a4be15
enh: add target building only libs and support destination folder for…
jopasserat Nov 29, 2016
14c324b
enh: Bake static libs build in Docker
jopasserat Nov 29, 2016
2187a25
enh: rewrite build script to call make in docker as one liner (and co…
jopasserat Nov 29, 2016
1168e38
enh: update README with new command lines
jopasserat Nov 29, 2016
d4b02c1
enh: update README with new command lines
jopasserat Nov 29, 2016
f33ef11
enh: add possibility to mount other volumes and change destinations +…
jopasserat Nov 29, 2016
7af3e62
Merge branch 'build_environment' of github.com:proot-me/proot-static-…
jopasserat Nov 29, 2016
49daa89
enh: rename Docker to make clearer it only target x86_64 archs
jopasserat Dec 21, 2016
742a84e
enh: lint Dockerfile
jopasserat Apr 13, 2017
80d5e4e
enh: update README
jopasserat Sep 7, 2017
fd6e053
enh: generate proot and care licenses upstream
jopasserat Sep 7, 2017
79313c5
enh: switch Dockerfile to multi-stage build
jopasserat Sep 7, 2017
49e9077
enh: try to mount latest version of sources by default
jopasserat Sep 8, 2017
04de69f
fix: missing file and set build dir permissions
jopasserat Sep 8, 2017
d4c66a0
fix: simplify user management
jopasserat Sep 8, 2017
4d08c91
enh: split build of environment and tools
jopasserat Sep 8, 2017
d75a917
enh: lint build.sh
jopasserat Sep 8, 2017
68dc928
fix: update README to new makefile
jopasserat Sep 8, 2017
21f4b39
enh: inject version files at runtime and use info in build
jopasserat Sep 16, 2017
3f703f1
enh: simplify build script
jopasserat Sep 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:jessie
MAINTAINER Jonathan Passerat-Palmbach, Imperial College London <[email protected]>

RUN apt update && apt install -y build-essential gawk autoconf autotools-dev python cmake uthash-dev

COPY . /opt/build/
WORKDIR /opt/build

RUN make -f GNUmakefile all_libs -j4

CMD bash

15 changes: 10 additions & 5 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# -q qemu-sh4
# make ...

proot-version = proot-v5.1.0
care-version = care-v2.2.1
glibc-version = glibc-2.16.0
proot-version = proot-v5.1.1
care-version = care-v2.2.2
glibc-version = glibc-2.19
libtalloc-version = talloc-2.1.1
libarchive-version = libarchive-3.1.2
libz-version = zlib-1.2.8
Expand Down Expand Up @@ -159,14 +159,19 @@ care-licenses: $(all_libs_a)
@echo "" >> $@
@echo " https://github.com/cedric-vincent/proot-static-build">> $@


all_libs: $(all_libs_a)

care: $(all_libs_a) care-licenses
tar -xzf $(packages)/$(care-version).tar.gz
cp care-licenses $(care-version)/src/licenses
env OBJECTS="cli/care-licenses.o" LDFLAGS="-static -L$(prefix)/lib -larchive -lz -llzo2" CPPFLAGS="-isystem $(prefix)/include -DCARE_BINARY_IS_PORTABLE " $(MAKE) -C $(care-version)/src/ care GIT=false
cp $(care-version)/src/$@ .
mkdir -p ./target
cp $(care-version)/src/$@ ./target/

proot: $(libc_a) $(libtalloc_a) proot-licenses
tar -xzf $(packages)/$(proot-version).tar.gz
cp proot-licenses $(proot-version)/src/licenses
env OBJECTS="cli/proot-licenses.o" LDFLAGS="-static -L$(prefix)/lib" CPPFLAGS="-isystem $(prefix)/include" $(MAKE) -C $(proot-version)/src/ GIT=false
cp $(proot-version)/src/$@ .
mkdir -p ./target
cp $(proot-version)/src/$@ ./target/
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@ PRoot static binaries were built using:

https://github.com/proot-me/proot-static-build


## Docker build environment ##

Build the Docker container:

`docker build -t proot-buildenv .`

Run a build
`./build.sh make care proot -j4`

This creates a `target` folder with both static binaries for care and proot.

## Special variables

If needed you can override the mountpoints within the container by prefixing the call to build.sh with these variables.

### `VOLUMES`

- Must be formatted as Docker expects them -> `/path_on_host:/mountpoint`
- Specify multiple volumes using the `;` separator
- The target in the containers should not be changed unless the container itself has been rebuilt with different paths
- It is necessary to wrap the whole expression passed to the variable in `""`
- Example: `VOLUMES="/data/my_modified_proot.tar.gz:/opt/build/packages/proot-v5.1.1.tar.gz;/data/my_modified_care.tar.gz:/opt/build/packages/care-v2.2.2.tar.gz"`

### `TARGET_DIR`

- This is the destination folder for static binaries
- Example: `TARGET_DIR=/tmp/mytarget`

### Example of modified command line

`VOLUMES=/data/my_modified_proot.tar.gz:/opt/build/packages/proot-v5.1.1.tar.gz;/data/my_modified_care.tar.gz:/opt/build/packages/care-v2.2.2.tar.gz TARGET_DIR=/tmp/mytarget ./build.sh make care proot -j4`

## Legacy builds (pre 5.1.1)

The ARM one was built on x86_64 using this command:

# Build PRoot/ARM statically:
Expand All @@ -30,3 +65,4 @@ Where slackwarearm-14.1 was created this way:

# Install all package correcty (ignore warnings):
ls ftp.arm.slackware.com/slackwarearm/slackwarearm-14.1/slackware/*/*.t?z | xargs -n 1 proot -q qemu-arm -S ~/rootfs/slackwarearm-14.1 -b ftp.arm.slackware.com installpkg

67 changes: 67 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

### VARIABLES

DOCKER_IMAGE='proot/proot-buildenv:latest'

CONTAINER_USERNAME='dummy'
CONTAINER_GROUPNAME='dummy'
GROUP_ID=$(id -g)
USER_ID=$(id -u)

# must be an absolute path
TARGET_DIR=${TARGET_DIR:-"$(pwd)/target"}

# VOLUMES must be formatted as Docker expects them -> /path_on_host:/mountpoint
# specify multiple volumes using the ; separator
VOLUMES=${VOLUMES:-""}

### FUNCTIONS

create_user_cmd()
{
if [[ ${USER_ID} -ne 0 ]]; then
echo \
groupadd -f -g ${GROUP_ID} ${CONTAINER_GROUPNAME} '&&' \
useradd -u ${USER_ID} -g ${GROUP_ID} ${CONTAINER_USERNAME} '&&' \
chown -R ${USER_ID}:${GROUP_ID} /opt/build
else
echo echo 'Running build as root...'
fi
}

mount_volumes() {

if [[ -n ${VOLUMES} ]]; then
echo -n "-v ${VOLUMES}" | sed -e 's/;/ -v /g'
fi

}

execute_as_cmd()
{
if [[ ${USER_ID} -ne 0 ]]; then
echo \
su ${CONTAINER_USERNAME} -c
else
echo \
eval
fi
}

full_container_cmd()
{
echo "'$(create_user_cmd) && $(execute_as_cmd) \"$@\"'"
}

### MAIN

mkdir -p ${TARGET_DIR}
eval docker run \
--rm=true \
-a stdout \
-v ${TARGET_DIR}:/opt/build/target $(mount_volumes) \
-w /opt/build \
${DOCKER_IMAGE} \
/bin/bash -ci $(full_container_cmd $@)

Binary file removed packages/care-v2.2.1.tar.gz
Binary file not shown.
Binary file added packages/care-v2.2.2.tar.gz
Binary file not shown.
Binary file removed packages/glibc-2.16.0.tar.gz
Binary file not shown.
Binary file not shown.
Binary file removed packages/proot-v5.1.0.tar.gz
Binary file not shown.
Binary file added packages/proot-v5.1.1.tar.gz
Binary file not shown.