mirror of
https://github.com/SynologyOpenSource/pkgscripts-ng.git
synced 2025-07-25 17:10:06 +00:00
186 lines
5.8 KiB
Bash
186 lines
5.8 KiB
Bash
#!/bin/bash
|
|
# Copyright (c) 2000-2020 Synology Inc. All rights reserved.
|
|
|
|
if [ -z "$__INCLUDE_PLATFORMS__" ]; then
|
|
__INCLUDE_PLATFORMS__=defined
|
|
|
|
. "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/init
|
|
Source include/variable
|
|
Source include/check
|
|
|
|
AllPlatformOptionNames="bromolow avoton alpine braswell apollolake grantley alpine4k monaco broadwell broadwellntbap kvmx64 kvmcloud armada38x denverton rtd1296 broadwellnk armada37xx purley geminilake v1000 epyc7002 r1000 broadwellnkv2 rtd1619b geminilakenk r1000nk v1000nk"
|
|
|
|
AllPlatforms=" bromolow BROMOLOW linux-3.10.x Intel Bromolow
|
|
avoton AVOTON linux-3.10.x Intel Avoton
|
|
alpine ALPINE linux-3.10.x-bsp AnnapurnaLabs Alpine
|
|
alpine4k ALPINE linux-3.10.x-bsp AnnapurnaLabs Alpine
|
|
braswell BRASWELL linux-3.10.x Intel Braswell
|
|
apollolake APOLLOLAKE linux-4.4.x Intel Apollo Lake
|
|
grantley GRANTLEY linux-3.10.x Intel Grantley
|
|
broadwell BROADWELL linux-4.4.x Intel Broadwell
|
|
broadwellnk BROADWELLNK linux-4.4.x Intel Broadwell with new kernel
|
|
broadwellntbap BROADWELLNTBAP linux-4.4.x Intel Broadwell with ntb kernel config in AP mode
|
|
monaco STM_MONACO linux-3.10.x-bsp STM Monaco H412
|
|
kvmx64 KVMX64 linux-4.4.x Virtual Machine
|
|
kvmcloud KVMCLOUD linux-4.4.x Virtual Machine on cloud
|
|
armada38x MARVELL_ARMADA38X linux-3.10.x-bsp Marvell armada38x
|
|
rtd1296 REALTEK_RTD1296 linux-4.4.x Realtek rtd1296
|
|
denverton DENVERTON linux-4.4.x Intel Denverton
|
|
purley PURLEY linux-4.4.x Intel Purley
|
|
armada37xx MARVELL_ARMADA37XX linux-4.4.x Marvell armada37xx
|
|
geminilake GEMINILAKE linux-4.4.x Intel Gemini Lake
|
|
v1000 V1000 linux-4.4.x AMD Ryzen Embedded V1000
|
|
epyc7002 EPYC7002 linux-5.10.x AMD EPYC embedded 7002 Rome
|
|
r1000 R1000 linux-4.4.x AMD Ryzen Embedded R1000
|
|
broadwellnkv2 BROADWELLNKV2 linux-4.4.x Intel Broadwell with port mapping v2
|
|
rtd1619b REALTEK_RTD1619B linux-5.10.x Realtek rtd1619b
|
|
geminilakenk GEMINILAKENK linux-5.10.x Intel Gemini Lake with kernel 5.10
|
|
r1000nk R1000NK linux-5.10.x AMD Ryzen Embedded R1000
|
|
v1000nk V1000NK linux-5.10.x AMD Ryzen Embedded V1000 with kernel 5.10
|
|
"
|
|
|
|
#
|
|
# Return name list of all supported platforms
|
|
#
|
|
AllPlatformOptions () {
|
|
echo "$AllPlatformOptionNames"
|
|
}
|
|
|
|
Is64BitPlatform() {
|
|
[ "$PLATFORM_FAMILY" = "SYNOPLAT_F_X86_64" ] || [ "$PLATFORM_FAMILY" = "SYNOPLAT_F_ARMV8" ]
|
|
}
|
|
|
|
|
|
# check build platform and set the corresponding variables:
|
|
# PLATFORM_ABBR, BUILD_TARGET, BUILD_OPT
|
|
#
|
|
# Usage
|
|
# AskPlatform $@
|
|
AskPlatform()
|
|
{
|
|
# PLATFORM_ABBR BUILD_TARGET kernel_version Comment
|
|
local INDEX="" i=1 abbr target kernel comment others
|
|
declare -a AbbrArray TargetArray
|
|
# init array & hash table
|
|
line=`echo "$AllPlatforms"| wc -l`
|
|
for (( i=1; i <= line; i++ )); do
|
|
abbr=`echo "$AllPlatforms" | awk '(NR=='$i'){print $1}'`
|
|
target=`echo "$AllPlatforms" | awk '(NR=='$i'){print $2}'`
|
|
declare AbbrHash_$abbr=$i
|
|
declare TargetHash_$target=$i
|
|
AbbrArray[$i]=$abbr
|
|
TargetArray[$i]=$target
|
|
done
|
|
|
|
if [ $# -gt 0 ]; then
|
|
for ThisArg in $@; do
|
|
# Remember platform choice
|
|
INDEX=AbbrHash_${ThisArg#--*}
|
|
if [ -n "${!INDEX}" ]; then
|
|
PLATFORM_ABBR=${ThisArg#--*}
|
|
BUILD_TARGET=${TargetArray[${!INDEX}]}
|
|
BUILD_OPT="--${PLATFORM_ABBR}"
|
|
fi
|
|
done
|
|
fi
|
|
if [ -z "${!INDEX}" -a -f /root/.bashrc -a -f /root/.chroot ]; then
|
|
PLATFORM_ABBR=$(grep "CCACHE_DIR=" /root/.bashrc | cut -d'"' -f2 | cut -d'/' -f3)
|
|
INDEX=AbbrHash_${PLATFORM_ABBR}
|
|
if [ -n "${!INDEX}" ]; then
|
|
BUILD_TARGET=${TargetArray[${!INDEX}]}
|
|
BUILD_OPT="--${PLATFORM_ABBR}"
|
|
else
|
|
echo "Failed to detect platform (\$platform) in /root/.bashrc"
|
|
fi
|
|
# Since alpine family share the same SYNO_PLATFORM, the above table scanning
|
|
# falls back to the latest ALPINE entry (alpine4k), we have to use another
|
|
# way to distinguish them
|
|
if [ "${BUILD_TARGET}" = "ALPINE" ]; then
|
|
local platform="alpine"
|
|
cat /root/.bashrc | grep "PS1" | grep "alpine4k" > /dev/null
|
|
if [ $? -eq 0 ]; then
|
|
platform="alpine4k"
|
|
fi
|
|
PLATFORM_ABBR="${platform}"
|
|
BUILD_OPT="--${platform}"
|
|
fi
|
|
fi
|
|
|
|
# Ask platform interactively if not specified in argument
|
|
if [ -z "$BUILD_TARGET" ]; then
|
|
echo "Please choose target platform:"
|
|
i=0
|
|
echo "$AllPlatforms" | while read abbr target kernel comment; do
|
|
printf "\t%4s %-30s%-20s%-20s\n" \
|
|
"[$((i+=1))]" "$comment" "($kernel)" "{--$abbr}"
|
|
done
|
|
echo -en "Enter a number: "
|
|
read Reply;
|
|
if [ -z "${AbbrArray[$Reply]}" ]; then
|
|
echo "Unknow platform. EXIT!!"
|
|
exit 1
|
|
fi
|
|
PLATFORM_ABBR="${AbbrArray[${Reply}]}"
|
|
BUILD_TARGET=${TargetArray[$Reply]}
|
|
BUILD_OPT="--${PLATFORM_ABBR}"
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Return name list of all supported platforms, comma separated
|
|
#
|
|
AllPlatformOptionsComma ()
|
|
{
|
|
local RetString
|
|
for PLATFORM in $AllPlatformOptionNames; do
|
|
RetString="${RetString}${PLATFORM},"
|
|
done
|
|
echo $RetString
|
|
}
|
|
|
|
#
|
|
# Check if $1 is a supported platform name.
|
|
# Support both forms of "platform" and "--platform".
|
|
#
|
|
# Returns 0 if true, else 1
|
|
#
|
|
IsPlatformOption ()
|
|
{
|
|
if [ $# -gt 1 ]; then
|
|
return 1
|
|
fi
|
|
for PLATFORM in $AllPlatformOptionNames; do
|
|
if [ "$1" = "$PLATFORM" ]; then
|
|
return 0
|
|
fi
|
|
# Handle arg with "--" too
|
|
if [ "$1" = "--$PLATFORM" ]; then
|
|
return 0
|
|
fi
|
|
done
|
|
# not matching any of known platforms
|
|
return 1
|
|
}
|
|
|
|
##########################################################################
|
|
# Read platform config file {{{
|
|
#
|
|
LoadPlatformRelated()
|
|
{
|
|
if ! source ${ScriptsDir}/include/platform.${PLATFORM_ABBR}; then
|
|
echo "Failed to include ${ScriptsDir}/include/platform.${PLATFORM_ABBR}"
|
|
return 1
|
|
fi
|
|
|
|
export SYNO_PLATFORM="${BUILD_TARGET}"
|
|
|
|
return 0
|
|
}
|
|
|
|
checkPlatformFunction() {
|
|
CheckInList "$1" $PLAT_SPEC_VAR
|
|
}
|
|
|
|
fi
|
|
# vim:ft=sh
|