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