rename vars
This commit is contained in:
parent
ee011f3a20
commit
def645a883
@ -10,6 +10,7 @@ panic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_cmdline() {
|
parse_cmdline() {
|
||||||
|
|
||||||
# store output in variable
|
# store output in variable
|
||||||
read -r cmdline < /proc/cmdline
|
read -r cmdline < /proc/cmdline
|
||||||
|
|
||||||
@ -143,8 +144,8 @@ cleanup() {
|
|||||||
|
|
||||||
boot_system() {
|
boot_system() {
|
||||||
exec switch_root /mnt/root \
|
exec switch_root /mnt/root \
|
||||||
${init:-/sbin/init} ||
|
${init:-/sbin/init} ||
|
||||||
panic "failed to boot system"
|
panic "failed to boot system"
|
||||||
}
|
}
|
||||||
|
|
||||||
/sbin/busybox --install -s
|
/sbin/busybox --install -s
|
||||||
|
90
tinyramfs
90
tinyramfs
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
msg() {
|
msg() {
|
||||||
# print message
|
# print message
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
info)
|
info)
|
||||||
printf "info >> %s\n" "$2" >&2
|
printf "info >> %s\n" "$2" >&2
|
||||||
@ -22,6 +23,7 @@ msg() {
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
# TODO more options
|
# TODO more options
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
usage: $0 [options]
|
usage: $0 [options]
|
||||||
-o, --output <file> output file
|
-o, --output <file> output file
|
||||||
@ -105,19 +107,19 @@ install_requirements() {
|
|||||||
|
|
||||||
# install user specified binaries
|
# install user specified binaries
|
||||||
[ "$binaries" ] &&
|
[ "$binaries" ] &&
|
||||||
for custom_binary in $binaries; do
|
for _binary in $binaries; do
|
||||||
install_binary "$custom_binary"
|
install_binary "$_binary"
|
||||||
done
|
done
|
||||||
|
|
||||||
# install util-linux binaries
|
# install util-linux binaries
|
||||||
[ "$util_linux" = 1 ] &&
|
[ "$util_linux" = 1 ] &&
|
||||||
for util_linux_binary in mount blkid; do
|
for _binary in mount blkid; do
|
||||||
install_binary "$util_linux_binary"
|
install_binary "$_binary"
|
||||||
done
|
done
|
||||||
|
|
||||||
# install mandatory binaries
|
# install mandatory binaries
|
||||||
for main_binary in busybox modprobe; do
|
for _binary in busybox modprobe; do
|
||||||
install_binary "$main_binary"
|
install_binary "$_binary"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +148,8 @@ install_devmgr() {
|
|||||||
|
|
||||||
case "$devmgr" in
|
case "$devmgr" in
|
||||||
udev)
|
udev)
|
||||||
for udev_binary in udevd udevadm dmsetup; do
|
for _binary in udevd udevadm dmsetup; do
|
||||||
install_binary "$udev_binary"
|
install_binary "$_binary"
|
||||||
done
|
done
|
||||||
|
|
||||||
find /usr/lib/udev \
|
find /usr/lib/udev \
|
||||||
@ -162,8 +164,8 @@ install_devmgr() {
|
|||||||
install -Dm755 "${filesdir}/storage-device" "${workdir}/lib/mdev/storage-device"
|
install -Dm755 "${filesdir}/storage-device" "${workdir}/lib/mdev/storage-device"
|
||||||
;;
|
;;
|
||||||
mdevd)
|
mdevd)
|
||||||
for mdevd_binary in mdevd mdevd-coldplug; do
|
for _binary in mdevd mdevd-coldplug; do
|
||||||
install_binary "$mdevd_binary"
|
install_binary "$_binary"
|
||||||
done
|
done
|
||||||
|
|
||||||
install -m644 "${filesdir}/mdev.conf" "${workdir}/etc/mdev.conf"
|
install -m644 "${filesdir}/mdev.conf" "${workdir}/etc/mdev.conf"
|
||||||
@ -181,8 +183,8 @@ install_lvm() {
|
|||||||
install_binary lvm
|
install_binary lvm
|
||||||
|
|
||||||
[ "$hostonly" = 1 ] &&
|
[ "$hostonly" = 1 ] &&
|
||||||
for lvm_driver in dm-thin-pool dm-multipath dm-snapshot dm-cache dm-log dm-mirror; do
|
for _driver in dm-thin-pool dm-multipath dm-snapshot dm-cache dm-log dm-mirror; do
|
||||||
install_driver "$lvm_driver"
|
install_driver "$_driver"
|
||||||
done
|
done
|
||||||
|
|
||||||
# install lvm config
|
# install lvm config
|
||||||
@ -214,8 +216,8 @@ install_luks() {
|
|||||||
install_binary cryptsetup
|
install_binary cryptsetup
|
||||||
|
|
||||||
[ "$hostonly" = 1 ] &&
|
[ "$hostonly" = 1 ] &&
|
||||||
for luks_driver in aes dm-crypt sha256 sha512 wp512 ecb lrw xts twofish serpent; do
|
for _driver in aes dm-crypt sha256 sha512 wp512 ecb lrw xts twofish serpent; do
|
||||||
install_driver "$luks_driver"
|
install_driver "$_driver"
|
||||||
done
|
done
|
||||||
|
|
||||||
# avoid "locking directory missing" warning
|
# avoid "locking directory missing" warning
|
||||||
@ -248,19 +250,19 @@ install_driver() {
|
|||||||
|
|
||||||
modprobe -S "$kernel" -D "$driver" 2> /dev/null |
|
modprobe -S "$kernel" -D "$driver" 2> /dev/null |
|
||||||
|
|
||||||
while read -r full_driver; do
|
while read -r driver; do
|
||||||
|
|
||||||
# strip unneeded stuff
|
# strip unneeded stuff
|
||||||
full_driver="${full_driver##*builtin*}"
|
driver="${driver##*builtin*}"
|
||||||
full_driver="${full_driver##*net*}"
|
driver="${driver##*net*}"
|
||||||
full_driver="${full_driver#insmod }"
|
driver="${driver#insmod }"
|
||||||
|
|
||||||
# check empty
|
# check empty
|
||||||
[ "$full_driver" ] || continue
|
[ "$driver" ] || continue
|
||||||
|
|
||||||
# check if already installed
|
# check if driver already installed
|
||||||
[ -e "${workdir}${full_driver}" ] ||
|
[ -e "${workdir}${driver}" ] ||
|
||||||
install -Dm644 "$full_driver" "${workdir}${full_driver}"
|
install -Dm644 "$driver" "${workdir}${driver}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,8 +275,8 @@ install_hostonly_drivers() {
|
|||||||
# perform autodetection of drivers via /sys
|
# perform autodetection of drivers via /sys
|
||||||
find /sys -name modalias -exec sort -u {} + |
|
find /sys -name modalias -exec sort -u {} + |
|
||||||
|
|
||||||
while read -r alias_driver; do
|
while read -r _driver; do
|
||||||
install_driver "$alias_driver"
|
install_driver "$_driver"
|
||||||
done
|
done
|
||||||
|
|
||||||
# install root fs driver
|
# install root fs driver
|
||||||
@ -282,8 +284,8 @@ install_hostonly_drivers() {
|
|||||||
|
|
||||||
# install user specified drivers
|
# install user specified drivers
|
||||||
[ "$drivers" ] &&
|
[ "$drivers" ] &&
|
||||||
for custom_driver in $drivers; do
|
for _driver in $drivers; do
|
||||||
install_driver "$custom_driver"
|
install_driver "$_driver"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,13 +306,13 @@ install_all_drivers() {
|
|||||||
"${modker}/kernel/drivers/virtio" \
|
"${modker}/kernel/drivers/virtio" \
|
||||||
-type f 2> /dev/null |
|
-type f 2> /dev/null |
|
||||||
|
|
||||||
while read -r path_driver; do
|
while read -r _driver; do
|
||||||
|
|
||||||
# strip path and extension
|
# strip path and extension
|
||||||
path_driver="${path_driver##*/}"
|
_driver="${_driver##*/}"
|
||||||
path_driver="${path_driver%%.*}"
|
_driver="${_driver%%.*}"
|
||||||
|
|
||||||
install_driver "$path_driver"
|
install_driver "$_driver"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,49 +327,47 @@ generate_depmod() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_binary() {
|
install_binary() {
|
||||||
binary="$1"
|
binary=$(command -v "$1")
|
||||||
fullbin=$(command -v "$binary")
|
|
||||||
workdirbin="${workdir}/usr/bin/"
|
workdirbin="${workdir}/usr/bin/"
|
||||||
|
|
||||||
# check if binary exists
|
# check if binary exists
|
||||||
[ "$fullbin" ] || msg panic "$binary doesn't exists"
|
[ "$binary" ] || msg panic "$binary doesn't exists"
|
||||||
|
|
||||||
# check if binary already installed
|
# check if binary already installed
|
||||||
[ -e "${workdirbin}${fullbin##*/}" ] && return
|
[ -e "${workdirbin}${binary##*/}" ] && return
|
||||||
|
|
||||||
# install and strip binary
|
# install and strip binary
|
||||||
install -s -m755 "$fullbin" "${workdirbin}${fullbin##*/}"
|
install -s -m755 "$binary" "${workdirbin}${binary##*/}"
|
||||||
|
|
||||||
# check static
|
# check static
|
||||||
ldd "$fullbin" > /dev/null 2>&1 || return
|
ldd "$binary" > /dev/null 2>&1 || return
|
||||||
|
|
||||||
# exract paths to libraries
|
# exract paths to libraries
|
||||||
ldd "$fullbin" |
|
ldd "$binary" |
|
||||||
|
|
||||||
while read -r library; do
|
while read -r _library; do
|
||||||
|
|
||||||
# strip unneeded stuff
|
# strip unneeded stuff
|
||||||
library="${library##*vdso*}"
|
_library="${_library##*vdso*}"
|
||||||
library="${library#* => }"
|
_library="${_library#* => }"
|
||||||
library="${library% *}"
|
_library="${_library% *}"
|
||||||
|
|
||||||
# check empty
|
# check empty
|
||||||
[ "$library" ] || continue
|
[ "$_library" ] || continue
|
||||||
|
|
||||||
install_library "$library"
|
install_library "$_library"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
install_library() {
|
install_library() {
|
||||||
library="$1"
|
library="$1"
|
||||||
namelib="${library##*/}"
|
|
||||||
reallib="/usr/lib/$(readlink "$library")"
|
reallib="/usr/lib/$(readlink "$library")"
|
||||||
fulllib=$(readlink -f "$library")
|
fulllib=$(readlink -f "$library")
|
||||||
workdirlib="${workdir}/usr/lib/"
|
workdirlib="${workdir}/usr/lib/"
|
||||||
|
|
||||||
# check if library already installed
|
# check if library already installed
|
||||||
[ -e "${workdirlib}${fulllib##*/}" ] &&
|
[ -e "${workdirlib}${fulllib##*/}" ] &&
|
||||||
[ -e "${workdirlib}${namelib}" ] &&
|
[ -e "${workdirlib}${library##*/}" ] &&
|
||||||
return
|
return
|
||||||
|
|
||||||
# install symlinks if any
|
# install symlinks if any
|
||||||
|
Loading…
Reference in New Issue
Block a user