You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 lines
1.8 KiB

#!/bin/bash
# Linux Live Kit version 7
#check_is_in_chroot
export PATH=.:./tools:../tools:/usr/sbin:/usr/bin:/sbin:/bin:/
CHANGEDIR=$(dirname $(readlink -f $0))
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"
sed -i 's,VMLINUZ="/vmlinuz",VMLINUZ="/boot/vmlinuz",g' $CHANGEDIR/config
elif [ -L /vmlinuz ] 2>/dev/null; then
VMLINUZ="/vmlinuz"
sed -i 's,VMLINUZ="/boot/vmlinuz",VMLINUZ="/vmlinuz",g' $CHANGEDIR/config
fi
# only root can continue, because only root can read all files from your system
allow_only_root
# check for mksquashfs with xz compression
if [ "$(mksquashfs 2>&1 | grep "Xdict-size")" = "" ]; then
echo "mksquashfs not found or doesn't support -comp xz, aborting, no changes made"
echo "you may consider installing squashfs-tools package"
exit 1
fi
MKISOFS=$(which xorriso)
if [ "$MKISOFS" = "" ]; then
echo "Cannot found xorriso, stop"
exit 3
fi
# build initramfs image
if [ "$SKIPINITRFS" = "" ]; then
echo "Building intramfs image..."
cd initramfs
INITRAMFS=$(./initramfs_create)
cd ..
fi
# create live kit filesystem (cpio archive)
rm -Rf "$LIVEKITDATA"
BOOT="$LIVEKITDATA"/"$LIVEKITNAME"/boot
mkdir -p "$BOOT"
mkdir -p "$BOOT"/../changes
mkdir -p "$BOOT"/../modules
if [ "$INITRAMFS" != "" ]; then
mv "$INITRAMFS" $BOOT/initrfs.img
fi
# BIOS / MBR booting
cp -r bootfiles/* $LIVEKITDATA
cp $VMLINUZ $BOOT/ || exit
# create compressed 01-core.sb
COREFS=""
for i in $MKMOD; do
if [ -d /$i ]; then
COREFS="$COREFS /$i"
fi
done
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