Browse Source

Merge branch 'master' into crims0n-master-patch-59406

master
crim50n 5 years ago
committed by GitHub
parent
commit
3e5e88b6f8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      README.md
  2. 2
      install
  3. 6
      linux-live/build
  4. 5
      linux-live/config
  5. 64
      linux-live/minioslib
  6. 9
      linux-live/modules/02-xorg/build
  7. 85
      linux-live/rootcopy/usr/bin/genminiosiso

17
README.md

@ -1,19 +1,22 @@
# MiniOS Live
Этот скрипт собирает загружаемый ISO образ MiniOS.
Поддерживаемые команды : setup_host build_bootstrap build_chroot build_live build_iso
**Поддерживаемые команды:** `setup_host build_bootstrap build_chroot build_live build_iso`
**Синтаксис:** `./install [start_cmd] [-] [end_cmd]`
Синтаксис:
$./install [start_cmd] [-] [end_cmd]
$ minios-install [start_cmd] [-] [end_cmd]
>запуск от start_cmd до end_cmd
>если start_cmd опущен, выполняются все команды, начиная с первой
>если end_cmd опущен, выполняются все команды до последней
>введите одну команду, чтобы запустить определенную команду
>введите '-' как единственный аргумент для запуска всех команд
- запуск от start_cmd до end_cmd
- если start_cmd опущен, выполняются все команды, начиная с первой
- если end_cmd опущен, выполняются все команды до последней
- введите одну команду, чтобы запустить определенную команду
- введите '-' как единственный аргумент для запуска всех команд
Примеры:./install build_bootstrap - build_chroot
./install - build_chroot
./install build_bootstrap -
./install cleanup
./install build_iso
./install -

2
install

@ -7,6 +7,8 @@ set -u # treat unset variable as error
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
ISO_DIR="$(dirname "$SCRIPT_DIR")"
#ISO_DIR=$SCRIPT_DIR/iso
#ISO_DIR=/build/nfs/iso
. $SCRIPT_DIR/linux-live/minioslib || exit 1
#. $SCRIPT_DIR/linux-live/installlib || exit 1

6
linux-live/build

@ -70,6 +70,8 @@ for i in $MKMOD; do
COREFS="$COREFS /$i"
fi
done
mksquashfs $COREFS $LIVEKITDATA/$LIVEKITNAME/01-core.$BEXT -comp xz -b 1024K -always-use-fragments -keep-as-directory || exit
mksquashfs $COREFS $LIVEKITDATA/$LIVEKITNAME/01-core.$BEXT -comp $COMP_TYPE -b 1024K -always-use-fragments -keep-as-directory || exit
cd $CWD
echo $LIVEKITDATA > /tmp/livekitdata
cd $CWD

5
linux-live/config

@ -21,7 +21,7 @@ SYSTEMNAME="MiniOS"
SYSTEMVER="2021"
#
DISTRIBUTION="bionic"
DISTRIBUTION="focal"
#
DISTRIBUTION_ARCH="amd64"
@ -32,6 +32,9 @@ DISTRIBUTION_VARIANT="minbase"
#
DISTRIBUTION_URL="http://ru.archive.ubuntu.com/ubuntu"
#
COMP_TYPE="xz"
# Kernel file, will be copied to your Live Kit
# Your kernel must support aufs and squashfs. Debian Jessie's kernel is ready
# out of the box.

64
linux-live/minioslib

@ -12,28 +12,28 @@
function common_variables() {
# normal
OUTPUT="/dev/stdout"
# silent
#OUTPUT="/dev/null"
# OUTPUT="/dev/stdout"
# log
#OUTPUT="/$LIVEKITNAME.log"
# Эта переменная задаётся в файле ./install
#ISO_DIR=$SCRIPT_DIR/iso
#ISO_DIR=/build/nfs/iso
OUTPUT="/var/log/$LIVEKITNAME.log"
# if = "1", creates a second iso with a constant filename
# если ="1", создаёт второй iso с постоянным именем файла
BUILD_TEST_ISO="1"
DEV_SYSTEM="1"
# if = "1", creates a copy of minios-live in chroot /opt
# если ="1", создаёт копию minios-live в chroot /opt
DEV_SYSTEM="0"
CREATE_BACKUP="1"
# if ="1", creates backup in parent folder
# если ="1", создаёт резервную копию в родительской папке
CREATE_BACKUP="0"
DEBIAN_FRONTEND_TYPE="noninteractive"
#DEBIAN_FRONTEND_TYPE="ncurses"
APT_CMD="apt"
APT_OPTIONS="-y --no-install-recommends"
APT_OPTIONS="-y" #--no-install-recommends"
}
# =================================================================
@ -103,7 +103,7 @@ function help() {
echo -e "\tПримеры:${LIGHTYELLOW}$0 build_bootstrap - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_bootstrap -${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 cleanup${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_iso${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 -${ENDCOLOUR}"
exit 0
else
@ -129,7 +129,7 @@ function help() {
echo -e "\tExamples:${LIGHTYELLOW}$0 build_bootstrap - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_bootstrap -${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 cleanup${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_iso${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 -${ENDCOLOUR}"
exit 0
fi
@ -251,7 +251,8 @@ function check_mounted() {
function check_build_dir() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
if [ "$(ls -A $BUILD_DIR >>$OUTPUT 2>&1)" != "" ]; then
# ▼ должно быть только перенаправление ошибки!
if [ "$(ls -A $BUILD_DIR 2>>$OUTPUT)" != "" ]; then
echo -e "${MAGENTA}$BUILD_DIR${ENDCOLOUR} is not empty."
cleanup
check_mounted
@ -382,7 +383,7 @@ function create_backup() {
mkdir -p $PARENT_DIR/minios-live-current
(cd $SCRIPT_DIR && cp --parents -afr * $PARENT_DIR/minios-live-current)
else
for file in $(find $SCRIPT_DIR -type f | sed "s,$SCRIPT_DIR/,,g" | sed "s,.script_version,,g"); do
for file in $(find $SCRIPT_DIR -path $SCRIPT_DIR/.git -prune -false -o -type f | sed "s,$SCRIPT_DIR/,,g" | sed "s,.script_version,,g"); do
if ! cmp $SCRIPT_DIR/$file $PARENT_DIR/minios-live-current/$file >>$OUTPUT 2>&1; then
CHANGED="1"
echo -e "$file has been modified since last backup." >>$OUTPUT 2>&1
@ -409,21 +410,6 @@ function create_backup() {
# =================================================================
# =================================================================
function select_distribution() {
# unused
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
case $DISTRIBUTION in
bionic)
$DEBOOTSTRAP_URL=http://ru.archive.ubuntu.com/ubuntu/
$SOURCES_LIST=$SCRIPT_DIR/linux-live/sources/bionic.list
;;
focal)
$DEBOOTSTRAP_URL=http://ru.archive.ubuntu.com/ubuntu/
$SOURCES_LIST=$SCRIPT_DIR/linux-live/sources/focal.list
;;
esac
}
function create_apt_list() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
if [ ! -f $SCRIPT_DIR/linux-live/aptsources/$DISTRIBUTION.list ]; then
@ -437,7 +423,7 @@ function build_bootstrap() {
current_process
export DEBIAN_FRONTEND=noninteractive
debootstrap --arch=$DISTRIBUTION_ARCH --variant=$DISTRIBUTION_VARIANT $DISTRIBUTION $BUILD_DIR $DISTRIBUTION_URL >>$OUTPUT 2>&1
debootstrap --arch=$DISTRIBUTION_ARCH --variant=$DISTRIBUTION_VARIANT $DISTRIBUTION $BUILD_DIR $DISTRIBUTION_URL >>$OUTPUT 2>>$OUTPUT
}
function copy_build_scripts() {
@ -551,11 +537,12 @@ function build_iso() {
B="-b boot/syslinux/isolinux.bin -c boot/syslinux/boot.cat"
C="-no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot"
if [ -x "$(which xorriso >>$OUTPUT 2>&1)" ]; then
# ▼ должно быть только перенаправление ошибки!
if [ -x "$(which xorriso 2>>$OUTPUT)" ]; then
M="xorriso -as mkisofs -isohybrid-mbr $DIR/boot/syslinux/isohdpfx.bin"
D=" -isohybrid-gpt-basdat -e"
elif [ -x "$(which genisoimage >>$OUTPUT 2>&1)" ]; then
# ▼ должно быть только перенаправление ошибки!
elif [ -x "$(which genisoimage 2>>$OUTPUT)" ]; then
M=genisoimage
D="-efi-boot"
else
@ -567,8 +554,10 @@ function build_iso() {
VER="$SYSTEMNAME $VER"
if ! $M -hide-rr-moved -f -r -J -l -V "$VER" -A "$VER" \
$B $C $D $E -o $ISO $DIR; then
if
! $M -hide-rr-moved -f -r -J -l -V "$VER" -A "$VER" \
$B $C $D $E -o $ISO $DIR
then
exit 1
fi
@ -576,7 +565,8 @@ function build_iso() {
# xorriso has hybridization built-in
if [ "$(echo $M | cut -d" " -f1)" != "xorriso" ]; then
if [ -x "$(which isohybrid >>$OUTPUT 2>&1)" ]; then
# ▼ должно быть только перенаправление ошибки!
if [ -x "$(which isohybrid 2>>$OUTPUT)" ]; then
isohybrid -uefi $ISO
else
echo ">>> No isohybrid to hybridize this ISO"

9
linux-live/modules/02-xorg/build

@ -0,0 +1,9 @@
#!/bin/bash
apt-get update
apt-get install -y \
xorg
xterm \
blackbox
savechanges /02-xorg.sb

85
linux-live/rootcopy/usr/bin/genminiosiso

@ -1,79 +1,48 @@
#!/bin/bash
CWD=$(pwd)
SOURCE=/run/initramfs/memory
TEMP=/tmp
REGEX='^$'
if [ "$1" = "-e" ]; then
REGEX="$2"
shift
shift
fi
. /run/initramfs/lib/config || exit 1
TARGET="$(readlink -f "$1")"
TMP=/tmp/changes$$
EXCLUDE="^\$|/\$|[.]wh[.][.]wh[.]orph/|^[.]wh[.][.]wh[.]plnk/|^[.]wh[.][.]wh[.]aufs|^var/cache/|^var/backups/|^var/tmp/|^var/log/|^var/lib/apt/|^var/lib/dhcp/|^var/lib/systemd/|^sbin/fsck[.]aufs|^etc/resolv[.]conf|^root/[.]Xauthority|^root/[.]xsession-errors|^root/[.]fehbg|^root/[.]fluxbox/lastwallpaper|^root/[.]fluxbox/menu_resolution|^etc/mtab|^etc/fstab|^boot/|^dev/|^mnt/|^proc/|^run/|^sys/|^tmp/"
CHANGES=/run/initramfs/memory/changes
if [ "$TARGET" = "" ]; then
if [ "$1" = "" ]; then
echo ""
echo "Generate MiniOS ISO image, adding specified modules"
echo "Regular expression is used to exclude any existing path or file with -e regex"
echo "savechanges - save all changed files in a compressed filesystem bundle"
echo " - excluding some predefined files such as /etc/mtab,"
echo " temp & log files, empty directories, apt cache, and such"
echo ""
echo "Usage:"
echo " $0 [[ -e regex ]] target.iso [[module.sb]] [[module.sb]] ..."
echo " $0 [ target_file.sb ] [ changes_directory ]"
echo ""
echo "Examples:"
echo " # to create MiniOS iso without chromium.sb module:"
echo " $0 -e 'chromium' minios_without_chromium.iso"
echo "If changes_directory is not specified, /run/initramfs/memory/changes is used."
echo ""
echo " # to create MiniOS text-mode core only:"
echo " $0 -e 'firmware|xorg|desktop|apps|chromium' minios_textmode.iso"
exit 1
fi
if [ -e "$SOURCE/data/boot/syslinux/isolinux.bin" ]; then
MINIOS=$SOURCE/data
fi
if [ "$MINIOS" = "" ]; then
echo "Cannot find boot/isolinux.bin in MiniOS data" >&2
exit 2
if [ ! "$2" = "" ]; then
CHANGES="$2"
fi
VER=2021
DATE=$(date +%Y-%m-%d-%H-%M)
DIR=$MINIOS ; ISO=$TEMP/minios_$DATE.iso
[ -n "$1" ] && ISO="$1"
# exclude the save_file itself of course
EXCLUDE="$EXCLUDE|^""$(readlink -f "$1" | cut -b 2- | sed -r "s/[.]/[.]/")""\$"
B="-b boot/syslinux/isolinux.bin -c boot/syslinux/boot.cat"
C="-no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot"
CWD=$(pwd)
if [ -x "$(which xorriso 2> /dev/null)" ]; then
M="xorriso -as mkisofs -isohybrid-mbr $DIR/boot/syslinux/isohdpfx.bin"
D=" -isohybrid-gpt-basdat -e"
elif [ -x "$(which genisoimage 2> /dev/null)" ]; then
M=genisoimage ; D="-efi-boot"
else
M=mkisofs ; D="-eltorito-platform 0xEF -eltorito-boot"
fi
cd $CHANGES || exit
E="EFI/boot/efiboot.img -no-emul-boot"
mkdir -p $TMP
mount -t tmpfs tmpfs $TMP
VER="MiniOS $VER"
find \( -type d -printf "%p/\n" , -not -type d -print \) \
| sed -r "s/^[.]\\///" | egrep -v "$EXCLUDE" \
| while read FILE; do
cp --parents -afr "$FILE" "$TMP"
done
if ! $M -hide-rr-moved -f -r -J -l -V "$VER" -A "$VER" \
$B $C $D $E -o $ISO $DIR ; then
exit 1
fi
cd $CWD
echo ">>> $ISO created"
# xorriso has hybridization built-in
if [ "$(echo $M | cut -d" " -f1)" != "xorriso" ]; then
if [ -x "$(which isohybrid 2> /dev/null)" ]; then
isohybrid -uefi $ISO
else
echo ">>> No isohybrid to hybridize this ISO"
fi
fi
mksquashfs $TMP "$1" -comp $COMP_TYPE -b 1024K -always-use-fragments -noappend
exit 0
umount $TMP
rmdir $TMP
Loading…
Cancel
Save