huge rework
This commit is contained in:
parent
347d0d2d01
commit
81f7aac01a
@ -66,7 +66,7 @@ setup_mdev() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# load drivers
|
# load drivers
|
||||||
find /sys -name modalias -type f -exec sort -u "{}" "+" |
|
find /sys -name modalias -type f -exec sort -u {} + |
|
||||||
xargs modprobe -qba
|
xargs modprobe -qba
|
||||||
}
|
}
|
||||||
|
|
||||||
|
118
tinyramfs
118
tinyramfs
@ -96,14 +96,20 @@ install_requirements() {
|
|||||||
|
|
||||||
# install user specified binaries
|
# install user specified binaries
|
||||||
[ "$binaries" ] &&
|
[ "$binaries" ] &&
|
||||||
install_binary "$binaries"
|
for custom_binary in $binaries; do
|
||||||
|
install_binary "$custom_binary"
|
||||||
|
done
|
||||||
|
|
||||||
# install util-linux binaries
|
# install util-linux binaries
|
||||||
[ "$util_linux" = 1 ] &&
|
[ "$util_linux" = 1 ] &&
|
||||||
install_binary mount blkid
|
for util_linux_binary in mount blkid; do
|
||||||
|
install_binary "$util_linux_binary"
|
||||||
|
done
|
||||||
|
|
||||||
# install mandatory binaries
|
# install mandatory binaries
|
||||||
install_binary busybox modprobe
|
for main_binary in busybox modprobe; do
|
||||||
|
install_binary "$main_binary"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
create_structure() {
|
create_structure() {
|
||||||
@ -136,11 +142,13 @@ create_symlinks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_devmgr() {
|
install_devmgr() {
|
||||||
|
msg info "installing device manager"
|
||||||
|
|
||||||
case "$devmgr" in
|
case "$devmgr" in
|
||||||
udev)
|
udev)
|
||||||
msg info "installing udev"
|
for udev_binary in udevd udevadm dmsetup; do
|
||||||
|
install_binary "$udev_binary"
|
||||||
install_binary udevd udevadm dmsetup
|
done
|
||||||
|
|
||||||
find /usr/lib/udev \
|
find /usr/lib/udev \
|
||||||
! -path "*rc_keymaps*" \
|
! -path "*rc_keymaps*" \
|
||||||
@ -151,8 +159,6 @@ install_devmgr() {
|
|||||||
msg panic "failed to install udev"
|
msg panic "failed to install udev"
|
||||||
;;
|
;;
|
||||||
mdev)
|
mdev)
|
||||||
msg info "installing mdev"
|
|
||||||
|
|
||||||
install -m644 "${filesdir}/mdev.conf" \
|
install -m644 "${filesdir}/mdev.conf" \
|
||||||
"${workdir}/etc/mdev.conf"
|
"${workdir}/etc/mdev.conf"
|
||||||
|
|
||||||
@ -160,9 +166,9 @@ install_devmgr() {
|
|||||||
"${workdir}/lib/mdev/storage-device"
|
"${workdir}/lib/mdev/storage-device"
|
||||||
;;
|
;;
|
||||||
mdevd)
|
mdevd)
|
||||||
msg info "installing mdevd"
|
for mdevd_binary in mdevd mdevd-coldplug; do
|
||||||
|
install_binary "$mdevd_binary"
|
||||||
install_binary mdevd mdevd-coldplug
|
done
|
||||||
|
|
||||||
install -m644 "${filesdir}/mdev.conf" \
|
install -m644 "${filesdir}/mdev.conf" \
|
||||||
"${workdir}/etc/mdev.conf"
|
"${workdir}/etc/mdev.conf"
|
||||||
@ -181,9 +187,10 @@ install_lvm() {
|
|||||||
|
|
||||||
install_binary lvm
|
install_binary lvm
|
||||||
|
|
||||||
lvm_drivers="dm-thin-pool dm-multipath dm-snapshot dm-cache dm-log dm-mirror"
|
|
||||||
[ "$hostonly" = 1 ] &&
|
[ "$hostonly" = 1 ] &&
|
||||||
install_driver "$lvm_drivers"
|
for lvm_driver in dm-thin-pool dm-multipath dm-snapshot dm-cache dm-log dm-mirror; do
|
||||||
|
install_driver "$lvm_driver"
|
||||||
|
done
|
||||||
|
|
||||||
# install lvm config
|
# install lvm config
|
||||||
if [ "$lvm_conf" = 1 ]; then
|
if [ "$lvm_conf" = 1 ]; then
|
||||||
@ -211,20 +218,18 @@ install_luks() {
|
|||||||
|
|
||||||
install_binary cryptsetup
|
install_binary cryptsetup
|
||||||
|
|
||||||
luks_drivers="aes dm-crypt sha256 sha512 wp512 ecb lrw xts twofish serpent"
|
|
||||||
[ "$hostonly" = 1 ] &&
|
[ "$hostonly" = 1 ] &&
|
||||||
install_driver "$luks_drivers"
|
for luks_driver in aes dm-crypt sha256 sha512 wp512 ecb lrw xts twofish serpent; do
|
||||||
|
install_driver "$luks_driver"
|
||||||
|
done
|
||||||
|
|
||||||
# avoid "locking directory missing" warning
|
# avoid "locking directory missing" warning
|
||||||
# message and libgcc_s.so.1 missing error
|
# message and libgcc_s.so.1 missing error
|
||||||
# see https://bugs.archlinux.org/task/56771
|
# see https://bugs.archlinux.org/task/56771
|
||||||
mkdir -p "${workdir}/run/cryptsetup"
|
mkdir -p "${workdir}/run/cryptsetup"
|
||||||
|
|
||||||
[ -e /usr/lib/libgcc_s.so.1 ] && {
|
[ -e /usr/lib/libgcc_s.so.1 ] &&
|
||||||
install -s -m755 /usr/lib/libgcc_s.so.1 \
|
install_library /usr/lib/libgcc_s.so.1
|
||||||
"${workdir}/usr/lib/libgcc_s.so.1" ||
|
|
||||||
msg panic "failed to install LUKS libraries"
|
|
||||||
}
|
|
||||||
|
|
||||||
# copy luks header
|
# copy luks header
|
||||||
[ -f "$luks_header" ] && {
|
[ -f "$luks_header" ] && {
|
||||||
@ -249,11 +254,7 @@ install_driver() {
|
|||||||
# check monolithic kernel(builtin drivers)
|
# check monolithic kernel(builtin drivers)
|
||||||
[ -d "${moddir}/${kernel}" ] || return
|
[ -d "${moddir}/${kernel}" ] || return
|
||||||
|
|
||||||
# we need splitting
|
driver="$1"
|
||||||
# shellcheck disable=SC2068
|
|
||||||
for driver in $@; do
|
|
||||||
|
|
||||||
# strip path and extension if any
|
|
||||||
driver="${driver##*/}"
|
driver="${driver##*/}"
|
||||||
driver="${driver%%.*}"
|
driver="${driver%%.*}"
|
||||||
|
|
||||||
@ -262,10 +263,13 @@ install_driver() {
|
|||||||
grep -v "builtin\|net" |
|
grep -v "builtin\|net" |
|
||||||
cut -d " " -f 2 |
|
cut -d " " -f 2 |
|
||||||
|
|
||||||
while read -r driver_dep; do
|
while read -r full_driver; do
|
||||||
install -Dm644 "$driver_dep" \
|
# check if driver already installed
|
||||||
"${workdir}${driver_dep}"
|
[ -e "${workdir}${full_driver}" ] &&
|
||||||
done
|
continue
|
||||||
|
|
||||||
|
install -Dm644 "$full_driver" \
|
||||||
|
"${workdir}${full_driver}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +280,11 @@ install_hostonly_drivers() {
|
|||||||
msg panic "hostonly mode required root_type option to be configured"
|
msg panic "hostonly mode required root_type option to be configured"
|
||||||
|
|
||||||
# perform autodetection of drivers via /sys
|
# perform autodetection of drivers via /sys
|
||||||
install_driver "$(find /sys -name modalias -exec sort -u "{}" "+")"
|
find /sys -name modalias -exec sort -u {} + |
|
||||||
|
|
||||||
|
while read -r alias_driver; do
|
||||||
|
install_driver "$alias_driver"
|
||||||
|
done
|
||||||
|
|
||||||
# TODO autodetect root fs driver
|
# TODO autodetect root fs driver
|
||||||
# TODO separate root type option
|
# TODO separate root type option
|
||||||
@ -285,7 +293,9 @@ install_hostonly_drivers() {
|
|||||||
|
|
||||||
# install user specified drivers
|
# install user specified drivers
|
||||||
[ "$drivers" ] &&
|
[ "$drivers" ] &&
|
||||||
install_driver "$drivers"
|
for custom_driver in $drivers; do
|
||||||
|
install_driver "$custom_driver"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
install_all_drivers() {
|
install_all_drivers() {
|
||||||
@ -293,8 +303,7 @@ install_all_drivers() {
|
|||||||
|
|
||||||
modker="${moddir}/${kernel}/kernel"
|
modker="${moddir}/${kernel}/kernel"
|
||||||
|
|
||||||
install_driver \
|
find \
|
||||||
"$(find \
|
|
||||||
"${modker}/arch" \
|
"${modker}/arch" \
|
||||||
"${modker}/crypto" \
|
"${modker}/crypto" \
|
||||||
"${modker}/fs" \
|
"${modker}/fs" \
|
||||||
@ -306,7 +315,11 @@ install_all_drivers() {
|
|||||||
"${modker}/drivers/usb/storage" \
|
"${modker}/drivers/usb/storage" \
|
||||||
"${modker}/drivers/usb/host" \
|
"${modker}/drivers/usb/host" \
|
||||||
"${modker}/drivers/virtio" \
|
"${modker}/drivers/virtio" \
|
||||||
-type f 2> /dev/null)"
|
-type f 2> /dev/null |
|
||||||
|
|
||||||
|
while read -r path_driver; do
|
||||||
|
install_driver "$path_driver"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_depmod() {
|
generate_depmod() {
|
||||||
@ -324,47 +337,45 @@ generate_depmod() {
|
|||||||
install_binary() {
|
install_binary() {
|
||||||
# TODO make strip optional
|
# TODO make strip optional
|
||||||
|
|
||||||
workdirbin="${workdir}/usr/bin/"
|
binary="$1"
|
||||||
|
|
||||||
# we need splitting
|
|
||||||
# shellcheck disable=SC2068
|
|
||||||
for binary in $@; do
|
|
||||||
msg info "installing binary $binary"
|
|
||||||
|
|
||||||
fullbin=$(command -v "$binary")
|
fullbin=$(command -v "$binary")
|
||||||
|
workdirbin="${workdir}/usr/bin/"
|
||||||
|
|
||||||
# check if binary exists
|
# check if binary exists
|
||||||
[ "$fullbin" ] ||
|
[ "$fullbin" ] ||
|
||||||
msg panic "$binary doesn't exists"
|
msg panic "$binary doesn't exists"
|
||||||
|
|
||||||
|
# check if binary already installed
|
||||||
|
[ -e "${workdirbin}${fullbin##*/}" ] &&
|
||||||
|
return
|
||||||
|
|
||||||
# install and strip binary
|
# install and strip binary
|
||||||
install -s -m755 "$fullbin" \
|
install -s -m755 "$fullbin" \
|
||||||
"${workdirbin}${fullbin##*/}"
|
"${workdirbin}${fullbin##*/}"
|
||||||
|
|
||||||
# check static
|
# check static
|
||||||
ldd "$fullbin" > /dev/null 2>&1 ||
|
ldd "$fullbin" > /dev/null 2>&1 ||
|
||||||
continue
|
return
|
||||||
|
|
||||||
# install libraries
|
# exract paths to libraries
|
||||||
install_library "$binary"
|
ldd $(command -v "$binary") |
|
||||||
|
sed -nr \
|
||||||
|
-e 's,.* (/.*lib.*/.*.so.*) .*,\1,p' \
|
||||||
|
-e 's,.*(/lib.*/ld.*.so.*) .*,\1,p' |
|
||||||
|
|
||||||
|
while read -r library; do
|
||||||
|
install_library "$library"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
install_library() {
|
install_library() {
|
||||||
# TODO make strip optional
|
# TODO make strip optional
|
||||||
|
|
||||||
workdirlib="${workdir}/usr/lib/"
|
library="$1"
|
||||||
|
|
||||||
# extract paths to libraries from ldd output
|
|
||||||
ldd $(command -v "$1") |
|
|
||||||
sed -nr \
|
|
||||||
-e 's,.* (/.*lib.*/.*.so.*) .*,\1,p' \
|
|
||||||
-e 's,.*(/lib.*/ld.*.so.*) .*,\1,p' |
|
|
||||||
|
|
||||||
while read -r library; do
|
|
||||||
namelib="${library##*/}"
|
namelib="${library##*/}"
|
||||||
reallib=$(readlink "$library")
|
reallib=$(readlink "$library")
|
||||||
fulllib=$(readlink -f "$library")
|
fulllib=$(readlink -f "$library")
|
||||||
|
workdirlib="${workdir}/usr/lib/"
|
||||||
|
|
||||||
# check symlink
|
# check symlink
|
||||||
if [ -h "$library" ]; then
|
if [ -h "$library" ]; then
|
||||||
@ -391,7 +402,6 @@ install_library() {
|
|||||||
install -s -m755 "$library" \
|
install -s -m755 "$library" \
|
||||||
"${workdirlib}${namelib}"
|
"${workdirlib}${namelib}"
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_files() {
|
install_files() {
|
||||||
|
Loading…
Reference in New Issue
Block a user