Skip to content

Commit

Permalink
Eudev tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbelavenuto committed Jul 14, 2022
1 parent 9c372a2 commit 8093df3
Show file tree
Hide file tree
Showing 51 changed files with 134 additions and 305 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2-alpha3
0.3-alpha1
2 changes: 1 addition & 1 deletion files/board/arpl/make-img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dd if="/dev/zero" of="${IMAGE_FILE}" bs=1M count=300 conv=sync 2>/dev/null
# Copy grub stage1 to image
dd if="${BOARD_PATH}/grub.bin" of="${IMAGE_FILE}" conv=notrunc,sync 2>/dev/null
# Create partitions on image
echo -e "n\np\n\n\n+100M\nt\n\n0b\nn\np\n\n\n+100M\nn\np\n\n\n\nw" | fdisk "${IMAGE_FILE}" >/dev/null
echo -e "n\np\n\n\n+150M\nt\n\n0b\nn\np\n\n\n+50M\nn\np\n\n\n\nw" | fdisk "${IMAGE_FILE}" >/dev/null

# Force umount, ignore errors
sudo umount "${BINARIES_DIR}/p1" 2>/dev/null || true
Expand Down
3 changes: 2 additions & 1 deletion files/board/arpl/overlayfs/opt/arpl/include/consts.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

ARPL_VERSION="0.2-alpha3"
ARPL_VERSION="0.3-alpha1"

# Define paths
TMP_PATH="/tmp"
UNTAR_PAT_PATH="${TMP_PATH}/pat"
RAMDISK_PATH="${TMP_PATH}/ramdisk"
LOG_FILE="${TMP_PATH}/log.txt"

Expand Down
144 changes: 23 additions & 121 deletions files/board/arpl/overlayfs/opt/arpl/menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ fi
# Get actual IP
IP=`ip route get 1.1.1.1 2>/dev/null | awk '{print$7}'`

# Define classes for hw detection
declare -A CLASSES
CLASSES["0100"]="SCSI"
CLASSES["0106"]="SATA"
CLASSES["0101"]="IDE"
CLASSES["0107"]="SAS"
CLASSES["0200"]="Ethernet"
CLASSES["0300"]="VGA"
CLASSES["0c03"]="USB Controller"
CLASSES["0c04"]="Fiber Channel"

# Dirty flag
DIRTY=0

Expand Down Expand Up @@ -100,8 +89,7 @@ function modelMenu() {
SN=""
writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}"
# Delete old files
rm -f "${MOD_ZIMAGE_FILE}"
rm -f "${MOD_RDGZ_FILE}"
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
DIRTY=1
# Remove addons
writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}"
Expand All @@ -122,8 +110,7 @@ function buildMenu() {
writeConfigKey "build" "${BUILD}" "${USER_CONFIG_FILE}"
DIRTY=1
# Remove old files
rm -f "${MOD_ZIMAGE_FILE}"
rm -f "${MOD_RDGZ_FILE}"
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}"
fi
}

Expand Down Expand Up @@ -164,63 +151,6 @@ function serialMenu() {
writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}"
}

###############################################################################
# Detect hardware
function detectHw() {
PLATFORM="`readModelKey "${MODEL}" "platform"`"
KVER="`readModelKey "${MODEL}" "builds.${BUILD}.kver"`"
# Get modules not needed
unset NOTNEEDED
declare -A NOTNEEDED
while read M; do
NOTNEEDED[${M}]="1"
done < <(readModelArray "${MODEL}" "builds.${BUILD}.modules-notneeded")
unset DEVC DEVN
declare -A DEVC
declare -A DEVN
while read L; do
F=` sed -E 's/^([0-9a-z]{2}:[0-9a-z]{2}.[0-9a-z]{1})[^\[]*\[([0-9a-z]{4})\]: (.*)/\1|\2|\3/' <<<"${L}"`
PCI="`cut -d'|' -f1 <<<"${F}"`"
CLASS="`cut -d'|' -f2 <<<"${F}"`"
NAME="`cut -d'|' -f3 <<<"${F}"`"
MODULE="`lspci -ks "${PCI}" | awk '/Kernel driver in use/{print$5}'`"
[ -z "${MODULE}" ] && continue
# If is a virtio module, change id
if grep -q "virtio" <<<"$MODULE"; then
MODULE="virtio"
fi
CLASS=${CLASSES[${CLASS}]} # Get class name of module
[ -z "${CLASS}" ] && continue # If no class, skip
arrayExistItem "${MODULE}" "${!ADDONS[@]}" && continue # Check if module already added
[ -n "${NOTNEEDED[${MODULE}]}" ] && continue # Check if module is not necessary
# Add module to list
DEVC[${MODULE}]="${CLASS}"
DEVN[${MODULE}]="${NAME}"
done < <(lspci -nn)
if [ ${#DEVC[@]} -eq 0 ]; then
dialog --backtitle "`backtitle`" --aspect 18 \
--msgbox "No device detected or already added!" 0 0
return
fi
for MODULE in ${!DEVC[@]}; do
CLASS="${DEVC[${MODULE}]}"
NAME="${DEVN[${MODULE}]}"
TEXT="Found a ${NAME}\nClass ${CLASS}\nModule ${MODULE}\nAccept?"
checkAddonExist "${MODULE}" "${PLATFORM}" "${KVER}" || TEXT+="\n\n\Z1PS: Addon for this module not found\Zn"
dialog --backtitle "`backtitle`" --title "Found Hardware" \
--colors --yesno "${TEXT}" 12 70
[ $? -ne 0 ] && continue
dialog --backtitle "`backtitle`" --title "params" \
--inputbox "Type a opcional params to module" 0 0 \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && continue
VALUE="`<${TMP_PATH}/resp`"
ADDONS["${MODULE}"]="${VALUE}"
writeConfigKey "addons.${MODULE}" "${VALUE}" "${USER_CONFIG_FILE}"
DIRTY=1
done
}

###############################################################################
# Manage addons/drivers
function addonMenu() {
Expand All @@ -233,25 +163,19 @@ function addonMenu() {
while IFS="=" read KEY VALUE; do
[ -n "${KEY}" ] && ADDONS["${KEY}"]="${VALUE}"
done < <(readConfigMap "addons" "${USER_CONFIG_FILE}")
NEXT="h"
NEXT="a"
# Loop menu
while true; do
dialog --backtitle "`backtitle`" --default-item ${NEXT} \
--menu "Choose a option" 0 0 0 \
h "Detect hardware" \
a "Add an addon" \
d "Delete addon(s)" \
s "Show user addons" \
m "Show all available addons" \
o "Download an addon" \
e "Exit" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
case "`<${TMP_PATH}/resp`" in
h)
detectHw
NEXT='e'
;;
a) NEXT='a'
rm "${TMP_PATH}/menu"
while read ADDON DESC; do
Expand Down Expand Up @@ -317,32 +241,6 @@ function addonMenu() {
dialog --backtitle "`backtitle`" --title "Available addons" \
--colors --msgbox "${MSG}" 0 0
;;
o)
TEXT="please enter the complete URL to download.\n"
TEXT+="\Zb(Official addons location: https://github.com/fbelavenuto/arpl-addons/releases)\Zn\n"
TEXT+="Ex: https://github.com/fbelavenuto/arpl-addons/releases/download/v0.2/9p.addon"
dialog --backtitle "`backtitle`" --aspect 18 --colors --inputbox "${TEXT}" 0 0 \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && continue
URL="`<"${TMP_PATH}/resp"`"
[ -z "${URL}" ] && continue
clear
echo "Downloading ${URL}"
curl --insecure -L "${URL}" -o "${TMP_PATH}/addon.tgz" --progress-bar
if [ $? -ne 0 ]; then
dialog --backtitle "`backtitle`" --title "Error downloading" --aspect 18 \
--msgbox "Check internet or cache disk space" 0 0
return 1
fi
ADDON="`untarAddon "${TMP_PATH}/addon.tgz"`"
if [ -n "${ADDON}" ]; then
dialog --backtitle "`backtitle`" --title "Success" --aspect 18 \
--msgbox "Addon '${ADDON}' added to loader" 0 0
else
dialog --backtitle "`backtitle`" --title "Invalid addon" --aspect 18 \
--msgbox "File format not recognized!" 0 0
fi
;;
e) return ;;
esac
done
Expand Down Expand Up @@ -530,26 +428,13 @@ function synoinfoMenu() {
}

###############################################################################
# Where the magic happens :D
function make() {
clear
PLATFORM="`readModelKey "${MODEL}" "platform"`"
KVER="`readModelKey "${MODEL}" "builds.${BUILD}.kver"`"
# Extract linux and ramdisk files from the DSM .pat
function extractDsmFiles() {
PAT_URL="`readModelKey "${MODEL}" "builds.${BUILD}.pat.url"`"
PAT_HASH="`readModelKey "${MODEL}" "builds.${BUILD}.pat.hash"`"
RAMDISK_HASH="`readModelKey "${MODEL}" "builds.${BUILD}.pat.ramdisk-hash"`"
ZIMAGE_HASH="`readModelKey "${MODEL}" "builds.${BUILD}.pat.zimage-hash"`"

# Check if all addon exists
while IFS="=" read ADDON PARAM; do
[ -z "${ADDON}" ] && continue
if ! checkAddonExist "${ADDON}" "${PLATFORM}" "${KVER}"; then
dialog --backtitle "`backtitle`" --title "Error" --aspect 18 \
--msgbox "Addon ${ADDON} not found!" 0 0
return 1
fi
done < <(readConfigMap "addons" "${USER_CONFIG_FILE}")

if [ ${RAMCACHE} -eq 0 ]; then
OUT_PATH="${CACHE_PATH}/dl"
echo "Cache in disk"
Expand All @@ -559,7 +444,6 @@ function make() {
fi
mkdir -p "${OUT_PATH}"

UNTAR_PAT_PATH="${TMP_PATH}/pat"
PAT_FILE="${MODEL}-${BUILD}.pat"
PAT_PATH="${OUT_PATH}/${PAT_FILE}"
EXTRACTOR_PATH="${CACHE_PATH}/extractor"
Expand Down Expand Up @@ -690,6 +574,24 @@ function make() {
cp "${UNTAR_PAT_PATH}/zImage" "${ORI_ZIMAGE_FILE}"
cp "${UNTAR_PAT_PATH}/rd.gz" "${ORI_RDGZ_FILE}"
echo "OK"
}

function make() {
clear
PLATFORM="`readModelKey "${MODEL}" "platform"`"
KVER="`readModelKey "${MODEL}" "builds.${BUILD}.kver"`"

# Check if all addon exists
while IFS="=" read ADDON PARAM; do
[ -z "${ADDON}" ] && continue
if ! checkAddonExist "${ADDON}" "${PLATFORM}" "${KVER}"; then
dialog --backtitle "`backtitle`" --title "Error" --aspect 18 \
--msgbox "Addon ${ADDON} not found!" 0 0
return 1
fi
done < <(readConfigMap "addons" "${USER_CONFIG_FILE}")

[ ! -f "${ORI_ZIMAGE_FILE}" -o ! -f "${ORI_RDGZ_FILE}" ] && extractDsmFiles

/opt/arpl/zimage-patch.sh
if [ $? -ne 0 ]; then
Expand Down
16 changes: 0 additions & 16 deletions files/board/arpl/overlayfs/opt/arpl/model-configs/DS1621+.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
id: "DS1621+"
modules-notneeded: &modules-notneeded
- ahci
- ata_piix
- amd_xgbe
- marvell10g
- i40e
- r8168
- r8169
- ixgbe
- etxhci_hcd
- xhci_hcd
- ehci-pci
- uhci_hcd
- mv14xx
synoinfo: &synoinfo
support_disk_compatibility: "no"
support_memory_compatibility: "no"
Expand Down Expand Up @@ -50,7 +36,6 @@ builds:
kver: "4.4.180"
rd-compressed: false
efi-bug: no
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand All @@ -70,7 +55,6 @@ builds:
kver: "4.4.180"
rd-compressed: false
efi-bug: no
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand Down
14 changes: 0 additions & 14 deletions files/board/arpl/overlayfs/opt/arpl/model-configs/DS2422+.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
id: "DS2422+"
modules-notneeded: &modules-notneeded
- ahci
- ata_piix
- amd_xgbe
- marvell10g
- i40e
- r8168
- ixgbe
- etxhci_hcd
- xhci_hcd
- ehci-pci
- uhci_hcd
- mv14xx
synoinfo: &synoinfo
support_disk_compatibility: "no"
support_memory_compatibility: "no"
Expand Down Expand Up @@ -47,7 +34,6 @@ builds:
kver: "4.4.180"
rd-compressed: false
efi-bug: no
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand Down
14 changes: 0 additions & 14 deletions files/board/arpl/overlayfs/opt/arpl/model-configs/DS3615xs.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
id: "DS3615xs"
modules-notneeded: &modules-notneeded
- ahci
- ata_piix
- i40e
- ixgbe
- igb
- e1000e
- dca
- etxhci_hcd
- xhci_hcd
- ehci-pci
- uhci_hcd
synoinfo: &synoinfo
esataportcfg: "0x0"
usbportcfg: "0x8700"
Expand Down Expand Up @@ -42,7 +30,6 @@ builds:
kver: "3.10.108"
rd-compressed: false
efi-bug: yes
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand All @@ -63,7 +50,6 @@ builds:
kver: "3.10.108"
rd-compressed: false
efi-bug: yes
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand Down
14 changes: 0 additions & 14 deletions files/board/arpl/overlayfs/opt/arpl/model-configs/DS3617xs.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
id: "DS3617xs"
modules-notneeded: &modules-notneeded
- ahci
- ata_piix
- i40e
- ixgbe
- igb
- e1000e
- dca
- xhci_pci
- xhci_hcd
- uhci_hcd
- mv14xx
synoinfo: &synoinfo
esataportcfg: "0x00"
usbportcfg: "0x8700"
Expand Down Expand Up @@ -46,7 +34,6 @@ builds:
kver: "4.4.180"
rd-compressed: false
efi-bug: no
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand All @@ -67,7 +54,6 @@ builds:
kver: "4.4.180"
rd-compressed: false
efi-bug: no
modules-notneeded: *modules-notneeded
cmdline:
<<: *cmdline
synoinfo:
Expand Down
Loading

0 comments on commit 8093df3

Please sign in to comment.