Compare commits

...

7 Commits

Author SHA1 Message Date
AuxXxilium
1ca9bf47fb Merge pull request #6112 from AuxXxilium/dev
build: update
2025-02-05 17:43:43 +01:00
AuxXxilium
c442175cfb build: update
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2025-02-05 17:41:13 +01:00
AuxXxilium
57d0cb2bf1 Merge pull request #6111 from AuxXxilium/dev
tree: add missing
2025-02-05 17:33:18 +01:00
AuxXxilium
6f8bd7034c tree: add missing
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2025-02-05 17:33:07 +01:00
AuxXxilium
05c6edbd0d Merge pull request #6087 from AuxXxilium/dev
Dev
2025-02-04 23:48:32 +01:00
AuxXxilium
28df568d8c tree: fix logic
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2025-02-04 16:56:15 +01:00
AuxXxilium
e7688433ef tree: cleanup
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2025-02-03 19:10:33 +01:00
11 changed files with 309 additions and 413 deletions

View File

@@ -75,7 +75,7 @@ jobs:
# Get extractor, LKM, Addons, Modules, Theme and Configs
- name: Get Dependencies for all Image
run: |
. scripts/func.sh "${{ secrets.BUILD_TOKEN }}"
. scripts/functions.sh "${{ secrets.BUILD_TOKEN }}"
echo "Get Dependencies"
getAddons "files/p3/addons"
@@ -104,7 +104,7 @@ jobs:
# Build incremental
- name: Build Image
run: |
. scripts/func.sh
. scripts/functions.sh
# Modify Source File
ARC_BUILD="$(date +'%y%m%d')"

View File

@@ -93,7 +93,7 @@ jobs:
# Build incremental
- name: Build image
run: |
. scripts/func.sh
. scripts/functions.sh
function writeConfigKey() {
[ "${2}" = "{}" ] && sudo yq eval '.'${1}' = {}' --inplace "${3}" 2>/dev/null || sudo yq eval '.'${1}' = "'"${2}"'"' --inplace "${3}" 2>/dev/null

View File

@@ -34,43 +34,66 @@ jobs:
sudo timedatectl set-timezone "Europe/Berlin"
sudo apt update
sudo apt install -y build-essential libtool pkgconf libzstd-dev liblzma-dev libssl-dev # kmodule dependencies
sudo apt install -y build-essential libtool pkgconf libzstd-dev liblzma-dev libssl-dev busybox dialog curl xz-utils cpio sed qemu-utils
- name: Get Release Data for Arc
YQ=$(command -v yq)
if [ -z "${YQ}" ] || ! ${YQ} --version 2>/dev/null | grep -q "v4."; then
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O "${YQ:-"/usr/bin/yq"}" && chmod +x "${YQ:-"/usr/bin/yq"}"
fi
- name: Get Addon Data for Arc
run: |
REPO="${{ github.server_url }}/${{ github.repository }}"
REPO="https://github.com/AuxXxilium/arc-addons"
PRERELEASE="true"
TAG=""
if [ "${PRERELEASE}" = "true" ]; then
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | sed -E 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)"
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | sed -r 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)"
else
LATESTURL="$(curl -skL --connect-timeout 10 -w %{url_effective} -o /dev/null "${REPO}/releases/latest")"
TAG="${LATESTURL##*/}"
fi
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
rm -f arc-${TAG}.img.zip
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/arc-${TAG}.img.zip" -o "arc-${TAG}.img.zip")
rm -f addons.zip
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/addons-${TAG}.zip" -o "addons.zip")
if [ $? -ne 0 -o ${STATUS:-0} -ne 200 ]; then
echo "Download failed"
exit 1
fi
unzip arc-${TAG}.img.zip -d "arc"
mkdir -p "mnt/p3/addons"
unzip addons.zip -d "mnt/p3/addons"
for i in $(find "mnt/p3/addons" -type f -name "*.addon"); do
if [ -f "${i}" ]; then
mkdir -p "mnt/p3/addons/$(basename "${i}" .addon)"
tar -xaf "${i}" -C "mnt/p3/addons/$(basename "${i}" .addon)"
fi
done
rm -f addons.zip
sudo ./localbuild.sh create arc/ws arc/arc.img
if [ $? -ne 0 ]; then
echo "create failed"
- name: Get Config Data for Arc
run: |
REPO="https://github.com/AuxXxilium/arc-configs"
LATESTURL="$(curl -skL --connect-timeout 10 -w %{url_effective} -o /dev/null "${REPO}/releases/latest")"
TAG="${LATESTURL##*/}"
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
rm -f configs.zip
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/configs-${TAG}.zip" -o "configs.zip")
if [ $? -ne 0 -o ${STATUS:-0} -ne 200 ]; then
echo "Download failed"
exit 1
fi
mkdir -p "mnt/p3/configs"
unzip configs.zip -d "mnt/p3/configs"
rm -f configs.zip
- name: Get data
run: |
pip install -r scripts/requirements.txt
python scripts/func.py getmodels -w "arc/ws" -j "docs/models.json"
python scripts/func.py getaddons -w "arc/ws" -j "docs/addons.json"
python scripts/func.py getmodules -w "arc/ws" -j "docs/modules.json"
python scripts/func.py getpats -w "arc/ws" -j "docs/pats.json"
python scripts/functions.py getmodels -w "." -j "docs/models.json"
python scripts/functions.py getaddons -w "." -j "docs/addons.json"
python scripts/functions.py getpats -w "." -j "docs/pats.json"
- name: Upload to Artifacts
if: success()

View File

@@ -1003,7 +1003,7 @@ function cmdlineMenu() {
2>"${TMP_PATH}/resp"
RET=$?
case ${RET} in
0) # ok-button
0)
NAME="$(sed -n '1p' "${TMP_PATH}/resp" 2>/dev/null)"
VALUE="$(sed -n '2p' "${TMP_PATH}/resp" 2>/dev/null)"
[[ "${NAME}" = *= ]] && NAME="${NAME%?}"
@@ -1016,11 +1016,11 @@ function cmdlineMenu() {
writeConfigKey "cmdline.\"${NAME//\"/}\"" "${VALUE}" "${USER_CONFIG_FILE}"
break
;;
1) # cancel-button
1)
break
;;
255) # ESC
# break
255)
break
;;
esac
done
@@ -1036,7 +1036,7 @@ function cmdlineMenu() {
done < <(readConfigMap "cmdline" "${USER_CONFIG_FILE}")
if [ ${#CMDLINE[@]} -eq 0 ]; then
dialog --backtitle "$(backtitle)" --msgbox "No user cmdline to remove" 0 0
continue
break
fi
ITEMS=""
for I in "${!CMDLINE[@]}"; do

View File

@@ -313,7 +313,7 @@ elif [ "${DIRECTBOOT}" = "false" ]; then
fi
# Wait for boot interrupt
# _bootwait || true
_bootwait || true
for T in $(busybox w 2>/dev/null | grep -v 'TTY' | awk '{print $2}'); do
if [ -w "/dev/${T}" ]; then

View File

@@ -47,6 +47,6 @@ EXTRACTOR_BIN="syno_extract_system_patch"
HTTPPORT=$(grep -i '^HTTP_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2)
[ -z "${HTTPPORT}" ] && HTTPPORT="" || true
DUFSPORT=$(grep -i '^DUFS_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2)
[ -z "${DUFSPORT}" ] && DUFSPORT=7304 || true
[ -z "${DUFSPORT}" ] && DUFSPORT="7304" || true
TTYDPORT=$(grep -i '^TTYD_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2)
[ -z "${TTYDPORT}" ] && TTYDPORT=7681 || true
[ -z "${TTYDPORT}" ] && TTYDPORT="7681" || true

View File

@@ -615,13 +615,15 @@ function onlineCheck() {
writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}"
fi
fi
NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
if [ -n "${NEWTAG}" ]; then
writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
updateOffline
checkHardwareID
else
writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}"
if [ "${ARC_BRANCH}" != "dev" ]; then
NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
if [ -n "${NEWTAG}" ]; then
writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
updateOffline
checkHardwareID
else
writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}"
fi
fi
}
@@ -701,7 +703,7 @@ function __umountDSMRootDisk() {
# bootwait SSH/Web
function _bootwait() {
BOOTWAIT="$(readConfigKey "bootwait" "${USER_CONFIG_FILE}")"
[ -z "${BOOTWAIT}" ] && BOOTWAIT=10
[ -z "${BOOTWAIT}" ] && BOOTWAIT="5"
busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WB
MSG=""
while [ ${BOOTWAIT} -gt 0 ]; do

View File

@@ -11,7 +11,7 @@ set -e
# Clean cached Files
sudo git clean -fdx
. scripts/func.sh "${AUX_TOKEN}"
. scripts/functions.sh "${AUX_TOKEN}"
# Unmount Image File
sudo umount "/tmp/p1" 2>/dev/null || true

622
scripts/functions.py Normal file → Executable file
View File

@@ -1,373 +1,251 @@
# -*- 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.
"""
pass
def mutually_exclusive_options(ctx, param, value):
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}`.")
return value
def validate_required_param(ctx, param, value):
if not value and "file" not in ctx.params and "data" not in ctx.params:
raise click.MissingParameter(param_decls=[param.name])
return value
def __fullversion(ver):
out = ver
arr = ver.split('-')
if len(arr) > 0:
a = arr[0].split('.')[0] if len(arr[0].split('.')) > 0 else '0'
b = arr[0].split('.')[1] if len(arr[0].split('.')) > 1 else '0'
c = arr[0].split('.')[2] if len(arr[0].split('.')) > 2 else '0'
d = arr[1] if len(arr) > 1 else '00000'
e = arr[2] if len(arr) > 2 else '0'
out = '{}.{}.{}-{}-{}'.format(a,b,c,d,e)
return out
@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.")
def makeqr(data, file, location, output):
"""
Generate a QRCode.
"""
try:
import fcntl, struct
import qrcode
from PIL import Image
FBIOGET_VSCREENINFO = 0x4600
FBIOPUT_VSCREENINFO = 0x4601
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.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="grey", back_color="black")
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)
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),),)
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:
vi = fcntl.ioctl(fb, FBIOGET_VSCREENINFO, bytes(160))
res = struct.unpack("I" * 40, vi)
if res[0] != 0 and res[1] != 0:
(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
loc = (img.size[0] * int(location), alpha.size[1] - img.size[1])
alpha.paste(img, loc)
alpha.save(output)
except:
pass
@cli.command()
@click.option("-p", "--platforms", type=str, help="The platforms of Syno.")
def getmodels(platforms=None):
"""
Get Syno Models.
"""
import json, requests, urllib3
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if platforms is not None and platforms != "":
PS = platforms.lower().replace(",", " ").split()
else:
PS = []
models = []
try:
req = session.get("https://autoupdate.synology.com/os/v2", timeout=10, verify=False)
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"]))
except:
pass
models.sort(key=lambda x: (x["arch"], x["name"]))
print(json.dumps(models, indent=4))
@cli.command()
@click.option("-p", "--platforms", type=str, help="The platforms of Syno.")
def getmodelsbykb(platforms=None):
"""
Get Syno Models.
"""
import json, requests, urllib3
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if platforms is not None and platforms != "":
PS = platforms.lower().replace(",", " ").split()
else:
PS = []
models = []
try:
import re
from bs4 import BeautifulSoup
url="https://kb.synology.com/en-us/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have"
#url = "https://kb.synology.cn/zh-cn/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have"
req = session.get(url, timeout=10, verify=False)
req.encoding = "utf-8"
bs = BeautifulSoup(req.text, "html.parser")
p = re.compile(r"data: (.*?),$", re.MULTILINE | re.DOTALL)
data = json.loads(p.search(bs.find("script", string=p).prettify()).group(1))
model = "(.*?)" # (.*?): all, FS6400: one
p = re.compile(r"<td>{}<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td>".format(model), re.MULTILINE | re.DOTALL,)
it = p.finditer(data["preload"]["content"].replace("\n", "").replace("\t", ""))
for i in it:
d = i.groups()
if len(d) == 6:
d = model + d
if len(PS) > 0 and d[5].lower() not in PS:
continue
models.append({"name": d[0].split("<br")[0], "arch": d[5].lower()})
except:
pass
models.sort(key=lambda x: (x["arch"], x["name"]))
print(json.dumps(models, indent=4))
@cli.command()
@click.option("-m", "--model", type=str, required=True, help="The model of Syno.")
@click.option("-v", "--version", type=str, required=True, help="The version of Syno.")
def getpats4mv(model, version):
import json, requests, urllib3
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
pats = {}
try:
urlInfo = "https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
urlSteps = "https://www.synology.com/api/support/findUpgradeSteps?"
#urlInfo = "https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn"
#urlSteps = "https://www.synology.cn/api/support/findUpgradeSteps?"
major = "&major={}".format(version.split('.')[0]) if len(version.split('.')) > 0 else ""
minor = "&minor={}".format(version.split('.')[1]) if len(version.split('.')) > 1 else ""
req = session.get("{}&product={}{}{}".format(urlInfo, model.replace("+", "%2B"), major, minor), timeout=10, verify=False)
req.encoding = "utf-8"
data = json.loads(req.text)
build_ver = data['info']['system']['detail'][0]['items'][0]['build_ver']
build_num = data['info']['system']['detail'][0]['items'][0]['build_num']
buildnano = data['info']['system']['detail'][0]['items'][0]['nano']
V=__fullversion("{}-{}-{}".format(build_ver, build_num, buildnano))
if not V in pats:
pats[V]={}
pats[V]['url'] = data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0]
pats[V]['sum'] = data['info']['system']['detail'][0]['items'][0]['files'][0]['checksum']
from_ver=0
for I in data['info']['pubVers']:
if from_ver == 0 or I['build'] < from_ver: from_ver = I['build']
for I in data['info']['productVers']:
if not I['version'].startswith(version): continue
if major == "" or minor == "":
majorTmp = "&major={}".format(I['version'].split('.')[0]) if len(I['version'].split('.')) > 0 else ""
minorTmp = "&minor={}".format(I['version'].split('.')[1]) if len(I['version'].split('.')) > 1 else ""
reqTmp = session.get("{}&product={}{}{}".format(urlInfo, model.replace("+", "%2B"), majorTmp, minorTmp), timeout=10, verify=False)
reqTmp.encoding = "utf-8"
dataTmp = json.loads(reqTmp.text)
build_ver = dataTmp['info']['system']['detail'][0]['items'][0]['build_ver']
build_num = dataTmp['info']['system']['detail'][0]['items'][0]['build_num']
buildnano = dataTmp['info']['system']['detail'][0]['items'][0]['nano']
V=__fullversion("{}-{}-{}".format(build_ver, build_num, buildnano))
if not V in pats:
pats[V]={}
pats[V]['url'] = dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0]
pats[V]['sum'] = dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['checksum']
for J in I['versions']:
to_ver=J['build']
reqSteps = session.get("{}&product={}&from_ver={}&to_ver={}".format(urlSteps, model.replace("+", "%2B"), from_ver, to_ver), timeout=10, verify=False)
if reqSteps.status_code != 200: continue
reqSteps.encoding = "utf-8"
dataSteps = json.loads(reqSteps.text)
for S in dataSteps['upgrade_steps']:
if not 'full_patch' in S or S['full_patch'] is False: continue
if not 'build_ver' in S or not S['build_ver'].startswith(version): continue
V=__fullversion("{}-{}-{}".format(S['build_ver'], S['build_num'], S['nano']))
if not V in pats:
pats[V] = {}
pats[V]['url'] = S['files'][0]['url'].split('?')[0]
pats[V]['sum'] = S['files'][0]['checksum']
except:
pass
pats = {k: pats[k] for k in sorted(pats.keys(), reverse=True)}
print(json.dumps(pats, indent=4))
@cli.command()
@click.option("-p", "--models", type=str, help="The models of Syno.")
def getpats(models=None):
import json, requests, urllib3, re
from bs4 import BeautifulSoup
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if models is not None and models != "":
MS = models.lower().replace(",", " ").split()
else:
MS = []
pats = {}
try:
req = session.get('https://archive.synology.com/download/Os/DSM', timeout=10, verify=False)
req.encoding = 'utf-8'
bs=BeautifulSoup(req.text, 'html.parser')
p = re.compile(r"(.*?)-(.*?)", re.MULTILINE | re.DOTALL)
l = bs.find_all('a', string=p)
for i in l:
ver = i.attrs['href'].split('/')[-1]
if not ver.startswith('7'): continue
req = session.get('https://archive.synology.com{}'.format(i.attrs['href']), timeout=10, verify=False)
req.encoding = 'utf-8'
bs=BeautifulSoup(req.text, 'html.parser')
p = re.compile(r"^(.*?)_(.*?)_(.*?).pat$", re.MULTILINE | re.DOTALL)
data = bs.find_all('a', string=p)
for item in data:
p = re.compile(r"DSM_(.*?)_(.*?).pat", re.MULTILINE | re.DOTALL)
rels = p.search(item.attrs['href'])
if rels != None:
info = p.search(item.attrs['href']).groups()
model = info[0].replace('%2B', '+')
if len(MS) > 0 and model.lower() not in MS:
continue
if model not in pats.keys():
pats[model]={}
pats[model][__fullversion(ver)] = item.attrs['href']
except:
pass
print(json.dumps(pats, indent=4))
@cli.command()
@click.option("-p", "--platforms", type=str, help="The platforms of Syno.")
def getmodelsoffline(platforms=None):
"""
Get Syno Models.
"""
import re, json
import requests
import fcntl, struct
if platforms is not None and platforms != "":
PS = platforms.lower().replace(",", " ").split()
else:
PS = []
models = []
with open(os.path.join('/mnt/p3/configs', "offline.json")) as user_file:
data = json.load(user_file)
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__":
# -*- coding: utf-8 -*-
#
# Copyright (C) 2025 AuxXxilium <https://github.com/AuxXxilium>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
import os, re, sys, glob, json, yaml, click, shutil, tarfile, kmodule, requests, urllib3
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry # type: ignore
from openpyxl import Workbook
@click.group()
def cli():
"""
The CLI is a commands to ARC.
"""
pass
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of ARC.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
def getmodels(workpath, jsonpath):
models = {}
platforms_yml = os.path.join(workpath, "mnt", "p3", "configs", "platforms.yml")
with open(platforms_yml, "r") as f:
P_data = yaml.safe_load(f)
P_platforms = P_data.get("platforms", [])
for P in P_platforms:
productvers = {}
for V in P_platforms[P]["productvers"]:
kpre = P_platforms[P]["productvers"][V].get("kpre", "")
kver = P_platforms[P]["productvers"][V].get("kver", "")
productvers[V] = f"{kpre}-{kver}" if kpre else kver
models[P] = {"productvers": productvers, "models": []}
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
try:
url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
#url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
req = session.get(url, timeout=10, verify=False)
req.encoding = "utf-8"
p = re.compile(r"<mUnique>(.*?)</mUnique>.*?<mLink>(.*?)</mLink>", re.MULTILINE | re.DOTALL)
data = p.findall(req.text)
except Exception as e:
click.echo(f"Error: {e}")
return
for item in data:
if not "DSM" in item[1]:
continue
arch = item[0].split("_")[1]
name = item[1].split("/")[-1].split("_")[1].replace("%2B", "+")
if arch not in models:
continue
if name in (A for B in models for A in models[B]["models"]):
continue
models[arch]["models"].append(name)
if jsonpath:
with open(jsonpath, "w") as f:
json.dump(models, f, indent=4, ensure_ascii=False)
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of ARC.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
def getpats(workpath, jsonpath):
def __fullversion(ver):
arr = ver.split('-')
a, b, c = (arr[0].split('.') + ['0', '0', '0'])[:3]
d = arr[1] if len(arr) > 1 else '00000'
e = arr[2] if len(arr) > 2 else '0'
return f'{a}.{b}.{c}-{d}-{e}'
platforms_yml = os.path.join(workpath, "mnt", "p3", "configs", "platforms.yml")
with open(platforms_yml, "r") as f:
data = yaml.safe_load(f)
platforms = data.get("platforms", [])
adapter = HTTPAdapter(max_retries=Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504]))
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
try:
url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
#url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1"
req = session.get(url, timeout=10, verify=False)
req.encoding = "utf-8"
p = re.compile(r"<mUnique>(.*?)</mUnique>.*?<mLink>(.*?)</mLink>", re.MULTILINE | re.DOTALL)
data = p.findall(req.text)
except Exception as e:
click.echo(f"Error: {e}")
return
models = []
for item in data:
if not "DSM" in item[1]:
continue
arch = item[0].split("_")[1]
name = item[1].split("/")[-1].split("_")[1].replace("%2B", "+")
if arch not in platforms:
continue
if name in models:
continue
models.append(name)
pats = {}
for M in models:
pats[M] = {}
version = '7'
urlInfo = "https://www.synology.com/api/support/findDownloadInfo?lang=en-us"
urlSteps = "https://www.synology.com/api/support/findUpgradeSteps?"
#urlInfo = "https://www.synology.cn/api/support/findDownloadInfo?lang=zh-cn"
#urlSteps = "https://www.synology.cn/api/support/findUpgradeSteps?"
major = f"&major={version.split('.')[0]}" if len(version.split('.')) > 0 else ""
minor = f"&minor={version.split('.')[1]}" if len(version.split('.')) > 1 else ""
try:
req = session.get(f"{urlInfo}&product={M.replace('+', '%2B')}{major}{minor}", timeout=10, verify=False)
req.encoding = "utf-8"
data = json.loads(req.text)
except Exception as e:
click.echo(f"Error: {e}")
continue
build_ver = data['info']['system']['detail'][0]['items'][0]['build_ver']
build_num = data['info']['system']['detail'][0]['items'][0]['build_num']
buildnano = data['info']['system']['detail'][0]['items'][0]['nano']
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
if V not in pats[M]:
pats[M][V] = {
'url': data['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': data['info']['system']['detail'][0]['items'][0]['files'][0]['checksum']
}
from_ver = min(I['build'] for I in data['info']['pubVers'])
for I in data['info']['productVers']:
if not I['version'].startswith(version):
continue
if not major or not minor:
majorTmp = f"&major={I['version'].split('.')[0]}" if len(I['version'].split('.')) > 0 else ""
minorTmp = f"&minor={I['version'].split('.')[1]}" if len(I['version'].split('.')) > 1 else ""
try:
reqTmp = session.get(f"{urlInfo}&product={M.replace('+', '%2B')}{majorTmp}{minorTmp}", timeout=10, verify=False)
reqTmp.encoding = "utf-8"
dataTmp = json.loads(reqTmp.text)
except Exception as e:
click.echo(f"Error: {e}")
continue
build_ver = dataTmp['info']['system']['detail'][0]['items'][0]['build_ver']
build_num = dataTmp['info']['system']['detail'][0]['items'][0]['build_num']
buildnano = dataTmp['info']['system']['detail'][0]['items'][0]['nano']
V = __fullversion(f"{build_ver}-{build_num}-{buildnano}")
if V not in pats[M]:
pats[M][V] = {
'url': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['url'].split('?')[0],
'sum': dataTmp['info']['system']['detail'][0]['items'][0]['files'][0]['checksum']
}
for J in I['versions']:
to_ver = J['build']
try:
reqSteps = session.get(f"{urlSteps}&product={M.replace('+', '%2B')}&from_ver={from_ver}&to_ver={to_ver}", timeout=10, verify=False)
if reqSteps.status_code != 200:
continue
reqSteps.encoding = "utf-8"
dataSteps = json.loads(reqSteps.text)
except Exception as e:
click.echo(f"Error: {e}")
continue
for S in dataSteps['upgrade_steps']:
if not S.get('full_patch') or not S['build_ver'].startswith(version):
continue
V = __fullversion(f"{S['build_ver']}-{S['build_num']}-{S['nano']}")
if V not in pats[M]:
pats[M][V] = {
'url': S['files'][0]['url'].split('?')[0],
'sum': S['files'][0]['checksum']
}
if jsonpath:
with open(jsonpath, "w") as f:
json.dump(pats, f, indent=4, ensure_ascii=False)
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of ARC.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
def getaddons(workpath, jsonpath):
AS = glob.glob(os.path.join(workpath, "mnt", "p3", "addons", "*", "manifest.yml"))
AS.sort()
addons = {}
for A in AS:
with open(A, "r") as file:
A_data = yaml.safe_load(file)
A_name = A_data.get("name", "")
A_system = A_data.get("system", False)
A_description = A_data.get("description", "")
addons[A_name] = {"system": A_system, "description": A_description}
if jsonpath:
with open(jsonpath, "w") as f:
json.dump(addons, f, indent=4, ensure_ascii=False)
@cli.command()
@click.option("-w", "--workpath", type=str, required=True, help="The workpath of ARC.")
@click.option("-j", "--jsonpath", type=str, required=True, help="The output path of jsonfile.")
def getmodules(workpath, jsonpath):
MS = glob.glob(os.path.join(workpath, "mnt", "p3", "modules", "*.tgz"))
MS.sort()
modules = {}
TMP_PATH = "/tmp/modules"
if os.path.exists(TMP_PATH):
shutil.rmtree(TMP_PATH)
for M in MS:
M_name = os.path.splitext(os.path.basename(M))[0]
M_modules = {}
os.makedirs(TMP_PATH)
with tarfile.open(M, "r") as tar:
tar.extractall(TMP_PATH)
KS = glob.glob(os.path.join(TMP_PATH, "*.ko"))
KS.sort()
for K in KS:
K_name = os.path.splitext(os.path.basename(K))[0]
K_info = kmodule.modinfo(K, basedir=os.path.dirname(K), kernel=None)[0]
K_description = K_info.get("description", "")
K_depends = K_info.get("depends", "")
M_modules[K_name] = {"description": K_description, "depends": K_depends}
modules[M_name] = M_modules
if os.path.exists(TMP_PATH):
shutil.rmtree(TMP_PATH)
if jsonpath:
with open(jsonpath, "w") as file:
json.dump(modules, file, indent=4, ensure_ascii=False)
if __name__ == "__main__":
cli()

View File

@@ -1,7 +0,0 @@
#!/usr/bin/env bash
function genRandomValue() {
for i in 0 1 2 3 4 5 6 7 8 9 A B C D E F G H J K L M N P Q R S T V W X Y Z; do
echo ${i}
done | sort -R | tail -1
}