优化代码
This commit is contained in:
parent
7882c3c7ff
commit
3beadb0c6b
|
@ -35,7 +35,7 @@ GET_TARGET_INFO() {
|
|||
while [[ -z "${x86_Test}" ]]
|
||||
do
|
||||
x86_Test="$(egrep -o "CONFIG_TARGET.*DEVICE.*=y" .config | sed -r 's/CONFIG_TARGET_(.*)_DEVICE_(.*)=y/\1/')"
|
||||
[[ ! -z "${x86_Test}" ]] && break
|
||||
[[ -n "${x86_Test}" ]] && break
|
||||
x86_Test="$(egrep -o "CONFIG_TARGET.*Generic=y" .config | sed -r 's/CONFIG_TARGET_(.*)_Generic=y/\1/')"
|
||||
[[ -z "${x86_Test}" ]] && TIME "Can not obtain the TARGET_PROFILE !" && exit 1
|
||||
done
|
||||
|
@ -47,8 +47,7 @@ GET_TARGET_INFO() {
|
|||
[[ -z "${TARGET_PROFILE}" ]] && TARGET_PROFILE="${Default_Device}"
|
||||
case ${TARGET_PROFILE} in
|
||||
x86_64)
|
||||
grep "CONFIG_TARGET_IMAGES_GZIP=y" ${Home}/.config > /dev/null 2>&1
|
||||
if [[ ! "$?" -ne 0 ]];then
|
||||
if [[ "$(cat ${Home}/.config)" =~ "CONFIG_TARGET_IMAGES_GZIP=y" ]];then
|
||||
Firmware_Type="img.gz"
|
||||
else
|
||||
Firmware_Type="img"
|
||||
|
@ -288,28 +287,40 @@ Mkdir() {
|
|||
|
||||
PKG_Finder() {
|
||||
unset PKG_RESULT
|
||||
PKG_TYPE=${1}
|
||||
PKG_DIR=${2}
|
||||
PKG_NAME=${3}
|
||||
[[ -z ${PKG_TYPE} ]] && [[ -z ${PKG_NAME} ]] || [[ -z ${PKG_DIR} ]] && return
|
||||
PKG_RESULT=$(find -name ${PKG_DIR}/${PKG_NAME} -type ${PKG_TYPE} -exec echo {} \;)
|
||||
if [[ ! -z "${PKG_RESULT}" ]];then
|
||||
TIME "[${PKG_NAME}] is detected,Dir: ${PKG_RESULT}"
|
||||
fi
|
||||
unset PKG_TYPE PKG_DIR PKG_NAME
|
||||
_PKG_TYPE=${1}
|
||||
_PKG_DIR=${2}
|
||||
_PKG_NAME=${3}
|
||||
[[ -z ${_PKG_TYPE} ]] && [[ -z ${_PKG_NAME} ]] || [[ -z ${_PKG_DIR} ]] && return
|
||||
PKG_RESULT=$(find -name ${_PKG_DIR}/${_PKG_NAME} -type ${_PKG_TYPE} -exec echo {} \;)
|
||||
[[ -n "${_PKG_RESULT}" ]] && echo "${_PKG_RESULT}"
|
||||
unset _PKG_TYPE _PKG_DIR _PKG_NAME
|
||||
}
|
||||
|
||||
Auto_ExtraPackages() {
|
||||
[[ ! -f "${GITHUB_WORKSPACE}/CustomPackages/${TARGET_PROFILE}" ]] && return
|
||||
TIME "Loading Custom Packages list: [${TARGET_PROFILE}] ..."
|
||||
echo "" >> ${GITHUB_WORKSPACE}/CustomPackages/${TARGET_PROFILE}
|
||||
cat ${GITHUB_WORKSPACE}/CustomPackages/${TARGET_PROFILE} | while read X
|
||||
do
|
||||
[[ -z "${X}" ]] && break
|
||||
ExtraPackages ${X}
|
||||
unset X
|
||||
done
|
||||
TIME "[CustomPackages] All done !"
|
||||
COMMON_FILE="${GITHUB_WORKSPACE}/CustomPackages/Common"
|
||||
TARGET_FILE="${GITHUB_WORKSPACE}/CustomPackages/${TARGET_PROFILE}"
|
||||
|
||||
if [ -f "${TARGET_FILE}" ];then
|
||||
if [ -f "${COMMON_FILE}" ];then
|
||||
TIME "Loading Common Packages list ..."
|
||||
echo -e "\n$(cat ${COMMON_FILE})" >> ${TARGET_FILE}
|
||||
fi
|
||||
TIME "Loading Custom Packages list: [${TARGET_PROFILE}] ..."
|
||||
cat ${TARGET_FILE} | while read X
|
||||
do
|
||||
[[ -n "${X}" ]] && {
|
||||
if [[ ! "${X}" =~ "#" ]];then
|
||||
ExtraPackages ${X}
|
||||
else
|
||||
TIME "Skip line: ${X}"
|
||||
fi
|
||||
}
|
||||
unset X
|
||||
done
|
||||
TIME "[CustomPackages] All done !"
|
||||
else
|
||||
TIME "Custom Packages list: [${TARGET_PROFILE}] is not detected !"
|
||||
fi
|
||||
}
|
||||
|
||||
ExtraPackages() {
|
||||
|
@ -319,21 +330,17 @@ ExtraPackages() {
|
|||
REPO_URL=${4}
|
||||
REPO_BRANCH=${5}
|
||||
|
||||
if [[ $# -lt 4 ]];then
|
||||
TIME "[ERROR] [$#] Missing options,skip check out..."
|
||||
return
|
||||
fi
|
||||
Mkdir package/${PKG_DIR}
|
||||
if [ -d "package/${PKG_DIR}/${PKG_NAME}" ];then
|
||||
TIME "Removing old package [${PKG_NAME}] ..."
|
||||
rm -rf package/${PKG_DIR}/${PKG_NAME}
|
||||
fi
|
||||
[ -d "${PKG_NAME}" ] && rm -rf ${PKG_NAME}
|
||||
TIME "Checking out package [${PKG_NAME}] to package/${PKG_DIR} ..."
|
||||
case "${PKG_PROTO}" in
|
||||
git)
|
||||
[[ -z "${REPO_BRANCH}" ]] && REPO_BRANCH=master
|
||||
git clone -b ${REPO_BRANCH} ${REPO_URL}/${PKG_NAME} ${PKG_NAME} > /dev/null 2>&1
|
||||
PKG_URL="$(echo ${REPO_URL}/${PKG_NAME} | sed s/[[:space:]]//g)"
|
||||
git clone -b ${REPO_BRANCH} ${PKG_URL} ${PKG_NAME} > /dev/null 2>&1
|
||||
;;
|
||||
svn)
|
||||
svn checkout ${REPO_URL}/${PKG_NAME} ${PKG_NAME} > /dev/null 2>&1
|
||||
|
@ -342,7 +349,7 @@ ExtraPackages() {
|
|||
TIME "[ERROR] Error option: ${PKG_PROTO} !" && return
|
||||
;;
|
||||
esac
|
||||
if [ -f ${PKG_NAME}/Makefile ] || [ -f ${PKG_NAME}/README* ] || [ ! "$(ls -A ${PKG_NAME})" = "" ];then
|
||||
if [ -f ${PKG_NAME}/Makefile ] || [ -f ${PKG_NAME}/README* ];then
|
||||
TIME "Package [${PKG_NAME}] is detected!"
|
||||
mv -f ${PKG_NAME} package/${PKG_DIR}
|
||||
fi
|
||||
|
@ -358,12 +365,12 @@ Replace_File() {
|
|||
[ -f "${GITHUB_WORKSPACE}/${FILE_NAME}" ] && _TYPE1="f" && _TYPE2="File"
|
||||
[ -d "${GITHUB_WORKSPACE}/${FILE_NAME}" ] && _TYPE1="d" && _TYPE2="Folder"
|
||||
if [ -${_TYPE1} "${GITHUB_WORKSPACE}/${FILE_NAME}" ];then
|
||||
[[ ! -z "${FILE_RENAME}" ]] && _RENAME="${FILE_RENAME}" || _RENAME=""
|
||||
[[ -n "${FILE_RENAME}" ]] && _RENAME="${FILE_RENAME}" || _RENAME=""
|
||||
if [ -${_TYPE1} "${GITHUB_WORKSPACE}/${FILE_NAME}" ];then
|
||||
TIME "Moving [${_TYPE2}] ${FILE_NAME} to ${2}/${FILE_RENAME} ..."
|
||||
mv -f ${GITHUB_WORKSPACE}/${FILE_NAME} ${PATCH_DIR}/${_RENAME}
|
||||
else
|
||||
TIME "CustomFiles ${_TYPE2} [${FILE_NAME}] is not detected,skip move ..."
|
||||
TIME "CustomFiles ${_TYPE2} [${FILE_NAME}] is not detected !"
|
||||
fi
|
||||
fi
|
||||
unset FILE_NAME PATCH_DIR FILE_RENAME
|
||||
|
@ -382,13 +389,13 @@ Update_Makefile() {
|
|||
PKG_DL_URL="${PKG_SOURCE_URL%\$(\PKG_VERSION*}"
|
||||
Offical_Version="$(curl -s ${api_URL} 2>/dev/null | grep 'tag_name' | egrep -o '[0-9].+[0-9.]+' | awk 'NR==1')"
|
||||
if [[ -z "${Offical_Version}" ]];then
|
||||
TIME "[ERROR] Failed to obtain the Offical version of [${PKG_NAME}],skip update ..."
|
||||
TIME "[ERROR] Failed to obtain the Offical version of [${PKG_NAME}] !"
|
||||
return
|
||||
fi
|
||||
Source_Version="$(grep "PKG_VERSION:=" ${Makefile} | cut -c14-20)"
|
||||
Source_HASH="$(grep "PKG_HASH:=" ${Makefile} | cut -c11-100)"
|
||||
if [[ -z "${Source_Version}" ]] || [[ -z "${Source_HASH}" ]];then
|
||||
TIME "[ERROR] Failed to obtain the Source version or Hash,skip update ..."
|
||||
TIME "[ERROR] Failed to obtain the Source version or Hash !"
|
||||
return
|
||||
fi
|
||||
if [[ ! "${Source_Version}" == "${Offical_Version}" ]];then
|
||||
|
@ -399,11 +406,11 @@ Update_Makefile() {
|
|||
Offical_HASH="$(sha256sum /tmp/tmp_file | cut -d ' ' -f1)"
|
||||
sed -i "s?PKG_HASH:=${Source_HASH}?PKG_HASH:=${Offical_HASH}?g" ${Makefile}
|
||||
else
|
||||
TIME "[ERROR] Failed to update the package [${PKG_NAME}],skip update ..."
|
||||
TIME "[ERROR] Failed to update the package [${PKG_NAME}] !"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
TIME "Package ${PKG_NAME} is not detected,skip update ..."
|
||||
TIME "Package ${PKG_NAME} is not detected !"
|
||||
fi
|
||||
unset _process1 _process2 Offical_Version Source_Version
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue