mirror of
https://github.com/RROrg/rr.git
synced 2025-06-21 05:51:05 +08:00
format
This commit is contained in:
parent
ad528f0de2
commit
e873c671ed
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
read_u8() {
|
||||
dd if=$1 bs=1 skip=$(($2)) count=1 2>/dev/null | od -An -tu1 | grep -Eo '[0-9]+'
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Calculate the amount of space needed to run the kernel, including room for
|
||||
# the .bss and .brk sections.
|
||||
|
@ -5,8 +5,8 @@ set -e
|
||||
. /opt/arpl/include/functions.sh
|
||||
|
||||
# Detect if has new local plugins to install/reinstall
|
||||
for F in `ls ${CACHE_PATH}/*.addon 2>/dev/null`; do
|
||||
ADDON=`basename "${F}" | sed 's|.addon||'`
|
||||
for F in $(ls ${CACHE_PATH}/*.addon 2>/dev/null); do
|
||||
ADDON=$(basename "${F}" | sed 's|.addon||')
|
||||
rm -rf "${ADDONS_PATH}/${ADDON}"
|
||||
mkdir -p "${ADDONS_PATH}/${ADDON}"
|
||||
echo "Installing ${F} to ${ADDONS_PATH}/${ADDON}"
|
||||
|
@ -5,15 +5,13 @@
|
||||
# be able to execute in the initramfs/preboot environment (so no bashism etc)
|
||||
# All comments will be stripped, functions here should NOT start with brp_ as they're not part of the builder
|
||||
|
||||
|
||||
if [ -z ${SED_PATH+x} ]; then
|
||||
echo "Your SED_PATH variable is not set/is empty!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
##$1 from, $2 to, $3 file to path
|
||||
_replace_in_file()
|
||||
{
|
||||
_replace_in_file() {
|
||||
if grep -q "$1" "$3"; then
|
||||
$SED_PATH -i "$3" -e "s#$1#$2#"
|
||||
fi
|
||||
@ -22,12 +20,11 @@ _replace_in_file()
|
||||
# Replace/remove/add values in .conf K=V file
|
||||
#
|
||||
# Args: $1 name, $2 new_val, $3 path
|
||||
_set_conf_kv()
|
||||
{
|
||||
_set_conf_kv() {
|
||||
# Delete
|
||||
if [ -z "$2" ]; then
|
||||
$SED_PATH -i "$3" -e "s/^$1=.*$//"
|
||||
return 0;
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Replace
|
||||
|
@ -4,8 +4,7 @@
|
||||
# possible (which turns out to be via init/main.c => load_default_modules => load_default_elevator_module
|
||||
# When the kernel is booted with "elevator=elevator" it will attempt to load a module "elevator-iosched"... and the rest
|
||||
# should be obvious from the code below. DO NOT print anything here (kernel doesn't attach STDOUT)
|
||||
for arg in "$@"
|
||||
do
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "elevator-iosched" ]; then
|
||||
insmod /usr/lib/modules/rp.ko
|
||||
rm /usr/lib/modules/rp.ko
|
||||
|
@ -1,28 +1,28 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
# Based on code and ideas from @jumkey
|
||||
|
||||
. /opt/arpl/include/functions.sh
|
||||
|
||||
MODEL="`readConfigKey "model" "${USER_CONFIG_FILE}"`"
|
||||
BUILD="`readConfigKey "build" "${USER_CONFIG_FILE}"`"
|
||||
KVER="`readModelKey "${MODEL}" "builds.${BUILD}.kver"`"
|
||||
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
|
||||
BUILD="$(readConfigKey "build" "${USER_CONFIG_FILE}")"
|
||||
KVER="$(readModelKey "${MODEL}" "builds.${BUILD}.kver")"
|
||||
|
||||
# Adapted from: scripts/Makefile.lib
|
||||
# Usage: size_append FILE [FILE2] [FILEn]...
|
||||
# Output: LE HEX with size of file in bytes (to STDOUT)
|
||||
file_size_le() {
|
||||
printf $(
|
||||
dec_size=0;
|
||||
dec_size=0
|
||||
for F in "${@}"; do
|
||||
fsize=$(stat -c "%s" ${F});
|
||||
dec_size=$(expr ${dec_size} + ${fsize});
|
||||
done;
|
||||
fsize=$(stat -c "%s" ${F})
|
||||
dec_size=$(expr ${dec_size} + ${fsize})
|
||||
done
|
||||
printf "%08x\n" ${dec_size} |
|
||||
sed 's/\(..\)/\1 /g' | {
|
||||
read ch0 ch1 ch2 ch3;
|
||||
read ch0 ch1 ch2 ch3
|
||||
for ch in ${ch3} ${ch2} ${ch1} ${ch0}; do
|
||||
printf '%s%03o' '\' $((0x${ch}));
|
||||
done;
|
||||
printf '%s%03o' '\' $((0x${ch}))
|
||||
done
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -31,14 +31,14 @@ size_le () {
|
||||
printf $(
|
||||
printf "%08x\n" "${@}" |
|
||||
sed 's/\(..\)/\1 /g' | {
|
||||
read ch0 ch1 ch2 ch3;
|
||||
read ch0 ch1 ch2 ch3
|
||||
for ch in ${ch3} ${ch2} ${ch1} ${ch0}; do
|
||||
printf '%s%03o' '\' $((0x${ch}));
|
||||
done;
|
||||
printf '%s%03o' '\' $((0x${ch}))
|
||||
done
|
||||
}
|
||||
)
|
||||
}
|
||||
SCRIPT_DIR=`dirname $0`
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
VMLINUX_MOD=${1}
|
||||
ZIMAGE_MOD=${2}
|
||||
KVER_MAJOR=${KVER:0:1}
|
||||
@ -64,9 +64,9 @@ if [ $KVER_MAJOR -eq 4 ] || [ $KVER_MAJOR -eq 3 ]; then
|
||||
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745134 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
|
||||
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745244 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
|
||||
|
||||
RUN_SIZE=`objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh"`
|
||||
RUN_SIZE=$(objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh")
|
||||
size_le ${RUN_SIZE} | dd of=${ZIMAGE_MOD} bs=15745210 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
|
||||
size_le $(($((16#`crc32 "${ZIMAGE_MOD}" | awk '{print$1}'`)) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
|
||||
size_le $(($((16#$(crc32 "${ZIMAGE_MOD}" | awk '{print$1}'))) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
|
||||
else
|
||||
# Kernel version 5.x
|
||||
gzip -dc "${SCRIPT_DIR}/bzImage-template-v5.gz" >"${ZIMAGE_MOD}"
|
||||
@ -76,5 +76,5 @@ else
|
||||
file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=34479132 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
|
||||
# RUN_SIZE=`objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh"`
|
||||
# size_le ${RUN_SIZE} | dd of=${ZIMAGE_MOD} bs=34626904 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog
|
||||
size_le $(($((16#`crc32 "${ZIMAGE_MOD}" | awk '{print$1}'`)) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
|
||||
size_le $(($((16#$(crc32 "${ZIMAGE_MOD}" | awk '{print$1}'))) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user