diff --git a/Dockerfile.x86_64 b/Dockerfile.x86_64 new file mode 100644 index 0000000..ff73026 --- /dev/null +++ b/Dockerfile.x86_64 @@ -0,0 +1,24 @@ +FROM debian:jessie as builder +MAINTAINER Jonathan Passerat-Palmbach, Imperial College London + +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install build-essential gawk autoconf autotools-dev python cmake uthash-dev + + +COPY packages /opt/build/packages +COPY versions.mak GNUmakefile /opt/build/ +WORKDIR /opt/build + +RUN make -f GNUmakefile all_libs -j4 + +FROM debian:jessie +WORKDIR /usr +COPY --from=builder /usr . +WORKDIR /opt/build +RUN chmod 1777 /opt/build +COPY --from=builder /opt/build/prefix /opt/build/prefix/ +COPY versions.mak /opt/build/ +COPY GNUmakefile_tools /opt/build/GNUmakefile + +CMD bash + diff --git a/GNUmakefile b/GNUmakefile index ebd2229..afb5a01 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 +include versions.mak + +glibc-version = glibc-2.19 libtalloc-version = talloc-2.1.1 libarchive-version = libarchive-3.1.2 libz-version = zlib-1.2.8 @@ -45,12 +45,6 @@ liblzo_a = $(prefix)/lib/liblzo2.a env = CFLAGS="-g -O2 -isystem $(prefix)/include" LDFLAGS="-L$(prefix)/lib" -VPATH := $(dir $(lastword $(MAKEFILE_LIST))) -packages = $(VPATH)/packages -prefix = $(PWD)/prefix -$(prefix): - mkdir $@ - $(libc_a): tar -xzf $(packages)/$(glibc-version).tar.gz mkdir $(glibc-version)/build @@ -97,76 +91,70 @@ $(liblzo_a): $(libc_a) all_libs_a = $(libc_a) $(libtalloc_a) $(libarchive_a) $(libz_a) $(liblzo_a) proot-licenses: $(libc_a) $(libtalloc_a) - @echo "" >> $@ - @echo "This version of PRoot is statically linked to the following software." >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "glibc:" >> $@ - @echo "" >> $@ - @$(glibc-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "libtalloc:" >> $@ - @echo "" >> $@ - @$(libtalloc-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "The build-system, sources and licences are available on:" >> $@ - @echo "" >> $@ - @echo " https://github.com/cedric-vincent/proot-static-build">> $@ + mkdir -p $(prefix)/licenses + @echo "" >> $(prefix)/licenses/$@ + @echo "This version of PRoot is statically linked to the following software." >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "glibc:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(glibc-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "libtalloc:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(libtalloc-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "The build-system, sources and licences are available on:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @echo " https://github.com/cedric-vincent/proot-static-build">> $(prefix)/licenses/$@ care-licenses: $(all_libs_a) - @echo "" >> $@ - @echo "This version of CARE is statically linked to the following software." >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "proot:" >> $@ - @echo "" >> $@ - @echo " * Copyright (C) 2013 STMicroelectronics" >> $@ - @echo " *" >> $@ - @echo " * This program is free software; you can redistribute it and/or" >> $@ - @echo " * modify it under the terms of the GNU General Public License as" >> $@ - @echo " * published by the Free Software Foundation; either version 2 of the" >> $@ - @echo " * License, or (at your option) any later version." >> $@ - @echo " *" >> $@ - @echo " * This program is distributed in the hope that it will be useful, but" >> $@ - @echo " * WITHOUT ANY WARRANTY; without even the implied warranty of" >> $@ - @echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" >> $@ - @echo " * General Public License for more details." >> $@ - @echo " *" >> $@ - @echo " * You should have received a copy of the GNU General Public License" >> $@ - @echo " * along with this program; if not, write to the Free Software" >> $@ - @echo " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA" >> $@ - @echo " * 02110-1301 USA." >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "glibc:" >> $@ - @echo "" >> $@ - @$(glibc-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "libtalloc:" >> $@ - @echo "" >> $@ - @$(libtalloc-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "libarchive:" >> $@ - @echo "" >> $@ - @$(libarchive-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "zlib:" >> $@ - @echo "" >> $@ - @$(libz-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "liblzo:" >> $@ - @echo "" >> $@ - @$(liblzo-license) >> $@ - @echo "------------------------------------------------------------------------" >> $@ - @echo "The build-system, sources and licences are available on:" >> $@ - @echo "" >> $@ - @echo " https://github.com/cedric-vincent/proot-static-build">> $@ - -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/$@ . - -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 $(prefix)/licenses + @echo "" >> $(prefix)/licenses/$@ + @echo "This version of CARE is statically linked to the following software." >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "proot:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @echo " * Copyright (C) 2013 STMicroelectronics" >> $(prefix)/licenses/$@ + @echo " *" >> $(prefix)/licenses/$@ + @echo " * This program is free software; you can redistribute it and/or" >> $(prefix)/licenses/$@ + @echo " * modify it under the terms of the GNU General Public License as" >> $(prefix)/licenses/$@ + @echo " * published by the Free Software Foundation; either version 2 of the" >> $(prefix)/licenses/$@ + @echo " * License, or (at your option) any later version." >> $(prefix)/licenses/$@ + @echo " *" >> $(prefix)/licenses/$@ + @echo " * This program is distributed in the hope that it will be useful, but" >> $(prefix)/licenses/$@ + @echo " * WITHOUT ANY WARRANTY; without even the implied warranty of" >> $(prefix)/licenses/$@ + @echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" >> $(prefix)/licenses/$@ + @echo " * General Public License for more details." >> $(prefix)/licenses/$@ + @echo " *" >> $(prefix)/licenses/$@ + @echo " * You should have received a copy of the GNU General Public License" >> $(prefix)/licenses/$@ + @echo " * along with this program; if not, write to the Free Software" >> $(prefix)/licenses/$@ + @echo " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA" >> $(prefix)/licenses/$@ + @echo " * 02110-1301 USA." >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "glibc:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(glibc-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "libtalloc:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(libtalloc-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "libarchive:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(libarchive-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "zlib:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(libz-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "liblzo:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @$(liblzo-license) >> $(prefix)/licenses/$@ + @echo "------------------------------------------------------------------------" >> $(prefix)/licenses/$@ + @echo "The build-system, sources and licences are available on:" >> $(prefix)/licenses/$@ + @echo "" >> $(prefix)/licenses/$@ + @echo " https://github.com/cedric-vincent/proot-static-build">> $(prefix)/licenses/$@ + + +all_libs: $(all_libs_a) care-licenses proot-licenses + diff --git a/GNUmakefile_tools b/GNUmakefile_tools new file mode 100644 index 0000000..4f17841 --- /dev/null +++ b/GNUmakefile_tools @@ -0,0 +1,16 @@ +include versions.mak + +care: + tar --transform='s,care-[^/]*,$(care-version),g' -zx -f $(packages)/$(care-version).tar.gz + cp $(prefix)/licenses/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 + mkdir -p ./target + cp $(care-version)/src/$@ $(prefix)/licenses/care-licenses ./target/ + +proot: + tar --transform="s,proot-[^/]*,$(proot-version),g" -zx -f $(packages)/$(proot-version).tar.gz + cp $(prefix)/licenses/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 + mkdir -p ./target + cp $(proot-version)/src/$@ $(prefix)/licenses/proot-licenses ./target/ + diff --git a/README.md b/README.md index 52f7bc5..b06047d 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,75 @@ # proot-static-build Build static variants of PRoot -PRoot static binaries were built using: +PRoot static binaries were built using: - https://github.com/proot-me/proot-static-build + https://github.com/proot-me/proot-static-build -The ARM one was built on x86_64 using this command: - - # Build PRoot/ARM statically: - cd ~/git/proot-static-build - mkdir build-arm - cd build-arm - proot -R ~/rootfs/slackwarearm-14.1 -b $(which cmake) -q qemu-arm make glibc-version=glibc-2.18 -f ../GNUmakefile proot -j4 + +## Docker build environment ## + +Build the Docker container: + +`docker build -t proot/proot-buildenv:latest -f Dockerfile.x86_64 .` + +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 default values by prefixing the call to `build.sh` with these variables. + +### `PROOT_TARBALL` and `CARE_TARBALL` + + - Must point to an **absolute path** + - Contains the path to a tarball of the source directories (including the parent project directory, see *Important notes* below to learn how to generate such a tarball) + - Example: `PROOT_TARBALL="/tmp/proot-portmap-seccomp.tar.gz" CARE_TARBALL="/tmp/care-portmap-seccomp.tar.gz" ./build.sh make care proot -j4` + +### `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-latest.tar.gz;/data/my_modified_care.tar.gz:/opt/build/packages/care-latest.tar.gz TARGET_DIR=/tmp/mytarget ./build.sh make care proot -j4` + + +### Important Notes ### + +- When preparing your modified version of the proot source tree to be statically build, think of cleaning the target files before generating the tarball: +`make clean` + +- The paths within the source archives **must match** those in the `GNUmakefile` file. They can be renamed on the fly using the following command (assuming a source directory named `PRoot`): +`tar cfz proot-latest.tar.gz PRoot --transform='s/PRoot/proot-latest/g'` + + +## Legacy builds (pre 5.1.1) + +The ARM one was built on x86_64 using this command: + + # Build PRoot/ARM statically: + cd ~/git/proot-static-build + mkdir build-arm + cd build-arm + proot -R ~/rootfs/slackwarearm-14.1 -b $(which cmake) -q qemu-arm make glibc-version=glibc-2.18 -f ../GNUmakefile proot -j4 Where slackwarearm-14.1 was created this way: - # Get Slackware/ARM packages: - wget -r -np http://ftp.arm.slackware.com/slackwarearm/slackwarearm-14.1/slackware/{a,ap,d,e,l,n,tcl}/ - mkdir ~/rootfs/slackwarearm-14.1 - - # Extract only a minimal subset (ignore errors): - ls ftp.arm.slackware.com/slackwarearm/slackwarearm-14.1/slackware/{a,l}/*.t?z | xargs -n 1 tar -C ~/rootfs/slackwarearm-14.1 -xf - - # Do a minimal post-installation setup: - mv ~/rootfs/slackwarearm-14.1/lib/incoming/* ~/rootfs/slackwarearm-14.1/lib/ - mv ~/rootfs/slackwarearm-14.1/bin/bash4.new ~/rootfs/slackwarearm-14.1/bin/bash - proot -q qemu-arm -r ~/rootfs/slackwarearm-14.1 /sbin/ldconfig - proot -q qemu-arm -r ~/rootfs/slackwarearm-14.1 ln -s /bin/bash /bin/sh - - # 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 + # Get Slackware/ARM packages: + wget -r -np http://ftp.arm.slackware.com/slackwarearm/slackwarearm-14.1/slackware/{a,ap,d,e,l,n,tcl}/ + mkdir ~/rootfs/slackwarearm-14.1 + + # Extract only a minimal subset (ignore errors): + ls ftp.arm.slackware.com/slackwarearm/slackwarearm-14.1/slackware/{a,l}/*.t?z | xargs -n 1 tar -C ~/rootfs/slackwarearm-14.1 -xf + + # Do a minimal post-installation setup: + mv ~/rootfs/slackwarearm-14.1/lib/incoming/* ~/rootfs/slackwarearm-14.1/lib/ + mv ~/rootfs/slackwarearm-14.1/bin/bash4.new ~/rootfs/slackwarearm-14.1/bin/bash + proot -q qemu-arm -r ~/rootfs/slackwarearm-14.1 /sbin/ldconfig + proot -q qemu-arm -r ~/rootfs/slackwarearm-14.1 ln -s /bin/bash /bin/sh + + # 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 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..740ac0b --- /dev/null +++ b/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +### VARIABLES + +DOCKER_IMAGE='proot/proot-buildenv:latest' + +BUILD_DIR="/opt/build" +GROUP_ID=$(id -g) +USER_ID=$(id -u) + +# must be an absolute path +TARGET_DIR=${TARGET_DIR:-"$(pwd)/target"} +VERSIONS_FILE="$(dirname $(readlink -f $0))/versions.mak" + +PROOT_VERSION="$(grep 'proot-version' ${VERSIONS_FILE} | tr -s ' ' | cut -d ' ' -f 3)" +CARE_VERSION="$(grep 'care-version' ${VERSIONS_FILE} | tr -s ' ' | cut -d ' ' -f 3)" +PROOT_TARBALL=${PROOT_TARBALL:-"$(pwd)/src/${PROOT_VERSION}.tar.gz"} +CARE_TARBALL=${CARE_TARBALL:-"$(pwd)/src/${CARE_VERSION}.tar.gz"} + +# VOLUMES must be formatted as Docker expects them -> /path_on_host:/mountpoint +# specify multiple volumes using the ; separator +# if no volume specified -> mount latest items +VOLUMES="${PROOT_TARBALL}:/opt/build/packages/${PROOT_VERSION}.tar.gz;${CARE_TARBALL}:/opt/build/packages/${CARE_VERSION}.tar.gz" + +### FUNCTIONS + +mount_volumes() { + + if [[ -n ${VOLUMES} ]]; then + echo -n "-v ${VOLUMES}" | sed -e 's/;/ -v /g' + fi + +} + +### MAIN + +mkdir -p "${TARGET_DIR}" +eval docker run \ + --user="${USER_ID}:${GROUP_ID}" \ + -it \ + --rm=true \ + -v "${TARGET_DIR}:/opt/build/target" "$(mount_volumes)" \ + -w "${BUILD_DIR}" \ + -e "PWD=${BUILD_DIR}" \ + "${DOCKER_IMAGE}" \ + "$@" + diff --git a/packages/care-v2.2.1.tar.gz b/packages/care-v2.2.1.tar.gz deleted file mode 100644 index 0223355..0000000 Binary files a/packages/care-v2.2.1.tar.gz and /dev/null differ diff --git a/packages/glibc-2.16.0.tar.gz b/packages/glibc-2.16.0.tar.gz deleted file mode 100644 index d371bf6..0000000 Binary files a/packages/glibc-2.16.0.tar.gz and /dev/null differ diff --git a/packages/glibc-2.18.tar.gz b/packages/glibc-2.19.tar.gz similarity index 68% rename from packages/glibc-2.18.tar.gz rename to packages/glibc-2.19.tar.gz index d63032b..c92a297 100644 Binary files a/packages/glibc-2.18.tar.gz and b/packages/glibc-2.19.tar.gz differ diff --git a/packages/proot-v5.1.0.tar.gz b/packages/proot-v5.1.0.tar.gz deleted file mode 100644 index ac630b8..0000000 Binary files a/packages/proot-v5.1.0.tar.gz and /dev/null differ diff --git a/src/care-v2.2.2.tar.gz b/src/care-v2.2.2.tar.gz new file mode 100644 index 0000000..cbbae33 Binary files /dev/null and b/src/care-v2.2.2.tar.gz differ diff --git a/src/proot-v5.1.1.tar.gz b/src/proot-v5.1.1.tar.gz new file mode 100644 index 0000000..0a6a704 Binary files /dev/null and b/src/proot-v5.1.1.tar.gz differ diff --git a/versions.mak b/versions.mak new file mode 100644 index 0000000..ad1bb69 --- /dev/null +++ b/versions.mak @@ -0,0 +1,9 @@ +proot-version = proot-latest +care-version = care-latest + +prefix = $(PWD)/prefix +$(prefix): + mkdir $@ + +packages = ./packages +