Re-update all
parent
f695584985
commit
a21d783923
42
build
42
build
|
|
@ -6,22 +6,23 @@
|
||||||
|
|
||||||
# Environment path
|
# Environment path
|
||||||
export PATH="${PATH}:.:./tools:../tools"
|
export PATH="${PATH}:.:./tools:../tools"
|
||||||
|
|
||||||
CHANGEDIR="$(dirname $0)"
|
|
||||||
echo "Changing current directory to $CHANGEDIR"
|
|
||||||
CWD="$(pwd)"
|
|
||||||
cd "$CHANGEDIR"
|
|
||||||
|
|
||||||
source ./.config || exit 1
|
source ./.config || exit 1
|
||||||
source ./livekitlib || exit 1
|
source ./livekitlib || exit 1
|
||||||
|
|
||||||
# only root can continue, because only root can read all files from your system
|
# only root can continue, because only root can read all files from your system
|
||||||
allow_only_root
|
allow_only_root
|
||||||
|
|
||||||
|
# Change directory to build environment
|
||||||
|
CHANGEDIR="$(dirname $0)"
|
||||||
|
echo "Changing current directory to $CHANGEDIR"
|
||||||
|
CWD="$(pwd)"
|
||||||
|
cd "$CHANGEDIR"
|
||||||
|
|
||||||
|
|
||||||
# It's building time!
|
# It's building time!
|
||||||
clear
|
clear
|
||||||
|
|
||||||
echo_livekit_msg "build: Linux Live Kit version 2.0 Improved"
|
echo_sign "BUILD SCRIPT"
|
||||||
echo_livekit_msg "build: Doing a self-check..."
|
echo_livekit_msg "build: Doing a self-check..."
|
||||||
|
|
||||||
# Start with 0 errors
|
# Start with 0 errors
|
||||||
|
|
@ -40,9 +41,11 @@ MKISOFS="$(which mkisofs 2>/dev/null || \
|
||||||
which genisoimage 2>/dev/null)"
|
which genisoimage 2>/dev/null)"
|
||||||
if [ -z "$MKISOFS" ]; then
|
if [ -z "$MKISOFS" ]; then
|
||||||
echo_err "build: 'mkisofs' / 'genisoimage': not-avail"
|
echo_err "build: 'mkisofs' / 'genisoimage': not-avail"
|
||||||
(( ERRS+=1 ))
|
|
||||||
|
# Hahaha! 'false'?!?!?
|
||||||
|
MKISOFS="false"
|
||||||
else
|
else
|
||||||
echo_livekit_msg "build: '`basename $MKISOFS`': avail"
|
echo_livekit_msg "build: '$(basename $MKISOFS)': avail"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if we have 'zip'
|
# Check if we have 'zip'
|
||||||
|
|
@ -114,7 +117,7 @@ cat bootfiles/BootInstall.sh | sed -r "s:MyLinux:$LIVEKITNAME:" > $BOOT/BootInst
|
||||||
echo_livekit_msg "build: Copying kernel..."
|
echo_livekit_msg "build: Copying kernel..."
|
||||||
cp $VMLINUZ $BOOT/
|
cp $VMLINUZ $BOOT/
|
||||||
|
|
||||||
# Copy files from include_bund/, but
|
# Copy files from include_bund/, but
|
||||||
# do not skip bundle creation
|
# do not skip bundle creation
|
||||||
#
|
#
|
||||||
if [ -n "$(ls -A include_bund/ | grep ".$BEXT")" ]; then
|
if [ -n "$(ls -A include_bund/ | grep ".$BEXT")" ]; then
|
||||||
|
|
@ -165,9 +168,14 @@ echo_livekit_msg "build: Creating ISO file for CD boot..."
|
||||||
-R -D -A "$LIVEKITNAME" -V "$LIVEKITNAME" \
|
-R -D -A "$LIVEKITNAME" -V "$LIVEKITNAME" \
|
||||||
-no-emul-boot -boot-info-table -boot-load-size 4 \
|
-no-emul-boot -boot-info-table -boot-load-size 4 \
|
||||||
-b "$LIVEKITNAME"/boot/isolinux.bin -c \
|
-b "$LIVEKITNAME"/boot/isolinux.bin -c \
|
||||||
"$LIVEKITNAME"/boot/isolinux.boot . &>/dev/null && \
|
"$LIVEKITNAME"/boot/isolinux.boot . &>/dev/null
|
||||||
echo_livekit_msg "build: Output file: $OUT_FILE.iso" || \
|
if [ $? -ne 0 ]; then
|
||||||
echo_err "build: $OUT_FILE.iso: Failed to generate ISO file!"
|
echo_warn "build: Failed to generate ISO image!"
|
||||||
|
SCAN=
|
||||||
|
else
|
||||||
|
echo_livekit_msg "build: ISO image: $OUT_FILE.iso"
|
||||||
|
SCAN=1
|
||||||
|
fi
|
||||||
|
|
||||||
# Substitute 'mylinux' with $LIVEKITNAME
|
# Substitute 'mylinux' with $LIVEKITNAME
|
||||||
cat "$CWD/bootinfo.txt" | fgrep -v "#" | \
|
cat "$CWD/bootinfo.txt" | fgrep -v "#" | \
|
||||||
|
|
@ -188,7 +196,13 @@ echo_livekit_msg "build: Process ID: $PID - Your results is in $TARGET"
|
||||||
|
|
||||||
# Generate checksum(s)
|
# Generate checksum(s)
|
||||||
echo_livekit_msg "build: Generating MD5 checksums: Please wait..."
|
echo_livekit_msg "build: Generating MD5 checksums: Please wait..."
|
||||||
MD5_ISO="$(md5sum $TARGET/$OUT_FILE.iso 2>/dev/null | cut -d ' ' -f 1)"
|
|
||||||
|
if [ "$SCAN" ]; then
|
||||||
|
MD5_ISO="$(md5sum $TARGET/$OUT_FILE.iso 2>/dev/null | cut -d ' ' -f 1)"
|
||||||
|
else
|
||||||
|
MD5_ISO="< FAILED TO GENERATE ISO IMAGE! >"
|
||||||
|
fi
|
||||||
|
|
||||||
MD5_ZIP="$(md5sum $TARGET/$OUT_FILE.zip 2>/dev/null | cut -d ' ' -f 1)"
|
MD5_ZIP="$(md5sum $TARGET/$OUT_FILE.zip 2>/dev/null | cut -d ' ' -f 1)"
|
||||||
|
|
||||||
cat >"$SUM_FILE" <<EOF
|
cat >"$SUM_FILE" <<EOF
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ BUNDLES=$MEMORY/bundles
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
echo_bold "Live Kit Improved v1.0 - INIT"
|
echo_sign "INIT START"
|
||||||
|
|
||||||
init_proc_sysfs
|
init_proc_sysfs
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ fstab_create "$UNION"
|
||||||
debug_shell
|
debug_shell
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo_bold "Live Kit Improved v1.0 - INIT-DONE"
|
echo_sign "INIT END"
|
||||||
change_root "$UNION"
|
change_root "$UNION"
|
||||||
|
|
||||||
# If everything fails, panic immidiately
|
# If everything fails, panic immidiately
|
||||||
|
|
|
||||||
147
livekitlib
147
livekitlib
|
|
@ -19,22 +19,22 @@ get_exclude()
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$EXCLUDE_LIST" | tr " " "\n" | grep "$PARENT_DIR" | \
|
echo "$EXCLUDE_LIST" | tr " " "\n" | grep "$PARENT_DIR" \
|
||||||
cut -d ":" -f 2 | while read KEY; do
|
| while read KEY; do
|
||||||
echo -n "-e $KEY "
|
echo -n "-e $KEY "
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output functions
|
# NOTE: DO NOT TOUCH THE ESCAPE CHARACTERS!
|
||||||
BLUE="\x1b[1;34m"
|
BLUE="[1;34m"
|
||||||
YELLOW="\x1b[1;33m"
|
YELLOW="[1;33m"
|
||||||
ORANGE="\x1b[0;33m"
|
ORANGE="[0;33m"
|
||||||
GREEN="\x1b[1;32m"
|
GREEN="[1;32m"
|
||||||
BOLD="\x1b[0;1m"
|
BOLD="[0;1m"
|
||||||
RED="\x1b[1;31m"
|
RED="[1;31m"
|
||||||
NC="\x1b[0m"
|
NC="[0m"
|
||||||
|
|
||||||
# echo-related
|
# debug related
|
||||||
debug_start()
|
debug_start()
|
||||||
{
|
{
|
||||||
if grep -q debug /proc/cmdline; then
|
if grep -q debug /proc/cmdline; then
|
||||||
|
|
@ -45,26 +45,29 @@ debug_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg_shell_start()
|
dbg_shell_start()
|
||||||
|
{
|
||||||
if grep -q 'dbg_shell' /proc/cmdline; then
|
if grep -q 'dbg_shell' /proc/cmdline; then
|
||||||
DBG_SHELL=1
|
DBG_SHELL=1
|
||||||
else
|
else
|
||||||
DBG_SHELL=
|
DBG_SHELL=
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_log()
|
debug_log()
|
||||||
{
|
{
|
||||||
if [ "$DBG_SHELL" ]; then
|
if [ "$DEBUG_IS_ENABLED" ]; then
|
||||||
echo -e "[ ${GREEN}"'debug'"${NC} ]: $@" >&2
|
echo "[${GREEN}"' debug '"${NC}]: $@" >&2
|
||||||
log "debug_log: $*"
|
log "debug_log: $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# echo related functions
|
||||||
|
|
||||||
# echo fatal tag
|
# echo fatal tag
|
||||||
# $1 = text to show
|
# $1 = text to show
|
||||||
echo_fatal()
|
echo_fatal()
|
||||||
{
|
{
|
||||||
echo -e "[${RED}"' fatal '"${NC}] $@" >&2
|
echo "[${RED}"' fatal '"${NC}] $@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# echo bold
|
# echo bold
|
||||||
|
|
@ -72,30 +75,36 @@ echo_fatal()
|
||||||
#
|
#
|
||||||
echo_bold()
|
echo_bold()
|
||||||
{
|
{
|
||||||
echo -e "$BOLD""$@""$NC"
|
echo "$BOLD""$@""$NC"
|
||||||
}
|
}
|
||||||
|
|
||||||
# echo livekit tag
|
# echo livekit tag
|
||||||
echo_livekit()
|
echo_livekit()
|
||||||
{
|
{
|
||||||
echo -ne "[${BLUE}"'livekit'"${NC}] "
|
echo "[${BLUE}"'livekit'"${NC}] "
|
||||||
}
|
}
|
||||||
|
|
||||||
echo_livekit_msg()
|
echo_livekit_msg()
|
||||||
{
|
{
|
||||||
echo -e "[${BLUE}"'livekit'"${NC}] $@"
|
echo "[${BLUE}"'livekit'"${NC}] $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# echo error
|
# echo error
|
||||||
echo_err()
|
echo_err()
|
||||||
{
|
{
|
||||||
echo -e "[${RED}"' error '"${NC}] $@" >&2
|
echo "[${RED}"' error '"${NC}] $@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# echo warn
|
# echo warn
|
||||||
echo_warn()
|
echo_warn()
|
||||||
{
|
{
|
||||||
echo -e "[${YELLOW}"' warn! '"${NC}] $@" >&2
|
echo "[${YELLOW}"' warn! '"${NC}] $@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# echo signature
|
||||||
|
echo_sign()
|
||||||
|
{
|
||||||
|
echo "${BOLD}"' Linux Live Kit Improved v1.0 - '"$* ${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# log - store given text in /var/log/livedbg
|
# log - store given text in /var/log/livedbg
|
||||||
|
|
@ -113,11 +122,10 @@ echolog()
|
||||||
# show information about the debug shell
|
# show information about the debug shell
|
||||||
show_debug_banner()
|
show_debug_banner()
|
||||||
{
|
{
|
||||||
echo_livekit >&2
|
echo_sign "DEBUGGING MODE"
|
||||||
echo "Debugging shell started." >&2
|
|
||||||
echo "The root shell is prepared for you!" >&2
|
echo "The root shell is prepared for you!" >&2
|
||||||
echo "Type your desired commands or press Ctrl-D to continue booting." >&2
|
echo "Type your desired commands or press Ctrl-D to continue booting." >&2
|
||||||
echo
|
echo >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug_shell
|
# debug_shell
|
||||||
|
|
@ -125,7 +133,7 @@ show_debug_banner()
|
||||||
#
|
#
|
||||||
debug_shell()
|
debug_shell()
|
||||||
{
|
{
|
||||||
if [ "$DEBUG_IS_ENABLED" ]; then
|
if [ "$DBG_SHELL" ]; then
|
||||||
show_debug_banner
|
show_debug_banner
|
||||||
setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1'
|
setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1'
|
||||||
echo
|
echo
|
||||||
|
|
@ -136,9 +144,8 @@ fatal()
|
||||||
{
|
{
|
||||||
log "FatalError: $@"
|
log "FatalError: $@"
|
||||||
echo_fatal "$@"
|
echo_fatal "$@"
|
||||||
echo -e "${RED}"'Please reboot this system now!'"${NC}"
|
echo_sign "EMERGENCY MODE" >&2
|
||||||
echo -e "${BOLD}"'Live Kig Log: /var/log/livekit-log'"${NC}"
|
echo_bold "Please consult /var/log/livekit-log for more info." >&2
|
||||||
echo -e "${BOLD}"'To get more information, please consult Live Kit Log for more info.'"${NC}"
|
|
||||||
setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1'
|
setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +155,7 @@ fatal()
|
||||||
allow_only_root()
|
allow_only_root()
|
||||||
{
|
{
|
||||||
if [ "0$UID" -ne 0 ]; then
|
if [ "0$UID" -ne 0 ]; then
|
||||||
echo_err "Only root can run `basename $0`"; exit 1
|
echo_err "Only root can run $(basename $0)"; exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,7 +214,7 @@ transfer_initramfs()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# mount virtual filesystems like proc etc
|
# mount virtual filesystems like proc, sys and such
|
||||||
#
|
#
|
||||||
init_proc_sysfs()
|
init_proc_sysfs()
|
||||||
{
|
{
|
||||||
|
|
@ -276,13 +283,14 @@ init_aufs()
|
||||||
debug_log "init_aufs" "$*"
|
debug_log "init_aufs" "$*"
|
||||||
# TODO maybe check here if aufs support is working at all
|
# TODO maybe check here if aufs support is working at all
|
||||||
# and produce useful error message if user has no aufs
|
# and produce useful error message if user has no aufs
|
||||||
modprobe aufs 2>/dev/null
|
modprobe aufs 2>/var/log/livekit-log
|
||||||
|
|
||||||
# if aufs module failed to load, panic immidiately
|
# TODO ACCOMPLISHED:
|
||||||
|
# If aufs module failed to load, panic immidiately
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
fatal "Failed to load AUFS module!"
|
fatal "Failed to load AUFS module!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# finally, refresh all devices
|
# finally, refresh all devices
|
||||||
refresh_devs
|
refresh_devs
|
||||||
}
|
}
|
||||||
|
|
@ -344,16 +352,19 @@ mounted_dir()
|
||||||
#
|
#
|
||||||
device_bestfs()
|
device_bestfs()
|
||||||
{
|
{
|
||||||
debug_log "device_bestfs" "$*"
|
debug_log "device_bestfs" "$*"
|
||||||
local FS
|
local FS
|
||||||
|
|
||||||
FS="$(blkid "$1" | sed -r "s/.*TYPE=//" | tr -d '"' | tr [A-Z] [a-z] | cut -d ' ' -f 1)"
|
FS="$(blkid "$1" | sed -r "s/.*TYPE=//" | tr -d '"' | \
|
||||||
if [ "$FS" = "msdos" -o "$FS" = "fat" ]; then
|
tr "[A-Z]" "[a-z]" | cut -d ' ' -f 1)"
|
||||||
FS="vfat"
|
if [ "$FS" = "msdos" -o "$FS" = "fat" ]; then
|
||||||
elif [ "$FS" = "ntfs" ]; then
|
FS="vfat"
|
||||||
FS="ntfs-3g"
|
elif [ "$FS" = "ntfs" ]; then
|
||||||
fi
|
FS="ntfs-3g"
|
||||||
echo "-t $FS"
|
else
|
||||||
|
FS="$FS"
|
||||||
|
fi
|
||||||
|
echo "-t $FS"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filesystem options for mount
|
# Filesystem options for mount
|
||||||
|
|
@ -463,38 +474,38 @@ download_data_pxe()
|
||||||
#
|
#
|
||||||
find_data_try()
|
find_data_try()
|
||||||
{
|
{
|
||||||
debug_log "find_data_try" "$*"
|
debug_log "find_data_try" "$*"
|
||||||
|
|
||||||
local DEVICE FS FROM OPTIONS
|
local DEVICE FS FROM OPTIONS
|
||||||
|
|
||||||
mkdir -p "$1"
|
mkdir -p "$1"
|
||||||
blkid | sort | cut -d: -f 1 | grep -E -v "/loop|/ram|/zram" | while read DEVICE; do
|
blkid | sort | cut -d: -f 1 | grep -E -v "/loop|/ram|/zram" | while read DEVICE; do
|
||||||
FROM="$2"
|
FROM="$2"
|
||||||
FS="$(device_bestfs "$DEVICE")"
|
FS="$(device_bestfs "$DEVICE")"
|
||||||
OPTIONS="$(fs_options $FS)"
|
OPTIONS="$(fs_options $FS)"
|
||||||
mount -r "$DEVICE" "$1" $FS $OPTIONS 2>/dev/null
|
mount -r "$DEVICE" "$1" $FS $OPTIONS 2>/dev/null
|
||||||
|
|
||||||
# if the FROM parameter is actual file, mount it again as loop (eg. iso)
|
# if the FROM parameter is actual file, mount it again as loop (eg. iso)
|
||||||
if [ -f "$1/$FROM" ]; then
|
if [ -f "$1/$FROM" ]; then
|
||||||
mount -o remount,rw "$DEVICE" "$1" 2>/dev/null
|
mount -o remount,rw "$DEVICE" "$1" 2>/dev/null
|
||||||
mkdir -p "$1/../iso"
|
mkdir -p "$1/../file"
|
||||||
mount -o loop,ro "$1/$FROM" "$1/../iso" 2>/dev/null
|
mount -o loop,ro "$1/$FROM" "$1/../file" 2>/dev/null
|
||||||
FROM="../iso/$LIVEKITNAME"
|
FROM="../file/$LIVEKITNAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# search for bundles in the mounted directory
|
# search for bundles in the mounted directory
|
||||||
if [ "$(find "$1/$FROM" -maxdepth 1 -name "*.$BEXT" 2>/dev/null)" != "" ]; then
|
if [ "$(find "$1/$FROM" -maxdepth 1 -name "*.$BEXT" 2>/dev/null)" != "" ]; then
|
||||||
# we found at least one bundle/module here
|
# we found at least one bundle/module here
|
||||||
mount -o remount,rw "$DEVICE" "$1" 2>/dev/null
|
mount -o remount,rw "$DEVICE" "$1" 2>/dev/null
|
||||||
echo "$1/$FROM" | tr -s "/" | sed -r "s:/[^/]+/[.][.]/:/:g"
|
echo "$1/$FROM" | tr -s "/" | sed -r "s:/[^/]+/[.][.]/:/:g"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# unmount twice, since there could be mounted ISO as loop too. If not, it doesn't hurt
|
# unmount twice, since there could be mounted ISO as loop too. If not, it doesn't hurt
|
||||||
umount "$1" 2>/dev/null
|
umount "$1" 2>/dev/null
|
||||||
umount "$1" 2>/dev/null
|
umount "$1" 2>/dev/null
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retry finding LIVEKIT data several times,
|
# Retry finding LIVEKIT data several times,
|
||||||
# until timeouted or until data is found
|
# until timeouted or until data is found
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue