Browse Source

added support for crims0n/minios-live-container (hub.docker.com)

master
crims0n 5 years ago
parent
commit
f96045bedb
  1. 5
      autoinstall
  2. 72
      docker/Dockerfile.py
  3. 5
      install
  4. 7
      linux-live/build
  5. 2
      linux-live/config
  6. 6
      linux-live/install_chroot
  7. 126
      linux-live/minioslib
  8. 2
      linux-live/pkglists/main.list

5
autoinstall

@ -8,6 +8,11 @@ SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
ISO_DIR="$(dirname "$SCRIPT_DIR")"/iso
set +u
if [ -z $OUTPUT ]; then
. $SCRIPT_DIR/linux-live/buildconfig || exit 1
fi
set -u
. $SCRIPT_DIR/linux-live/minioslib || exit 1
. $SCRIPT_DIR/linux-live/config || exit 1

72
docker/Dockerfile.py

@ -1,3 +1,4 @@
#!/usr/bin/python3
# Dockerfile.py
import sys
@ -12,29 +13,64 @@ class DockerFile(pydocker.DockerFile):
""" add here your custom features """
d = DockerFile(base_img='debian:8.2', name='jen-soft/custom-debian:8.2')
d = DockerFile(base_img='ubuntu:focal', name='crims0n/minios-live:latest')
d.RUN_bash_script('/opt/set_repo.sh', r'''
cp /etc/apt/sources.list /etc/apt/sources.list.copy
cat >/etc/apt/sources.list <<EOL
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main
deb http://ftp.nl.debian.org/debian/ jessie main
deb-src http://ftp.nl.debian.org/debian/ jessie main
deb http://ftp.nl.debian.org/debian/ testing main
EOL
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC
apt-get clean && apt-get update
d.RUN_bash_script('/opt/install.sh', r'''
apt-get update -y
apt-get install -y wget patch sudo debootstrap xorriso
mkdir -p /opt/minios-live
wget -qO- wget -qO- http://crims0n.ru:33011/minios-live-current.tar.gz | tar xz -C /opt/minios-live
cd /opt/
wget -c http://ru.archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.123ubuntu2_all.deb
dpkg -i /opt/debootstrap_1.0.123ubuntu2_all.deb
rm -f /opt/debootstrap_1.0.123ubuntu2_all.deb
cat <<'EOF' >/usr/share/debootstrap/functions.diff
--- functions 2020-10-23 20:42:16.000000000 +0300
+++ functions.new 2021-01-16 23:22:25.612064306 +0300
@@ -1176,7 +1176,9 @@
umount_on_exit /dev/shm
umount_on_exit /proc
umount_on_exit /proc/bus/usb
- umount "$TARGET/proc" 2>/dev/null || true
+ if [ ! -h "$TARGET/proc" ]; then
+ umount "$TARGET/proc" 2>/dev/null || true
+ fi
# some container environment are used at second-stage, it already treats /proc and so on
if [ -z "$(ls -A "$TARGET/proc")" ]; then
EOF
cd /usr/share/debootstrap/
patch </usr/share/debootstrap/functions.diff
apt-get clean
find /var/log/ -type f | xargs rm -f
rm -f /var/backups/*
rm -f /var/cache/ldconfig/*
rm -f /var/cache/debconf/*
rm -f /var/cache/fontconfig/*
rm -f /var/cache/apt/archives/*.deb
rm -f /var/cache/apt/*.bin
rm -f /var/cache/debconf/*-old
rm -f /var/lib/apt/extended_states
rm -f /var/lib/apt/lists/*Packages
rm -f /var/lib/apt/lists/*Translation*
rm -f /var/lib/apt/lists/*InRelease
rm -f /var/lib/apt/lists/deb.*
rm -f /var/lib/dpkg/*-old
''')
d.EXPOSE = 80
d.WORKDIR = '/opt'
d.ENV = 'LOGPATH="/var/log"'
d.ENV = 'BUILD_TEST_ISO="0"'
d.ENV = 'DEV_SYSTEM="0"'
d.ENV = 'CREATE_BACKUP="0"'
d.ENV = 'DEBIAN_FRONTEND_TYPE="noninteractive"'
d.ENV = 'APT_CMD="apt-get"'
d.ENV = 'APT_OPTIONS="-y"'
d.VOLUME = '/build'
d.WORKDIR = '/build'
# d.ENTRYPOINT = ["/opt/www-data/entrypoint.sh"]
d.CMD = ["python", "--version"]
d.CMD = ["/opt/minios-live/autoinstall", "-"]
d.build_img()

5
install

@ -8,6 +8,11 @@ SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
ISO_DIR="$(dirname "$SCRIPT_DIR")"/iso
set +u
if [ -z $OUTPUT ]; then
. $SCRIPT_DIR/linux-live/buildconfig || exit 1
fi
set -u
. $SCRIPT_DIR/linux-live/minioslib || exit 1
. $SCRIPT_DIR/linux-live/config || exit 1

7
linux-live/build

@ -3,9 +3,6 @@
#check_is_in_chroot
#. ./cleanup
. ./copy
export PATH=.:./tools:../tools:/usr/sbin:/usr/bin:/sbin:/bin:/
CHANGEDIR=$(dirname $(readlink -f $0))
@ -13,8 +10,12 @@ echo "Changing current directory to $CHANGEDIR"
CWD="$(pwd)"
cd $CHANGEDIR
#. ./cleanup
. ./copy
. ./config || exit 1
. ./livekitlib || exit 1
. ./buildconfig || exit 1
if [ -L /boot/vmlinuz ] 2>/dev/null; then
VMLINUZ="/boot/vmlinuz"

2
linux-live/config

@ -30,7 +30,7 @@ DISTRIBUTION_ARCH="amd64"
DISTRIBUTION_VARIANT="minbase"
#
DISTRIBUTION_URL="http://ru.archive.ubuntu.com/ubuntu"
DISTRIBUTION_URL="http://archive.ubuntu.com/ubuntu"
#
COMP_TYPE="xz"

6
linux-live/install_chroot

@ -6,8 +6,12 @@ set -u # treat unset variable as error
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
set +u
if [ -z $OUTPUT ]; then
. $SCRIPT_DIR/buildconfig || exit 1
fi
set -u
. $SCRIPT_DIR/minioslib || exit 1
#. $SCRIPT_DIR/installlib || exit 1
. $SCRIPT_DIR/config || exit 1
CMD=(chroot_setup_host chroot_pkg_install chroot_configure chroot_finish_up)

126
linux-live/minioslib

@ -11,11 +11,8 @@
# =================================================================
function common_variables() {
# default is output to log. you can use OUTPUT="/dev/stdout" if you want to route events to standard output.
#OUTPUT="/var/log/$LIVEKITNAME.log"
OUTPUT="/dev/stdout"
#
CONTAINER_TYPE="0"
set +u
if [ -z $container ]; then
container=""
@ -25,25 +22,12 @@ function common_variables() {
OUTPUT="/dev/stdout"
#CONTAINER="docker"
fi
# if = "1", creates a second iso with a constant filename
# если ="1", создаёт второй iso с постоянным именем файла
BUILD_TEST_ISO="1"
# if = "1", creates a copy of minios-live in chroot /opt
# если ="1", создаёт копию minios-live в chroot /opt
DEV_SYSTEM="0"
# if ="1", creates backup in parent folder
# если ="1", создаёт резервную копию в родительской папке
CREATE_BACKUP="0"
DEBIAN_FRONTEND_TYPE="noninteractive"
#DEBIAN_FRONTEND_TYPE="ncurses"
APT_CMD="apt-get"
APT_OPTIONS="-y" #--no-install-recommends"
if [ -f /.dockerenv ] || [ "$container" = "podman" ] && [ ! -d /opt/minios-live ] && [ ! -f /.minios-live-container ]; then
CONTAINER_TYPE="1"
fi
if [[ (-f /.dockerenv || "$container" = "podman") && (-d /opt/minios-live || -f /.minios-live-container) ]]; then
CONTAINER_TYPE="2"
fi
}
# =================================================================
@ -385,16 +369,20 @@ function chroot_mount_fs() {
check_mounted
: 'if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
ln -s /dev $BUILD_DIR/dev
ln -s /run $BUILD_DIR/run
ln -s /proc $BUILD_DIR/proc
ln -s /sys $BUILD_DIR/sys
ln -s /tmp $BUILD_DIR/tmp
else'
mount --bind /dev $BUILD_DIR/dev
mount --bind /run $BUILD_DIR/run
mount none -t proc $BUILD_DIR/proc
mount none -t sysfs $BUILD_DIR/sys
mount none -t devpts $BUILD_DIR/dev/pts
mount none -t tmpfs $BUILD_DIR/tmp
#chroot $BUILD_DIR mount none -t proc /proc
#chroot $BUILD_DIR mount none -t sysfs /sys
#chroot $BUILD_DIR mount none -t devpts /dev/pts
#chroot $BUILD_DIR mount none -t tmpfs /tmp
#fi
}
# =================================================================
@ -404,11 +392,17 @@ function chroot_mount_fs() {
function chroot_umount_fs() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
: 'if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
set +e
rm -f $BUILD_DIR/dev >>$OUTPUT 2>&1
rm -f $BUILD_DIR/run >>$OUTPUT 2>&1
rm -f $BUILD_DIR/proc >>$OUTPUT 2>&1
rm -f $BUILD_DIR/sys >>$OUTPUT 2>&1
rm -f $BUILD_DIR/tmp >>$OUTPUT 2>&1
set -e
else'
set +e
#chroot $BUILD_DIR umount /proc
#chroot $BUILD_DIR umount /sys
#chroot $BUILD_DIR umount /dev/pts
#chroot $BUILD_DIR umount /tmp
umount $BUILD_DIR/proc >>$OUTPUT 2>&1
umount $BUILD_DIR/sys >>$OUTPUT 2>&1
umount $BUILD_DIR/dev/pts >>$OUTPUT 2>&1
@ -416,13 +410,15 @@ function chroot_umount_fs() {
umount $BUILD_DIR/dev >>$OUTPUT 2>&1
umount $BUILD_DIR/run >>$OUTPUT 2>&1
set -e
#fi
check_mounted
}
function remove_log_file() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
if [ -f /$LIVEKITNAME.log ]; then
rm -f /$LIVEKITNAME.log
if [ -f $LOGPATH/$LIVEKITNAME.log ]; then
rm -f $LOGPATH/$LIVEKITNAME.log
fi
if [ -f $BUILD_DIR/$LIVEKITNAME.log ]; then
rm -f $BUILD_DIR/$LIVEKITNAME.log
@ -485,7 +481,7 @@ function create_apt_list() {
function build_bootstrap() {
current_process
if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
if [ $CONTAINER_TYPE = "1" ]; then
if [ ! -f /.minios-live ]; then
setup_host
fi
@ -530,10 +526,24 @@ function copy_build_scripts() {
fi
}
function preserve_environment_variables() {
if [ -d /opt/minios-live ]; then
chroot $BUILD_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
LOGPATH=$LOGPATH \
BUILD_TEST_ISO=$BUILD_TEST_ISO \
CREATE_BACKUP=$CREATE_BACKUP \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS
fi
}
function build_chroot() {
current_process
if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
if [ $CONTAINER_TYPE = "1" ]; then
if [ ! -f /.minios-live ]; then
setup_host
fi
@ -545,10 +555,10 @@ function build_chroot() {
create_apt_list
if [ "$OUTPUT"="/$LIVEKITNAME.log" ] && [ -f /$LIVEKITNAME.log ]; then
if [ "$OUTPUT"="$LOGPATH/$LIVEKITNAME.log" ] && [ -f /$LIVEKITNAME.log ]; then
mv -f /$LIVEKITNAME.log $BUILD_DIR/$LIVEKITNAME.log
fi
if [ "$OUTPUT"="/$LIVEKITNAME.log" ] && [ -f $BUILD_DIR/$LIVEKITNAME.log ]; then
if [ "$OUTPUT"="$LOGPATH/$LIVEKITNAME.log" ] && [ -f $BUILD_DIR/$LIVEKITNAME.log ]; then
echo "===========================================" >>$BUILD_DIR/$LIVEKITNAME.log 2>&1
echo "===========================================" >>$BUILD_DIR/$LIVEKITNAME.log 2>&1
echo "=============== CHROOT LOG ================" >>$BUILD_DIR/$LIVEKITNAME.log 2>&1
@ -557,11 +567,23 @@ function build_chroot() {
fi
cp -f $SCRIPT_DIR/linux-live/aptsources/$DISTRIBUTION.list $BUILD_DIR/etc/apt/sources.list
chroot $BUILD_DIR /linux-live/install_chroot -
if [ -d /opt/minios-live ] || [ -f /.minios-live-container ]; then
chroot $BUILD_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
LOGPATH=$LOGPATH \
BUILD_TEST_ISO=$BUILD_TEST_ISO \
CREATE_BACKUP=$CREATE_BACKUP \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS /linux-live/install_chroot -
else
chroot $BUILD_DIR /linux-live/install_chroot -
fi
chroot_umount_fs
if [ "$OUTPUT"="/$LIVEKITNAME.log" ] && [ -f $BUILD_DIR/$LIVEKITNAME.log ]; then
if [ "$OUTPUT"="$LOGPATH/$LIVEKITNAME.log" ] && [ -f $BUILD_DIR/$LIVEKITNAME.log ]; then
mv -f $BUILD_DIR/$LIVEKITNAME.log $SCRIPT_DIR/$LIVEKITNAME.log
if [ -f $SCRIPT_DIR/$LIVEKITNAME.log ]; then
echo -e "Installation log was saved to ${MAGENTA}$SCRIPT_DIR/$LIVEKITNAME.log${ENDCOLOUR}"
@ -572,7 +594,7 @@ function build_chroot() {
function build_live() {
current_process
if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
if [ $CONTAINER_TYPE = "1" ]; then
if [ ! -f /.minios-live ]; then
setup_host
fi
@ -585,10 +607,22 @@ function build_live() {
check_build_dir
chroot $BUILD_DIR mount none -t proc /proc
chroot $BUILD_DIR /bin/bash -x <<'EOF'
: 'chroot $BUILD_DIR /bin/bash -x <<EOF
cd /linux-live
./build
EOF
EOF'
if [ -d /opt/minios-live ] || [ -f /.minios-live-container ]; then
chroot $BUILD_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
LOGPATH=$LOGPATH \
BUILD_TEST_ISO=$BUILD_TEST_ISO \
CREATE_BACKUP=$CREATE_BACKUP \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS /linux-live/build
else
chroot $BUILD_DIR /linux-live/build
fi
chroot $BUILD_DIR umount /proc
}
@ -596,7 +630,7 @@ EOF
function build_iso() {
current_process
if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
if [ $CONTAINER_TYPE = "1" ]; then
if [ ! -f /.minios-live ]; then
setup_host
fi
@ -680,7 +714,9 @@ function build_iso() {
function setup_host() {
current_process
hostreq_pkg_list
if [ $CONTAINER_TYPE != "2" ]; then
hostreq_pkg_list
fi
}
function chroot_setup_host() {
@ -702,7 +738,7 @@ function chroot_setup_host() {
function hostreq_pkg_list() {
echo -e "${YELLOW}=====> installing required software for host system ...${ENDCOLOUR}"
$APT_CMD update >>$OUTPUT 2>&1
if [ -f /.dockerenv ] || [ "$container" = "podman" ]; then
if [ $CONTAINER_TYPE = "1" ]; then
touch /.minios-live
$APT_CMD install -y wget patch >>$OUTPUT 2>&1
cd ~

2
linux-live/pkglists/main.list

@ -6,4 +6,4 @@ xz-utils
# имя этого ▼ пакета нужно задавать в зависимости от необходимого типа ядра
#linux-image-generic-hwe-18.04
#linux-image-generic
linux-image-oem-20.04
linux-image-generic-hwe-20.04
Loading…
Cancel
Save