Correct errors
parent
66ac5cef86
commit
f9a10045dc
|
|
@ -1,130 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Generate initramfs image
|
||||
# Original author: Tomas M <http://www.linux-live.org/>
|
||||
# Modified by: 'JohnDaH4x0r' [terencedoesmc12 AT gmail DOT com]
|
||||
|
||||
source ../.config
|
||||
|
||||
INITRAMFS=/tmp/$LIVEKITNAME-initramfs-$PID
|
||||
|
||||
# copy file to initramfs tree, including
|
||||
# all library dependencies (as shown by ldd)
|
||||
# $1 = file to copy (full path)
|
||||
copy_including_deps()
|
||||
{
|
||||
# if source doesn't exist or target exists, do nothing
|
||||
if [ ! -e "$1" -o -e "$INITRAMFS"/"$1" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
cp -R --parents "$1" "$INITRAMFS"
|
||||
if [ -L "$1" ]; then
|
||||
DIR="$(dirname "$1")"
|
||||
LNK="$(readlink "$1")"
|
||||
copy_including_deps "$(cd "$DIR"; realpath -s "$LNK")"
|
||||
fi
|
||||
|
||||
ldd "$1" 2>/dev/null | sed -r "s/.*=>|[(].*//g" | sed -r "s/^\\s+|\\s+\$//" \
|
||||
| while read LIB; do
|
||||
copy_including_deps "$LIB"
|
||||
done
|
||||
|
||||
for MOD in $(find "$1" -type f | grep .ko); do
|
||||
for DEP in $(cat /$LMK/modules.dep | fgrep /$(basename $MOD):); do
|
||||
copy_including_deps "/$LMK/$DEP"
|
||||
done
|
||||
done
|
||||
|
||||
shift
|
||||
if [ "$1" != "" ]; then
|
||||
copy_including_deps "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
rm -Rf $INITRAMFS
|
||||
mkdir -p $INITRAMFS/{bin,dev,etc,lib,lib64,mnt,proc,root,run,sys,tmp,usr,var/log}
|
||||
ln -s bin $INITRAMFS/sbin
|
||||
|
||||
cd static
|
||||
./update
|
||||
cd ..
|
||||
|
||||
cp static/{busybox,mount.dynfilefs,mount.ntfs-3g,eject} $INITRAMFS/bin
|
||||
chmod a+x $INITRAMFS/bin/{busybox,mount.*,eject}
|
||||
|
||||
$INITRAMFS/bin/busybox | grep , | grep -v Copyright | tr "," " " | while read LINE; do
|
||||
for TOOL in $LINE; do
|
||||
if [ ! -e $INITRAMFS/bin/$TOOL ]; then
|
||||
ln -s busybox $INITRAMFS/bin/$TOOL
|
||||
fi
|
||||
done
|
||||
done
|
||||
rm -f $INITRAMFS/{s,}bin/init
|
||||
|
||||
mknod $INITRAMFS/dev/console c 5 1
|
||||
mknod $INITRAMFS/dev/null c 1 3
|
||||
mknod $INITRAMFS/dev/ram0 b 1 0
|
||||
mknod $INITRAMFS/dev/tty1 c 4 1
|
||||
mknod $INITRAMFS/dev/tty2 c 4 2
|
||||
mknod $INITRAMFS/dev/tty3 c 4 3
|
||||
mknod $INITRAMFS/dev/tty4 c 4 4
|
||||
|
||||
#copy_including_deps /usr/bin/strace
|
||||
#copy_including_deps /usr/bin/lsof
|
||||
|
||||
copy_including_deps /$LMK/kernel/fs # all filesystems
|
||||
copy_including_deps /$LMK/kernel/drivers/staging/zsmalloc # needed by zram
|
||||
copy_including_deps /$LMK/kernel/drivers/block/zram
|
||||
copy_including_deps /$LMK/kernel/drivers/block/loop.*
|
||||
|
||||
# usb drivers
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/storage/usb-storage.*
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/host
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/common
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/core
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/usbhid
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/hid.*
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/uhid.*
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/hid-generic.*
|
||||
|
||||
# disk and cdrom drivers
|
||||
copy_including_deps /$LMK/kernel/drivers/cdrom
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/sr_mod.*
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/sd_mod.*
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/scsi_mod.*
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/sg.*
|
||||
copy_including_deps /$LMK/kernel/drivers/ata
|
||||
|
||||
# copy all custom-built modules
|
||||
copy_including_deps /$LMK/updates
|
||||
|
||||
copy_including_deps /$LMK/modules.*
|
||||
|
||||
|
||||
find $INITRAMFS -name "*.ko.gz" -exec gunzip {} \;
|
||||
|
||||
# trim modules.order file. Perhaps we could remove it entirely
|
||||
MODULEORDER="$(cd "$INITRAMFS/$LMK/"; find -name "*.ko" | sed -r "s:^./::g" | tr "\n" "|" | sed -r "s:[.]:.:g")"
|
||||
cat $INITRAMFS/$LMK/modules.order | sed -r "s/.ko.gz\$/.ko/" | grep -E "$MODULEORDER"/foo/bar > $INITRAMFS/$LMK/_
|
||||
mv $INITRAMFS/$LMK/_ $INITRAMFS/$LMK/modules.order
|
||||
|
||||
depmod -b $INITRAMFS $KERNEL
|
||||
|
||||
echo "root::0:0::/root:/bin/bash" >$INITRAMFS/etc/passwd
|
||||
touch $INITRAMFS/etc/{m,fs}tab
|
||||
|
||||
cp init $INITRAMFS
|
||||
chmod a+x $INITRAMFS/init
|
||||
cp cleanup $INITRAMFS/lib
|
||||
chmod a+x $INITRAMFS/lib/cleanup
|
||||
ln -s ../init $INITRAMFS/bin/init
|
||||
cp ../livekitlib $INITRAMFS/lib/
|
||||
cp ../.config $INITRAMFS/lib/
|
||||
|
||||
cd $INITRAMFS
|
||||
find . -print | cpio -o -H newc 2>/dev/null | xz -f --extreme --check=crc32 >$INITRAMFS.img
|
||||
echo $INITRAMFS.img
|
||||
|
||||
cd ..
|
||||
rm -Rf $INITRAMFS
|
||||
#mv $INITRAMFS.img /tmp/initrfs.img
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Initial script for Linux Live Kit / Linux Live Kit Improved
|
||||
# Modifier: "JohnDaH4x0r"
|
||||
|
||||
# Modify and export/declare new PATH
|
||||
export PATH=.:/:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# Source Live Kit library script
|
||||
. /lib/.config
|
||||
. /lib/livekitlib
|
||||
|
||||
# Declare start of 'init' state
|
||||
clear
|
||||
echo_sign "INIT START"
|
||||
|
||||
# Run switch_root: initramfs -> tmpfs
|
||||
transfer_initramfs
|
||||
|
||||
# Directory variables pointing to /memory
|
||||
MEMORY=/memory
|
||||
CHANGES=$MEMORY/changes
|
||||
UNION=$MEMORY/union
|
||||
DATAMNT=$MEMORY/data
|
||||
BUNDLES=$MEMORY/bundles
|
||||
|
||||
# Initliaise /proc, /sys and such
|
||||
init_proc_sysfs
|
||||
|
||||
# Initialise debugging if requested
|
||||
debug_start
|
||||
dbg_shell_start
|
||||
|
||||
# 1st debug shell interval
|
||||
debug_shell
|
||||
|
||||
# Initialise important kernel modules
|
||||
init_devs
|
||||
init_aufs
|
||||
init_zram
|
||||
|
||||
# Then, modprobe everything
|
||||
modprobe_everything
|
||||
|
||||
# Find data dir with filesystem bundles
|
||||
# NEW:
|
||||
# Only 15 seconds before timeout, to minimize the
|
||||
# pain of waiting a "whole" minute.
|
||||
#
|
||||
DATA="$(find_data 15 "$DATAMNT")"
|
||||
|
||||
# 2nd debug shell interval
|
||||
debug_shell
|
||||
|
||||
# Setup persistent changes
|
||||
persistent_changes "$DATA" "$CHANGES"
|
||||
|
||||
# 3rd debug shell interval
|
||||
debug_shell
|
||||
|
||||
# Copy data to RAM if requested by user
|
||||
DATA="$(copy_to_ram "$DATA" "$CHANGES")"
|
||||
|
||||
# Setup an empty union
|
||||
init_union "$CHANGES" "$UNION"
|
||||
|
||||
# 4th debug shell interval
|
||||
debug_shell
|
||||
|
||||
# Append bundles to union
|
||||
union_append_bundles "$DATA" "$BUNDLES" "$UNION"
|
||||
|
||||
# 5th debug shell interval
|
||||
debug_shell
|
||||
|
||||
# Copy contents of 'rootcopy/'
|
||||
copy_rootcopy_content "$DATA" "$UNION"
|
||||
|
||||
# Generate a basic 'fstab' with the core filesystems
|
||||
fstab_create "$UNION"
|
||||
|
||||
# 6th and final debug shell interval
|
||||
debug_shell
|
||||
|
||||
# Declare the end of first 'init' state
|
||||
clear
|
||||
echo_sign "INIT END"
|
||||
|
||||
# Change root to main OS and let the 'init' in the
|
||||
# main OS do the rest...
|
||||
change_root "$UNION"
|
||||
|
||||
# < ======== NOTHING SHOULD GO OVER THIS LINE! ======== >
|
||||
fatal "Unknown error!"
|
||||
Loading…
Reference in New Issue