diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..184c31c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/builds +/dist +/logs +/downloads +/tools diff --git a/.travis.yml b/.travis.yml index 86d96392..66c79d4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,18 @@ language: c - compiler: gcc +sudo: false +dist: trusty -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq libtalloc-dev uthash-dev libarchive-dev gdb strace realpath - - sudo pip install cpp-coveralls - -script: if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make -C src loader.exe loader-m32.exe build.h && env CFLAGS=--coverage LDFLAGS='--coverage' make -C src proot && env PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PWD/src make -C tests; fi +env: + - TARGET=x86_64-linux-musl + - TARGET=i486-linux-musl + - TARGET=aarch64-linux-musl + - TARGET=arm-linux-musleabi + - TARGET=arm-linux-musleabihf -after_success: - - coveralls --build-root src --exclude tests --gcov-options '\-lp' -env: - global: - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "G2fG/oWcEOiG+RYLCK3XOO/7ZXn4LoiIyOT4fxxJzb43gu/90lEkbwsALqVAAjh/Fn5T4rYqiECeJ0jEhxvWak1pK/jkFshfXzL34yaY8ZLNtwvnFf7+DDtsj1Hx136TEjYuyc/jasoTf/3fNlIX6Oh1BB6c0UtJfHwTfbreRbI=" +script: + - bash build ${TARGET} -addons: - coverity_scan: - project: - name: "cedric-vincent/PRoot" - description: "PRoot" - notification_email: cedric.vincent@gmail.com - build_command_prepend: - build_command: make -C src - branch_pattern: coverity_scan +after_success: + - bash upload diff --git a/build b/build new file mode 100755 index 00000000..d343b3d5 --- /dev/null +++ b/build @@ -0,0 +1,141 @@ +#!/usr/bin/env bash +set -e + +TARGET=$1 + +if [[ -z "${TARGET}" ]] ; then + printf "Usage: $0 target\n" + exit 1 +fi + +HOSTCC=$CC + +if [[ -z "$HOSTCC" ]] ; then + HOSTCC="cc" +fi + +unset CC CXX LINK AR NM READELF RANLIB + +MUSL_CROSS_MAKE_RELEASE=8 +MUSL_CROSS_MAKE_SRC="https://github.com/just-containers/musl-cross-make/releases/download/v${MUSL_CROSS_MAKE_RELEASE}" + +versions__talloc=2.1.11 +versions__queue=1.72 +versions__zlib=1.2.11 +versions__gcc=7.2.0 +versions__github_release=0.7.2 + +sources__talloc="https://www.samba.org/ftp/talloc/talloc-${versions__talloc}.tar.gz" +sources__queue="http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/sys/queue.h?rev=${versions__queue}" +sources__zlib="https://zlib.net/zlib-${versions__zlib}.tar.gz" +sources__gcc="$MUSL_CROSS_MAKE_SRC/gcc-${versions__gcc}-${TARGET}.tar.xz" +sources__github_release="https://github.com/aktau/github-release/releases/download/v${versions__github_release}/linux-amd64-github-release.tar.bz2" +sources__gcc_manifest="${MUSL_CROSS_MAKE_SRC}/gcc-7.2.0-manifest.txt" + +files__talloc="$(basename ${sources__talloc})" +files__queue="queue-${versions__queue}.h" +files__zlib="$(basename ${sources__zlib})" +files__gcc="$(basename ${sources__gcc})" +files__gcc_manifest="$(basename ${sources__gcc_manifest})" +files__github_release="$(basename ${sources__github_release})" + + +THISDIR=$(pwd) +DISTDIR=$(pwd)/dist +DOWNLOADDIR=$(pwd)/downloads +BUILDDIR=$(pwd)/builds/${TARGET} +TOOLDIR=$(pwd)/tools +LOGDIR=$(pwd)/logs + +mkdir -p $DISTDIR/bin +mkdir -p $DOWNLOADDIR +mkdir -p $BUILDDIR +mkdir -p $TOOLDIR/bin +mkdir -p $LOGDIR +rm -f $LOGDIR/*${TARGET}*.txt + +download_package() { + package=$1 + + package_file="files__${package}" + package_file="${!package_file}" + + package_source="sources__${package}" + package_source="${!package_source}" + + if [[ ! -f "$DOWNLOADDIR/${package_file}" ]] ; then + printf "Downloading ${package_file}\n" + curl -s -R -L -o "$DOWNLOADDIR/${package_file}" \ + "${package_source}" + fi +} + +export PATH="$TOOLDIR/bin:$PATH" + +download_package "talloc" +download_package "queue" +download_package "zlib" +download_package "gcc" "gcc cross-compiler" +download_package "gcc_manifest" "gcc manifest" +download_package "github_release" "github-release" + +while read -r line; do + key=$(printf "${line}" | cut -d"=" -f1) + value=$(printf "${line}" | cut -d"=" -f2) + case "${key}" in + musl|gcc) printf -v "versions__${key}" "%s" "$value" ;; + esac +done < $DOWNLOADDIR/gcc-7.2.0-manifest.txt + +tar xf "$DOWNLOADDIR/gcc-7.2.0-${TARGET}.tar.xz" -C $TOOLDIR +tar xf "$DOWNLOADDIR/${files__github_release}" -C $TOOLDIR/bin --strip-components=3 + +cp $DOWNLOADDIR/queue-${versions__queue}.h $TOOLDIR/$TARGET/include/sys/queue.h + +printf "Building zlib\n" +tar xf "$DOWNLOADDIR/zlib-${versions__zlib}.tar.gz" -C $BUILDDIR +cd $BUILDDIR/zlib-${versions__zlib} + +CC="$TARGET-gcc" \ +CPP="$TARGET-cpp" \ +AR="$TARGET-ar" \ +RANLIB="$TARGET-ranlib" \ +./configure \ + --prefix=$TOOLDIR/$TARGET +make +make install + +printf "Building talloc\n" + +tar xf "$DOWNLOADDIR/talloc-${versions__talloc}.tar.gz" -C $BUILDDIR +cd $BUILDDIR/talloc-${versions__talloc} + +CC="$TARGET-gcc" \ +CPP="$TARGET-cpp" \ +AR="$TARGET-ar" \ +RANLIB="$TARGET-ranlib" \ +./configure \ + --prefix=$TOOLDIR/$TARGET \ + --cross-compile \ + --cross-answers=$THISDIR/waf-answers/${TARGET}.answers \ + --cross-execute=${TARGET}- \ + --disable-python \ + --hostcc=$HOSTCC \ + --prefix=$TOOLDIR/${TARGET} +make +make install +rm -f $TOOLDIR/$TARGET/lib/libtalloc.a +${TARGET}-ar qf $TOOLDIR/$TARGET/lib/libtalloc.a bin/default/talloc_5.o + +rm -rf $BUILDDIR/proot +mkdir -p $BUILDDIR/proot +cp -r $THISDIR/src $BUILDDIR/proot/src +cp -r $THISDIR/tests $BUILDDIR/proot/tests +cp -r $THISDIR/doc $BUILDDIR/proot/doc +cd $BUILDDIR/proot/src +make CROSS_COMPILE="${TARGET}-" LDFLAGS="-s -static -ltalloc" + +cp $BUILDDIR/proot/src/proot $DISTDIR/bin/proot +tar cJf $DISTDIR/proot-5.1.0-${TARGET}.tar.xz -C $DISTDIR bin + +printf 'Built using `musl-%s` and `talloc-%s`\n' "${versions__musl}" "${versions__talloc}" > $DISTDIR/release.md diff --git a/upload b/upload new file mode 100755 index 00000000..8ae3097b --- /dev/null +++ b/upload @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e + +# don't loop if files don't exist +shopt -s nullglob + +# exit if TRAVIS_TAG is empty, no need to release anything +if [ -z "${TRAVIS_TAG}" ]; then + exit 0 +fi + +export "PATH=$(pwd)/tools/bin:$PATH" + +# get user and repo names +USERNAME=$(echo ${TRAVIS_REPO_SLUG} | cut -d"/" -f1) +REPONAME=$(echo ${TRAVIS_REPO_SLUG} | cut -d"/" -f2) + +# release +github-release release \ + --user "${USERNAME}" \ + --repo "${REPONAME}" \ + --tag "${TRAVIS_TAG}" \ + --name "${TRAVIS_TAG}" \ + --description "$(cat $(pwd)/dist/release.md)" || true + +# binaries +for i in "$(pwd)/dist/"*.tar.xz; do + name=$(basename ${i}) + github-release upload \ + --user "${USERNAME}" \ + --repo "${REPONAME}" \ + --tag "${TRAVIS_TAG}" \ + --name "${name}" \ + --file "${i}" +done diff --git a/waf-answers/aarch64-linux-musl.answers b/waf-answers/aarch64-linux-musl.answers new file mode 100644 index 00000000..8941e5d5 --- /dev/null +++ b/waf-answers/aarch64-linux-musl.answers @@ -0,0 +1,46 @@ +Checking uname sysname type: "Linux" +Checking uname machine type: "dontcare" +Checking uname release type: "dontcare" +Checking uname version type: "dontcare" +Checking simple C program: OK +building library support: OK +Checking for large file support: OK +Checking for -D_FILE_OFFSET_BITS=64: OK +Checking for WORDS_BIGENDIAN: OK +Checking size of char: "1" +Checking size of int: "4" +Checking size of long long: "8" +Checking size of long: "8" +Checking size of off_t: "8" +Checking size of short: "2" +Checking size of size_t: "8" +Checking size of ssize_t: "8" +Checking size of dev_t: "8" +Checking size of ino_t: "8" +Checking size of time_t: "8" +Checking size of void*: "8" +Checking for C99 vsnprintf: OK +Checking for HAVE_SECURE_MKSTEMP: OK +rpath library support: OK +-Wl,--version-script support: OK +Checking size of bool: "1" +Checking size of int8_t: "1" +Checking size of uint8_t: "1" +Checking size of int16_t: "2" +Checking size of uint16_t: "2" +Checking size of int32_t: "4" +Checking size of uint32_t: "4" +Checking size of int64_t: "8" +Checking size of uint64_t: "8" +Checking correct behavior of strtoll: OK +Checking correct behavior of strptime: OK +Checking for HAVE_IFACE_GETIFADDRS: OK +Checking for HAVE_IFACE_IFCONF: OK +Checking for HAVE_IFACE_IFREQ: OK +Checking getconf LFS_CFLAGS: "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +Checking for large file support without additional flags: OK +Checking for working strptime: OK +Checking for HAVE_SHARED_MMAP: OK +Checking for HAVE_MREMAP: OK +Checking for HAVE_INCOHERENT_MMAP: NO +Checking getconf large file support flags work: OK diff --git a/waf-answers/arm-linux-musleabi.answers b/waf-answers/arm-linux-musleabi.answers new file mode 100644 index 00000000..99598533 --- /dev/null +++ b/waf-answers/arm-linux-musleabi.answers @@ -0,0 +1,46 @@ +Checking uname sysname type: "Linux" +Checking uname machine type: "dontcare" +Checking uname release type: "dontcare" +Checking uname version type: "dontcare" +Checking simple C program: OK +building library support: OK +Checking for large file support: OK +Checking for -D_FILE_OFFSET_BITS=64: OK +Checking for WORDS_BIGENDIAN: OK +Checking size of char: "1" +Checking size of int: "4" +Checking size of long long: "8" +Checking size of long: "4" +Checking size of off_t: "8" +Checking size of short: "2" +Checking size of size_t: "4" +Checking size of ssize_t: "4" +Checking size of dev_t: "8" +Checking size of ino_t: "8" +Checking size of time_t: "4" +Checking size of void*: "4" +Checking for C99 vsnprintf: OK +Checking for HAVE_SECURE_MKSTEMP: OK +rpath library support: OK +-Wl,--version-script support: OK +Checking size of bool: "1" +Checking size of int8_t: "1" +Checking size of uint8_t: "1" +Checking size of int16_t: "2" +Checking size of uint16_t: "2" +Checking size of int32_t: "4" +Checking size of uint32_t: "4" +Checking size of int64_t: "8" +Checking size of uint64_t: "8" +Checking correct behavior of strtoll: OK +Checking correct behavior of strptime: OK +Checking for HAVE_IFACE_GETIFADDRS: OK +Checking for HAVE_IFACE_IFCONF: OK +Checking for HAVE_IFACE_IFREQ: OK +Checking getconf LFS_CFLAGS: "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +Checking for large file support without additional flags: OK +Checking for working strptime: OK +Checking for HAVE_SHARED_MMAP: OK +Checking for HAVE_MREMAP: OK +Checking for HAVE_INCOHERENT_MMAP: NO +Checking getconf large file support flags work: OK diff --git a/waf-answers/arm-linux-musleabihf.answers b/waf-answers/arm-linux-musleabihf.answers new file mode 100644 index 00000000..99598533 --- /dev/null +++ b/waf-answers/arm-linux-musleabihf.answers @@ -0,0 +1,46 @@ +Checking uname sysname type: "Linux" +Checking uname machine type: "dontcare" +Checking uname release type: "dontcare" +Checking uname version type: "dontcare" +Checking simple C program: OK +building library support: OK +Checking for large file support: OK +Checking for -D_FILE_OFFSET_BITS=64: OK +Checking for WORDS_BIGENDIAN: OK +Checking size of char: "1" +Checking size of int: "4" +Checking size of long long: "8" +Checking size of long: "4" +Checking size of off_t: "8" +Checking size of short: "2" +Checking size of size_t: "4" +Checking size of ssize_t: "4" +Checking size of dev_t: "8" +Checking size of ino_t: "8" +Checking size of time_t: "4" +Checking size of void*: "4" +Checking for C99 vsnprintf: OK +Checking for HAVE_SECURE_MKSTEMP: OK +rpath library support: OK +-Wl,--version-script support: OK +Checking size of bool: "1" +Checking size of int8_t: "1" +Checking size of uint8_t: "1" +Checking size of int16_t: "2" +Checking size of uint16_t: "2" +Checking size of int32_t: "4" +Checking size of uint32_t: "4" +Checking size of int64_t: "8" +Checking size of uint64_t: "8" +Checking correct behavior of strtoll: OK +Checking correct behavior of strptime: OK +Checking for HAVE_IFACE_GETIFADDRS: OK +Checking for HAVE_IFACE_IFCONF: OK +Checking for HAVE_IFACE_IFREQ: OK +Checking getconf LFS_CFLAGS: "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +Checking for large file support without additional flags: OK +Checking for working strptime: OK +Checking for HAVE_SHARED_MMAP: OK +Checking for HAVE_MREMAP: OK +Checking for HAVE_INCOHERENT_MMAP: NO +Checking getconf large file support flags work: OK diff --git a/waf-answers/i486-linux-musl.answers b/waf-answers/i486-linux-musl.answers new file mode 100644 index 00000000..99598533 --- /dev/null +++ b/waf-answers/i486-linux-musl.answers @@ -0,0 +1,46 @@ +Checking uname sysname type: "Linux" +Checking uname machine type: "dontcare" +Checking uname release type: "dontcare" +Checking uname version type: "dontcare" +Checking simple C program: OK +building library support: OK +Checking for large file support: OK +Checking for -D_FILE_OFFSET_BITS=64: OK +Checking for WORDS_BIGENDIAN: OK +Checking size of char: "1" +Checking size of int: "4" +Checking size of long long: "8" +Checking size of long: "4" +Checking size of off_t: "8" +Checking size of short: "2" +Checking size of size_t: "4" +Checking size of ssize_t: "4" +Checking size of dev_t: "8" +Checking size of ino_t: "8" +Checking size of time_t: "4" +Checking size of void*: "4" +Checking for C99 vsnprintf: OK +Checking for HAVE_SECURE_MKSTEMP: OK +rpath library support: OK +-Wl,--version-script support: OK +Checking size of bool: "1" +Checking size of int8_t: "1" +Checking size of uint8_t: "1" +Checking size of int16_t: "2" +Checking size of uint16_t: "2" +Checking size of int32_t: "4" +Checking size of uint32_t: "4" +Checking size of int64_t: "8" +Checking size of uint64_t: "8" +Checking correct behavior of strtoll: OK +Checking correct behavior of strptime: OK +Checking for HAVE_IFACE_GETIFADDRS: OK +Checking for HAVE_IFACE_IFCONF: OK +Checking for HAVE_IFACE_IFREQ: OK +Checking getconf LFS_CFLAGS: "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +Checking for large file support without additional flags: OK +Checking for working strptime: OK +Checking for HAVE_SHARED_MMAP: OK +Checking for HAVE_MREMAP: OK +Checking for HAVE_INCOHERENT_MMAP: NO +Checking getconf large file support flags work: OK diff --git a/waf-answers/x86_64-linux-musl.answers b/waf-answers/x86_64-linux-musl.answers new file mode 100644 index 00000000..8941e5d5 --- /dev/null +++ b/waf-answers/x86_64-linux-musl.answers @@ -0,0 +1,46 @@ +Checking uname sysname type: "Linux" +Checking uname machine type: "dontcare" +Checking uname release type: "dontcare" +Checking uname version type: "dontcare" +Checking simple C program: OK +building library support: OK +Checking for large file support: OK +Checking for -D_FILE_OFFSET_BITS=64: OK +Checking for WORDS_BIGENDIAN: OK +Checking size of char: "1" +Checking size of int: "4" +Checking size of long long: "8" +Checking size of long: "8" +Checking size of off_t: "8" +Checking size of short: "2" +Checking size of size_t: "8" +Checking size of ssize_t: "8" +Checking size of dev_t: "8" +Checking size of ino_t: "8" +Checking size of time_t: "8" +Checking size of void*: "8" +Checking for C99 vsnprintf: OK +Checking for HAVE_SECURE_MKSTEMP: OK +rpath library support: OK +-Wl,--version-script support: OK +Checking size of bool: "1" +Checking size of int8_t: "1" +Checking size of uint8_t: "1" +Checking size of int16_t: "2" +Checking size of uint16_t: "2" +Checking size of int32_t: "4" +Checking size of uint32_t: "4" +Checking size of int64_t: "8" +Checking size of uint64_t: "8" +Checking correct behavior of strtoll: OK +Checking correct behavior of strptime: OK +Checking for HAVE_IFACE_GETIFADDRS: OK +Checking for HAVE_IFACE_IFCONF: OK +Checking for HAVE_IFACE_IFREQ: OK +Checking getconf LFS_CFLAGS: "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +Checking for large file support without additional flags: OK +Checking for working strptime: OK +Checking for HAVE_SHARED_MMAP: OK +Checking for HAVE_MREMAP: OK +Checking for HAVE_INCOHERENT_MMAP: NO +Checking getconf large file support flags work: OK