From 54f762941700a851a2f6b0fafaa2fd4e61dbbc33 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sun, 30 Nov 2014 23:56:17 +0100 Subject: [PATCH 01/11] Fix issue #32 --- README.md | 22 ++++++++++++++++++++++ lib/core.sh | 5 ++++- tests/test_core.sh | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c52057f..1b4b863 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,28 @@ permissions. Since JuJu gives the possibility to install packages either as root or as normal user you need to remember that and remove the package with the right user! +###No servers configured for repository### +-**Q**: Why I cannot install packages? +``` + pacman -S lsof + Packages (1): lsof-4.88-2 + + Total Download Size: 0.09 MiB + Total Installed Size: 0.21 MiB + + error: no servers configured for repository: core + error: no servers configured for repository: community + error: failed to commit transaction (no servers configured for repository) + Errors occurred, no packages were upgraded. +``` + +-**A**: You need simply to update the mirrorlist file according to your location: +``` + # Uncomment the repository line according to your location + nano /etc/pacman.d/mirrorlist + pacman -Syy +``` + License ------- Copyright (c) 2012-2014 diff --git a/lib/core.sh b/lib/core.sh index 11a1f69..b881f47 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -108,6 +108,9 @@ function _setup_juju(){ imagepath=$1 tar -zxpf ${imagepath} -C ${JUJU_HOME} mkdir -p ${JUJU_HOME}/run/lock + warn "Warn: Change the mirrorlist file according to your location:" + info " nano /etc/pacman.d/mirrorlist" + info " pacman -Syy" info "JuJu installed successfully" } @@ -233,7 +236,7 @@ function build_image_juju(){ mkdir -p ${maindir}/root _prepare_build_directory info "Installing pacman and its dependencies..." - pacstrap -d ${maindir}/root pacman arch-install-scripts binutils libunistring + pacstrap -M -d ${maindir}/root pacman arch-install-scripts binutils libunistring nano info "Generating the locales..." ln -sf /usr/share/zoneinfo/posix/UTC ${maindir}/root/etc/localtime diff --git a/tests/test_core.sh b/tests/test_core.sh index 1a4be0c..9f8da7c 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -50,7 +50,7 @@ function test_setup_juju(){ tar -czvf juju-${ARCH}.tar.gz file } WGET=wget_mock - setup_juju 1> /dev/null + setup_juju &> /dev/null [ -e $JUJU_HOME/file ] || return 1 [ -e $JUJU_HOME/run/lock ] || return 1 } @@ -59,7 +59,7 @@ function test_setup_juju(){ function test_setup_from_file_juju(){ touch file tar -czvf juju-${ARCH}.tar.gz file 1> /dev/null - setup_from_file_juju juju-${ARCH}.tar.gz 1> /dev/null + setup_from_file_juju juju-${ARCH}.tar.gz &> /dev/null [ -e $JUJU_HOME/file ] || return 1 [ -e $JUJU_HOME/run/lock ] || return 1 From b5ad28b4b1fbdccbd056d304da40ba6350d3035e Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 2 Dec 2014 02:38:07 +0100 Subject: [PATCH 02/11] Fix issue #31 --- lib/core.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index 11a1f69..4a6b250 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -233,7 +233,7 @@ function build_image_juju(){ mkdir -p ${maindir}/root _prepare_build_directory info "Installing pacman and its dependencies..." - pacstrap -d ${maindir}/root pacman arch-install-scripts binutils libunistring + pacstrap -G -d ${maindir}/root pacman arch-install-scripts binutils libunistring info "Generating the locales..." ln -sf /usr/share/zoneinfo/posix/UTC ${maindir}/root/etc/localtime @@ -260,19 +260,24 @@ function build_image_juju(){ makepkg -sfcA --asroot pacman --noconfirm --root ${maindir}/root -U proot*.pkg.tar.xz - rm ${maindir}/root/var/cache/pacman/pkg/* - info "Copying JuJu scripts..." git clone https://github.com/fsquillace/juju.git ${maindir}/root/opt/juju echo 'export PATH=$PATH:/opt/juju/bin' > ${maindir}/root/etc/profile.d/juju.sh chmod +x ${maindir}/root/etc/profile.d/juju.sh + info "Setting up the pacman keyring (this might take a while!)..." + pacman --root ${maindir}/root --noconfirm -S psmisc + arch-chroot ${maindir}/root bash -c "pacman-key --init; pacman-key --populate archlinux; killall gpg-agent" + pacman --root ${maindir}/root --noconfirm -Rsn psmisc + info "Validating JuJu image..." arch-chroot ${maindir}/root pacman -Qi pacman &> /dev/null arch-chroot ${maindir}/root yaourt -V &> /dev/null arch-chroot ${maindir}/root proot --help &> /dev/null arch-chroot ${maindir}/root arch-chroot --help &> /dev/null + rm ${maindir}/root/var/cache/pacman/pkg/* + builtin cd ${ORIGIN_WD} local imagefile="juju-${ARCH}.tar.gz" info "Compressing image to ${imagefile}..." From 0b0c3be4dc1a4f12b95ee83e7da00c592ba2e8f9 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 2 Dec 2014 23:28:20 +0100 Subject: [PATCH 03/11] Remove the juju.sh profile since juju could be used internally --- lib/core.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index e72a562..c4c6618 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -265,8 +265,6 @@ function build_image_juju(){ info "Copying JuJu scripts..." git clone https://github.com/fsquillace/juju.git ${maindir}/root/opt/juju - echo 'export PATH=$PATH:/opt/juju/bin' > ${maindir}/root/etc/profile.d/juju.sh - chmod +x ${maindir}/root/etc/profile.d/juju.sh info "Setting up the pacman keyring (this might take a while!)..." pacman --root ${maindir}/root --noconfirm -S psmisc From 1444bcd6499e9797f14d41f6822a29889bb6ffb4 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Mon, 15 Dec 2014 20:56:57 +0100 Subject: [PATCH 04/11] Add sed command to JuJu image --- lib/core.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.sh b/lib/core.sh index c4c6618..24d302d 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -236,7 +236,7 @@ function build_image_juju(){ mkdir -p ${maindir}/root _prepare_build_directory info "Installing pacman and its dependencies..." - pacstrap -G -M -d ${maindir}/root pacman arch-install-scripts binutils libunistring nano + pacstrap -G -M -d ${maindir}/root pacman arch-install-scripts binutils libunistring nano sed info "Generating the locales..." ln -sf /usr/share/zoneinfo/posix/UTC ${maindir}/root/etc/localtime From 6163bc3d4657d0b371d2b6437e17f341fc4c1395 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sun, 21 Dec 2014 20:48:01 +0100 Subject: [PATCH 05/11] Add link to README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1b4b863..a306108 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,9 @@ After creating the image juju-x86\_64.tar.gz you can install it by running: # juju -i juju-x86_64.tar.gz +Related wiki page: +- [How to build a JuJu image using QEMU](https://github.com/fsquillace/juju/wiki/How-to-build-a-JuJu-image-using-QEMU) + ### Bind directories ### To bind and host directory to a guest location, you can use proot arguments: ``` From 97c03a59615a8e6c0df71da96d115f622328184a Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sat, 20 Dec 2014 16:10:41 +0100 Subject: [PATCH 06/11] Add proot compat binary --- lib/core.sh | 65 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index 24d302d..52ed541 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -28,6 +28,15 @@ set -e source "$(dirname ${BASH_ARGV[0]})/util.sh" ################################# VARIABLES ############################## + +if [ "$JUJU_ENV" == "1" ] +then + die "Error: Nested JuJu environments are not allowed" +elif [ ! -z $JUJU_ENV ] && [ "$JUJU_ENV" != "0" ] +then + die "The variable JUJU_ENV is not properly set" +fi + [ -z ${JUJU_HOME} ] && JUJU_HOME=~/.juju if [ -z ${JUJU_TEMPDIR} ] || [ ! -d ${JUJU_TEMPDIR} ] then @@ -48,37 +57,36 @@ else fi TAR=tar -ARCH=$(uname -m) -[[ $ARCH =~ .*(armv6).* ]] && ARCH=${BASH_REMATCH[1]} +HOST_ARCH=$(uname -m) -if [ $ARCH == "i686" ] +if [ $HOST_ARCH == "i686" ] || [ $HOST_ARCH == "i386" ] then + ARCH="x86" LD_LIB="${JUJU_HOME}/lib/ld-linux.so.2" -elif [ $ARCH == "x86_64" ] +elif [ $HOST_ARCH == "x86_64" ] then + ARCH="x86_64" LD_LIB="${JUJU_HOME}/lib64/ld-linux-x86-64.so.2" -elif [ $ARCH == "armv6" ] +elif [[ $HOST_ARCH =~ .*(arm).* ]] then + ARCH="arm" LD_LIB="${JUJU_HOME}/lib/ld-linux-armhf.so.3" else die "Unknown architecture ${ARCH}" fi -if [ -z $JUJU_ENV ] || [ "$JUJU_ENV" == "0" ] -then - PROOT="$LD_LIB --library-path ${JUJU_HOME}/usr/lib:${JUJU_HOME}/lib ${JUJU_HOME}/usr/bin/proot" - SH="/bin/sh --login" -elif [ "$JUJU_ENV" == "1" ] -then - die "Error: Nested JuJu environments are not allowed" -else - die "The variable JUJU_ENV is not properly set" -fi +PROOT_BIN="${JUJU_HOME}/usr/bin/proot" +PROOT_COMPAT_BIN="${JUJU_HOME}/opt/proot/proot-${ARCH}" +PROOT="$LD_LIB --library-path ${JUJU_HOME}/usr/lib:${JUJU_HOME}/lib ${PROOT_BIN}" +PROOT_COMPAT="${PROOT_COMPAT_BIN}" +PROOT_LINK=http://static.proot.me/proot-${ARCH} +SH="/bin/sh --login" CHROOT=${JUJU_HOME}/usr/bin/arch-chroot TRUE=${JUJU_HOME}/usr/bin/true ID="${JUJU_HOME}/usr/bin/id -u" + ################################# MAIN FUNCTIONS ############################## function is_juju_installed(){ @@ -168,12 +176,27 @@ function run_juju_as_root(){ function _run_juju_with_proot(){ - ${PROOT} ${TRUE} &> /dev/null || export PROOT_NO_SECCOMP=1 + local proot_bin=${PROOT} + if ! ${proot_bin} ${TRUE} &> /dev/null + then + if PROOT_NO_SECCOMP=1 ${proot_bin} ${TRUE} &> /dev/null + then + export PROOT_NO_SECCOMP=1 + else + proot_bin=${PROOT_COMPAT} + if PROOT_NO_SECCOMP=1 ${proot_bin} ${TRUE} &> /dev/null + then + export PROOT_NO_SECCOMP=1 + else + die "Proot cannot be executed." + fi + fi + fi - [ "$(${PROOT} ${ID} 2> /dev/null )" == "0" ] && \ + [ "$(${proot_bin} ${ID} 2> /dev/null )" == "0" ] && \ die "You cannot access with root privileges. Use --root option instead." - JUJU_ENV=1 ${PROOT} $@ + JUJU_ENV=1 ${proot_bin} $@ local ret=$? export -n PROOT_NO_SECCOMP @@ -263,6 +286,12 @@ function build_image_juju(){ makepkg -sfcA --asroot pacman --noconfirm --root ${maindir}/root -U proot*.pkg.tar.xz + info "Installing compatibility binary proot" + mkdir -p ${maindir}/root/opt/proot + builtin cd ${maindir}/root/opt/proot + $WGET $PROOT_LINK + chmod +x proot-$ARCH + info "Copying JuJu scripts..." git clone https://github.com/fsquillace/juju.git ${maindir}/root/opt/juju From be1bd7b48717f6559e9938a13796d782456e4bad Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sun, 21 Dec 2014 21:34:24 +0100 Subject: [PATCH 07/11] Fix issue #38 --- lib/core.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core.sh b/lib/core.sh index 24d302d..4a84f61 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -204,6 +204,8 @@ function delete_juju(){ die "Try to delete juju using root permissions" fi fi + # the CA directories are read only and can be deleted only by changing the mod + chmod -R +w ${JUJU_HOME}/etc/ca-certificates if rm -rf ${JUJU_HOME}/* then info "JuJu deleted in ${JUJU_HOME}" From 410b7512d4a99b229602e5e5d4f1454a8cdbb044 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 23 Dec 2014 01:55:22 +0100 Subject: [PATCH 08/11] Fix issue #36 - Add tests for proot compat --- lib/core.sh | 42 +++++++++++++++--------------------- tests/test_core.sh | 54 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 59 insertions(+), 37 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index 52ed541..dd3cdf5 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -83,10 +83,8 @@ PROOT_LINK=http://static.proot.me/proot-${ARCH} SH="/bin/sh --login" CHROOT=${JUJU_HOME}/usr/bin/arch-chroot -TRUE=${JUJU_HOME}/usr/bin/true ID="${JUJU_HOME}/usr/bin/id -u" - ################################# MAIN FUNCTIONS ############################## function is_juju_installed(){ @@ -174,33 +172,27 @@ function run_juju_as_root(){ JUJU_ENV=1 ${CHROOT} $JUJU_HOME /usr/bin/bash -c "mkdir -p /run/lock && $(_define_chroot_args "$@")" } +function _run_proot(){ + if ! JUJU_ENV=1 ${@} + then + info "Trying execute proot with PROOT_NO_SECCOMP=1 " + JUJU_ENV=1 PROOT_NO_SECCOMP=1 ${@} + fi +} + function _run_juju_with_proot(){ - local proot_bin=${PROOT} - if ! ${proot_bin} ${TRUE} &> /dev/null - then - if PROOT_NO_SECCOMP=1 ${proot_bin} ${TRUE} &> /dev/null - then - export PROOT_NO_SECCOMP=1 - else - proot_bin=${PROOT_COMPAT} - if PROOT_NO_SECCOMP=1 ${proot_bin} ${TRUE} &> /dev/null - then - export PROOT_NO_SECCOMP=1 - else - die "Proot cannot be executed." - fi - fi - fi - - [ "$(${proot_bin} ${ID} 2> /dev/null )" == "0" ] && \ + [ "$(${ID} 2> /dev/null )" == "0" ] && \ die "You cannot access with root privileges. Use --root option instead." - JUJU_ENV=1 ${proot_bin} $@ - local ret=$? - export -n PROOT_NO_SECCOMP - - return $ret + if ! _run_proot ${PROOT} ${@} + then + info "Trying to execute proot compat binary" + if ! _run_proot ${PROOT_COMPAT} ${@} + then + die "Proot cannot be executed: Try to use juju -p \"-k 3.10\"" + fi + fi } diff --git a/tests/test_core.sh b/tests/test_core.sh index 9f8da7c..c84f78c 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -101,8 +101,6 @@ function test_run_juju_as_user_proot_args(){ install_mini_juju run_juju_as_user "--help" "" 1> /dev/null is_equal $? 0 || return 1 - run_juju_as_user "--helps" "" &> /dev/null - is_equal $? 1 || return 1 mkdir $JUJU_TEMPDIR/newdir touch $JUJU_TEMPDIR/newdir/newfile @@ -110,24 +108,57 @@ function test_run_juju_as_user_proot_args(){ is_equal $? 0 || return 1 export -f _run_juju_with_proot + export -f _run_proot + export -f info export PROOT - export TRUE + export PROOT_COMPAT + ID="/usr/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null + is_equal $? 1 || return 1 + export -n _run_juju_with_proot + export -n _run_proot + export -n info + export -n PROOT + export -n PROOT_COMPAT +} + +function test_run_juju_with_proot_with_compat(){ + install_mini_juju + PROOT="/usr/bin/true" + PROOT_COMPAT="/usr/bin/false" + _run_juju_with_proot "" "" 1> /dev/null + is_equal $? 0 || return 1 + + PROOT="/usr/bin/false" + PROOT_COMPAT="/usr/bin/true" + _run_juju_with_proot "" "" 1> /dev/null + is_equal $? 0 || return 1 + + export -f _run_juju_with_proot + export -f _run_proot + export -f info + PROOT="/usr/bin/false" PROOT_COMPAT="/usr/bin/false" ID="/usr/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null + is_equal $? 1 || return 1 + export -n _run_juju_with_proot + export -n _run_proot + export -n info +} + +function test_run_juju_with_proot_as_root(){ + export -f _run_juju_with_proot ID="/usr/bin/echo 0" bash -ic "_run_juju_with_proot" &> /dev/null is_equal $? 1 || return 1 export -n _run_juju_with_proot unset _run_juju_with_proot - export -n PROOT - export -n TRUE } -function test_run_juju_as_user_seccomp(){ - install_mini_juju - PROOT="" - local output=$(_run_juju_with_proot "" "env" | grep "PROOT_NO_SECCOMP") +function test_run_proot_seccomp(){ + local output=$(_run_proot "env" | grep "^PROOT_NO_SECCOMP") is_equal $output "" || return 1 - TRUE="/usr/bin/false" - local output=$(_run_juju_with_proot "" "env" | grep "PROOT_NO_SECCOMP") + envv(){ + env | grep "^PROOT_NO_SECCOMP" + } + local output=$(_run_proot "envv" | grep "^PROOT_NO_SECCOMP") is_equal $output "PROOT_NO_SECCOMP=1" || return 1 } @@ -153,7 +184,6 @@ function test_nested_juju(){ is_equal $? 1 || return 1 } - for func in $(declare -F | grep test_ | awk '{print $3}' | xargs) do set_up From 460a0a595e35f811281755f640c76d21b4b770a2 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 23 Dec 2014 13:25:25 +0100 Subject: [PATCH 09/11] Change test for compatibility with old environment --- lib/core.sh | 6 +++--- tests/test_core.sh | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index dd3cdf5..340e8b3 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -175,7 +175,7 @@ function run_juju_as_root(){ function _run_proot(){ if ! JUJU_ENV=1 ${@} then - info "Trying execute proot with PROOT_NO_SECCOMP=1 " + warn "Proot error: Trying to execute proot with PROOT_NO_SECCOMP=1..." JUJU_ENV=1 PROOT_NO_SECCOMP=1 ${@} fi } @@ -187,10 +187,10 @@ function _run_juju_with_proot(){ if ! _run_proot ${PROOT} ${@} then - info "Trying to execute proot compat binary" + warn "Proot error: Trying to execute proot compatible binary..." if ! _run_proot ${PROOT_COMPAT} ${@} then - die "Proot cannot be executed: Try to use juju -p \"-k 3.10\"" + die "Error: Check if the juju arguments are correct or use the option juju -p \"-k 3.10\"" fi fi } diff --git a/tests/test_core.sh b/tests/test_core.sh index c84f78c..5ceb561 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -85,13 +85,13 @@ function test_run_juju_as_root(){ function test_run_juju_as_user(){ install_mini_juju - local output=$(run_juju_as_user "" "mkdir -v /newdir2" | awk -F: '{print $1}') + local output=$(run_juju_as_user "-k 3.10" "/usr/bin/mkdir -v /newdir2" 2> /dev/null | awk -F: '{print $1}') is_equal "$output" "/usr/bin/mkdir" || return 1 [ -e $JUJU_HOME/newdir2 ] is_equal $? 0 || return 1 - SH="mkdir -v /newdir" - local output=$(run_juju_as_user "" | awk -F: '{print $1}') + SH="/usr/bin/mkdir -v /newdir" + local output=$(run_juju_as_user "-k 3.10" 2> /dev/null | awk -F: '{print $1}') is_equal "$output" "/usr/bin/mkdir" || return 1 [ -e $JUJU_HOME/newdir ] is_equal $? 0 || return 1 @@ -99,12 +99,12 @@ function test_run_juju_as_user(){ function test_run_juju_as_user_proot_args(){ install_mini_juju - run_juju_as_user "--help" "" 1> /dev/null + run_juju_as_user "--help" "" &> /dev/null is_equal $? 0 || return 1 mkdir $JUJU_TEMPDIR/newdir touch $JUJU_TEMPDIR/newdir/newfile - run_juju_as_user "-b $JUJU_TEMPDIR/newdir:/newdir" "ls -l /newdir/newfile" 1> /dev/null + run_juju_as_user "-b $JUJU_TEMPDIR/newdir:/newdir -k 3.10" "ls -l /newdir/newfile" &> /dev/null is_equal $? 0 || return 1 export -f _run_juju_with_proot @@ -112,7 +112,7 @@ function test_run_juju_as_user_proot_args(){ export -f info export PROOT export PROOT_COMPAT - ID="/usr/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null + ID="/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null is_equal $? 1 || return 1 export -n _run_juju_with_proot export -n _run_proot @@ -123,20 +123,20 @@ function test_run_juju_as_user_proot_args(){ function test_run_juju_with_proot_with_compat(){ install_mini_juju - PROOT="/usr/bin/true" - PROOT_COMPAT="/usr/bin/false" - _run_juju_with_proot "" "" 1> /dev/null + PROOT="/bin/true" + PROOT_COMPAT="/bin/false" + _run_juju_with_proot "" "" &> /dev/null is_equal $? 0 || return 1 - PROOT="/usr/bin/false" - PROOT_COMPAT="/usr/bin/true" - _run_juju_with_proot "" "" 1> /dev/null + PROOT="/bin/false" + PROOT_COMPAT="/bin/true" + _run_juju_with_proot "" "" &> /dev/null is_equal $? 0 || return 1 export -f _run_juju_with_proot export -f _run_proot export -f info - PROOT="/usr/bin/false" PROOT_COMPAT="/usr/bin/false" ID="/usr/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null + PROOT="/bin/false" PROOT_COMPAT="/bin/false" ID="/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null is_equal $? 1 || return 1 export -n _run_juju_with_proot export -n _run_proot @@ -145,7 +145,7 @@ function test_run_juju_with_proot_with_compat(){ function test_run_juju_with_proot_as_root(){ export -f _run_juju_with_proot - ID="/usr/bin/echo 0" bash -ic "_run_juju_with_proot" &> /dev/null + ID="/bin/echo 0" bash -ic "_run_juju_with_proot" &> /dev/null is_equal $? 1 || return 1 export -n _run_juju_with_proot unset _run_juju_with_proot @@ -158,13 +158,13 @@ function test_run_proot_seccomp(){ envv(){ env | grep "^PROOT_NO_SECCOMP" } - local output=$(_run_proot "envv" | grep "^PROOT_NO_SECCOMP") + local output=$(_run_proot "envv" 2> /dev/null | grep "^PROOT_NO_SECCOMP") is_equal $output "PROOT_NO_SECCOMP=1" || return 1 } function test_run_juju_as_fakeroot(){ install_mini_juju - local output=$(run_juju_as_fakeroot "" "id" | awk '{print $1}') + local output=$(run_juju_as_fakeroot "-k 3.10" "id" 2> /dev/null | awk '{print $1}') is_equal "$output" "uid=0(root)" || return 1 } From a91729820e16c8b17ec8d4149c5bdab964de021a Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 23 Dec 2014 14:48:22 +0100 Subject: [PATCH 10/11] Fix tests --- tests/test_core.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_core.sh b/tests/test_core.sh index 5ceb561..c6613d3 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -109,14 +109,16 @@ function test_run_juju_as_user_proot_args(){ export -f _run_juju_with_proot export -f _run_proot - export -f info + export -f warn + export -f die export PROOT export PROOT_COMPAT ID="/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null is_equal $? 1 || return 1 export -n _run_juju_with_proot export -n _run_proot - export -n info + export -n warn + export -n die export -n PROOT export -n PROOT_COMPAT } @@ -135,12 +137,14 @@ function test_run_juju_with_proot_with_compat(){ export -f _run_juju_with_proot export -f _run_proot - export -f info + export -f warn + export -f die PROOT="/bin/false" PROOT_COMPAT="/bin/false" ID="/bin/echo 1" bash -ic "_run_juju_with_proot --helps" &> /dev/null is_equal $? 1 || return 1 export -n _run_juju_with_proot export -n _run_proot - export -n info + export -n warn + export -n die } function test_run_juju_with_proot_as_root(){ From 63d242344981717a2dac68d053d2b868400120b6 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 23 Dec 2014 15:23:41 +0100 Subject: [PATCH 11/11] Update doc for the new compat binary --- README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a306108..52567f0 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ Just clone JuJu somewhere (for example in ~/juju): $ git clone git://github.com/fsquillace/juju ~/juju $ export PATH=~/juju/bin:$PATH -JuJu can only works on GNU/Linux OS with kernel version greater or equal -2.6.32 on 64 bit 32 bit and ARMv6 architectures. +JuJu can works on GNU/Linux OS with kernel version greater or equal +2.6.0 (JuJu was not tested on kernel versions older than this) on 64 bit 32 bit and ARMv6 architectures. Advanced usage -------------- @@ -84,12 +84,15 @@ Check out the proot options with: Dependencies ------------ JuJu comes with a very short list of dependencies in order to be installed in most -of GNU/Linux distributions. The dependencies needed in the host OS are: +of GNU/Linux distributions. The needed executables in the host OS are: - bash - wget or curl - tar +- getopt +- id - mkdir -- linux kernel 2.6.32+ + +The minimum recommended linux kernel is 2.6.0+ Troubleshooting --------------- @@ -110,9 +113,17 @@ that contains all the essential packages for compiling source code (such as gcc, ###Kernel too old### - **Q**: Why do I get the error: "FATAL: kernel too old"? - **A**: This is because the executable from the precompiled package cannot -always run if the kernel is old. -In order to check if the executable can be compatible with the kernel of -the host OS just use file command, for instance: +properly run if the kernel is old. +JuJu contains two different PRoot binaries, and one of them is highly compatible +with old linux kernel versions. JuJu will detect which PRoot binary need to be +executed but you may need to specify the PRoot *-k* option if the guest rootfs +requires a newer kernel version: +``` + juju -p "-k 3.10" +``` + +In order to check if an executable inside JuJu environment can be compatible +with the kernel of the host OS just use the *file* command, for instance: ``` file ~/.juju/usr/bin/bash