tree: reformate part 1

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-05-07 22:45:15 +02:00
parent ecd82e1c04
commit 8cafe04730
11 changed files with 266 additions and 183 deletions

View File

@ -37,7 +37,7 @@ function addonSelection() {
# read platform and kernel version to check if addon exists
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
# read addons from user config
unset ADDONS
declare -A ADDONS
@ -73,10 +73,9 @@ function addonSelection() {
###############################################################################
# Permit user select the modules to include
function modulesMenu() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
# Modify KVER for Epyc7002
if [ "${PLATFORM}" = "epyc7002" ]; then
KVERP="${PRODUCTVER}-${KVER}"
@ -916,11 +915,10 @@ function updateMenu() {
--msgbox "Error downloading Updatefile!" 0 0
return 1
fi
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
if [[ -n "${MODEL}" && -n "${PRODUCTVER}" ]]; then
PLATFORM="$(readModelKey "${MODEL}" "platform")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
if [ -n "${PRODUCTVER}" ]; then
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
if [ "${PLATFORM}" = "epyc7002" ]; then
KVERP="${PRODUCTVER}-${KVER}"
else
@ -1077,9 +1075,9 @@ function sysinfo() {
if [ "${CONFDONE}" = "true" ]; then
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")"
REMAP="$(readConfigKey "arc.remap" "${USER_CONFIG_FILE}")"
@ -1306,9 +1304,9 @@ function fullsysinfo() {
if [ "${CONFDONE}" = "true" ]; then
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")"
REMAP="$(readConfigKey "arc.remap" "${USER_CONFIG_FILE}")"

View File

@ -49,29 +49,31 @@ KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
# Get DSM Data from Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")"
if [ -n "${MODEL}" ]; then
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
fi
# Get Arc Data from Config
DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")"
ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
BOOTIPWAIT="$(readConfigKey "arc.bootipwait" "${USER_CONFIG_FILE}")"
DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")"
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")"
KERNEL="$(readConfigKey "arc.kernel" "${USER_CONFIG_FILE}")"
KERNELLOAD="$(readConfigKey "arc.kernelload" "${USER_CONFIG_FILE}")"
KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")"
MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")"
ODP="$(readConfigKey "arc.odp" "${USER_CONFIG_FILE}")"
HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")"
KERNEL="$(readConfigKey "arc.kernel" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
RD_COMPRESSED="$(readConfigKey "rd-compressed" "${USER_CONFIG_FILE}")"
SATADOM="$(readConfigKey "satadom" "${USER_CONFIG_FILE}")"
USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")"
ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")"
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")"
SATACONTROLLER="$(readConfigKey "device.satacontroller" "${USER_CONFIG_FILE}")"
SCSICONTROLLER="$(readConfigKey "device.sciscontroller" "${USER_CONFIG_FILE}")"
@ -107,7 +109,7 @@ function backtitle() {
IPCON="(IP)"
fi
BACKTITLE="${ARC_TITLE} | "
BACKTITLE+="${MODEL} | "
BACKTITLE+="${MODEL}(${PLATFORM}) | "
BACKTITLE+="${PRODUCTVER} | "
BACKTITLE+="${IPCON} | "
BACKTITLE+="Patch: ${ARCPATCH} | "
@ -242,11 +244,11 @@ function arcModel() {
function arcVersion() {
# read model values for arcbuild
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
if [ "${CUSTOM}" = "false" ]; then
# Select Build for DSM
ITEMS="$(readConfigEntriesArray "productvers" "${MODEL_CONFIG_PATH}/${MODEL}.yml" | sort -r)"
ITEMS="$(readConfigEntriesArray "platforms.${PLATFORM}.productvers" "${P_FILE}" | sort -r)"
dialog --clear --no-items --nocancel --backtitle "$(backtitle)" \
--menu "Choose a Version" 7 30 0 ${ITEMS} 2>"${TMP_PATH}/resp"
resp=$(cat ${TMP_PATH}/resp)
@ -266,7 +268,7 @@ function arcVersion() {
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
fi
fi
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
# Modify KVER for Epyc7002
if [ "${PLATFORM}" = "epyc7002" ]; then
KVERP="${PRODUCTVER}-${KVER}"
@ -479,9 +481,8 @@ function arcSettings() {
function premake() {
# Read Model Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
DT="$(readModelKey "${MODEL}" "dt")"
# Read Config for Arc Settings
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
@ -510,9 +511,9 @@ function premake() {
function arcSummary() {
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
ADDONSINFO="$(readConfigEntriesArray "addons" "${USER_CONFIG_FILE}")"
REMAP="$(readConfigKey "arc.remap" "${USER_CONFIG_FILE}")"
@ -587,7 +588,7 @@ function arcSummary() {
function make() {
# Read Model Config
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
@ -1121,9 +1122,9 @@ else
ODP="false"
writeConfigKey "arc.odp" "${ODP}" "${USER_CONFIG_FILE}"
fi
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
if [[ -n "${PLATFORM}" && -n "${KVER}" ]]; then
if [ "${PLATFORM}" = "epyc7002" ]; then
KVERP="${PRODUCTVER}-${KVER}"

View File

@ -39,7 +39,9 @@ if [[ "${ZIMAGE_HASH_CUR}" != "${ZIMAGE_HASH}" || "${RAMDISK_HASH_CUR}" != "${RA
fi
# Read model/system variables
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")"
MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")"
@ -85,9 +87,7 @@ KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")"
DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")"
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM=${PLATFORM:-"unknown"}
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
declare -A CMDLINE
@ -111,31 +111,54 @@ if [ ${EFI} -eq 1 ]; then
else
CMDLINE['noefi']=""
fi
if [ ! "${BUS}" = "usb" ]; then
SZ=$(blockdev --getsz ${LOADER_DISK} 2>/dev/null) # SZ=$(cat /sys/block/${LOADER_DISK/\/dev\//}/size)
SS=$(blockdev --getss ${LOADER_DISK} 2>/dev/null) # SS=$(cat /sys/block/${LOADER_DISK/\/dev\//}/queue/hw_sector_size)
SIZE=$((${SZ:-0} * ${SS:-0} / 1024 / 1024 + 10))
# Read SATADoM type
SATADOM="$(readConfigKey "satadom" "${USER_CONFIG_FILE}")"
if echo "epyc7002" | grep -wq "${PLATFORM}"; then
CMDLINE['synoboot_satadom']="-1"
else
CMDLINE['synoboot_satadom']="${SATADOM:-0}"
if [ $(echo "${KVER:-4}" | cut -d'.' -f1) -lt 5 ]; then
if [ ! "${BUS}" = "usb" ]; then
SZ=$(blockdev --getsz ${LOADER_DISK} 2>/dev/null) # SZ=$(cat /sys/block/${LOADER_DISK/\/dev\//}/size)
SS=$(blockdev --getss ${LOADER_DISK} 2>/dev/null) # SS=$(cat /sys/block/${LOADER_DISK/\/dev\//}/queue/hw_sector_size)
SIZE=$((${SZ:-0} * ${SS:-0} / 1024 / 1024 + 10))
# Read SATADoM type
SATADOM="$(readConfigKey "satadom" "${USER_CONFIG_FILE}")"
CMDLINE['synoboot_satadom']="${SATADOM:-2}"
CMDLINE['dom_szmax']="${SIZE}"
fi
CMDLINE['dom_szmax']="${SIZE}"
CMDLINE["elevator"]="elevator"
fi
if [ "${DT}" = "true" ]; then
CMDLINE["syno_ttyS0"]="serial,0x3f8"
CMDLINE["syno_ttyS1"]="serial,0x2f8"
else
CMDLINE["SMBusHddDynamicPower"]="1"
CMDLINE["syno_hdd_detect"]="0"
CMDLINE["syno_hdd_powerup_seq"]="0"
fi
CMDLINE['panic']="${KERNELPANIC:-0}"
CMDLINE['console']="ttyS0,115200n8"
#CMDLINE['no_console_suspend']="1"
# CMDLINE['no_console_suspend']="1"
CMDLINE['consoleblank']="600"
CMDLINE['earlyprintk']=""
CMDLINE['earlycon']="uart8250,io,0x3f8,115200n8"
if [ "${EMMCBOOT}" = "true" ]; then
CMDLINE['root']="/dev/mmcblk0p1"
else
CMDLINE['root']="/dev/md0"
CMDLINE['root']="/dev/md0"
CMDLINE['loglevel']="15"
CMDLINE['log_buf_len']="32M"
CMDLINE["HddHotplug"]="1"
CMDLINE["vender_format_version"]="2"
if [ -n "$(ls /dev/mmcblk* 2>/dev/null)" ] && [ ! "${BUS}" = "mmc" ] && [ ! "${EMMCBOOT}" = "true" ]; then
[ ! "${CMDLINE['modprobe.blacklist']}" = "" ] && CMDLINE['modprobe.blacklist']+=","
CMDLINE['modprobe.blacklist']+="sdhci,sdhci_pci,sdhci_acpi"
fi
if [ "${DT}" = "true" ] && ! echo "epyc7002 purley broadwellnkv2" | grep -wq "${PLATFORM}"; then
[ ! "${CMDLINE['modprobe.blacklist']}" = "" ] && CMDLINE['modprobe.blacklist']+=","
CMDLINE['modprobe.blacklist']+="mpt3sas"
fi
if echo "epyc7002 apollolake geminilake" | grep -wq "${PLATFORM}"; then
CMDLINE["intel_iommu"]="igfx_off"
fi
if echo "purley broadwellnkv2" | grep -wq "${PLATFORM}"; then
CMDLINE["SASmodel"]="1"
fi
# Cmdline NIC Settings
NIC=0
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
for ETH in ${ETHX}; do
MAC="$(readConfigKey "mac.${ETH}" "${USER_CONFIG_FILE}")"
[ -n "${MAC}" ] && NIC=$((${NIC} + 1)) && CMDLINE["mac${NIC}"]="${MAC}"
@ -146,34 +169,7 @@ if [ "${MACSYS}" = "hardware" ]; then
elif [ "${MACSYS}" = "custom" ]; then
CMDLINE['skip_vender_mac_interfaces']="$(seq -s, $((${NIC} + 1)) 7)"
fi
CMDLINE['loglevel']="15"
CMDLINE['log_buf_len']="32M"
CMDLINE["HddHotplug"]="1"
CMDLINE["elevator"]="elevator"
if [ -n "$(ls /dev/mmcblk* 2>/dev/null)" ] && [ ! "${BUS}" = "mmc" ] && [ ! "${EMMCBOOT}" = "true" ]; then
[ ! "${CMDLINE['modprobe.blacklist']}" = "" ] && CMDLINE['modprobe.blacklist']+=","
CMDLINE['modprobe.blacklist']+="sdhci,sdhci_pci,sdhci_acpi"
fi
if [ "${DT}" = "true" ]; then
CMDLINE["vender_format_version"]="2"
CMDLINE["syno_ttyS0"]="serial,0x3f8"
CMDLINE["syno_ttyS1"]="serial,0x2f8"
if ! echo "epyc7002 purley broadwellnkv2" | grep -wq "${PLATFORM}"; then
[ ! "${CMDLINE['modprobe.blacklist']}" = "" ] && CMDLINE['modprobe.blacklist']+=","
CMDLINE['modprobe.blacklist']+="mpt3sas"
fi
else
CMDLINE["SMBusHddDynamicPower"]="1"
CMDLINE["syno_hdd_detect"]="0"
CMDLINE["syno_hdd_powerup_seq"]="0"
CMDLINE["vender_format_version"]="2"
fi
if echo "epyc7002 apollolake geminilake" | grep -wq "${PLATFORM}"; then
CMDLINE["intel_iommu"]="igfx_off"
fi
if echo "purley broadwellnkv2" | grep -wq "${PLATFORM}"; then
CMDLINE["SASmodel"]="1"
fi
# Read user cmdline
while IFS=': ' read -r KEY VALUE; do
[ -n "${KEY}" ] && CMDLINE["${KEY}"]="${VALUE}"

View File

@ -28,6 +28,7 @@ ADDONS_PATH="${PART3_PATH}/addons"
MODULES_PATH="${PART3_PATH}/modules"
MODEL_CONFIG_PATH="${PART3_PATH}/configs"
S_FILE="${MODEL_CONFIG_PATH}/serials.yml"
P_FILE="${MODEL_CONFIG_PATH}/platforms.yml"
PATCH_PATH="${PART3_PATH}/patches"
LKM_PATH="${PART3_PATH}/lkms"
CUSTOM_PATH="${PART3_PATH}/custom"

View File

@ -1,32 +1,43 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
import os, click
WORK_PATH = os.path.abspath(os.path.dirname(__file__))
@click.group()
def cli():
"""
The CLI is a commands to Arc.
The CLI is a commands to RR.
"""
pass
def mutually_exclusive_options(ctx, param, value):
other_option = 'file' if param.name == 'data' else 'data'
other_option = "file" if param.name == "data" else "data"
if value is not None and ctx.params.get(other_option) is not None:
raise click.UsageError(f'Illegal usage: `{param.name}` is mutually exclusive with `{other_option}`.')
raise click.UsageError(f"Illegal usage: `{param.name}` is mutually exclusive with `{other_option}`.")
return value
def validate_required_param(ctx, param, value):
if not value and 'file' not in ctx.params and 'data' not in ctx.params:
if not value and "file" not in ctx.params and "data" not in ctx.params:
raise click.MissingParameter(param_decls=[param.name])
return value
@cli.command()
@click.option('-d', "--data", type=str, callback=mutually_exclusive_options, is_eager=True, help="The data of QRCode.")
@click.option('-f', "--file", type=str, callback=mutually_exclusive_options, is_eager=True, help="The file of QRCode.")
@click.option('--validate', is_flag=True, callback=validate_required_param, expose_value=False, is_eager=True)
@click.option('-l', "--location", type=click.IntRange(0, 7), required=True, help="The location of QRCode. (range 0<=x<=7)")
@click.option('-o', "--output", type=str, required=True, help="The output file of QRCode.")
@click.option("-d", "--data", type=str, callback=mutually_exclusive_options, is_eager=True, help="The data of QRCode.")
@click.option("-f", "--file", type=str, callback=mutually_exclusive_options, is_eager=True, help="The file of QRCode.")
@click.option("--validate", is_flag=True, callback=validate_required_param, expose_value=False, is_eager=True)
@click.option("-l", "--location", type=click.IntRange(0, 7), required=True, help="The location of QRCode. (range 0<=x<=7)")
@click.option("-o", "--output", type=str, required=True, help="The output file of QRCode.")
def makeqr(data, file, location, output):
"""
Generate a QRCode.
@ -40,10 +51,10 @@ def makeqr(data, file, location, output):
FBIOGET_FSCREENINFO = 0x4602
FBDEV = "/dev/fb0"
if data is not None:
qr = qrcode.QRCode(version=1, box_size=10, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4)
qr = qrcode.QRCode(version=1, box_size=10, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4,)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="grey", back_color="black")
img = qr.make_image(fill_color="purple", back_color="white")
img = img.convert("RGBA")
pixels = img.load()
for i in range(img.size[0]):
@ -54,27 +65,68 @@ def makeqr(data, file, location, output):
if os.path.exists(os.path.join(WORK_PATH, "logo.png")):
icon = Image.open(os.path.join(WORK_PATH, "logo.png"))
icon = icon.convert("RGBA")
img.paste(icon.resize((int(img.size[0] / 5), int(img.size[1] / 5))), (int((img.size[0] - int(img.size[0] / 5)) / 2), int((img.size[1] - int(img.size[1] / 5)) / 2)))
img.paste(icon.resize((int(img.size[0] / 5), int(img.size[1] / 5))), (int((img.size[0] - int(img.size[0] / 5)) / 2), int((img.size[1] - int(img.size[1] / 5)) / 2),),)
if file is not None:
img = Image.open(file)
# img = img.convert("RGBA")
# pixels = img.load()
# for i in range(img.size[0]):
# for j in range(img.size[1]):
# if pixels[i, j] == (255, 255, 255, 255):
# pixels[i, j] = (255, 255, 255, 0)
(xres, yres) = (1920, 1080)
with open(FBDEV, 'rb')as fb:
with open(FBDEV, "rb") as fb:
vi = fcntl.ioctl(fb, FBIOGET_VSCREENINFO, bytes(160))
res = struct.unpack('I'*40, vi)
res = struct.unpack("I" * 40, vi)
if res[0] != 0 and res[1] != 0:
(xres, yres) = (res[0], res[1])
(xres, yres) = (res[0], res[1])
xqr, yqr = (int(xres / 8), int(xres / 8))
img = img.resize((xqr, yqr))
alpha = Image.new("RGBA", (xres, yres), (0, 0, 0, 0))
if int(location) not in range(0, 8):
location = 0
location = 0
loc = (img.size[0] * int(location), alpha.size[1] - img.size[1])
alpha.paste(img, loc)
alpha.save(output)
@cli.command()
@click.option("-p", "--platforms", type=str, help="The platforms of Syno.")
def getmodels(platforms=None):
"""
Get Syno Models.
"""
import re, json
import requests
if platforms is not None and platforms != "":
PS = platforms.lower().replace(",", " ").split()
else:
PS = []
models = []
req = requests.get("https://autoupdate.synology.com/os/v2")
req.encoding = "utf-8"
data = json.loads(req.text)
for I in data["channel"]["item"]:
if not I["title"].startswith("DSM"):
continue
for J in I["model"]:
arch = J["mUnique"].split("_")[1]
name = J["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+")
if len(PS) > 0 and arch.lower() not in PS:
continue
if any(name == B["name"] for B in models):
continue
models.append({"name": name, "arch": arch})
models = sorted(models, key=lambda k: (k["arch"], k["name"]))
print(json.dumps(models, indent=4))
if __name__ == "__main__":
cli()
cli()

View File

@ -5,33 +5,6 @@
. ${ARC_PATH}/include/configFile.sh
. ${ARC_PATH}/include/addons.sh
###############################################################################
# read key value from model config file
# 1 - Model
# 2 - Key
# Return Value
function readModelKey() {
readConfigKey "${2}" "${MODEL_CONFIG_PATH}/${1}.yml"
}
###############################################################################
# read Entries as map(key=value) from model config
# 1 - Model
# 2 - Path of key
# Returns map of values
function readModelMap() {
readConfigMap "${2}" "${MODEL_CONFIG_PATH}/${1}.yml"
}
###############################################################################
# read an array from model config
# 1 - Model
# 2 - Path of key
# Returns array/map of values
function readModelArray() {
readConfigArray "${2}" "${MODEL_CONFIG_PATH}/${1}.yml"
}
###############################################################################
# Just show error message and dies
function die() {
@ -49,6 +22,23 @@ function dieLog() {
exit 1
}
###############################################################################
# Check if a item exists into array
# 1 - Item
# 2.. - Array
# Return 0 if exists
function arrayExistItem() {
EXISTS=1
ITEM="${1}"
shift
for i in "$@"; do
[ "${i}" = "${ITEM}" ] || continue
EXISTS=0
break
done
return ${EXISTS}
}
###############################################################################
# Generate a number with 6 digits from 1 to 30000
function random() {
@ -82,11 +72,11 @@ function genRandomValue() {
# 1 - Model
# Returns serial number
function generateSerial() {
ID="$(readModelKey "${1}" "id")"
PREFIX="$(readConfigArray "${ID}.prefix" "${S_FILE}" | sort -R | tail -1)"
MIDDLE="$(readConfigArray "${ID}.middle" "${S_FILE}" | sort -R | tail -1)"
SUFFIX="$(readConfigKey "${ID}.suffix" "${S_FILE}")"
PREFIX="$(readConfigArray "${1}.prefix" "${S_FILE}" | sort -R | tail -1)"
MIDDLE="$(readConfigArray "${1}.middle" "${S_FILE}" | sort -R | tail -1)"
SUFFIX="$(readConfigKey "${1}.suffix" "${S_FILE}")"
SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}"
case "${SUFFIX}" in
numeric)
SUFFIX="$(random)"
@ -95,8 +85,8 @@ function generateSerial() {
SUFFIX="$(genRandomLetter)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomValue)$(genRandomLetter)"
;;
esac
SERIAL="${PREFIX:-"0000"}${MIDDLE:-"XXX"}${SUFFIX:-"123456"}"
echo ${SERIAL}
echo "${SERIAL}"
return 0
}
@ -123,24 +113,37 @@ function generateMacAddress() {
# Validate a serial number for a model
# 1 - Model
# 2 - Serial number to test
# Returns 1 if serial number is valid
# Returns 1 if serial number is invalid
function validateSerial() {
PREFIX=$(readModelArray "${1}" "serial.prefix")
MIDDLE=$(readModelKey "${1}" "serial.middle")
S=${2:0:4}
P=${2:4:3}
PREFIX="$(readConfigArray "${1}.prefix" "${S_FILE}" 2>/dev/null)"
MIDDLE="$(readConfigArray "${1}.middle" "${S_FILE}" 2>/dev/null)"
SUFFIX="$(readConfigKey "${1}.suffix" "${S_FILE}" 2>/dev/null)"
P=${2:0:4}
M=${2:4:3}
S=${2:7}
L=${#2}
if [ ${L} -ne 13 ]; then
return 0
return 1
fi
echo "${PREFIX}" | grep -q "${S}"
if [ $? -eq 1 ]; then
return 0
if ! arrayExistItem ${P} ${PREFIX}; then
return 1
fi
if [ "${MIDDLE}" != "${P}" ]; then
return 0
if ! arrayExistItem ${M} ${MIDDLE}; then
return 1
fi
return 1
case "${SUFFIX:-"alpha"}" in
numeric)
if ! echo "${S}" | grep -q "^[0-9]\{6\}$"; then
return 1
fi
;;
alpha)
if ! echo "${S}" | grep -q "^[A-Z][0-9][0-9][0-9][0-9][A-Z]$"; then
return 1
fi
;;
esac
return 0
}
###############################################################################
@ -418,4 +421,27 @@ function rebootTo() {
[ ! -f "${ENVFILE}" ] && grub-editenv ${ENVFILE} create
grub-editenv ${ENVFILE} set next_entry="${1}"
reboot
}
###############################################################################
# Copy DSM files to the boot partition
# 1 - DSM root path
function copyDSMFiles() {
if [ -f "${1}/VERSION" ] && [ -f "${1}/grub_cksum.syno" ] && [ -f "${1}/GRUB_VER" ] && [ -f "${1}/zImage" ] && [ -f "${1}/rd.gz" ]; then
# Remove old model files
rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/grub_cksum.syno" "${PART2_PATH}/GRUB_VER"
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}"
# Remove old build files
rm -f "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null
# Copy new model files
cp -f "${1}/grub_cksum.syno" "${PART1_PATH}"
cp -f "${1}/GRUB_VER" "${PART1_PATH}"
cp -f "${1}/grub_cksum.syno" "${PART2_PATH}"
cp -f "${1}/GRUB_VER" "${PART2_PATH}"
cp -f "${1}/zImage" "${ORI_ZIMAGE_FILE}"
cp -f "${1}/rd.gz" "${ORI_RDGZ_FILE}"
return 0
else
return 1
fi
}

View File

@ -66,11 +66,13 @@ initConfigKey "lkm" "prod" "${USER_CONFIG_FILE}"
initConfigKey "mac" "{}" "${USER_CONFIG_FILE}"
initConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
initConfigKey "model" "" "${USER_CONFIG_FILE}"
initConfigKey "modelid" "" "${USER_CONFIG_FILE}"
initConfigKey "netmask" "{}" "${USER_CONFIG_FILE}"
initConfigKey "platform" "" "${USER_CONFIG_FILE}"
initConfigKey "productver" "" "${USER_CONFIG_FILE}"
initConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}"
initConfigKey "rd-compressed" "false" "${USER_CONFIG_FILE}"
initConfigKey "satadom" "0" "${USER_CONFIG_FILE}"
initConfigKey "satadom" "2" "${USER_CONFIG_FILE}"
initConfigKey "static" "{}" "${USER_CONFIG_FILE}"
initConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
initConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}"

View File

@ -28,44 +28,41 @@ mkdir -p "${RAMDISK_PATH}"
) >/dev/null 2>&1
# Read Model Data
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")"
SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")"
LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")"
KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")"
USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")"
KERNEL="$(readConfigKey "kernel" "${USER_CONFIG_FILE}")"
RD_COMPRESSED="$(readConfigKey "rd-compressed" "${USER_CONFIG_FILE}")"
# Check if DSM Version changed
. "${RAMDISK_PATH}/etc/VERSION"
# Read DSM Informations
PRODUCTVERDSM="${majorversion}.${minorversion}"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
# Read new PAT Info from Config
PAT_URL="$(readConfigKey "arc.paturl" "${USER_CONFIG_FILE}")"
PAT_HASH="$(readConfigKey "arc.pathash" "${USER_CONFIG_FILE}")"
[ "${PATURL:0:1}" = "#" ] && PATURL=""
[ "${PATSUM:0:1}" = "#" ] && PATSUM=""
# Check if DSM Version changed
. "${RAMDISK_PATH}/etc/VERSION"
PRODUCTVERDSM="${majorversion}.${minorversion}"
if [ "${PRODUCTVERDSM}" != "${PRODUCTVER}" ]; then
# Update new buildnumber
echo -e "Ramdisk Version ${PRODUCTVER} does not match DSM Version ${PRODUCTVERDSM}!"
echo -e "Try to use DSM Version ${PRODUCTVERDSM} for Patch."
writeConfigKey "productver" "${USER_CONFIG_FILE}"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
PAT_URL=""
PAT_HASH=""
fi
# Sanity check
if [[ -z "${PLATFORM}" || -z "${KVER}" ]]; then
echo "ERROR: Configuration for model ${MODEL} and productversion ${PRODUCTVER} not found." >"${LOG_FILE}"
exit 1
fi
# Read model data
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
# Modify KVER for Epyc7002
if [ "${PLATFORM}" = "epyc7002" ]; then
@ -74,19 +71,25 @@ else
KVERP="${KVER}"
fi
# Sanity check
if [[ -z "${PLATFORM}" || -z "${KVER}" ]]; then
echo "ERROR: Configuration for model ${MODEL} and productversion ${PRODUCTVER} not found." >"${LOG_FILE}"
exit 1
fi
declare -A SYNOINFO
declare -A ADDONS
declare -A MODULES
# Read synoinfo from config
# Read synoinfo and addons from config
while IFS=': ' read -r KEY VALUE; do
[ -n "${KEY}" ] && SYNOINFO["${KEY}"]="${VALUE}"
done <<<$(readConfigMap "synoinfo" "${USER_CONFIG_FILE}")
# Read synoinfo from config
while IFS=': ' read -r KEY VALUE; do
[ -n "${KEY}" ] && ADDONS["${KEY}"]="${VALUE}"
done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}")
# Read modules from config
# Read modules from user config
while IFS=': ' read -r KEY VALUE; do
[ -n "${KEY}" ] && MODULES["${KEY}"]="${VALUE}"
done <<<$(readConfigMap "modules" "${USER_CONFIG_FILE}")
@ -94,7 +97,7 @@ done <<<$(readConfigMap "modules" "${USER_CONFIG_FILE}")
# Patches (diff -Naru OLDFILE NEWFILE > xxx.patch)
PATCHS=()
PATCHS+=("ramdisk-etc-rc-*.patch")
PATCHS+=("ramdisk-init-script-v${KVER:0:1}-*.patch")
PATCHS+=("ramdisk-init-script-*.patch")
PATCHS+=("ramdisk-post-init-script-*.patch")
PATCHS+=("ramdisk-disable-root-pwd-*.patch")
PATCHS+=("ramdisk-disable-disabled-ports-*.patch")
@ -149,28 +152,29 @@ echo "Create addons.sh" >"${LOG_FILE}"
mkdir -p "${RAMDISK_PATH}/addons"
echo "#!/bin/sh" >"${RAMDISK_PATH}/addons/addons.sh"
echo 'echo "addons.sh called with params ${@}"' >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export LOADERLABEL=ARC" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export LOADERVERSION=${ARC_VERSION}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export PLATFORM=${PLATFORM}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export MODEL=${MODEL}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export MLINK=${PAT_URL}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export MCHECKSUM=${PAT_HASH}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export LAYOUT=${LAYOUT}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export KEYMAP=${KEYMAP}" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export LOADERLABEL=\"ARC\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export LOADERVERSION=\"${ARC_VERSION}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export PLATFORM=\"${PLATFORM}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export PRODUCTVER=\"${PRODUCTVER}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export MODEL=\"${MODEL}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export MLINK=\"${PAT_URL}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export MCHECKSUM=\"${PAT_HASH}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export LAYOUT=\"${LAYOUT}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
echo "export KEYMAP=\"${KEYMAP}\"" >>"${RAMDISK_PATH}/addons/addons.sh"
chmod +x "${RAMDISK_PATH}/addons/addons.sh"
# Required addons: "revert" "misc" "eudev" "disks" "localrss" "wol"
# This order cannot be changed.
for ADDON in "revert" "misc" "eudev" "disks" "localrss" "notify" "updatenotify" "wol" "acpid"; do
for ADDON in "redpill" "revert" "misc" "eudev" "disks" "localrss" "notify" "wol" "updatenotify" "wol" "acpid"; do
PARAMS=""
if [ "${ADDON}" = "disks" ]; then
PARAMS="${HDDSORT} ${USBMOUNT}"
PARAMS=${HDDSORT}
[ -f "${USER_UP_PATH}/${MODEL}.dts" ] && cp -f "${USER_UP_PATH}/${MODEL}.dts" "${RAMDISK_PATH}/addons/model.dts"
fi
installAddon "${ADDON}" "${PLATFORM}" || exit 1
echo "/addons/${ADDON}.sh \${1} ${PARAMS}" >>"${RAMDISK_PATH}/addons/addons.sh" 2>>"${LOG_FILE}" || exit 1
done
# User Addons
# User addons
for ADDON in ${!ADDONS[@]}; do
PARAMS=${ADDONS[${ADDON}]}
installAddon "${ADDON}" "${PLATFORM}" || exit 1
@ -197,7 +201,7 @@ fi
# Backup current loader configs
BACKUP_PATH="${RAMDISK_PATH}/usr/arc/backup"
rm -rf "${BACKUP_PATH}"
for F in "${USER_GRUB_CONFIG}" "${USER_CONFIG_FILE}"; do
for F in "${USER_GRUB_CONFIG}" "${USER_CONFIG_FILE}" "${USER_UP_PATH}" "${SCRIPTS_PATH}"; do
if [ -f "${F}" ]; then
FD="$(dirname "${F}")"
mkdir -p "${FD/\/mnt/${BACKUP_PATH}}"

View File

@ -29,7 +29,7 @@ LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")"
KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")"
if [ -n "${MODEL}" ]; then
PLATFORM="$(readModelKey "${MODEL}" "platform")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
DT="$(readModelKey "${MODEL}" "dt")"
fi
@ -212,23 +212,27 @@ function arcUpdate() {
fi
fi
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
MODELID="$(readConfigKey "modelid" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
if [[ -n "${MODEL}" && -n "${PRODUCTVER}" ]]; then
PLATFORM="$(readModelKey "${MODEL}" "platform")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
# Modify KVER for Epyc7002
if [ "${PLATFORM}" = "epyc7002" ]; then
KVER="${PRODUCTVER}-${KVER}"
KVERP="${PRODUCTVER}-${KVER}"
else
KVERP="${KVER}"
fi
fi
rm -rf "${MODULES_PATH}"
mkdir -p "${MODULES_PATH}"
unzip -oq "${TMP_PATH}/modules.zip" -d "${MODULES_PATH}" >/dev/null 2>&1
# Rebuild modules if model/build is selected
if [[ -n "${PLATFORM}" && -n "${KVER}" ]]; then
if [[ -n "${PLATFORM}" && -n "${KVERP}" ]]; then
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
while read -r ID DESC; do
writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}"
done <<<$(getAllModules "${PLATFORM}" "${KVER}")
done <<<$(getAllModules "${PLATFORM}" "${KVERP}")
fi
rm -f "${TMP_PATH}/modules.zip"
# Update Configs

View File

@ -5,9 +5,9 @@
. ${ARC_PATH}/include/functions.sh
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
# Adapted from: scripts/Makefile.lib
# Usage: size_append FILE [FILE2] [FILEn]...
@ -44,7 +44,7 @@ size_le() {
VMLINUX_MOD=${1}
ZIMAGE_MOD=${2}
KVER_MAJOR=${KVER:0:1}
if [[ ${KVER_MAJOR} -eq 4 || ${KVER_MAJOR} -eq 3 ]]; then
if [ ${KVER_MAJOR} -eq 4 ]; then
# Kernel version 4.x or 3.x (bromolow)
#zImage_head 16494
#payload(

View File

@ -14,10 +14,9 @@ rm -f "${MOD_ZIMAGE_FILE}"
KERNEL="$(readConfigKey "arc.kernel" "${USER_CONFIG_FILE}")"
if [ "${KERNEL}" = "custom" ]; then
echo -e "Using customized zImage"
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")"
PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")"
PLATFORM="$(readModelKey "${MODEL}" "platform")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.[${PRODUCTVER}].kver" "${P_FILE}")"
# Modify KVER for Epyc7002
if [ "${PLATFORM}" = "epyc7002" ]; then
KVERP="${PRODUCTVER}-${KVER}"