mirror of
https://github.com/fsquillace/junest.git
synced 2026-01-23 10:35:36 +00:00
Issue #63: Change name to JuNest!
This commit is contained in:
parent
c7638f0655
commit
82cb6caa14
6 changed files with 157 additions and 157 deletions
22
.travis.yml
22
.travis.yml
|
|
@ -4,20 +4,20 @@ sudo: required
|
|||
|
||||
install:
|
||||
- PATH=$PWD/bin:$PATH
|
||||
- jujube -f echo 'Installing jujube'
|
||||
- sed -i -e "s/#Server/Server/" ~/.jujube/etc/pacman.d/mirrorlist
|
||||
- jujube -f pacman --noconfirm -Syy
|
||||
- jujube -f pacman --noconfirm -S base-devel
|
||||
- junest -f echo 'Installing junest'
|
||||
- sed -i -e "s/#Server/Server/" ~/.junest/etc/pacman.d/mirrorlist
|
||||
- junest -f pacman --noconfirm -Syy
|
||||
- junest -f pacman --noconfirm -S base-devel
|
||||
|
||||
script:
|
||||
- ./tests/test_all.sh
|
||||
# Test on installing package from AUR
|
||||
- jujube -f yaourt --noconfirm -S tcptraceroute
|
||||
- sudo $PWD/bin/jujube -r tcptraceroute localhost
|
||||
- junest -f yaourt --noconfirm -S tcptraceroute
|
||||
- sudo $PWD/bin/junest -r tcptraceroute localhost
|
||||
# Test on installing package from official repo
|
||||
- jujube -f pacman --noconfirm -S tree
|
||||
- jujube -f tree
|
||||
- junest -f pacman --noconfirm -S tree
|
||||
- junest -f tree
|
||||
# Test on installing package from official repo with root access
|
||||
- jujube -f pacman --noconfirm -S iftop
|
||||
- sudo bin/jujube -r iftop -t -s 5
|
||||
- yes | jujube -d
|
||||
- junest -f pacman --noconfirm -S iftop
|
||||
- sudo bin/junest -r iftop -t -s 5
|
||||
- yes | junest -d
|
||||
|
|
|
|||
100
README.md
100
README.md
|
|
@ -1,19 +1,19 @@
|
|||
JuJube
|
||||
JuNest
|
||||
======
|
||||
The Arch Linux based distro that runs upon any Linux distros without root access
|
||||
|
||||
[](https://travis-ci.org/fsquillace/jujube)
|
||||
[](https://travis-ci.org/fsquillace/junest)
|
||||
|
||||
Description
|
||||
===========
|
||||
**JuJube** is a lightweight Arch Linux based distribution that allows to have
|
||||
**JuNest** (Jailed User NEST) is a lightweight Arch Linux based distribution that allows to have
|
||||
an isolated GNU/Linux environment inside any generic host GNU/Linux OS
|
||||
and without the need to have root privileges for installing packages.
|
||||
|
||||
JuJube contains mainly the package managers (called pacman and yaourt) that allows to access
|
||||
JuNest contains mainly the package managers (called pacman and yaourt) that allows to access
|
||||
to a wide range of packages from the Arch Linux repositories.
|
||||
|
||||
The main advantages on using JuJube are:
|
||||
The main advantages on using JuNest are:
|
||||
|
||||
- Install packages without root privileges.
|
||||
- Isolated environment in which you can install packages without affecting a production system.
|
||||
|
|
@ -21,47 +21,47 @@ The main advantages on using JuJube are:
|
|||
- Available for x86\_64, x86 and ARM architectures but you can build your own image from scratch too!
|
||||
- All Arch Linux lovers can have their favourite distro everywhere!
|
||||
|
||||
JuJube follows the [Arch Linux philosophy](https://wiki.archlinux.org/index.php/The_Arch_Way).
|
||||
JuNest follows the [Arch Linux philosophy](https://wiki.archlinux.org/index.php/The_Arch_Way).
|
||||
|
||||
Quickstart
|
||||
==========
|
||||
There are three different ways you can run JuJube:
|
||||
There are three different ways you can run JuNest:
|
||||
|
||||
- As normal user - Allow to make basic operations using [proot](https://wiki.archlinux.org/index.php/Proot): ```jujube```
|
||||
- As normal user - Allow to make basic operations using [proot](https://wiki.archlinux.org/index.php/Proot): ```junest```
|
||||
|
||||
- As fakeroot - Allow to install/remove packages using [proot](https://wiki.archlinux.org/index.php/Proot): ```jujube -f```
|
||||
- As fakeroot - Allow to install/remove packages using [proot](https://wiki.archlinux.org/index.php/Proot): ```junest -f```
|
||||
|
||||
- As root - Allow to have fully root privileges inside JuJube environment using [arch-chroot](https://wiki.archlinux.org/index.php/Chroot) (you need to be root for executing this): ```jujube -r```
|
||||
- As root - Allow to have fully root privileges inside JuNest environment using [arch-chroot](https://wiki.archlinux.org/index.php/Chroot) (you need to be root for executing this): ```junest -r```
|
||||
|
||||
If the JuJube image has not been downloaded yet, the script will download
|
||||
the JuJube image and will place it to the default directory ~/.jujube.
|
||||
You can change the default directory by changing the environment variable *JUJUBE\_HOME*.
|
||||
If the JuNest image has not been downloaded yet, the script will download
|
||||
the JuNest image and will place it to the default directory ~/.junest.
|
||||
You can change the default directory by changing the environment variable *JUNEST\_HOME*.
|
||||
|
||||
If you are new on Archlinux and you are not familiar with *pacman* package manager
|
||||
visit the [pacman rosetta page](https://wiki.archlinux.org/index.php/Pacman_Rosetta).
|
||||
|
||||
Installation
|
||||
============
|
||||
JuJube can works on GNU/Linux OS with kernel version greater or equal
|
||||
2.6.0 (JuJube was not tested on kernel versions older than this) on 64 bit, 32 bit and ARM architectures.
|
||||
JuNest can works on GNU/Linux OS with kernel version greater or equal
|
||||
2.6.0 (JuNest was not tested on kernel versions older than this) on 64 bit, 32 bit and ARM architectures.
|
||||
|
||||
## Method one (Recommended) ##
|
||||
Just clone the JuJube repo somewhere (for example in ~/jujube):
|
||||
Just clone the JuNest repo somewhere (for example in ~/junest):
|
||||
|
||||
git clone git://github.com/fsquillace/jujube ~/jujube
|
||||
export PATH=~/jujube/bin:$PATH
|
||||
git clone git://github.com/fsquillace/junest ~/junest
|
||||
export PATH=~/junest/bin:$PATH
|
||||
|
||||
## Method two ##
|
||||
Alternatively, another installation method would be to directly download the JuJube image and place it to the default directory ~/.jujube:
|
||||
Alternatively, another installation method would be to directly download the JuNest image and place it to the default directory ~/.junest:
|
||||
|
||||
ARCH=<one of "x86_64", "x86", "arm">
|
||||
mkdir ~/.jujube
|
||||
curl https://dl.dropboxusercontent.com/u/42449030/jujube/jujube-${ARCH}.tar.gz | tar -xz -C ~/.jujube
|
||||
export PATH=~/.jujube/opt/jujube/bin:$PATH
|
||||
mkdir ~/.junest
|
||||
curl https://dl.dropboxusercontent.com/u/42449030/junest/junest-${ARCH}.tar.gz | tar -xz -C ~/.junest
|
||||
export PATH=~/.junest/opt/junest/bin:$PATH
|
||||
|
||||
Dependencies
|
||||
============
|
||||
JuJube comes with a very short list of dependencies in order to be installed in most
|
||||
JuNest comes with a very short list of dependencies in order to be installed in most
|
||||
of GNU/Linux distributions. The needed executables in the host OS are:
|
||||
|
||||
- bash
|
||||
|
|
@ -77,53 +77,53 @@ Advanced usage
|
|||
============
|
||||
|
||||
## Build image ##
|
||||
You can build a new JuJube image from scratch by running the following command:
|
||||
You can build a new JuNest image from scratch by running the following command:
|
||||
|
||||
jujube -b [-n]
|
||||
junest -b [-n]
|
||||
|
||||
The script will create a directory containing all the essentials
|
||||
files in order to make JuJube working properly (such as pacman, yaourt, arch-chroot and proot).
|
||||
files in order to make JuNest working properly (such as pacman, yaourt, arch-chroot and proot).
|
||||
The option **-n** will skip the final validation tests if they are not needed.
|
||||
Remember that the script to build the image must run in an Arch Linux OS with
|
||||
arch-install-scripts, package-query, git and the base-devel packages installed.
|
||||
To change the build directory just use the *JUJUBE_TEMPDIR* (by default /tmp).
|
||||
To change the build directory just use the *JUNEST_TEMPDIR* (by default /tmp).
|
||||
|
||||
After creating the image jujube-x86\_64.tar.gz you can install it by running:
|
||||
After creating the image junest-x86\_64.tar.gz you can install it by running:
|
||||
|
||||
jujube -i jujube-x86_64.tar.gz
|
||||
junest -i junest-x86_64.tar.gz
|
||||
|
||||
Related wiki page:
|
||||
|
||||
- [How to build a JuJube image using QEMU](https://github.com/fsquillace/jujube/wiki/How-to-build-a-JuJube-image-using-QEMU)
|
||||
- [How to build a JuNest image using QEMU](https://github.com/fsquillace/junest/wiki/How-to-build-a-JuNest-image-using-QEMU)
|
||||
|
||||
## Bind directories ##
|
||||
To bind a host directory to a guest location, you can use proot arguments:
|
||||
|
||||
jujube -p "-b /mnt/mydata:/home/user/mydata"
|
||||
junest -p "-b /mnt/mydata:/home/user/mydata"
|
||||
|
||||
Check out the proot options with:
|
||||
|
||||
jujube -p "--help"
|
||||
junest -p "--help"
|
||||
|
||||
##Automatic fallback to classic chroot##
|
||||
Since the [arch-chroot](https://wiki.archlinux.org/index.php/Chroot) may not work
|
||||
on some distros, JuJube automatically tries to fallback to the classic chroot.
|
||||
on some distros, JuNest automatically tries to fallback to the classic chroot.
|
||||
|
||||
## JuJube as a container ##
|
||||
Although JuJube has not been designed to be a complete container, it is even possible to
|
||||
## JuNest as a container ##
|
||||
Although JuNest has not been designed to be a complete container, it is even possible to
|
||||
virtualize the process tree thanks to the [systemd container](https://wiki.archlinux.org/index.php/Systemd-nspawn).
|
||||
The JuJube containter allows to run services inside the container that can be
|
||||
The JuNest containter allows to run services inside the container that can be
|
||||
visible from the host OS through the network.
|
||||
The drawbacks of this are that the host OS must use systemd as a service manager,
|
||||
and the container can only be executed using root privileges.
|
||||
|
||||
To boot a JuJube container:
|
||||
To boot a JuNest container:
|
||||
|
||||
sudo systemd-nspawn -bD ~/.jujube
|
||||
sudo systemd-nspawn -bD ~/.junest
|
||||
|
||||
Related wiki page:
|
||||
|
||||
- [How to run jujube as a container](https://github.com/fsquillace/jujube/wiki/How-to-run-JuJube-as-a-container)
|
||||
- [How to run junest as a container](https://github.com/fsquillace/junest/wiki/How-to-run-JuNest-as-a-container)
|
||||
|
||||
Troubleshooting
|
||||
===============
|
||||
|
|
@ -134,7 +134,7 @@ Troubleshooting
|
|||
|
||||
Cannot find the gzip binary required for compressing man and info pages.
|
||||
|
||||
> **A**: JuJube comes with a very basic number of packages.
|
||||
> **A**: JuNest comes with a very basic number of packages.
|
||||
In order to install packages using yaourt you may need to install the package group **base-devel**
|
||||
that contains all the essential packages for compiling source code (such as gcc, make, patch, etc):
|
||||
|
||||
|
|
@ -146,17 +146,17 @@ that contains all the essential packages for compiling source code (such as gcc,
|
|||
|
||||
> **A**: This is because the executable from the precompiled package cannot
|
||||
properly run if the kernel is old.
|
||||
JuJube contains two different PRoot binaries, and one of them is highly compatible
|
||||
with old linux kernel versions. JuJube will detect which PRoot binary need to be
|
||||
JuNest contains two different PRoot binaries, and one of them is highly compatible
|
||||
with old linux kernel versions. JuNest 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:
|
||||
|
||||
jujube -p "-k 3.10"
|
||||
junest -p "-k 3.10"
|
||||
|
||||
In order to check if an executable inside JuJube environment can be compatible
|
||||
In order to check if an executable inside JuNest environment can be compatible
|
||||
with the kernel of the host OS just use the *file* command, for instance:
|
||||
|
||||
file ~/.jujube/usr/bin/bash
|
||||
file ~/.junest/usr/bin/bash
|
||||
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked
|
||||
(uses shared libs), for GNU/Linux 2.6.32,
|
||||
BuildID[sha1]=ec37e49e7188ff4030052783e61b859113e18ca6, stripped
|
||||
|
|
@ -172,7 +172,7 @@ From the output you can see what is the minimum recommended Linux kernel version
|
|||
> **A**: The ping command uses *suid* permissions that allow to execute the command using
|
||||
root privileges. The fakeroot mode is not able to execute a command set with suid,
|
||||
and you may need to use root privileges. There are other few commands that
|
||||
have *suid* permission, you can list the commands from your JuJube environment
|
||||
have *suid* permission, you can list the commands from your JuNest environment
|
||||
with the following command:
|
||||
|
||||
find /usr/bin -perm +4000
|
||||
|
|
@ -201,7 +201,7 @@ To quick fix this, you can just install a fonts package:
|
|||
|
||||
> **A**: In these cases the package installation went smoothly anyway.
|
||||
This should happen every time you install package with root privileges
|
||||
since JuJube will try to preserve the JuJube environment by assigning ownership
|
||||
since JuNest will try to preserve the JuNest environment by assigning ownership
|
||||
of the files to the real user.
|
||||
|
||||
##No servers configured for repository##
|
||||
|
|
@ -228,7 +228,7 @@ of the files to the real user.
|
|||
More documentation
|
||||
==================
|
||||
There are additional tutorials in the
|
||||
[JuJube wiki page](https://github.com/fsquillace/jujube/wiki).
|
||||
[JuNest wiki page](https://github.com/fsquillace/junest/wiki).
|
||||
|
||||
License
|
||||
=======
|
||||
|
|
@ -253,11 +253,11 @@ Filippo Squillace <feel.squally@gmail.com>
|
|||
|
||||
WWW
|
||||
===
|
||||
https://github.com/fsquillace/jujube
|
||||
https://github.com/fsquillace/junest
|
||||
|
||||
Last words
|
||||
==========
|
||||
Quote of the [lotus](http://en.wikipedia.org/wiki/Ziziphus_lotus) (a selvatic jujube plant)
|
||||
Quote of the [lotus](http://en.wikipedia.org/wiki/Ziziphus_lotus) (a selvatic junest plant)
|
||||
|
||||
> Per nove infausti dì sul mar pescoso
|
||||
> i venti rei mi trasportaro. Al fine
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# This file is part of JuJube (https://github.com/fsquillace/jujube).
|
||||
# This file is part of JuNest (https://github.com/fsquillace/junest).
|
||||
#
|
||||
# Copyright (c) 2012-2015
|
||||
#
|
||||
|
|
@ -28,13 +28,13 @@ usage() {
|
|||
echo -e "$NAME: $DESCRIPTION"
|
||||
echo -e "Usage: $CMD [options] [--] [command]"
|
||||
echo -e "Options:"
|
||||
echo -e "-i, --setup-from-file <image> Setup the $NAME image in ${JUJUBE_HOME}"
|
||||
echo -e "-i, --setup-from-file <image> Setup the $NAME image in ${JUNEST_HOME}"
|
||||
echo -e "-f, --fakeroot Run $NAME with fakeroot privileges"
|
||||
echo -e "-r, --root Run $NAME with root privileges"
|
||||
echo -e "-p, --proot-args Proot arguments"
|
||||
echo -e "-b, --build-image Build a $NAME image (must run in ArchLinux)"
|
||||
echo -e "-n, --disable-validation Disable the $NAME image validation"
|
||||
echo -e "-d, --delete Delete $NAME from ${JUJUBE_HOME}"
|
||||
echo -e "-d, --delete Delete $NAME from ${JUNEST_HOME}"
|
||||
echo -e "-h, --help Show this help message"
|
||||
echo -e "-v, --version Show the $NAME version"
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ function execute_operation(){
|
|||
setup_env
|
||||
fi
|
||||
elif $OPT_SETUP_FROM_FILE; then
|
||||
die "Error: The image cannot be installed since $JUJUBE_HOME is not empty."
|
||||
die "Error: The image cannot be installed since $JUNEST_HOME is not empty."
|
||||
fi
|
||||
|
||||
if $OPT_FAKEROOT; then
|
||||
122
lib/core.sh
122
lib/core.sh
|
|
@ -27,8 +27,8 @@ source "$(dirname ${BASH_ARGV[0]})/util.sh"
|
|||
|
||||
################################# VARIABLES ##############################
|
||||
|
||||
NAME='JuJube'
|
||||
CMD='jujube'
|
||||
NAME='JuNest'
|
||||
CMD='junest'
|
||||
VERSION='4.7.4'
|
||||
CODE_NAME='Mairei'
|
||||
DESCRIPTION='The Arch Linux based distro that runs upon any Linux distros without root access'
|
||||
|
|
@ -37,18 +37,18 @@ HOMEPAGE="https://github.com/fsquillace/${CMD}"
|
|||
COPYRIGHT='2012-2015'
|
||||
|
||||
|
||||
if [ "$JUJUBE_ENV" == "1" ]
|
||||
if [ "$JUNEST_ENV" == "1" ]
|
||||
then
|
||||
die "Error: Nested ${NAME} environments are not allowed"
|
||||
elif [ ! -z $JUJUBE_ENV ] && [ "$JUJUBE_ENV" != "0" ]
|
||||
elif [ ! -z $JUNEST_ENV ] && [ "$JUNEST_ENV" != "0" ]
|
||||
then
|
||||
die "The variable JUJUBE_ENV is not properly set"
|
||||
die "The variable JUNEST_ENV is not properly set"
|
||||
fi
|
||||
|
||||
[ -z ${JUJUBE_HOME} ] && JUJUBE_HOME=~/.${CMD}
|
||||
if [ -z ${JUJUBE_TEMPDIR} ] || [ ! -d ${JUJUBE_TEMPDIR} ]
|
||||
[ -z ${JUNEST_HOME} ] && JUNEST_HOME=~/.${CMD}
|
||||
if [ -z ${JUNEST_TEMPDIR} ] || [ ! -d ${JUNEST_TEMPDIR} ]
|
||||
then
|
||||
JUJUBE_TEMPDIR=/tmp
|
||||
JUNEST_TEMPDIR=/tmp
|
||||
fi
|
||||
|
||||
ENV_REPO=https://dl.dropboxusercontent.com/u/42449030/${CMD}
|
||||
|
|
@ -66,28 +66,28 @@ HOST_ARCH=$(uname -m)
|
|||
if [ $HOST_ARCH == "i686" ] || [ $HOST_ARCH == "i386" ]
|
||||
then
|
||||
ARCH="x86"
|
||||
LD_LIB="${JUJUBE_HOME}/lib/ld-linux.so.2"
|
||||
LD_LIB="${JUNEST_HOME}/lib/ld-linux.so.2"
|
||||
elif [ $HOST_ARCH == "x86_64" ]
|
||||
then
|
||||
ARCH="x86_64"
|
||||
LD_LIB="${JUJUBE_HOME}/lib64/ld-linux-x86-64.so.2"
|
||||
LD_LIB="${JUNEST_HOME}/lib64/ld-linux-x86-64.so.2"
|
||||
elif [[ $HOST_ARCH =~ .*(arm).* ]]
|
||||
then
|
||||
ARCH="arm"
|
||||
LD_LIB="${JUJUBE_HOME}/lib/ld-linux-armhf.so.3"
|
||||
LD_LIB="${JUNEST_HOME}/lib/ld-linux-armhf.so.3"
|
||||
else
|
||||
die "Unknown architecture ${ARCH}"
|
||||
fi
|
||||
|
||||
PROOT_COMPAT="${JUJUBE_HOME}/opt/proot/proot-${ARCH}"
|
||||
PROOT_COMPAT="${JUNEST_HOME}/opt/proot/proot-${ARCH}"
|
||||
PROOT_LINK=http://static.proot.me/proot-${ARCH}
|
||||
|
||||
SH=("/bin/sh" "--login")
|
||||
CHROOT=${JUJUBE_HOME}/usr/bin/arch-chroot
|
||||
CLASSIC_CHROOT=${JUJUBE_HOME}/usr/bin/chroot
|
||||
CHROOT=${JUNEST_HOME}/usr/bin/arch-chroot
|
||||
CLASSIC_CHROOT=${JUNEST_HOME}/usr/bin/chroot
|
||||
TRUE=/usr/bin/true
|
||||
ID="/usr/bin/id -u"
|
||||
CHOWN="${JUJUBE_HOME}/usr/bin/chown"
|
||||
CHOWN="${JUNEST_HOME}/usr/bin/chown"
|
||||
LN="ln"
|
||||
|
||||
################################# MAIN FUNCTIONS ##############################
|
||||
|
|
@ -98,7 +98,7 @@ function download(){
|
|||
}
|
||||
|
||||
function is_env_installed(){
|
||||
[ -d "$JUJUBE_HOME" ] && [ "$(ls -A $JUJUBE_HOME)" ] && return 0
|
||||
[ -d "$JUNEST_HOME" ] && [ "$(ls -A $JUNEST_HOME)" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
|
|
@ -119,11 +119,11 @@ function _prepare_build_directory(){
|
|||
|
||||
|
||||
function _setup_env(){
|
||||
is_env_installed && die "Error: ${NAME} has been already installed in $JUJUBE_HOME"
|
||||
mkdir -p "${JUJUBE_HOME}"
|
||||
is_env_installed && die "Error: ${NAME} has been already installed in $JUNEST_HOME"
|
||||
mkdir -p "${JUNEST_HOME}"
|
||||
imagepath=$1
|
||||
$TAR -zxpf ${imagepath} -C ${JUJUBE_HOME}
|
||||
mkdir -p ${JUJUBE_HOME}/run/lock
|
||||
$TAR -zxpf ${imagepath} -C ${JUNEST_HOME}
|
||||
mkdir -p ${JUNEST_HOME}/run/lock
|
||||
warn "Warn: The default mirror URL is ${DEFAULT_MIRROR}."
|
||||
warn "To change it:"
|
||||
info " nano /etc/pacman.d/mirrorlist"
|
||||
|
|
@ -134,7 +134,7 @@ function _setup_env(){
|
|||
|
||||
|
||||
function setup_env(){
|
||||
local maindir=$(TMPDIR=$JUJUBE_TEMPDIR mktemp -d -t ${CMD}.XXXXXXXXXX)
|
||||
local maindir=$(TMPDIR=$JUNEST_TEMPDIR mktemp -d -t ${CMD}.XXXXXXXXXX)
|
||||
_prepare_build_directory
|
||||
|
||||
info "Downloading ${NAME}..."
|
||||
|
|
@ -166,30 +166,30 @@ function run_env_as_root(){
|
|||
|
||||
local main_cmd="${SH[@]}"
|
||||
[ "$1" != "" ] && main_cmd="$(insert_quotes_on_spaces "$@")"
|
||||
local cmd="mkdir -p ${JUJUBE_HOME}/${HOME} && mkdir -p /run/lock && ${main_cmd}"
|
||||
local cmd="mkdir -p ${JUNEST_HOME}/${HOME} && mkdir -p /run/lock && ${main_cmd}"
|
||||
|
||||
trap - QUIT EXIT ABRT KILL TERM INT
|
||||
trap "[ -z $uid ] || ${CHOWN} -R ${uid} ${JUJUBE_HOME}; rm -r ${JUJUBE_HOME}/etc/mtab" EXIT QUIT ABRT KILL TERM INT
|
||||
trap "[ -z $uid ] || ${CHOWN} -R ${uid} ${JUNEST_HOME}; rm -r ${JUNEST_HOME}/etc/mtab" EXIT QUIT ABRT KILL TERM INT
|
||||
|
||||
[ ! -e ${JUJUBE_HOME}/etc/mtab ] && $LN -s /proc/self/mounts ${JUJUBE_HOME}/etc/mtab
|
||||
[ ! -e ${JUNEST_HOME}/etc/mtab ] && $LN -s /proc/self/mounts ${JUNEST_HOME}/etc/mtab
|
||||
|
||||
if ${CHROOT} $JUJUBE_HOME ${TRUE} 1> /dev/null
|
||||
if ${CHROOT} $JUNEST_HOME ${TRUE} 1> /dev/null
|
||||
then
|
||||
JUJUBE_ENV=1 ${CHROOT} $JUJUBE_HOME "${SH[@]}" "-c" "${cmd}"
|
||||
JUNEST_ENV=1 ${CHROOT} $JUNEST_HOME "${SH[@]}" "-c" "${cmd}"
|
||||
local ret=$?
|
||||
elif ${CLASSIC_CHROOT} $JUJUBE_HOME ${TRUE} 1> /dev/null
|
||||
elif ${CLASSIC_CHROOT} $JUNEST_HOME ${TRUE} 1> /dev/null
|
||||
then
|
||||
warn "Warning: The executable arch-chroot does not work, falling back to classic chroot"
|
||||
JUJUBE_ENV=1 ${CLASSIC_CHROOT} $JUJUBE_HOME "${SH[@]}" "-c" "${cmd}"
|
||||
JUNEST_ENV=1 ${CLASSIC_CHROOT} $JUNEST_HOME "${SH[@]}" "-c" "${cmd}"
|
||||
local ret=$?
|
||||
else
|
||||
die "Error: Chroot does not work"
|
||||
fi
|
||||
|
||||
# The ownership of the files is assigned to the real user
|
||||
[ -z $uid ] || ${CHOWN} -R ${uid} ${JUJUBE_HOME}
|
||||
[ -z $uid ] || ${CHOWN} -R ${uid} ${JUNEST_HOME}
|
||||
|
||||
[ -e ${JUJUBE_HOME}/etc/mtab ] && rm -r ${JUJUBE_HOME}/etc/mtab
|
||||
[ -e ${JUNEST_HOME}/etc/mtab ] && rm -r ${JUNEST_HOME}/etc/mtab
|
||||
|
||||
trap - QUIT EXIT ABRT KILL TERM INT
|
||||
return $?
|
||||
|
|
@ -200,11 +200,11 @@ function _run_proot(){
|
|||
shift
|
||||
if ${PROOT_COMPAT} $proot_args ${TRUE} 1> /dev/null
|
||||
then
|
||||
JUJUBE_ENV=1 ${PROOT_COMPAT} $proot_args "${@}"
|
||||
JUNEST_ENV=1 ${PROOT_COMPAT} $proot_args "${@}"
|
||||
elif PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} $proot_args ${TRUE} 1> /dev/null
|
||||
then
|
||||
warn "Proot error: Trying to execute proot with PROOT_NO_SECCOMP=1..."
|
||||
JUJUBE_ENV=1 PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} $proot_args "${@}"
|
||||
JUNEST_ENV=1 PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} $proot_args "${@}"
|
||||
else
|
||||
die "Error: Check if the ${CMD} arguments are correct or use the option ${CMD} -p \"-k 3.10\""
|
||||
fi
|
||||
|
|
@ -227,43 +227,43 @@ function _run_env_with_proot(){
|
|||
function run_env_as_fakeroot(){
|
||||
local proot_args="$1"
|
||||
shift
|
||||
[ "$(_run_proot "-R ${JUJUBE_HOME} $proot_args" ${ID} 2> /dev/null )" == "0" ] && \
|
||||
[ "$(_run_proot "-R ${JUNEST_HOME} $proot_args" ${ID} 2> /dev/null )" == "0" ] && \
|
||||
die "You cannot access with root privileges. Use --root option instead."
|
||||
|
||||
[ ! -e ${JUJUBE_HOME}/etc/mtab ] && $LN -s /proc/self/mounts ${JUJUBE_HOME}/etc/mtab
|
||||
_run_env_with_proot "-S ${JUJUBE_HOME} $proot_args" "${@}"
|
||||
[ ! -e ${JUNEST_HOME}/etc/mtab ] && $LN -s /proc/self/mounts ${JUNEST_HOME}/etc/mtab
|
||||
_run_env_with_proot "-S ${JUNEST_HOME} $proot_args" "${@}"
|
||||
}
|
||||
|
||||
|
||||
function run_env_as_user(){
|
||||
local proot_args="$1"
|
||||
shift
|
||||
[ "$(_run_proot "-R ${JUJUBE_HOME} $proot_args" ${ID} 2> /dev/null )" == "0" ] && \
|
||||
[ "$(_run_proot "-R ${JUNEST_HOME} $proot_args" ${ID} 2> /dev/null )" == "0" ] && \
|
||||
die "You cannot access with root privileges. Use --root option instead."
|
||||
|
||||
[ -e ${JUJUBE_HOME}/etc/mtab ] && rm -f ${JUJUBE_HOME}/etc/mtab
|
||||
_run_env_with_proot "-R ${JUJUBE_HOME} $proot_args" "${@}"
|
||||
[ -e ${JUNEST_HOME}/etc/mtab ] && rm -f ${JUNEST_HOME}/etc/mtab
|
||||
_run_env_with_proot "-R ${JUNEST_HOME} $proot_args" "${@}"
|
||||
}
|
||||
|
||||
|
||||
function delete_env(){
|
||||
! ask "Are you sure to delete ${NAME} located in ${JUJUBE_HOME}" "N" && return
|
||||
if mountpoint -q ${JUJUBE_HOME}
|
||||
! ask "Are you sure to delete ${NAME} located in ${JUNEST_HOME}" "N" && return
|
||||
if mountpoint -q ${JUNEST_HOME}
|
||||
then
|
||||
info "There are mounted directories inside ${JUJUBE_HOME}"
|
||||
if ! umount --force ${JUJUBE_HOME}
|
||||
info "There are mounted directories inside ${JUNEST_HOME}"
|
||||
if ! umount --force ${JUNEST_HOME}
|
||||
then
|
||||
error "Cannot umount directories in ${JUJUBE_HOME}"
|
||||
error "Cannot umount directories in ${JUNEST_HOME}"
|
||||
die "Try to delete ${NAME} using root permissions"
|
||||
fi
|
||||
fi
|
||||
# the CA directories are read only and can be deleted only by changing the mod
|
||||
chmod -R +w ${JUJUBE_HOME}/etc/ca-certificates
|
||||
if rm -rf ${JUJUBE_HOME}/*
|
||||
chmod -R +w ${JUNEST_HOME}/etc/ca-certificates
|
||||
if rm -rf ${JUNEST_HOME}/*
|
||||
then
|
||||
info "${NAME} deleted in ${JUJUBE_HOME}"
|
||||
info "${NAME} deleted in ${JUNEST_HOME}"
|
||||
else
|
||||
error "Error: Cannot delete ${NAME} in ${JUJUBE_HOME}"
|
||||
error "Error: Cannot delete ${NAME} in ${JUNEST_HOME}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ function build_image_env(){
|
|||
|
||||
local disable_validation=$1
|
||||
|
||||
local maindir=$(TMPDIR=$JUJUBE_TEMPDIR mktemp -d -t ${CMD}.XXXXXXXXXX)
|
||||
local maindir=$(TMPDIR=$JUNEST_TEMPDIR mktemp -d -t ${CMD}.XXXXXXXXXX)
|
||||
sudo mkdir -p ${maindir}/root
|
||||
trap - QUIT EXIT ABRT KILL TERM INT
|
||||
trap "sudo rm -rf ${maindir}; die \"Error occurred when installing ${NAME}\"" EXIT QUIT ABRT KILL TERM INT
|
||||
|
|
@ -365,28 +365,28 @@ function validate_image(){
|
|||
$TAR -zxpf ${imagefile} -C ${testdir}
|
||||
mkdir -p ${testdir}/run/lock
|
||||
sed -i -e "s/#Server/Server/" ${testdir}/etc/pacman.d/mirrorlist
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -Syy
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -Syy
|
||||
|
||||
# Check most basic executables work
|
||||
JUJUBE_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r pacman -Qi pacman 1> /dev/null
|
||||
JUJUBE_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r yaourt -V 1> /dev/null
|
||||
JUJUBE_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r /opt/proot/proot-$ARCH --help 1> /dev/null
|
||||
JUJUBE_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r arch-chroot --help 1> /dev/null
|
||||
JUNEST_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r pacman -Qi pacman 1> /dev/null
|
||||
JUNEST_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r yaourt -V 1> /dev/null
|
||||
JUNEST_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r /opt/proot/proot-$ARCH --help 1> /dev/null
|
||||
JUNEST_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r arch-chroot --help 1> /dev/null
|
||||
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -S base-devel
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -S base-devel
|
||||
local yaourt_package=tcptraceroute
|
||||
info "Installing ${yaourt_package} package from AUR repo using proot..."
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f sh --login -c "yaourt --noconfirm -S ${yaourt_package}"
|
||||
JUJUBE_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r tcptraceroute localhost
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f sh --login -c "yaourt --noconfirm -S ${yaourt_package}"
|
||||
JUNEST_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r tcptraceroute localhost
|
||||
|
||||
local repo_package=sysstat
|
||||
info "Installing ${repo_package} package from official repo using proot..."
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -S ${repo_package}
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} iostat
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f iostat
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -S ${repo_package}
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} iostat
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f iostat
|
||||
|
||||
local repo_package=iftop
|
||||
info "Installing ${repo_package} package from official repo using root..."
|
||||
JUJUBE_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -S ${repo_package}
|
||||
JUJUBE_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r iftop -t -s 5
|
||||
JUNEST_HOME=${testdir} ${testdir}/opt/${CMD}/bin/${CMD} -f pacman --noconfirm -S ${repo_package}
|
||||
JUNEST_HOME=${testdir} sudo ${testdir}/opt/${CMD}/bin/${CMD} -r iftop -t -s 5
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# This file is part of JuJube (https://github.com/fsquillace/jujube)
|
||||
# This file is part of JuNest (https://github.com/fsquillace/junest)
|
||||
#
|
||||
# Copyright (c) 2012-2015
|
||||
#
|
||||
|
|
|
|||
|
|
@ -5,35 +5,35 @@ function oneTimeSetUp(){
|
|||
|
||||
CURRPWD=$PWD
|
||||
ENV_MAIN_HOME=/tmp/envtesthome
|
||||
[ -e $ENV_MAIN_HOME ] || JUJUBE_HOME=$ENV_MAIN_HOME bash --rcfile "$(dirname $0)/../lib/core.sh" -ic "setup_env"
|
||||
JUJUBE_HOME=""
|
||||
[ -e $ENV_MAIN_HOME ] || JUNEST_HOME=$ENV_MAIN_HOME bash --rcfile "$(dirname $0)/../lib/core.sh" -ic "setup_env"
|
||||
JUNEST_HOME=""
|
||||
}
|
||||
|
||||
function install_mini_env(){
|
||||
cp -rfa $ENV_MAIN_HOME/* $JUJUBE_HOME
|
||||
cp -rfa $ENV_MAIN_HOME/* $JUNEST_HOME
|
||||
}
|
||||
|
||||
function setUp(){
|
||||
cd $CURRPWD
|
||||
JUJUBE_HOME=$(TMPDIR=/tmp mktemp -d -t envhome.XXXXXXXXXX)
|
||||
JUNEST_HOME=$(TMPDIR=/tmp mktemp -d -t envhome.XXXXXXXXXX)
|
||||
source "$(dirname $0)/../lib/core.sh"
|
||||
ORIGIN_WD=$(TMPDIR=/tmp mktemp -d -t envowd.XXXXXXXXXX)
|
||||
cd $ORIGIN_WD
|
||||
JUJUBE_TEMPDIR=$(TMPDIR=/tmp mktemp -d -t envtemp.XXXXXXXXXX)
|
||||
JUNEST_TEMPDIR=$(TMPDIR=/tmp mktemp -d -t envtemp.XXXXXXXXXX)
|
||||
|
||||
set +e
|
||||
|
||||
trap - QUIT EXIT ABRT KILL TERM INT
|
||||
trap "rm -rf ${JUJUBE_HOME}; rm -rf ${ORIGIN_WD}; rm -rf ${JUJUBE_TEMPDIR}" EXIT QUIT ABRT KILL TERM INT
|
||||
trap "rm -rf ${JUNEST_HOME}; rm -rf ${ORIGIN_WD}; rm -rf ${JUNEST_TEMPDIR}" EXIT QUIT ABRT KILL TERM INT
|
||||
}
|
||||
|
||||
|
||||
function tearDown(){
|
||||
# the CA directories are read only and can be deleted only by changing the mod
|
||||
[ -d ${JUJUBE_HOME}/etc/ca-certificates ] && chmod -R +w ${JUJUBE_HOME}/etc/ca-certificates
|
||||
rm -rf $JUJUBE_HOME
|
||||
[ -d ${JUNEST_HOME}/etc/ca-certificates ] && chmod -R +w ${JUNEST_HOME}/etc/ca-certificates
|
||||
rm -rf $JUNEST_HOME
|
||||
rm -rf $ORIGIN_WD
|
||||
rm -rf $JUJUBE_TEMPDIR
|
||||
rm -rf $JUNEST_TEMPDIR
|
||||
trap - QUIT EXIT ABRT KILL TERM INT
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ function tearDown(){
|
|||
function test_is_env_installed(){
|
||||
is_env_installed
|
||||
assertEquals $? 1
|
||||
touch $JUJUBE_HOME/just_file
|
||||
touch $JUNEST_HOME/just_file
|
||||
is_env_installed
|
||||
assertEquals $? 0
|
||||
}
|
||||
|
|
@ -66,17 +66,17 @@ function test_download(){
|
|||
function test_setup_env(){
|
||||
wget_mock(){
|
||||
# Proof that the setup is happening
|
||||
# inside $JUJUBE_TEMPDIR
|
||||
local cwd=${PWD#${JUJUBE_TEMPDIR}}
|
||||
# inside $JUNEST_TEMPDIR
|
||||
local cwd=${PWD#${JUNEST_TEMPDIR}}
|
||||
local parent_dir=${PWD%${cwd}}
|
||||
assertEquals "$JUJUBE_TEMPDIR" "${parent_dir}"
|
||||
assertEquals "$JUNEST_TEMPDIR" "${parent_dir}"
|
||||
touch file
|
||||
tar -czvf ${CMD}-${ARCH}.tar.gz file
|
||||
}
|
||||
WGET=wget_mock
|
||||
setup_env &> /dev/null
|
||||
assertTrue "[ -e $JUJUBE_HOME/file ]"
|
||||
assertTrue "[ -e $JUJUBE_HOME/run/lock ]"
|
||||
setup_env 1> /dev/null
|
||||
assertTrue "[ -e $JUNEST_HOME/file ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/run/lock ]"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -84,8 +84,8 @@ function test_setup_env_from_file(){
|
|||
touch file
|
||||
tar -czvf ${CMD}-${ARCH}.tar.gz file 1> /dev/null
|
||||
setup_env_from_file ${CMD}-${ARCH}.tar.gz &> /dev/null
|
||||
assertTrue "[ -e $JUJUBE_HOME/file ]"
|
||||
assertTrue "[ -e $JUJUBE_HOME/run/lock ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/file ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/run/lock ]"
|
||||
|
||||
$(setup_env_from_file noexist.tar.gz 2> /dev/null)
|
||||
assertEquals $? 1
|
||||
|
|
@ -95,8 +95,8 @@ function test_setup_env_from_file_with_absolute_path(){
|
|||
touch file
|
||||
tar -czvf ${CMD}-${ARCH}.tar.gz file 1> /dev/null
|
||||
setup_env_from_file ${ORIGIN_WD}/${CMD}-${ARCH}.tar.gz &> /dev/null
|
||||
assertTrue "[ -e $JUJUBE_HOME/file ]"
|
||||
assertTrue "[ -e $JUJUBE_HOME/run/lock ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/file ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/run/lock ]"
|
||||
}
|
||||
|
||||
function test_run_env_as_root(){
|
||||
|
|
@ -150,20 +150,20 @@ function test_run_env_as_user(){
|
|||
install_mini_env
|
||||
local output=$(run_env_as_user "-k 3.10" "/usr/bin/mkdir" "-v" "/newdir2" | awk -F: '{print $1}')
|
||||
assertEquals "$output" "/usr/bin/mkdir"
|
||||
assertTrue "[ -e $JUJUBE_HOME/newdir2 ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/newdir2 ]"
|
||||
|
||||
SH=("/usr/bin/mkdir" "-v" "/newdir")
|
||||
local output=$(run_env_as_user "-k 3.10" | awk -F: '{print $1}')
|
||||
assertEquals "$output" "/usr/bin/mkdir"
|
||||
assertTrue "[ -e $JUJUBE_HOME/newdir ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/newdir ]"
|
||||
}
|
||||
|
||||
function test_run_env_as_proot_mtab(){
|
||||
install_mini_env
|
||||
$(run_env_as_fakeroot "-k 3.10" "echo")
|
||||
assertTrue "[ -e $JUJUBE_HOME/etc/mtab ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/etc/mtab ]"
|
||||
$(run_env_as_user "-k 3.10" "echo")
|
||||
assertTrue "[ ! -e $JUJUBE_HOME/etc/mtab ]"
|
||||
assertTrue "[ ! -e $JUNEST_HOME/etc/mtab ]"
|
||||
}
|
||||
|
||||
function test_run_env_as_root_mtab(){
|
||||
|
|
@ -174,14 +174,14 @@ function test_run_env_as_root_mtab(){
|
|||
CLASSIC_CHROOT="sudo $CLASSIC_CHROOT"
|
||||
CHOWN="sudo $CHOWN"
|
||||
$(run_env_as_root "echo")
|
||||
assertTrue "[ ! -e $JUJUBE_HOME/etc/mtab ]"
|
||||
assertTrue "[ ! -e $JUNEST_HOME/etc/mtab ]"
|
||||
}
|
||||
|
||||
function test_run_env_with_quotes(){
|
||||
install_mini_env
|
||||
local output=$(run_env_as_user "-k 3.10" "bash" "-c" "/usr/bin/mkdir -v /newdir2" | awk -F: '{print $1}')
|
||||
assertEquals "$output" "/usr/bin/mkdir"
|
||||
assertTrue "[ -e $JUJUBE_HOME/newdir2 ]"
|
||||
assertTrue "[ -e $JUNEST_HOME/newdir2 ]"
|
||||
}
|
||||
|
||||
function test_run_env_as_user_proot_args(){
|
||||
|
|
@ -189,9 +189,9 @@ function test_run_env_as_user_proot_args(){
|
|||
run_env_as_user "--help" "" &> /dev/null
|
||||
assertEquals $? 0
|
||||
|
||||
mkdir $JUJUBE_TEMPDIR/newdir
|
||||
touch $JUJUBE_TEMPDIR/newdir/newfile
|
||||
run_env_as_user "-b $JUJUBE_TEMPDIR/newdir:/newdir -k 3.10" "ls" "-l" "/newdir/newfile" &> /dev/null
|
||||
mkdir $JUNEST_TEMPDIR/newdir
|
||||
touch $JUNEST_TEMPDIR/newdir/newfile
|
||||
run_env_as_user "-b $JUNEST_TEMPDIR/newdir:/newdir -k 3.10" "ls" "-l" "/newdir/newfile" &> /dev/null
|
||||
assertEquals $? 0
|
||||
|
||||
$(_run_env_with_proot --helps 2> /dev/null)
|
||||
|
|
@ -248,7 +248,7 @@ function test_delete_env(){
|
|||
|
||||
function test_nested_env(){
|
||||
install_mini_env
|
||||
JUJUBE_ENV=1 bash -ic "source $CURRPWD/$(dirname $0)/../lib/core.sh" &> /dev/null
|
||||
JUNEST_ENV=1 bash -ic "source $CURRPWD/$(dirname $0)/../lib/core.sh" &> /dev/null
|
||||
assertEquals $? 1
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue