Browse Source

commit on master

master
crims0n 5 years ago
parent
commit
f066c22e6e
  1. 4
      linux-live/build
  2. 3
      linux-live/config
  3. 45
      linux-live/minioslib
  4. 85
      linux-live/rootcopy/usr/bin/genminiosiso

4
linux-live/build

@ -70,8 +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
echo $LIVEKITDATA > /tmp/livekitdata
cd $CWD
cd $CWD

3
linux-live/config

@ -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.

45
linux-live/minioslib

@ -14,7 +14,7 @@ function common_variables() {
# normal
# OUTPUT="/dev/stdout"
# log
OUTPUT="/$LIVEKITNAME.log"
OUTPUT="/var/log/$LIVEKITNAME.log"
# if = "1", creates a second iso with a constant filename
# если ="1", создаёт второй iso с постоянным именем файла
@ -22,7 +22,7 @@ function common_variables() {
# if = "1", creates a copy of minios-live in chroot /opt
# если ="1", создаёт копию minios-live в chroot /opt
DEV_SYSTEM="1"
DEV_SYSTEM="0"
# if ="1", creates backup in parent folder
# если ="1", создаёт резервную копию в родительской папке
@ -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
@ -437,7 +438,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 +552,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
@ -569,7 +571,7 @@ function build_iso() {
if
! $M -hide-rr-moved -f -r -J -l -V "$VER" -A "$VER" \
$B $C $D $E -o $ISO $DIR
$B $C $D $E -o $ISO $DIR
then
exit 1
fi
@ -578,7 +580,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"
@ -642,12 +645,12 @@ function hostreq_pkg_list() {
echo -e "${YELLOW}=====> installing required software for host system ...${ENDCOLOUR}"
if [ -f $SCRIPT_DIR/linux-live/pkglists/hostreq.list ]; then
sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install -y \
$(grep -vE "^\s*#" $SCRIPT_DIR/linux-live/pkglists/hostreq.list | tr "\n" " ") >>$OUTPUT 2>&1
$(grep -vE "^\s*#" $SCRIPT_DIR/linux-live/pkglists/hostreq.list | tr "\n" " ") >>$OUTPUT 2>&1
else
sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install -y binutils debootstrap squashfs-tools xorriso grub-pc-bin grub-efi-$DISTRIBUTION_ARCH-bin mtools >>$OUTPUT 2>&1
fi
}
@ -660,7 +663,7 @@ function prereq_pkg_list() {
$APT_CMD upgrade $APT_OPTIONS >>$OUTPUT 2>&1 &&
echo -e "${YELLOW}=====> installing packages ...${ENDCOLOUR}" &&
$APT_CMD install $APT_OPTIONS \
$(grep -vE "^\s*#" $SCRIPT_DIR/pkglists/prereq.list | tr "\n" " ") >>$OUTPUT 2>&1
$(grep -vE "^\s*#" $SCRIPT_DIR/pkglists/prereq.list | tr "\n" " ") >>$OUTPUT 2>&1
else
# we need to install systemd first, to configure machine id
$APT_CMD update >>$OUTPUT 2>&1 &&
@ -675,12 +678,12 @@ function main_pkg_list() {
echo -e "${YELLOW}=====> installing main packages for chroot system ...${ENDCOLOUR}"
if [ -f $SCRIPT_DIR/pkglists/hostreq.list ]; then
sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install $APT_OPTIONS \
$(grep -vE "^\s*#" $SCRIPT_DIR/pkglists/main.list | tr "\n" " ") >>$OUTPUT 2>&1
$(grep -vE "^\s*#" $SCRIPT_DIR/pkglists/main.list | tr "\n" " ") >>$OUTPUT 2>&1
else
sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install $APT_OPTIONS ubuntu-minimal resolvconf xz-utils linux-image-generic >>$OUTPUT 2>&1
fi
}
@ -689,9 +692,9 @@ function other_pkg_list() {
echo -e "${YELLOW}=====> installing other packages for chroot system ...${ENDCOLOUR}"
if [ -f $SCRIPT_DIR/pkglists/hostreq.list ]; then
sudo DEBIAN_FRONTEND=$DEBIAN_FRONTEND_TYPE \
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install $APT_OPTIONS \
$(grep -vE "^\s*#" $SCRIPT_DIR/pkglists/other.list | tr "\n" " ") >>$OUTPUT 2>&1
$(grep -vE "^\s*#" $SCRIPT_DIR/pkglists/other.list | tr "\n" " ") >>$OUTPUT 2>&1
fi
}
@ -833,4 +836,4 @@ function chroot_finish_up() {
}
if [ grep ]; then
echo
fi
fi

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