forked from RPi-Distro/pi-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Docker support (RPi-Distro#40)
* Added Docker support - replaced necessity for devicemapper (through kpartx) by using parted and losetup with offsets - added Dockerfile - added dependency for parted and grep - added hints to README.md - common: loop through unmounts, fix shellcheck warnings * stage2: use debconf instead of console-setup patch. Fixes RPi-Distro#41
- Loading branch information
Showing
11 changed files
with
182 additions
and
57 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 @@ | ||
output/ | ||
work/ | ||
deploy/ |
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,12 @@ | ||
FROM debian:jessie | ||
|
||
RUN apt-get -y update && \ | ||
apt-get -y install \ | ||
git vim parted \ | ||
quilt realpath qemu-user-static debootstrap zerofree pxz zip dosfstools \ | ||
bsdtar libcap2-bin rsync grep \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . /pi-gen/ | ||
|
||
VOLUME [ "/pi-gen/work", "/pi-gen/deploy"] |
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
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,73 @@ | ||
#!/bin/bash -e | ||
DOCKER="docker" | ||
set +e | ||
$DOCKER ps >/dev/null 2>&1 | ||
if [ $? != 0 ]; then | ||
DOCKER="sudo docker" | ||
fi | ||
if ! $DOCKER ps >/dev/null; then | ||
echo "error connecting to docker:" | ||
$DOCKER ps | ||
exit 1 | ||
fi | ||
set -e | ||
|
||
config_mount= | ||
if [ -f config ]; then | ||
config_mount="-v $(pwd)/config:/pi-gen/config:ro" | ||
source config | ||
fi | ||
|
||
CONTAINER_NAME=${CONTAINER_NAME:-pigen_work} | ||
CONTINUE=${CONTINUE:-0} | ||
|
||
if [ "$*" != "" ] || [ -z "${IMG_NAME}" ]; then | ||
if [ -z "${IMG_NAME}" ]; then | ||
echo "IMG_NAME not set in 'build'" 1>&2 | ||
echo 1>&2 | ||
fi | ||
cat >&2 <<EOF | ||
Usage: | ||
build-docker.sh [options] | ||
Optional environment arguments: ( =<default> ) | ||
CONTAINER_NAME=pigen_work set a name for the build container | ||
CONTINUE=0 continue from a previously started container | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
CONTAINER_EXISTS=$($DOCKER ps -a --filter name="$CONTAINER_NAME" -q) | ||
CONTAINER_RUNNING=$($DOCKER ps --filter name="$CONTAINER_NAME" -q) | ||
if [ "$CONTAINER_RUNNING" != "" ]; then | ||
echo "The build is already running in container $CONTAINER_NAME. Aborting." | ||
exit 1 | ||
fi | ||
if [ "$CONTAINER_EXISTS" != "" ] && [ "$CONTINUE" != "1" ]; then | ||
echo "Container $CONTAINER_NAME already exists and you did not specify CONTINUE=1. Aborting." | ||
echo "You can delete the existing container like this:" | ||
echo " docker rm $CONTAINER_NAME" | ||
exit 1 | ||
fi | ||
|
||
$DOCKER build -t pi-gen . | ||
if [ "$CONTAINER_EXISTS" != "" ]; then | ||
trap "echo 'got CTRL+C... please wait 5s';docker stop -t 5 ${CONTAINER_NAME}_cont" SIGINT SIGTERM | ||
time $DOCKER run --rm --privileged \ | ||
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ | ||
pi-gen \ | ||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && | ||
cd /pi-gen; ./build.sh; | ||
rsync -av work/*/build.log deploy/" & | ||
wait | ||
else | ||
trap "echo 'got CTRL+C... please wait 5s'; docker stop -t 5 ${CONTAINER_NAME}" SIGINT SIGTERM | ||
$DOCKER run --name "${CONTAINER_NAME}" --privileged \ | ||
-v $(pwd)/deploy:/pi-gen/deploy \ | ||
${config_mount} \ | ||
pi-gen \ | ||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && | ||
cd /pi-gen; ./build.sh && | ||
rsync -av work/*/build.log deploy/" & | ||
wait | ||
fi | ||
echo "Done! Your image(s) should be in deploy/" |
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
quilt | ||
parted | ||
realpath | ||
qemu-arm-static:qemu-user-static | ||
debootstrap | ||
kpartx zerofree | ||
zerofree | ||
pxz zip | ||
mkdosfs:dosfstools | ||
capsh:libcap2-bin | ||
bsdtar | ||
grep | ||
rsync |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
01-useradd.diff | ||
02-swap.diff | ||
03-console-setup.diff | ||
04-inputrc.diff | ||
05-path.diff | ||
06-rc_local.diff | ||
|