Aded the image generation to the build chain. Script improvements. Added 'rebuild' script and script to test the MLL image.

This commit is contained in:
Ivan Davidov 2017-11-26 23:47:10 +02:00
parent 1a219a8e0e
commit 2113a18fbe
4 changed files with 103 additions and 12 deletions

45
src/13_generate_image.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
set -e
echo "*** GENERATE IMAGE BEGIN ***"
SRC_DIR=$(pwd)
# Prepare the work area.
rm -f mll_image.tgz
rm -rf $SRC_DIR/work/mll_image
mkdir -p $SRC_DIR/work/mll_image
# Copy the rootfs.
cp -r $SRC_DIR/work/rootfs/* \
$SRC_DIR/work/mll_image
# Copy the overlay area.
cp -r $SRC_DIR/work/src/minimal_overlay/rootfs/* \
$SRC_DIR/work/mll_image
cd $SRC_DIR/work/mll_image
# Generate the image file (ordinary 'tgz').
tar -zcf $SRC_DIR/mll_image.tgz *
cat << CEOF
################################################################
# #
# Minimal Linux Live image 'mll_image.tgz' has been generated. #
# #
# You can import the MLL image in Docker like this: #
# #
# docker import mll_image.tgz minimal-linux-live:latest #
# #
# Then you can run MLL container in Docker like this: #
# #
# docker run -it minimal-linux-live /bin/sh #
# #
################################################################
CEOF
echo "*** GENERATE IMAGE END ***"

View File

@ -28,17 +28,20 @@ cleanup() {
rm -rf $TEMP_DIR
}
buildDockerImage() {
buildImage() {
rm -f $SRC_DIR/mll_image.tgz
cd $TEMP_DIR/docker_root
cd $TEMP_DIR/image_root
tar -zcf $SRC_DIR/mll_image.tgz *
cd $SRC_DIR
}
prepareDocker() {
mkdir $TEMP_DIR/docker_root
cp -r $TEMP_DIR/rootfs_extracted/* $TEMP_DIR/docker_root
cp -r $TEMP_DIR/iso_extracted/minimal/rootfs/* $TEMP_DIR/docker_root
prepareImage() {
mkdir $TEMP_DIR/image_root
cp -r $TEMP_DIR/rootfs_extracted/* $TEMP_DIR/image_root
if [ -d $TEMP_DIR/iso_extracted/minimal/rootfs ] ; then
cp -r $TEMP_DIR/iso_extracted/minimal/rootfs/* $TEMP_DIR/image_root
fi
}
extractRootfs() {
@ -57,12 +60,12 @@ extractISO() {
}
prepareTempDir() {
if [ -d "`ls -d mll_docker_*`" ] ; then
chmod -R ugo+rw mll_docker_*
rm -rf mll_docker_*
if [ -d mll_image ] ; then
chmod -R ugo+rw mll_image
rm -rf mll_image
fi
TEMP_DIR=`mktemp -d mll_docker_XXXX`
TEMP_DIR=$SRC_DIR/mll_image
}
checkPrerequsites() {
@ -104,8 +107,8 @@ main() {
prepareTempDir
extractISO
extractRootfs
prepareDocker
buildDockerImage
prepareImage
buildImage
cleanup
finalWords
}

14
src/rebuild.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -e
# This script is useful if you have already built MLL and
# you want to perform fast repackaging of all components.
#
# Note: this will also rebuild all overlay bundles.
./08_prepare_src.sh
./09_generate_rootfs.sh
./10_pack_rootfs.sh
./12_generate_iso.sh
./13_generate_image.sh

29
src/test_image.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
set -e
clear() {
if [ ! "`docker ps -a | grep minimal`" = "" ] ; then
docker stop `docker ps -a | grep minimal | awk '{print $1}'`
docker rm `docker ps -a | grep minimal | awk '{print $1}'`
fi
if [ ! "`docker images -a | grep minimal`" = "" ] ; then
docker rmi `docker images -a | grep minimal | awk '{print $1}'`
fi
}
run() {
docker import mll_image.tgz minimal-linux-live:latest
docker run minimal-linux-live /bin/cat /etc/motd
}
clear
run
clear
cat << CEOF
Test passed - well done!
CEOF