2023-04-13 04:41:49 +00:00
|
|
|
#!/usr/bin/evn bash
|
|
|
|
#
|
|
|
|
set -o pipefail
|
|
|
|
set -o errexit
|
|
|
|
set -o errtrace
|
|
|
|
|
|
|
|
WEBDAV_USER=${WEBDAV_USER:?WEBDAV_USER not set}
|
|
|
|
WEBDAV_PASS=${WEBDAV_PASS:?WEBDAV_PASS not set}
|
|
|
|
WEBDAV_HOST=${WEBDAV_HOST:?WEBDAV_HOST not set}
|
|
|
|
WEBDAV_REPOPATH=${WEBDAV_REPOPATH:?WEBDAV_REPOPATH not set}
|
|
|
|
|
|
|
|
function curl_alias {
|
|
|
|
curl --show-error --silent --user "${WEBDAV_USER}:${WEBDAV_PASS}" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function webdav_is_file_exists {
|
|
|
|
local target="${1%/}"
|
|
|
|
local target="${target#/}"
|
|
|
|
local resp=$(curl_alias --head --write-out "%{http_code}" "${WEBDAV_HOST}/${WEBDAV_REPOPATH}/${target}" | tail -n 1)
|
|
|
|
[[ "${resp}" == "200" ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
function webdav_mkcol {
|
|
|
|
local dirname="${1#/}"
|
|
|
|
curl_alias --request MKCOL "${WEBDAV_HOST}/${dirname}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function webdav_upload_file {
|
2023-04-13 06:04:38 +00:00
|
|
|
echo "uploading file $1 to ${WEBDAV_HOST}/${WEBDAV_REPOPATH}/$2 ..."
|
2023-04-13 04:41:49 +00:00
|
|
|
curl_alias --silent --upload-file "$1" "${WEBDAV_HOST}/${WEBDAV_REPOPATH}/$2"
|
|
|
|
echo "file $1 uploaded to ${WEBDAV_HOST}/${WEBDAV_REPOPATH}/$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
function build_single {
|
|
|
|
(
|
|
|
|
local package_name="$1"
|
|
|
|
local package_path="$(realpath "$1")"
|
|
|
|
cd "$package_path"
|
|
|
|
local target_filename="$(../makedeb/makedeb -STF | tail -n 1)"
|
|
|
|
|
|
|
|
if webdav_is_file_exists "${target_filename}" ; then
|
|
|
|
echo "${package_name} already built, skipped."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
../makedeb/makedeb
|
|
|
|
|
|
|
|
webdav_upload_file "${target_filename}" "${target_filename}"
|
|
|
|
)
|
|
|
|
}
|