This repository has been archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chroot seems to work for simple enough builds
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM debian:9 | ||
RUN echo "ASD" > /asd | ||
RUN cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
[ -z "$1" ] && echo "Must at least provide context of build" && exit 1 | ||
|
||
CHROOT=${CHROOT_LOCATION:-$HOME/.makisu-chroot-$RANDOM} | ||
SSL_CERT_DIR=${SSL_CERTS:-/etc/ssl/certs} | ||
CONTEXT=${@: -1} | ||
BUILD_VOLUMES="$CONTEXT:/context,$BUILD_VOLUMES" | ||
|
||
function makisu::prepare_internals () { | ||
mkdir -p $CHROOT/makisu-internal/certs | ||
cp $(which makisu) $CHROOT/makisu-internal/makisu | ||
cat $SSL_CERT_DIR/* > $CHROOT/makisu-internal/certs/cacerts.pem | ||
} | ||
|
||
function makisu::prepare_dev () { | ||
mkdir -p $CHROOT/dev | ||
mknod -m 622 $CHROOT/dev/console c 5 1 | ||
mknod -m 666 $CHROOT/dev/null c 1 3 | ||
mknod -m 666 $CHROOT/dev/zero c 1 5 | ||
mknod -m 666 $CHROOT/dev/ptmx c 5 2 | ||
mknod -m 666 $CHROOT/dev/tty c 5 0 | ||
mknod -m 444 $CHROOT/dev/random c 1 8 | ||
mknod -m 444 $CHROOT/dev/urandom c 1 9 | ||
chown root:tty $CHROOT/dev/{console,ptmx,tty} | ||
} | ||
|
||
function makisu::prepare_etc () { | ||
mkdir -p $CHROOT/etc | ||
cp /etc/*.conf $CHROOT/etc/ | ||
} | ||
|
||
function makisu::prepare_volumes () { | ||
for vol in $(sed "s/,/ /g" <<< $BUILD_VOLUMES); do | ||
from=$(cut -d ':' -f 1 <<< $vol) | ||
to=$(cut -d ':' -f 2 <<< $vol) | ||
echo "Copying volume $from to chroot directory $CHROOT/$to" | ||
mkdir -p $CHROOT/$to | ||
cp -r $from/* $CHROOT/$to | ||
done | ||
} | ||
|
||
echo "Preparing chroot at $CHROOT" | ||
rm -rf $CHROOT | ||
|
||
makisu::prepare_internals | ||
makisu::prepare_etc | ||
makisu::prepare_dev | ||
makisu::prepare_volumes | ||
|
||
makisu_args=${@:1:$#-1} | ||
echo "Starting Makisu: makisu $makisu_args /context" | ||
chroot $CHROOT/ /makisu-internal/makisu $makisu_args /context |