Skip to content

Commit

Permalink
Merge branch 'main' into linux5
Browse files Browse the repository at this point in the history
  • Loading branch information
fbelavenuto committed Dec 7, 2022
2 parents 9d0eb20 + d194e50 commit 0ba4c03
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 69 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
# Copy files
echo "Copying files"
sed 's/^ARPL_VERSION=.*/ARPL_VERSION="'${VERSION}'"/' -i files/board/arpl/overlayfs/opt/arpl/include/consts.sh
echo "${VERSION}" > files/board/arpl/p1/ARPL-VERSION
cp -Ru files/* .buildroot/
cd .buildroot
echo "Generating default config"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0-beta7
1.0-beta8
2 changes: 1 addition & 1 deletion files/board/arpl/overlayfs/opt/arpl/include/consts.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

ARPL_VERSION="1.0-beta7"
ARPL_VERSION="1.0-beta8"

# Define paths
TMP_PATH="/tmp"
Expand Down
23 changes: 23 additions & 0 deletions files/board/arpl/overlayfs/opt/arpl/include/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ function arrayExistItem() {
return ${EXISTS}
}

###############################################################################
# Get values in .conf K=V file
# 1 - key
# 2 - file
function _get_conf_kv() {
grep "${1}" "${2}" | sed "s|^${1}=\"\(.*\)\"$|\1|g"
}

###############################################################################
# Replace/remove/add values in .conf K=V file
# 1 - name
Expand All @@ -168,3 +176,18 @@ function _set_conf_kv() {
# Add if doesn't exist
echo "$1=\"$2\"" >> $3
}

###############################################################################
# Find and mount the DSM root filesystem
# (based on pocopico's TCRP code)
function findAndMountDSMRoot() {
[ $(mount | grep -i "${DSMROOT_PATH}" | wc -l) -gt 0 ] && return 0
dsmrootdisk="$(blkid /dev/sd* | grep -i raid | awk '{print $1 " " $4}' | grep UUID | grep sd[a-z]1 | head -1 | awk -F ":" '{print $1}')"
[ -z "${dsmrootdisk}" ] && return -1
[ $(mount | grep -i "${DSMROOT_PATH}" | wc -l) -eq 0 ] && mount -t ext4 $dsmrootdisk "${DSMROOT_PATH}"
if [ $(mount | grep -i "${DSMROOT_PATH}" | wc -l) -eq 0 ]; then
echo "Failed to mount"
return -1
fi
return 0
}
1 change: 1 addition & 0 deletions files/board/arpl/overlayfs/opt/arpl/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fsck.ext2 -p ${LOADER_DISK}3 >/dev/null 2>&1 || true
mkdir -p ${BOOTLOADER_PATH}
mkdir -p ${SLPART_PATH}
mkdir -p ${CACHE_PATH}
mkdir -p ${DSMROOT_PATH}
# Mount the partitions
mount ${LOADER_DISK}1 ${BOOTLOADER_PATH} || die "Can't mount ${BOOTLOADER_PATH}"
mount ${LOADER_DISK}2 ${SLPART_PATH} || die "Can't mount ${SLPART_PATH}"
Expand Down
188 changes: 123 additions & 65 deletions files/board/arpl/overlayfs/opt/arpl/menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,74 +61,83 @@ function backtitle() {
###############################################################################
# Shows available models to user choose one
function modelMenu() {
RESTRICT=1
FLGBETA=0
dialog --backtitle "`backtitle`" --title "Model" --aspect 18 \
--infobox "Reading models" 0 0
while true; do
echo "" > "${TMP_PATH}/menu"
FLGNEX=0
while read M; do
M="`basename ${M}`"
M="${M::-4}"
PLATFORM=`readModelKey "${M}" "platform"`
DT="`readModelKey "${M}" "dt"`"
BETA="`readModelKey "${M}" "beta"`"
[ "${BETA}" = "true" -a ${FLGBETA} -eq 0 ] && continue
# Check id model is compatible with CPU
COMPATIBLE=1
if [ ${RESTRICT} -eq 1 ]; then
for F in `readModelArray "${M}" "flags"`; do
if ! grep -q "^flags.*${F}.*" /proc/cpuinfo; then
COMPATIBLE=0
FLGNEX=1
break
fi
done
if [ -z "${1}" ]; then
RESTRICT=1
FLGBETA=0
dialog --backtitle "`backtitle`" --title "Model" --aspect 18 \
--infobox "Reading models" 0 0
while true; do
echo "" > "${TMP_PATH}/menu"
FLGNEX=0
while read M; do
M="`basename ${M}`"
M="${M::-4}"
PLATFORM=`readModelKey "${M}" "platform"`
DT="`readModelKey "${M}" "dt"`"
BETA="`readModelKey "${M}" "beta"`"
[ "${BETA}" = "true" -a ${FLGBETA} -eq 0 ] && continue
# Check id model is compatible with CPU
COMPATIBLE=1
if [ ${RESTRICT} -eq 1 ]; then
for F in `readModelArray "${M}" "flags"`; do
if ! grep -q "^flags.*${F}.*" /proc/cpuinfo; then
COMPATIBLE=0
FLGNEX=1
break
fi
done
fi
[ "${DT}" = "true" ] && DT="-DT" || DT=""
[ ${COMPATIBLE} -eq 1 ] && echo "${M} \"\Zb${PLATFORM}${DT}\Zn\" " >> "${TMP_PATH}/menu"
done < <(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sort)
[ ${FLGNEX} -eq 1 ] && echo "f \"\Z1Disable flags restriction\Zn\"" >> "${TMP_PATH}/menu"
[ ${FLGBETA} -eq 0 ] && echo "b \"\Z1Show beta models\Zn\"" >> "${TMP_PATH}/menu"
dialog --backtitle "`backtitle`" --colors --menu "Choose the model" 0 0 0 \
--file "${TMP_PATH}/menu" 2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "f" ]; then
RESTRICT=0
continue
fi
[ "${DT}" = "true" ] && DT="-DT" || DT=""
[ ${COMPATIBLE} -eq 1 ] && echo "${M} \"\Zb${PLATFORM}${DT}\Zn\" " >> "${TMP_PATH}/menu"
done < <(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sort)
[ ${FLGNEX} -eq 1 ] && echo "f \"\Z1Disable flags restriction\Zn\"" >> "${TMP_PATH}/menu"
[ ${FLGBETA} -eq 0 ] && echo "b \"\Z1Show beta models\Zn\"" >> "${TMP_PATH}/menu"
dialog --backtitle "`backtitle`" --colors --menu "Choose the model" 0 0 0 \
--file "${TMP_PATH}/menu" 2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ "${resp}" = "f" ]; then
RESTRICT=0
continue
fi
if [ "${resp}" = "b" ]; then
FLGBETA=1
continue
fi
# If user change model, clean buildnumber and S/N
if [ "${MODEL}" != "${resp}" ]; then
MODEL=${resp}
writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}"
BUILD=""
writeConfigKey "build" "${BUILD}" "${USER_CONFIG_FILE}"
SN=""
writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}"
# Delete old files
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
DIRTY=1
fi
break
done
if [ "${resp}" = "b" ]; then
FLGBETA=1
continue
fi
break
done
else
resp="${1}"
fi
# If user change model, clean buildnumber and S/N
if [ "${MODEL}" != "${resp}" ]; then
MODEL=${resp}
writeConfigKey "model" "${MODEL}" "${USER_CONFIG_FILE}"
BUILD=""
writeConfigKey "build" "${BUILD}" "${USER_CONFIG_FILE}"
SN=""
writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}"
# Delete old files
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
DIRTY=1
fi
}

###############################################################################
# Shows available buildnumbers from a model to user choose one
function buildMenu() {
ITEMS="`readConfigEntriesArray "builds" "${MODEL_CONFIG_PATH}/${MODEL}.yml" | sort -r`"
dialog --clear --no-items --backtitle "`backtitle`" \
--menu "Choose a build number" 0 0 0 ${ITEMS} 2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
if [ -z "${1}" ]; then
dialog --clear --no-items --backtitle "`backtitle`" \
--menu "Choose a build number" 0 0 0 ${ITEMS} 2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && return
else
if ! arrayExistItem "${1}" ${ITEMS}; then return; fi
resp="${1}"
fi
if [ "${BUILD}" != "${resp}" ]; then
dialog --backtitle "`backtitle`" --title "Build Number" \
--infobox "Reconfiguring Synoinfo, Addons and Modules" 0 0
Expand Down Expand Up @@ -753,6 +762,7 @@ function advancedMenu() {
echo "r \"Switch direct boot: \Z4${DIRECTBOOT}\Zn\"" >> "${TMP_PATH}/menu"
fi
echo "u \"Edit user config file manually\"" >> "${TMP_PATH}/menu"
echo "t \"Try to recovery a DSM installed system\"" >> "${TMP_PATH}/menu"
echo "e \"Exit\"" >> "${TMP_PATH}/menu"

dialog --default-item ${NEXT} --backtitle "`backtitle`" --title "Advanced" \
Expand All @@ -771,11 +781,55 @@ function advancedMenu() {
NEXT="u"
;;
u) editUserConfig; NEXT="e" ;;
t) tryRecoveryDSM ;;
e) break ;;
esac
done
}

###############################################################################
# Try to recovery a DSM already installed
function tryRecoveryDSM() {
dialog --backtitle "`backtitle`" --title "Try recovery DSM" --aspect 18 \
--infobox "Trying to recovery a DSM installed system" 0 0
if findAndMountDSMRoot; then
MODEL=""
BUILD=""
if [ -f "${DSMROOT_PATH}/.syno/patch/VERSION" ]; then
eval `cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep unique`
eval `cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep base`
if [ -n "${unique}" ] ; then
while read F; do
M="`basename ${F}`"
M="${M::-4}"
UNIQUE=`readModelKey "${M}" "unique"`
[ "${unique}" = "${UNIQUE}" ] || continue
# Found
modelMenu "${M}"
done < <(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sort)
if [ -n "${MODEL}" ]; then
buildMenu ${base}
if [ -n "${BUILD}" ]; then
cp "${DSMROOT_PATH}/.syno/patch/zImage" "${SLPART_PATH}"
cp "${DSMROOT_PATH}/.syno/patch/rd.gz" "${SLPART_PATH}"
MSG="Found a installation:\nModel: ${MODEL}\nBuildnumber: ${BUILD}"
SN=`_get_conf_kv SN "${DSMROOT_PATH}/etc/synoinfo.conf"`
if [ -n "${SN}" ]; then
writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}"
MSG+="\nSerial: ${SN}"
fi
dialog --backtitle "`backtitle`" --title "Try recovery DSM" \
--aspect 18 --msgbox "${MSG}" 0 0
fi
fi
fi
fi
else
dialog --backtitle "`backtitle`" --title "Try recovery DSM" --aspect 18 \
--msgbox "Unfortunately I couldn't mount the DSM partition!" 0 0
fi
}

###############################################################################
# Permit user select the modules to include
function selectModules() {
Expand Down Expand Up @@ -980,7 +1034,7 @@ function updateMenu() {
dialog --backtitle "`backtitle`" --title "Update arpl" --aspect 18 \
--yesno "Arpl updated with success to ${TAG}!\nReboot?" 0 0
[ $? -ne 0 ] && continue
reboot
arpl-reboot.sh config
exit
;;

Expand Down Expand Up @@ -1105,10 +1159,14 @@ while true; do
echo "a \"Addons\"" >> "${TMP_PATH}/menu"
echo "x \"Cmdline menu\"" >> "${TMP_PATH}/menu"
echo "i \"Synoinfo menu\"" >> "${TMP_PATH}/menu"
echo "d \"Build the loader\"" >> "${TMP_PATH}/menu"
fi
fi
echo "v \"Advanced menu\"" >> "${TMP_PATH}/menu"
if [ -n "${MODEL}" ]; then
if [ -n "${BUILD}" ]; then
echo "d \"Build the loader\"" >> "${TMP_PATH}/menu"
fi
fi
if loaderIsConfigured; then
echo "b \"Boot the loader\" " >> "${TMP_PATH}/menu"
fi
Expand All @@ -1117,7 +1175,7 @@ while true; do
echo "c \"Clean disk cache\"" >> "${TMP_PATH}/menu"
fi
echo "p \"Update menu\"" >> "${TMP_PATH}/menu"
echo "e \"Exit\"" >> "${TMP_PATH}/menu"
echo "e \"Exit\"" >> "${TMP_PATH}/menu"

dialog --default-item ${NEXT} --backtitle "`backtitle`" --colors \
--menu "Choose the option" 0 0 0 --file "${TMP_PATH}/menu" \
Expand All @@ -1131,7 +1189,7 @@ while true; do
x) cmdlineMenu; NEXT="i" ;;
i) synoinfoMenu; NEXT="d" ;;
d) make; NEXT="v" ;;
v) advancedMenu; NEXT="d" ;;
v) advancedMenu; NEXT="b" ;;
b) boot ;;
k) keymapMenu ;;
c) dialog --backtitle "`backtitle`" --title "Cleaning" --aspect 18 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ serial:
- "2040"
- "20C0"
- "2150"
middle: "SBR"
middle: "TQR"
suffix: "alpha"
disks: 4
builds:
Expand Down
7 changes: 6 additions & 1 deletion files/board/arpl/overlayfs/opt/arpl/ramdisk-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mkdir -p "${RAMDISK_PATH}"
MODEL="`readConfigKey "model" "${USER_CONFIG_FILE}"`"
BUILD="`readConfigKey "build" "${USER_CONFIG_FILE}"`"
LKM="`readConfigKey "lkm" "${USER_CONFIG_FILE}"`"
SN="`readConfigKey "sn" "${USER_CONFIG_FILE}"`"

if [ ${BUILD} -ne ${buildnumber} ]; then
echo -e "\033[A\n\033[1;32mBuild number changed from \033[1;31m${BUILD}\033[1;32m to \033[1;31m${buildnumber}\033[0m"
Expand Down Expand Up @@ -72,6 +73,8 @@ echo -n "."
for KEY in ${!SYNOINFO[@]}; do
_set_conf_kv "${KEY}" "${SYNOINFO[${KEY}]}" "${RAMDISK_PATH}/etc/synoinfo.conf" >"${LOG_FILE}" 2>&1 || dieLog
done
# Add serial number to synoinfo.conf, to help to recovery a installed DSM
_set_conf_kv "SN" "${SN}" "${RAMDISK_PATH}/etc/synoinfo.conf" >"${LOG_FILE}" 2>&1 || dieLog

# Patch /sbin/init.post
echo -n "."
Expand All @@ -80,9 +83,11 @@ sed -e "/@@@CONFIG-MANIPULATORS-TOOLS@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e
rm "${TMP_PATH}/rp.txt"
touch "${TMP_PATH}/rp.txt"
for KEY in ${!SYNOINFO[@]}; do
echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc/synoinfo.conf'" >> "${TMP_PATH}/rp.txt"
echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc/synoinfo.conf'" >> "${TMP_PATH}/rp.txt"
echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc.defaults/synoinfo.conf'" >> "${TMP_PATH}/rp.txt"
done
echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc/synoinfo.conf'" >> "${TMP_PATH}/rp.txt"
echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc.defaults/synoinfo.conf'" >> "${TMP_PATH}/rp.txt"
sed -e "/@@@CONFIG-GENERATED@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e '}' -i "${RAMDISK_PATH}/sbin/init.post"
rm "${TMP_PATH}/rp.txt"

Expand Down
1 change: 1 addition & 0 deletions files/board/arpl/overlayfs/root/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export EDITOR="/bin/nano"
export BOOTLOADER_PATH="/mnt/p1"
export SLPART_PATH="/mnt/p2" # Synologic partition
export CACHE_PATH="/mnt/p3"
export DSMROOT_PATH="/mnt/dsmroot"
export PATH="${PATH}:/opt/arpl"

if [ ! -f ${HOME}/.initialized ]; then
Expand Down
1 change: 1 addition & 0 deletions files/board/arpl/p1/ARPL-VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0-beta8
1 change: 1 addition & 0 deletions img-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fi
echo "Copying files"
VERSION=`cat VERSION`
sed 's/^ARPL_VERSION=.*/ARPL_VERSION="'${VERSION}'"/' -i files/board/arpl/overlayfs/opt/arpl/include/consts.sh
echo "${VERSION}" > files/board/arpl/p1/ARPL-VERSION
cp -Ru files/* .buildroot/

cd .buildroot
Expand Down
1 change: 1 addition & 0 deletions update-list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ replace:
".buildroot/output/images/bzImage": "/mnt/p3/bzImage-arpl"
".buildroot/output/images/rootfs.cpio.xz": "/mnt/p3/initrd-arpl"
"files/board/arpl/p1/grub/grub.cfg": "/mnt/p1/grub/grub.cfg"
"files/board/arpl/p1/ARPL-VERSION" : "/mnt/p1/ARPL-VERSION"
remove:

0 comments on commit 0ba4c03

Please sign in to comment.