formatting
This commit is contained in:
parent
3608109b78
commit
a0bd4caf46
50
generate
50
generate
@ -57,18 +57,18 @@ check_requirements() {
|
|||||||
msg info "checking requirements"
|
msg info "checking requirements"
|
||||||
|
|
||||||
# check busybox installed
|
# check busybox installed
|
||||||
command -v busybox >/dev/null 2>&1 && {
|
command -v busybox > /dev/null 2>&1 && {
|
||||||
# check busybox supports CONFIG_FEATURE_INSTALLER
|
# check busybox supports CONFIG_FEATURE_INSTALLER
|
||||||
busybox --help | grep -q "\-\-install \[\-s\]" || msg panic "recompile busybox with CONFIG_FEATURE_INSTALLER"
|
busybox --help | grep -q "\-\-install \[\-s\]" || msg panic "recompile busybox with CONFIG_FEATURE_INSTALLER"
|
||||||
|
|
||||||
# check requirements for init
|
# check requirements for init
|
||||||
for busybox_dep in mdev uevent switch_root; do
|
for busybox_dep in mdev uevent switch_root; do
|
||||||
busybox $busybox_dep --help >/dev/null 2>&1 || msg panic "recompile busybox with $busybox_dep"
|
busybox $busybox_dep --help > /dev/null 2>&1 || msg panic "recompile busybox with $busybox_dep"
|
||||||
done
|
done
|
||||||
} || msg panic "busybox doesn't installed"
|
} || msg panic "busybox doesn't installed"
|
||||||
|
|
||||||
# check kmod modprobe installed
|
# check kmod modprobe installed
|
||||||
command -v modprobe >/dev/null 2>&1 && {
|
command -v modprobe > /dev/null 2>&1 && {
|
||||||
# busybox modprobe doesn't supported(yet)
|
# busybox modprobe doesn't supported(yet)
|
||||||
modprobe --version 2>&1 | grep -q "kmod" || msg panic "kmod modprobe version doesn't installed"
|
modprobe --version 2>&1 | grep -q "kmod" || msg panic "kmod modprobe version doesn't installed"
|
||||||
} || msg panic "modprobe doesn't installed"
|
} || msg panic "modprobe doesn't installed"
|
||||||
@ -76,7 +76,7 @@ check_requirements() {
|
|||||||
# check util-linux tools
|
# check util-linux tools
|
||||||
[ "$use_util_linux" = 1 ] && {
|
[ "$use_util_linux" = 1 ] && {
|
||||||
# check mount installed
|
# check mount installed
|
||||||
if command -v mount >/dev/null 2>&1; then
|
if command -v mount > /dev/null 2>&1; then
|
||||||
mount --version 2>&1 | grep -q "util-linux" || {
|
mount --version 2>&1 | grep -q "util-linux" || {
|
||||||
msg warning "util-linux mount version doesn't installed. PARTUUID and filesystem type autodetection support will be missing"
|
msg warning "util-linux mount version doesn't installed. PARTUUID and filesystem type autodetection support will be missing"
|
||||||
use_util_linux=0
|
use_util_linux=0
|
||||||
@ -86,7 +86,7 @@ check_requirements() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check blkid installed
|
# check blkid installed
|
||||||
if command -v blkid >/dev/null 2>&1; then
|
if command -v blkid > /dev/null 2>&1; then
|
||||||
blkid --version 2>&1 | grep -q "util-linux" || {
|
blkid --version 2>&1 | grep -q "util-linux" || {
|
||||||
msg warning "util-linux blkid version doesn't installed. PARTUUID support will be missing"
|
msg warning "util-linux blkid version doesn't installed. PARTUUID support will be missing"
|
||||||
use_util_linux=0
|
use_util_linux=0
|
||||||
@ -166,7 +166,7 @@ install_udev() {
|
|||||||
msg info "installing udev"
|
msg info "installing udev"
|
||||||
install_binaries udevd udevadm dmsetup
|
install_binaries udevd udevadm dmsetup
|
||||||
# FIXME rewrite this piece of crap
|
# FIXME rewrite this piece of crap
|
||||||
find /usr/lib/udev -type f | grep -v "rc_keymaps\|hwdb.d" | cpio -pd "$tmpdir" >/dev/null 2>&1
|
find /usr/lib/udev -type f | grep -v "rc_keymaps\|hwdb.d" | cpio -pd "$tmpdir" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# handle lvm
|
# handle lvm
|
||||||
@ -177,7 +177,7 @@ install_lvm() {
|
|||||||
# if hostonly mode enabled install only needed drivers
|
# if hostonly mode enabled install only needed drivers
|
||||||
[ "$hostonly" = 1 ] && {
|
[ "$hostonly" = 1 ] && {
|
||||||
for lvm_driver in dm-thin-pool dm-multipath dm-snapshot dm-cache dm-log dm-mirror; do
|
for lvm_driver in dm-thin-pool dm-multipath dm-snapshot dm-cache dm-log dm-mirror; do
|
||||||
for lvm_driver_dep in $(modprobe -D "$lvm_driver" 2>/dev/null | grep -v builtin | cut -d " " -f 2); do
|
for lvm_driver_dep in $(modprobe -D "$lvm_driver" 2> /dev/null | grep -v builtin | cut -d " " -f 2); do
|
||||||
install -Dm644 "$lvm_driver_dep" "${tmpdir}${lvm_driver_dep}"
|
install -Dm644 "$lvm_driver_dep" "${tmpdir}${lvm_driver_dep}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -187,7 +187,7 @@ install_lvm() {
|
|||||||
install -Dm644 /etc/lvm/*.conf -t "${tmpdir}/etc/lvm" || msg panic "failed to install LVM config"
|
install -Dm644 /etc/lvm/*.conf -t "${tmpdir}/etc/lvm" || msg panic "failed to install LVM config"
|
||||||
else
|
else
|
||||||
mkdir "${tmpdir}/etc/lvm"
|
mkdir "${tmpdir}/etc/lvm"
|
||||||
cat <<EOF > "${tmpdir}/etc/lvm/lvm.conf"
|
cat << EOF > "${tmpdir}/etc/lvm/lvm.conf"
|
||||||
devices {
|
devices {
|
||||||
issue_discards = ${lvm_discard:-0}
|
issue_discards = ${lvm_discard:-0}
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ install_luks() {
|
|||||||
# if hostonly mode enabled install only needed drivers
|
# if hostonly mode enabled install only needed drivers
|
||||||
[ "$hostonly" = 1 ] && {
|
[ "$hostonly" = 1 ] && {
|
||||||
for luks_driver in aes dm-crypt sha256 sha512 wp512 ecb lrw xts twofish serpent; do
|
for luks_driver in aes dm-crypt sha256 sha512 wp512 ecb lrw xts twofish serpent; do
|
||||||
for luks_driver_dep in $(modprobe -D "$luks_driver" 2>/dev/null | grep -v builtin | cut -d " " -f 2); do
|
for luks_driver_dep in $(modprobe -D "$luks_driver" 2> /dev/null | grep -v builtin | cut -d " " -f 2); do
|
||||||
install -Dm644 "$luks_driver_dep" "${tmpdir}${luks_driver_dep}"
|
install -Dm644 "$luks_driver_dep" "${tmpdir}${luks_driver_dep}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -243,7 +243,7 @@ install_drivers() {
|
|||||||
|
|
||||||
# perform autodetection of drivers via /sys
|
# perform autodetection of drivers via /sys
|
||||||
find /sys/devices -name modalias -exec sort -u "{}" "+" | while read -r driver; do
|
find /sys/devices -name modalias -exec sort -u "{}" "+" | while read -r driver; do
|
||||||
for driver_dep in $(modprobe -D "$driver" 2>/dev/null | grep -v builtin | cut -d " " -f 2); do
|
for driver_dep in $(modprobe -D "$driver" 2> /dev/null | grep -v builtin | cut -d " " -f 2); do
|
||||||
install -Dm644 "$driver_dep" "${tmpdir}${driver_dep}"
|
install -Dm644 "$driver_dep" "${tmpdir}${driver_dep}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -251,14 +251,14 @@ install_drivers() {
|
|||||||
# TODO autodetect root fs driver
|
# TODO autodetect root fs driver
|
||||||
# TODO separate root type option
|
# TODO separate root type option
|
||||||
# install root fs driver
|
# install root fs driver
|
||||||
for root_driver in $(modprobe -D "$root_type" 2>/dev/null | grep -v builtin | cut -d " " -f 2); do
|
for root_driver in $(modprobe -D "$root_type" 2> /dev/null | grep -v builtin | cut -d " " -f 2); do
|
||||||
install -Dm644 "$root_driver" "${tmpdir}${root_driver}"
|
install -Dm644 "$root_driver" "${tmpdir}${root_driver}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# install user specified drivers
|
# install user specified drivers
|
||||||
[ -n "$drivers" ] && {
|
[ -n "$drivers" ] && {
|
||||||
printf "%s\n" "$drivers" | while read -r custom_driver; do
|
printf "%s\n" "$drivers" | while read -r custom_driver; do
|
||||||
for custom_driver_dep in $(modprobe -D "$custom_driver" 2>/dev/null | grep -v builtin | cut -d " " -f 2); do
|
for custom_driver_dep in $(modprobe -D "$custom_driver" 2> /dev/null | grep -v builtin | cut -d " " -f 2); do
|
||||||
install -Dm644 "$custom_driver_dep" "${tmpdir}${custom_driver_dep}"
|
install -Dm644 "$custom_driver_dep" "${tmpdir}${custom_driver_dep}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -280,7 +280,7 @@ install_all_drivers() {
|
|||||||
"${modker}/kernel/drivers/usb/storage" \
|
"${modker}/kernel/drivers/usb/storage" \
|
||||||
"${modker}/kernel/drivers/usb/host" \
|
"${modker}/kernel/drivers/usb/host" \
|
||||||
"${modker}/kernel/drivers/virtio" \
|
"${modker}/kernel/drivers/virtio" \
|
||||||
-type f | cpio -pd "$tmpdir" >/dev/null 2>&1
|
-type f | cpio -pd "$tmpdir" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate "modules" files
|
# generate "modules" files
|
||||||
@ -299,13 +299,13 @@ install_binaries() {
|
|||||||
printf "%s\n" "$@" | while read -r binary; do
|
printf "%s\n" "$@" | while read -r binary; do
|
||||||
msg info "installing binary $binary"
|
msg info "installing binary $binary"
|
||||||
# check binary existence
|
# check binary existence
|
||||||
command -v "$binary" >/dev/null 2>&1 || msg panic "$binary doesn't exists"
|
command -v "$binary" > /dev/null 2>&1 || msg panic "$binary doesn't exists"
|
||||||
|
|
||||||
# install and strip binary
|
# install and strip binary
|
||||||
install -s -m755 "$(command -v $binary)" -t "${tmpdir}/usr/bin"
|
install -s -m755 "$(command -v $binary)" -t "${tmpdir}/usr/bin"
|
||||||
|
|
||||||
# check statically linking
|
# check statically linking
|
||||||
ldd "$(command -v $binary)" >/dev/null 2>&1 || continue
|
ldd "$(command -v $binary)" > /dev/null 2>&1 || continue
|
||||||
|
|
||||||
# install libraries
|
# install libraries
|
||||||
install_libraries $binary
|
install_libraries $binary
|
||||||
@ -344,7 +344,7 @@ install_files() {
|
|||||||
msg info "installing files"
|
msg info "installing files"
|
||||||
# FIXME eof broken
|
# FIXME eof broken
|
||||||
# initialize config
|
# initialize config
|
||||||
cat <<EOF > "${tmpdir}/config"
|
cat << EOF > "${tmpdir}/config"
|
||||||
debug="$debug"
|
debug="$debug"
|
||||||
root="$root"
|
root="$root"
|
||||||
root_type="$root_type"
|
root_type="$root_type"
|
||||||
@ -358,7 +358,7 @@ luks_args="$luks_args"
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# needed for devmgr
|
# needed for devmgr
|
||||||
cat <<EOF > "${tmpdir}/etc/group"
|
cat << EOF > "${tmpdir}/etc/group"
|
||||||
root:x:0:
|
root:x:0:
|
||||||
tty:x:5:
|
tty:x:5:
|
||||||
dialout:x:11:
|
dialout:x:11:
|
||||||
@ -376,7 +376,7 @@ floppy:x:8:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# needed for devmgr
|
# needed for devmgr
|
||||||
cat <<EOF > "${tmpdir}/etc/passwd"
|
cat << EOF > "${tmpdir}/etc/passwd"
|
||||||
root:x:0:0::/root:/bin/sh
|
root:x:0:0::/root:/bin/sh
|
||||||
nobody:x:99:99::/:/bin/false
|
nobody:x:99:99::/:/bin/false
|
||||||
EOF
|
EOF
|
||||||
@ -390,12 +390,14 @@ EOF
|
|||||||
create_initramfs() {
|
create_initramfs() {
|
||||||
msg info "creating initramfs image"
|
msg info "creating initramfs image"
|
||||||
{
|
{
|
||||||
( cd "$tmpdir"
|
(
|
||||||
find . |
|
cd "$tmpdir"
|
||||||
cpio -oH newc |
|
find . \
|
||||||
gzip -9 ) |
|
| cpio -oH newc \
|
||||||
tee "${script_dir}/initramfs-${kernel}.img.gz"
|
| gzip -9
|
||||||
} >/dev/null 2>&1 || msg panic "failed to generate initramfs image"
|
) \
|
||||||
|
| tee "${script_dir}/initramfs-${kernel}.img.gz"
|
||||||
|
} > /dev/null 2>&1 || msg panic "failed to generate initramfs image"
|
||||||
}
|
}
|
||||||
|
|
||||||
# check root
|
# check root
|
||||||
|
10
init
10
init
@ -22,7 +22,7 @@ mnt_pseudofs() {
|
|||||||
use_mdev() {
|
use_mdev() {
|
||||||
# setup hotplugger
|
# setup hotplugger
|
||||||
if [ -e /proc/sys/kernel/hotplug ]; then
|
if [ -e /proc/sys/kernel/hotplug ]; then
|
||||||
printf /sbin/mdev >/proc/sys/kernel/hotplug
|
printf /sbin/mdev > /proc/sys/kernel/hotplug
|
||||||
else
|
else
|
||||||
uevent mdev &
|
uevent mdev &
|
||||||
fi
|
fi
|
||||||
@ -100,7 +100,7 @@ unlock_luks() {
|
|||||||
|
|
||||||
# manually trigger LVM if udev disabled
|
# manually trigger LVM if udev disabled
|
||||||
trigger_lvm() {
|
trigger_lvm() {
|
||||||
lvm vgchange --quiet --sysinit -a y >/dev/null
|
lvm vgchange --quiet --sysinit -a y > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# mount rootfs to /mnt/root
|
# mount rootfs to /mnt/root
|
||||||
@ -121,7 +121,7 @@ cleanup() {
|
|||||||
case "$devmgr" in
|
case "$devmgr" in
|
||||||
mdev)
|
mdev)
|
||||||
# stop mdev
|
# stop mdev
|
||||||
{ printf "" >/proc/sys/kernel/hotplug || killall uevent; } >/dev/null 2>&1
|
{ printf "" > /proc/sys/kernel/hotplug || killall uevent; } > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
mdevd)
|
mdevd)
|
||||||
# stop mdevd
|
# stop mdevd
|
||||||
@ -135,7 +135,7 @@ cleanup() {
|
|||||||
|
|
||||||
# TODO re-do
|
# TODO re-do
|
||||||
# if debug mode off then restore kernel logging
|
# if debug mode off then restore kernel logging
|
||||||
[ "$debug" = 0 ] && printf 1 >/proc/sys/kernel/printk
|
[ "$debug" = 0 ] && printf 1 > /proc/sys/kernel/printk
|
||||||
|
|
||||||
# unmount pseudofs's
|
# unmount pseudofs's
|
||||||
umount /dev /sys /proc /tmp
|
umount /dev /sys /proc /tmp
|
||||||
@ -158,7 +158,7 @@ if [ "$debug" = 1 ]; then
|
|||||||
set -x
|
set -x
|
||||||
else
|
else
|
||||||
# silence is golden
|
# silence is golden
|
||||||
printf 0 >/proc/sys/kernel/printk
|
printf 0 > /proc/sys/kernel/printk
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#parse_cmdline
|
#parse_cmdline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user