mirror of
https://github.com/fsquillace/junest.git
synced 2026-07-25 20:03:58 +00:00
Add support for ARM
This commit is contained in:
parent
251a4a2c7f
commit
ebe7a34507
2 changed files with 50 additions and 24 deletions
28
bin/juju
28
bin/juju
|
|
@ -28,22 +28,24 @@ source "$(dirname $0)/../lib/core.sh"
|
|||
###################################
|
||||
|
||||
usage() {
|
||||
echo -e "JuJu: The portable GNU/Linux distribution"
|
||||
echo -e "Usage: $NAME [options]"
|
||||
echo -e "Options:"
|
||||
echo -e "-i, --setup-from-file <image> Setup the JuJu image in ${JUJU_HOME}"
|
||||
echo -e "-f, --fakeroot Run JuJu with fakeroot privileges"
|
||||
echo -e "-r, --root Run JuJu with root privileges"
|
||||
echo -e "-b, --build-image Build a JuJu image (must run in ArchLinux only)"
|
||||
echo -e "-d, --delete Delete JuJu from ${JUJU_HOME}"
|
||||
echo -e "-h, --help Show this help message"
|
||||
echo -e "-v, --version Show the $NAME version"
|
||||
echo -e "JuJu: The portable GNU/Linux distribution"
|
||||
echo -e "Usage: $NAME [options]"
|
||||
echo -e "Options:"
|
||||
echo -e "-i, --setup-from-file <image> Setup the JuJu image in ${JUJU_HOME}"
|
||||
echo -e "-f, --fakeroot Run JuJu with fakeroot privileges"
|
||||
echo -e "-r, --root Run JuJu with root privileges"
|
||||
echo -e "-b, --build-image Build a JuJu image (must run in ArchLinux
|
||||
with base-devel, package-query
|
||||
and arch-install-scripts installed)"
|
||||
echo -e "-d, --delete Delete JuJu from ${JUJU_HOME}"
|
||||
echo -e "-h, --help Show this help message"
|
||||
echo -e "-v, --version Show the $NAME version"
|
||||
}
|
||||
|
||||
version() {
|
||||
echo -e "JuJu ($VERSION): The portable GNU/Linux distribution"
|
||||
echo -e "Copyright (c) 2012-2014 Filippo Squillace <feel.squally@gmail.com>"
|
||||
echo -e "Homepage: http://github.com/fsquillace/juju"
|
||||
echo -e "JuJu ($VERSION): The portable GNU/Linux distribution"
|
||||
echo -e "Copyright (c) 2012-2014 Filippo Squillace <feel.squally@gmail.com>"
|
||||
echo -e "Homepage: http://github.com/fsquillace/juju"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
46
lib/core.sh
46
lib/core.sh
|
|
@ -28,7 +28,14 @@ set -e
|
|||
source "$(dirname ${BASH_ARGV[0]})/util.sh"
|
||||
|
||||
################################# VARIABLES ##############################
|
||||
[ -z ${JUJU_HOME} ] && JUJU_HOME=~/.juju
|
||||
if [ -z ${JUJU_HOME} ] || [ ! -d ${JUJU_HOME} ]
|
||||
then
|
||||
JUJU_HOME=~/.juju
|
||||
fi
|
||||
if [ -z ${JUJU_TEMPDIR} ] || [ ! -d ${JUJU_TEMPDIR} ]
|
||||
then
|
||||
JUJU_TEMPDIR=/tmp
|
||||
fi
|
||||
JUJU_REPO=https://bitbucket.org/fsquillace/juju-repo/raw/master
|
||||
ORIGIN_WD=$(pwd)
|
||||
|
||||
|
|
@ -45,6 +52,9 @@ else
|
|||
fi
|
||||
TAR=tar
|
||||
|
||||
ARCH=$(uname -m | grep -oE "^armv[567]")
|
||||
[ "$ARCH" == "" ] && ARCH=$(uname -m)
|
||||
|
||||
PROOT="${JUJU_HOME}/lib64/ld-linux-x86-64.so.2 --library-path ${JUJU_HOME}/usr/lib:${JUJU_HOME}/lib ${JUJU_HOME}/usr/bin/proot"
|
||||
################################# MAIN FUNCTIONS ##############################
|
||||
|
||||
|
|
@ -75,12 +85,12 @@ function _setup_juju(){
|
|||
|
||||
function setup_juju(){
|
||||
# Setup the JuJu environment
|
||||
local maindir=$(TMPDIR=/tmp mktemp -d -t juju.XXXXXXXXXX)
|
||||
local maindir=$(TMPDIR=$JUJU_TEMPDIR mktemp -d -t juju.XXXXXXXXXX)
|
||||
prepare_build_directory
|
||||
|
||||
info "Downloading JuJu..."
|
||||
builtin cd ${maindir}
|
||||
local imagefile=juju-$(uname -m).tar.gz
|
||||
local imagefile=juju-${ARCH}.tar.gz
|
||||
$WGET ${JUJU_REPO}/${imagefile}
|
||||
|
||||
info "Installing JuJu..."
|
||||
|
|
@ -154,17 +164,34 @@ function delete_juju(){
|
|||
|
||||
}
|
||||
|
||||
function _check_package(){
|
||||
if ! pacman -Qq $1 > /dev/null
|
||||
then
|
||||
error "Package $1 must be installed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function build_image_juju(){
|
||||
# The function must runs on ArchLinux
|
||||
# The dependencies are:
|
||||
# arch-install-scripts
|
||||
# base-devel
|
||||
# package-query
|
||||
local maindir=$(TMPDIR=/tmp mktemp -d -t juju.XXXXXXXXXX)
|
||||
_check_package arch-install-scripts
|
||||
_check_package gcc
|
||||
_check_package package-query
|
||||
local maindir=$(TMPDIR=$JUJU_TEMPDIR mktemp -d -t juju.XXXXXXXXXX)
|
||||
mkdir -p ${maindir}/root
|
||||
prepare_build_directory
|
||||
info "Installing pacman and its dependencies..."
|
||||
pacstrap -d ${maindir}/root pacman arch-install-scripts binutils
|
||||
pacstrap -d ${maindir}/root pacman arch-install-scripts binutils libunistring
|
||||
|
||||
info "Generating the locales..."
|
||||
ln -sf /usr/share/zoneinfo/posix/UTC ${maindir}/root/etc/localtime
|
||||
echo "en_US.UTF-8 UTF-8" >> ${maindir}/root/etc/locale.gen
|
||||
arch-chroot ${maindir}/root locale-gen
|
||||
echo 'LANG = "en_US.UTF-8"' >> ${maindir}/root/etc/locale.conf
|
||||
|
||||
info "Compiling and installing yaourt..."
|
||||
mkdir -p ${maindir}/packages/{package-query,yaourt,proot}
|
||||
|
|
@ -182,18 +209,15 @@ function build_image_juju(){
|
|||
info "Compiling and installing proot..."
|
||||
builtin cd ${maindir}/packages/proot
|
||||
$WGET https://aur.archlinux.org/packages/pr/proot/PKGBUILD
|
||||
sed "s/arch=\(.*\)/arch=('any')/" PKGBUILD > PKGBUILD.1
|
||||
mv PKGBUILD.1 PKGBUILD
|
||||
makepkg -sfc --asroot
|
||||
pacman --noconfirm --root ${maindir}/root -U proot*.pkg.tar.xz
|
||||
|
||||
ln -sf /usr/share/zoneinfo/posix/UTC ${maindir}/root/etc/localtime
|
||||
echo "en_US.UTF-8 UTF-8" >> ${maindir}/root/etc/locale.gen
|
||||
arch-chroot ${maindir}/root locale-gen
|
||||
echo 'LANG = "en_US.UTF-8"' >> ${maindir}/root/etc/locale.conf
|
||||
|
||||
rm ${maindir}/root/var/cache/pacman/pkg/*
|
||||
|
||||
builtin cd ${ORIGIN_WD}
|
||||
local imagefile="juju-$(uname -m).tar.gz"
|
||||
local imagefile="juju-${ARCH}.tar.gz"
|
||||
info "Compressing image to ${imagefile}..."
|
||||
tar -zcpf ${imagefile} -C ${maindir}/root .
|
||||
cleanup_build_directory ${maindir}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue