X-OpenWrt/Scripts/AutoBuild_Function.sh

482 lines
13 KiB
Bash
Raw Normal View History

2021-01-05 23:38:00 +00:00
#!/bin/bash
2021-06-06 05:55:56 +00:00
# AutoBuild Module by Hyy2001 <https://github.com/Hyy2001X/AutoBuild-Actions>
2021-01-05 23:38:00 +00:00
# AutoBuild Functions
Firmware_Diy_Before() {
ECHO "[Firmware_Diy_Before] Starting ..."
2022-03-23 12:59:28 +00:00
WORK="${GITHUB_WORKSPACE}/openwrt"
CONFIG_TEMP="${GITHUB_WORKSPACE}/openwrt/.config"
2022-03-23 12:59:28 +00:00
CD ${WORK}
Firmware_Diy_Core
2022-08-31 14:18:39 +00:00
[[ ${Short_Fw_Date} == true ]] && Compile_Date="$(cut -c1-8 <<< ${Compile_Date})"
Github="$(grep "https://github.com/[a-zA-Z0-9]" ${GITHUB_WORKSPACE}/.git/config | cut -c8-100 | sed 's/^[ \t]*//g')"
2022-08-31 14:18:39 +00:00
[[ -z ${Author} || ${Author} == AUTO ]] && Author="$(cut -d "/" -f4 <<< ${Github})"
OP_AUTHOR="$(cut -d "/" -f4 <<< ${REPO_URL})"
OP_REPO="$(cut -d "/" -f5 <<< ${REPO_URL})"
2022-03-23 12:59:28 +00:00
OP_BRANCH="$(Get_Branch)"
if [[ ${OP_BRANCH} =~ (master|main) ]]
then
OP_VERSION_HEAD="R$(date +%y.%m)-"
else
2022-08-31 14:18:39 +00:00
OP_BRANCH="$(egrep -o "[0-9]+.[0-9]+" <<< ${OP_BRANCH} | awk 'NR==1')"
OP_VERSION_HEAD="R${OP_BRANCH}-"
fi
case "${OP_AUTHOR}/${OP_REPO}" in
coolsnowwolf/lede)
2022-03-15 03:46:54 +00:00
Version_File=package/lean/default-settings/files/zzz-default-settings
2021-07-02 15:51:31 +00:00
zzz_Default_Version="$(egrep -o "R[0-9]+\.[0-9]+\.[0-9]+" ${Version_File})"
OP_VERSION="${zzz_Default_Version}-${Compile_Date}"
;;
immortalwrt/immortalwrt)
2022-03-15 03:46:54 +00:00
Version_File=package/base-files/files/etc/openwrt_release
OP_VERSION="${OP_VERSION_HEAD}${Compile_Date}"
;;
*)
OP_VERSION="${OP_VERSION_HEAD}${Compile_Date}"
;;
esac
2021-06-17 09:55:08 +00:00
while [[ -z ${x86_Test} ]];do
x86_Test="$(egrep -o "CONFIG_TARGET.*DEVICE.*=y" ${CONFIG_TEMP} | sed -r 's/CONFIG_TARGET_(.*)_DEVICE_(.*)=y/\1/')"
2021-06-17 09:55:08 +00:00
[[ -n ${x86_Test} ]] && break
x86_Test="$(egrep -o "CONFIG_TARGET.*Generic=y" ${CONFIG_TEMP} | sed -r 's/CONFIG_TARGET_(.*)_Generic=y/\1/')"
[[ -z ${x86_Test} ]] && break
done
2022-03-23 12:59:28 +00:00
if [[ ${x86_Test} == x86_64 ]]
then
2021-06-06 05:55:56 +00:00
TARGET_PROFILE=x86_64
2022-03-23 12:59:28 +00:00
else
TARGET_PROFILE="$(egrep -o "CONFIG_TARGET.*DEVICE.*=y" ${CONFIG_TEMP} | sed -r 's/.*DEVICE_(.*)=y/\1/')"
2022-03-23 12:59:28 +00:00
fi
[[ -z ${TARGET_PROFILE} ]] && ECHO "Unable to get [TARGET_PROFILE] !"
TARGET_BOARD="$(awk -F '[="]+' '/TARGET_BOARD/{print $2}' ${CONFIG_TEMP})"
TARGET_SUBTARGET="$(awk -F '[="]+' '/TARGET_SUBTARGET/{print $2}' ${CONFIG_TEMP})"
2022-03-23 12:59:28 +00:00
if [[ -z ${Fw_MFormat} || ${Fw_MFormat} =~ (false|AUTO) ]]
then
case "${TARGET_BOARD}" in
ramips | reltek | ath* | ipq* | bcm47xx | bmips | kirkwood | mediatek)
2022-03-23 12:59:28 +00:00
Fw_MFormat=bin
;;
rockchip | x86 | bcm27xx | mxs | sunxi | zynq)
2022-03-23 12:59:28 +00:00
Fw_MFormat="$(gz_Check)"
;;
mvebu)
case "${TARGET_SUBTARGET}" in
cortexa53 | cortexa72)
2022-03-23 12:59:28 +00:00
Fw_MFormat="$(gz_Check)"
;;
esac
;;
octeon | oxnas | pistachio)
2022-03-23 12:59:28 +00:00
Fw_MFormat=tar
;;
esac
2022-03-23 12:59:28 +00:00
fi
2022-03-15 03:46:54 +00:00
[[ ${Author_URL} != false && ${Author_URL} == AUTO ]] && Author_URL="${Github}"
[[ ${Author_URL} == false ]] && unset Author_URL
2022-03-23 12:59:28 +00:00
if [[ ${Default_Flag} == AUTO ]]
then
TARGET_FLAG=${CONFIG_FILE/${TARGET_PROFILE}-/}
[[ ${TARGET_FLAG} =~ ${TARGET_PROFILE} || -z ${TARGET_FLAG} || ${TARGET_FLAG} == ${CONFIG_FILE} ]] && TARGET_FLAG=Full
else
2022-03-23 12:59:28 +00:00
if [[ ! ${Default_Flag} =~ (\"|=|-|_|\.|\#|\|) && ${Default_Flag} =~ [a-zA-Z0-9] ]]
then
2022-03-23 12:59:28 +00:00
TARGET_FLAG="${Default_Flag}"
fi
fi
if [[ ! ${Tempoary_FLAG} =~ (\"|=|-|_|\.|\#|\|) && ${Tempoary_FLAG} =~ [a-zA-Z0-9] ]]
then
TARGET_FLAG="${Tempoary_FLAG}"
fi
2021-07-16 16:11:35 +00:00
case "${TARGET_BOARD}" in
x86)
2022-03-23 12:59:28 +00:00
AutoBuild_Fw="AutoBuild-${OP_REPO}-${TARGET_PROFILE}-${OP_VERSION}-BOOT-${TARGET_FLAG}-SHA256.FORMAT"
2021-06-06 05:55:56 +00:00
;;
*)
2022-03-23 12:59:28 +00:00
AutoBuild_Fw="AutoBuild-${OP_REPO}-${TARGET_PROFILE}-${OP_VERSION}-${TARGET_FLAG}-SHA256.FORMAT"
2021-06-06 05:55:56 +00:00
;;
esac
cat >> ${GITHUB_ENV} <<EOF
2022-03-23 12:59:28 +00:00
WORK=${WORK}
CONFIG_TEMP=${CONFIG_TEMP}
2022-03-23 12:59:28 +00:00
AutoBuild_Features=${AutoBuild_Features}
x86_Full_Images=${x86_Full_Images}
AutoBuild_Fw=${AutoBuild_Fw}
2021-08-03 10:41:36 +00:00
CustomFiles=${GITHUB_WORKSPACE}/CustomFiles
Scripts=${GITHUB_WORKSPACE}/Scripts
2022-03-15 03:46:54 +00:00
BASE_FILES=${GITHUB_WORKSPACE}/openwrt/package/base-files/files
FEEDS_LUCI=${GITHUB_WORKSPACE}/openwrt/package/feeds/luci
FEEDS_PKG=${GITHUB_WORKSPACE}/openwrt/package/feeds/packages
2022-03-23 12:59:28 +00:00
Default_Title="${Default_Title}"
Regex_Skip="${Regex_Skip}"
Version_File=${Version_File}
2022-03-23 12:59:28 +00:00
Fw_MFormat=${Fw_MFormat}
FEEDS_CONF=${WORK}/feeds.conf.default
Author_URL=${Author_URL}
ENV_FILE=${GITHUB_ENV}
2021-06-06 05:55:56 +00:00
EOF
source ${GITHUB_ENV}
echo -e "### VARIABLE LIST ###\n$(cat ${GITHUB_ENV})\n"
ECHO "[Firmware_Diy_Before] Done"
2021-01-11 13:44:45 +00:00
}
Firmware_Diy_Main() {
ECHO "[Firmware_Diy_Main] Starting ..."
2022-03-23 12:59:28 +00:00
CD ${WORK}
2022-03-15 03:46:54 +00:00
chmod 777 -R ${Scripts} ${CustomFiles}
2022-03-23 12:59:28 +00:00
if [[ ${AutoBuild_Features} == true ]]
then
2023-03-12 15:55:38 +00:00
AddPackage git other AutoBuild-Packages xopenwrt master
2022-09-09 04:29:47 +00:00
echo -e "\nCONFIG_PACKAGE_luci-app-autoupdate=y" >> ${CONFIG_FILE}
2022-05-07 05:32:10 +00:00
for i in ${GITHUB_ENV} $(PKG_Finder d package AutoBuild-Packages)/autoupdate/files/etc/autoupdate/default
do
cat >> ${i} <<EOF
Author=${Author}
Github=${Github}
TARGET_PROFILE=${TARGET_PROFILE}
TARGET_BOARD=${TARGET_BOARD}
TARGET_SUBTARGET=${TARGET_SUBTARGET}
TARGET_FLAG=${TARGET_FLAG}
OP_VERSION=${OP_VERSION}
OP_AUTHOR=${OP_AUTHOR}
OP_REPO=${OP_REPO}
OP_BRANCH=${OP_BRANCH}
EOF
2022-05-06 08:40:05 +00:00
done ; unset i
2022-05-07 05:32:10 +00:00
AutoUpdate_Version=$(awk -F '=' '/Version/{print $2}' $(PKG_Finder d package AutoBuild-Packages)/autoupdate/files/bin/autoupdate | awk 'NR==1')
2022-05-06 08:40:05 +00:00
Copy ${CustomFiles}/Depends/tools ${BASE_FILES}/bin
Copy ${CustomFiles}/Depends/profile ${BASE_FILES}/etc
Copy ${CustomFiles}/Depends/base-files-essential ${BASE_FILES}/lib/upgrade/keep.d
case "${OP_AUTHOR}/${OP_REPO}" in
coolsnowwolf/lede)
2022-05-06 08:40:05 +00:00
Copy ${CustomFiles}/Depends/coremark.sh $(PKG_Finder d "package feeds" coremark)
2021-11-03 01:16:26 +00:00
sed -i '\/etc\/firewall.user/d;/exit 0/d' ${Version_File}
if [[ -n ${TARGET_FLAG} ]]
then
sed -i "s?${zzz_Default_Version}?${TARGET_FLAG} ${zzz_Default_Version} @ ${Author} [${Display_Date}]?g" ${Version_File}
else
sed -i "s?${zzz_Default_Version}?${zzz_Default_Version} @ ${Author} [${Display_Date}]?g" ${Version_File}
fi
;;
immortalwrt/immortalwrt)
Copy ${CustomFiles}/Depends/openwrt_release_${OP_AUTHOR} ${BASE_FILES}/etc openwrt_release
if [[ -n ${TARGET_FLAG} ]]
then
sed -i "s?ImmortalWrt?ImmortalWrt ${TARGET_FLAG} @ ${Author} [${Display_Date}]?g" ${Version_File}
else
sed -i "s?ImmortalWrt?ImmortalWrt @ ${Author} [${Display_Date}]?g" ${Version_File}
fi
;;
esac
2021-08-05 07:27:21 +00:00
sed -i "s?By?By ${Author}?g" ${CustomFiles}/Depends/banner
sed -i "s?Openwrt?Openwrt ${OP_VERSION} / AutoUpdate ${AutoUpdate_Version}?g" ${CustomFiles}/Depends/banner
2022-03-23 12:59:28 +00:00
if [[ -n ${Default_Title} ]]
then
if [[ -n ${TARGET_FLAG} ]]
then
2022-03-23 12:59:28 +00:00
sed -i "s?Powered by AutoBuild-Actions?${Default_Title} @ ${TARGET_FLAG}?g" ${CustomFiles}/Depends/banner
else
2022-03-23 12:59:28 +00:00
sed -i "s?Powered by AutoBuild-Actions?${Default_Title}?g" ${CustomFiles}/Depends/banner
fi
fi
case "${OP_AUTHOR}/${OP_REPO}" in
immortalwrt/immortalwrt)
2022-05-06 08:40:05 +00:00
Copy ${CustomFiles}/Depends/banner $(PKG_Finder d package default-settings)/files openwrt_banner
;;
*)
Copy ${CustomFiles}/Depends/banner ${BASE_FILES}/etc
;;
esac
fi
2022-03-23 12:59:28 +00:00
if [[ -n ${Tempoary_IP} ]]
then
ECHO "Using Tempoary IP Address: ${Tempoary_IP} ..."
Default_IP="${Tempoary_IP}"
2022-03-23 12:59:28 +00:00
fi
if [[ -n ${Default_IP} && ${Default_IP} =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
Old_IP=$(awk -F '[="]+' '/ipaddr:-/{print $3}' ${BASE_FILES}/bin/config_generate | awk 'NR==1')
if [[ ! ${Default_IP} == ${Old_IP} ]]
then
ECHO "Setting default IP Address to ${Default_IP} ..."
sed -i "s/${Old_IP}/${Default_IP}/g" ${BASE_FILES}/bin/config_generate
fi
2022-03-23 12:59:28 +00:00
fi
ECHO "[Firmware_Diy_Main] Done"
}
Firmware_Diy_Other() {
ECHO "[Firmware_Diy_Other] Starting ..."
2022-03-23 12:59:28 +00:00
CD ${WORK}
if [[ -n ${Author_URL} ]]
then
cat >> ${CONFIG_TEMP} <<EOF
CONFIG_KERNEL_BUILD_USER="${Author}"
CONFIG_KERNEL_BUILD_DOMAIN="${Author_URL}"
EOF
fi
2022-08-21 02:13:10 +00:00
Kconfig_Path=${CustomFiles}/Kconfig
Tree=${WORK}/target/linux
cd ${Kconfig_Path}
for i in $(du -a | awk '{print $2}' | busybox sed -r 's/.\//\1/' | grep -wv '^.' | sort | uniq)
do
if [[ -d $i && $(ls -1 $i 2> /dev/null) ]]
then
:
elif [[ -e $i ]]
then
_Kconfig=$(dirname $i)
__Kconfig=$(basename $i)
ECHO " - Found Kconfig_file: ${__Kconfig} at ${_Kconfig}"
if [[ -e ${Tree}/$i && ${__Kconfig} != config-generic ]]
then
ECHO " -- Found Tree: ${Tree}/$i, refreshing ${Tree}/$i ..."
echo >> ${Tree}/$i
if [[ $? == 0 ]]
then
cat $i >> ${Tree}/$i
ECHO " --- Done"
else
ECHO " --- Failed to write new content ..."
fi
elif [[ ${__Kconfig} == config-generic ]]
then
for j in $(ls -1 ${Tree}/${_Kconfig} | egrep "config-[0-9]+")
do
ECHO " -- Generic Kconfig_file, refreshing ${Tree}/${_Kconfig}/$j ..."
echo >> ${Tree}/${_Kconfig}/$j
if [[ $? == 0 ]]
then
cat $i >> ${Tree}/${_Kconfig}/$j
ECHO " --- Done"
else
ECHO " --- Failed to write new content ..."
fi
done
fi
fi
done
CD ${WORK}
ECHO "[Firmware_Diy_Other] Done"
2021-01-11 13:44:45 +00:00
}
Firmware_Diy_End() {
ECHO "[Firmware_Diy_End] Starting ..."
2022-11-08 15:00:13 +00:00
ECHO "[$(date "+%H:%M:%S")] Actions Avaliable: $(df -h | grep "/dev/root" | awk '{printf $4}')"
2022-03-23 12:59:28 +00:00
cd ${WORK}
MKDIR ${WORK}/bin/Firmware
Fw_Path="${WORK}/bin/targets/${TARGET_BOARD}/${TARGET_SUBTARGET}"
cd ${Fw_Path}
echo -e "### FIRMWARE OUTPUT ###\n$(ls -1)\n"
2021-07-16 16:11:35 +00:00
case "${TARGET_BOARD}" in
x86)
2022-03-23 12:59:28 +00:00
if [[ ${x86_Full_Images} == true ]]
then
Process_Fw $(List_MFormat)
else
Process_Fw ${Fw_MFormat}
fi
2021-02-19 08:17:31 +00:00
;;
*)
2022-03-23 12:59:28 +00:00
if [[ -n ${Fw_MFormat} ]]
then
2022-03-23 12:59:28 +00:00
Process_Fw ${Fw_MFormat}
else
2022-03-23 12:59:28 +00:00
Process_Fw $(List_MFormat)
fi
2021-02-19 08:17:31 +00:00
;;
esac
2022-03-23 12:59:28 +00:00
if [[ $(ls) =~ 'AutoBuild-' ]]
then
cd -
2022-11-08 15:00:13 +00:00
mv -f ${Fw_Path}/AutoBuild-* bin/Firmware
2022-03-23 12:59:28 +00:00
fi
2022-08-21 02:13:10 +00:00
ECHO "[$(date "+%H:%M:%S")] Actions Avaliable: $(df -h | grep "/dev/root" | awk '{printf $4}')"
ECHO "[Firmware_Diy_End] Done"
2021-01-11 13:44:45 +00:00
}
2022-03-23 12:59:28 +00:00
Process_Fw() {
2021-07-16 16:11:35 +00:00
while [[ $1 ]];do
2022-03-23 12:59:28 +00:00
Process_Fw_Core $1 $(List_Fw $1 | Regex)
2021-07-16 16:11:35 +00:00
shift
done
}
2022-03-23 12:59:28 +00:00
Process_Fw_Core() {
Fw_Format=$1
2021-07-16 16:11:35 +00:00
shift
while [[ $1 ]];do
2022-03-23 12:59:28 +00:00
Fw=${AutoBuild_Fw}
2021-07-16 16:11:35 +00:00
case "${TARGET_BOARD}" in
x86)
2022-03-23 12:59:28 +00:00
[[ $1 =~ efi ]] && Fw_Boot=UEFI || Fw_Boot=BIOS
Fw=${Fw/BOOT/${Fw_Boot}}
2021-07-16 16:11:35 +00:00
;;
esac
2022-03-23 12:59:28 +00:00
Fw=${Fw/SHA256/$(Get_sha256 $1)}
Fw=${Fw/FORMAT/${Fw_Format}}
if [[ -f $1 ]]
then
2022-11-08 15:00:13 +00:00
ECHO "Moving [$1] to [${Fw}] ..."
mv -f $1 ${Fw}
2022-03-23 12:59:28 +00:00
else
ECHO "Failed to copy [${Fw}] ..."
fi
2021-07-16 16:11:35 +00:00
shift
done
}
2022-03-23 12:59:28 +00:00
List_Fw() {
if [[ -z $* ]]
then
for X in $(List_sha256);do
2022-08-31 14:18:39 +00:00
cut -d "*" -f2 <<< "${X}"
2021-07-16 16:11:35 +00:00
done
2022-03-23 12:59:28 +00:00
else
2021-07-16 16:11:35 +00:00
while [[ $1 ]];do
2022-03-23 12:59:28 +00:00
for X in $(List_sha256);do
2022-08-31 14:18:39 +00:00
[[ ${X} == *$1 ]] && cut -d "*" -f2 <<< "${X}"
2021-07-16 16:11:35 +00:00
done
shift
done
2022-03-23 12:59:28 +00:00
fi
}
Regex() {
egrep -v "${Regex_Skip}"
2021-07-16 16:11:35 +00:00
}
2022-03-23 12:59:28 +00:00
List_sha256() {
cat ${Fw_Path}/sha256sums 2> /dev/null | Regex | tr -s '\n'
2021-07-16 16:11:35 +00:00
}
2022-03-23 12:59:28 +00:00
List_MFormat() {
2022-08-31 14:18:39 +00:00
List_sha256 | cut -d "*" -f2 | cut -d "." -f2-3 | sort | uniq
2021-06-06 05:55:56 +00:00
}
2022-03-23 12:59:28 +00:00
Get_sha256() {
List_sha256 | grep $1 | awk '{print $1}' | cut -c1-5
2021-06-06 05:55:56 +00:00
}
2022-03-23 12:59:28 +00:00
Get_Branch() {
2021-08-03 10:41:36 +00:00
git -C $(pwd) rev-parse --abbrev-ref HEAD | grep -v HEAD || \
git -C $(pwd) describe --exact-match HEAD || \
git -C $(pwd) rev-parse HEAD
2021-05-19 01:03:41 +00:00
}
2022-03-23 12:59:28 +00:00
gz_Check() {
[[ $(cat ${CONFIG_TEMP}) =~ CONFIG_TARGET_IMAGES_GZIP=y ]] && {
echo img.gz
} || echo img
}
ECHO() {
2021-06-17 09:55:08 +00:00
echo "[$(date "+%H:%M:%S")] $*"
2021-01-05 23:38:00 +00:00
}
2021-02-23 11:44:45 +00:00
PKG_Finder() {
local Result
2022-03-23 12:59:28 +00:00
if [[ $# -ne 3 ]]
then
ECHO "Usage: PKG_Finder <f | d> Search_Path Target_Name/Target_Path"
2021-04-16 10:57:19 +00:00
return 0
2022-03-23 12:59:28 +00:00
fi
Result=$(find $2 -name $3 -type $1 -exec echo {} \; 2> /dev/null)
[[ -n ${Result} ]] && echo "${Result}"
2021-02-23 11:44:45 +00:00
}
CD() {
cd $1
[[ ! $? == 0 ]] && ECHO "Unable to enter target directory $1 ..." || ECHO "Entering directory: $(pwd) ..."
}
MKDIR() {
while [[ $1 ]];do
if [[ ! -d $1 ]]
then
mkdir -p $1 || ECHO "Failed to create target directory: [$1] ..."
fi
shift
done
}
AddPackage() {
2022-03-23 12:59:28 +00:00
if [[ $# -lt 4 ]]
then
ECHO "Syntax error: [$#] [$*]"
2021-04-16 10:57:19 +00:00
return 0
2022-03-23 12:59:28 +00:00
fi
2021-07-19 04:17:05 +00:00
PKG_PROTO=$1
case "${PKG_PROTO}" in
git | svn)
:
;;
*)
ECHO "Unknown content: ${PKG_PROTO}"
return 0
2021-07-19 04:17:05 +00:00
;;
esac
PKG_DIR=$2
2021-08-03 10:41:36 +00:00
[[ ! ${PKG_DIR} =~ ${GITHUB_WORKSPACE} ]] && PKG_DIR=package/${PKG_DIR}
2021-07-19 04:17:05 +00:00
PKG_NAME=$3
2021-06-17 09:55:08 +00:00
REPO_URL="https://github.com/$4"
2021-07-19 05:18:50 +00:00
REPO_BRANCH=$5
[[ ${REPO_URL} =~ "${OP_AUTHOR}/${OP_REPO}" ]] && return 0
2021-06-06 05:55:56 +00:00
MKDIR ${PKG_DIR}
2022-03-23 12:59:28 +00:00
if [[ -d ${PKG_DIR}/${PKG_NAME} ]]
then
ECHO "Removing old package: [${PKG_NAME}] ..."
2021-08-03 10:41:36 +00:00
rm -rf ${PKG_DIR}/${PKG_NAME}
2022-03-23 12:59:28 +00:00
fi
ECHO "Checking out package [${PKG_NAME}] to ${PKG_DIR} ..."
2021-03-04 03:48:24 +00:00
case "${PKG_PROTO}" in
git)
2022-03-23 12:59:28 +00:00
if [[ -z ${REPO_BRANCH} ]]
then
ECHO "WARNING: Syntax missing <branch> ,using default branch: [master]"
2021-07-19 05:18:50 +00:00
REPO_BRANCH=master
2022-03-23 12:59:28 +00:00
fi
2021-04-15 07:12:03 +00:00
PKG_URL="$(echo ${REPO_URL}/${PKG_NAME} | sed s/[[:space:]]//g)"
git clone -b ${REPO_BRANCH} ${PKG_URL} ${PKG_NAME} > /dev/null 2>&1
2021-03-04 03:48:24 +00:00
;;
svn)
svn checkout ${REPO_URL}/${PKG_NAME} ${PKG_NAME} > /dev/null 2>&1
;;
esac
2022-03-23 12:59:28 +00:00
if [[ -f ${PKG_NAME}/Makefile || -n $(ls -A ${PKG_NAME}) ]]
then
2021-08-03 10:41:36 +00:00
mv -f "${PKG_NAME}" "${PKG_DIR}"
[[ $? == 0 ]] && ECHO "Done"
2022-03-23 12:59:28 +00:00
else
ECHO "Failed to download package ${PKG_NAME} ..."
fi
2021-01-05 23:38:00 +00:00
}
2021-06-18 02:08:35 +00:00
Copy() {
2022-03-23 12:59:28 +00:00
if [[ ! $# =~ [23] ]]
then
ECHO "Syntax error: [$#] [$*]"
2021-04-16 10:57:19 +00:00
return 0
2022-03-23 12:59:28 +00:00
fi
if [[ ! -f $1 && ! -d $1 ]]
then
ECHO "$1: No such file or directory ..."
2021-06-18 02:08:35 +00:00
return 0
2022-03-23 12:59:28 +00:00
fi
MKDIR $2
if [[ -z $3 ]]
then
2022-03-22 16:46:35 +00:00
ECHO "[C] Copying $1 to $2 ..."
cp -a $1 $2
2021-08-03 10:41:36 +00:00
else
2022-03-22 16:46:35 +00:00
ECHO "[R] Copying $1 to $2/$3 ..."
cp -a $1 $2/$3
2021-08-03 10:41:36 +00:00
fi
2022-03-22 16:46:35 +00:00
[[ $? == 0 ]] && ECHO "Done"
2021-11-07 02:19:58 +00:00
}