formatting

This commit is contained in:
illiliti 2020-02-11 21:02:23 +03:00
parent 3608109b78
commit a0bd4caf46
2 changed files with 153 additions and 151 deletions

View File

@ -57,18 +57,18 @@ check_requirements() {
msg info "checking requirements"
# check busybox installed
command -v busybox >/dev/null 2>&1 && {
command -v busybox > /dev/null 2>&1 && {
# check busybox supports CONFIG_FEATURE_INSTALLER
busybox --help | grep -q "\-\-install \[\-s\]" || msg panic "recompile busybox with CONFIG_FEATURE_INSTALLER"
# check requirements for init
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
} || msg panic "busybox doesn't 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)
modprobe --version 2>&1 | grep -q "kmod" || msg panic "kmod modprobe version doesn't installed"
} || msg panic "modprobe doesn't installed"
@ -76,7 +76,7 @@ check_requirements() {
# check util-linux tools
[ "$use_util_linux" = 1 ] && {
# 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" || {
msg warning "util-linux mount version doesn't installed. PARTUUID and filesystem type autodetection support will be missing"
use_util_linux=0
@ -86,7 +86,7 @@ check_requirements() {
fi
# 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" || {
msg warning "util-linux blkid version doesn't installed. PARTUUID support will be missing"
use_util_linux=0
@ -166,7 +166,7 @@ install_udev() {
msg info "installing udev"
install_binaries udevd udevadm dmsetup
# 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
@ -177,7 +177,7 @@ install_lvm() {
# if hostonly mode enabled install only needed drivers
[ "$hostonly" = 1 ] && {
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}"
done
done
@ -187,7 +187,7 @@ install_lvm() {
install -Dm644 /etc/lvm/*.conf -t "${tmpdir}/etc/lvm" || msg panic "failed to install LVM config"
else
mkdir "${tmpdir}/etc/lvm"
cat <<EOF > "${tmpdir}/etc/lvm/lvm.conf"
cat << EOF > "${tmpdir}/etc/lvm/lvm.conf"
devices {
issue_discards = ${lvm_discard:-0}
}
@ -207,7 +207,7 @@ install_luks() {
# if hostonly mode enabled install only needed drivers
[ "$hostonly" = 1 ] && {
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}"
done
done
@ -243,7 +243,7 @@ install_drivers() {
# perform autodetection of drivers via /sys
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}"
done
done
@ -251,14 +251,14 @@ install_drivers() {
# TODO autodetect root fs driver
# TODO separate root type option
# 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}"
done
# install user specified drivers
[ -n "$drivers" ] && {
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}"
done
done
@ -280,7 +280,7 @@ install_all_drivers() {
"${modker}/kernel/drivers/usb/storage" \
"${modker}/kernel/drivers/usb/host" \
"${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
@ -299,13 +299,13 @@ install_binaries() {
printf "%s\n" "$@" | while read -r binary; do
msg info "installing binary $binary"
# 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 -s -m755 "$(command -v $binary)" -t "${tmpdir}/usr/bin"
# 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 $binary
@ -344,7 +344,7 @@ install_files() {
msg info "installing files"
# FIXME eof broken
# initialize config
cat <<EOF > "${tmpdir}/config"
cat << EOF > "${tmpdir}/config"
debug="$debug"
root="$root"
root_type="$root_type"
@ -358,7 +358,7 @@ luks_args="$luks_args"
EOF
# needed for devmgr
cat <<EOF > "${tmpdir}/etc/group"
cat << EOF > "${tmpdir}/etc/group"
root:x:0:
tty:x:5:
dialout:x:11:
@ -376,7 +376,7 @@ floppy:x:8:
EOF
# needed for devmgr
cat <<EOF > "${tmpdir}/etc/passwd"
cat << EOF > "${tmpdir}/etc/passwd"
root:x:0:0::/root:/bin/sh
nobody:x:99:99::/:/bin/false
EOF
@ -390,12 +390,14 @@ EOF
create_initramfs() {
msg info "creating initramfs image"
{
( cd "$tmpdir"
find . |
cpio -oH newc |
gzip -9 ) |
tee "${script_dir}/initramfs-${kernel}.img.gz"
} >/dev/null 2>&1 || msg panic "failed to generate initramfs image"
(
cd "$tmpdir"
find . \
| cpio -oH newc \
| gzip -9
) \
| tee "${script_dir}/initramfs-${kernel}.img.gz"
} > /dev/null 2>&1 || msg panic "failed to generate initramfs image"
}
# check root

10
init
View File

@ -22,7 +22,7 @@ mnt_pseudofs() {
use_mdev() {
# setup hotplugger
if [ -e /proc/sys/kernel/hotplug ]; then
printf /sbin/mdev >/proc/sys/kernel/hotplug
printf /sbin/mdev > /proc/sys/kernel/hotplug
else
uevent mdev &
fi
@ -100,7 +100,7 @@ unlock_luks() {
# manually trigger LVM if udev disabled
trigger_lvm() {
lvm vgchange --quiet --sysinit -a y >/dev/null
lvm vgchange --quiet --sysinit -a y > /dev/null
}
# mount rootfs to /mnt/root
@ -121,7 +121,7 @@ cleanup() {
case "$devmgr" in
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)
# stop mdevd
@ -135,7 +135,7 @@ cleanup() {
# TODO re-do
# 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
umount /dev /sys /proc /tmp
@ -158,7 +158,7 @@ if [ "$debug" = 1 ]; then
set -x
else
# silence is golden
printf 0 >/proc/sys/kernel/printk
printf 0 > /proc/sys/kernel/printk
fi
#parse_cmdline