Merge branch 'master' into 'master'

Utilize osdn to serve a *latest* url

See merge request tools/development-tools/manjaro-tools!306
This commit is contained in:
Bernhard Landauer 2019-12-02 00:35:25 +01:00
commit 3983d1ffff
3 changed files with 50 additions and 8 deletions

View file

@ -84,7 +84,7 @@ display_settings(){
msg "ISO INFO:"
msg2 "iso_label: %s" "${iso_label}"
msg2 "iso_compression: %s" "${iso_compression}"
msg "BUILD QUEUE:"
run show_profile "${build_list_iso}"
}

View file

@ -204,13 +204,37 @@ make_iso() {
# Sanity checks
[[ ! -d "${iso_root}" ]] && return 1
if [[ -f "${iso_dir}/${iso_file}" ]]; then
msg2 "Removing existing bootable image..."
rm -rf "${iso_dir}/${iso_file}"
msg2 "Removing ${iso_file} related files ..."
[[ -f "${iso_dir}/${iso_file}" ]] && rm -f "${iso_dir}/${iso_file}"
[[ -f "${iso_dir}/${iso_file}.sig" ]] && rm -f "${iso_dir}/${iso_file}.sig"
[[ -f "${iso_dir}/${iso_file}.sha1" ]] && rm -f "${iso_dir}/${iso_file}.sha1"
[[ -f "${iso_dir}/${iso_file}.sha256" ]] && rm -f "${iso_dir}/${iso_file}.sha256"
[[ -f "${iso_dir}/${iso_file}.torrent" ]] && rm -f "${iso_dir}/${iso_file}.torrent"
fi
assemble_iso
[[ ${target_branch} == "stable" ]] && [[ ${extra} == "true" ]] && gen_latest_html
msg "Done [Build ISO]"
}
gen_latest_html(){
if [[ ${edition} == "community" ]] || [[ ${edition} == "manjaro" ]]; then
if [[ -f "${iso_dir}/${iso_file}" ]]; then
msg2 "Creating download link ..."
direct_url="https://osdn.net/dl/${edition}/${iso_file}"
[[ ${edition} == "community" ]] && direct_url="https://osdn.net/dl/manjaro-${edition}/${iso_file}"
html_doc="<!DOCTYPE HTML>"
html_doc+="<meta charset=\"UTF-8\">"
html_doc+="<meta http-equiv=\"refresh\" content=\"1; url=${direct_url}\">"
html_doc+="<script>window.location.href=\"${direct_url}\"</script>"
html_doc+="<title>Download Redirection</title>"
html_doc+="If you are not redirected automatically, follow the <a href=\"${direct_url}\">link to latest iso</a>"
echo ${html_doc} > "${iso_dir}/.latest"
fi
fi
}
gen_iso_fn(){
local vars=() name
vars+=("${iso_name}")
@ -218,7 +242,7 @@ gen_iso_fn(){
[[ -n ${profile} ]] && vars+=("${profile}")
fi
vars+=("${dist_release}")
[[ ! ${target_branch} == "stable" ]] && vars+=("${target_branch}")
[[ ${extra} == 'false' ]] && vars+=("minimal")
@ -227,10 +251,11 @@ gen_iso_fn(){
vars+=("${kernel}")
[[ ${target_arch} == "i686" ]] && vars+=("${target_arch}")
[[ ${target_arch} == "i686" ]] && vars+=("${target_arch}")
for n in ${vars[@]}; do
name=${name:-}${name:+-}${n}
done
echo $name
}

View file

@ -15,6 +15,11 @@ connect(){
echo "${account}${storage}${project}"
}
connect_webserver(){
local webserver="@shell.osdn.net:/home/groups/m/ma/"
echo "${account}${webserver}${project}"
}
make_torrent(){
find ${src_dir} -type f -name "*.torrent" -delete
@ -34,7 +39,7 @@ prepare_transfer(){
hidden="$2"
edition=$(get_edition "${profile}")
[[ -z ${project} ]] && project="$(get_project)"
url=$(connect)
server=$(connect)
target_dir="${profile}/${dist_release}"
src_dir="${run_dir}/${edition}/${target_dir}"
@ -73,16 +78,28 @@ sync_dir(){
${ssh_agent} && ssh_add
msg "Start upload [%s] to [%s] ..." "$1" "${project}"
while [[ $count -le $max_count ]]; do
rsync ${rsync_args[*]} ${src_dir}/ ${url}/${target_dir}/
while [[ $count -le $max_count ]]; do
rsync ${rsync_args[*]} --exclude '.latest' ${src_dir}/ ${server}/${target_dir}/
if [[ $? != 0 ]]; then
count=$(($count + 1))
msg "Upload failed. retrying (%s/%s) ..." "$count" "$max_count"
sleep 2
else
count=$(($max_count + 1))
[[ -f "${src_dir}/.latest" ]] && sync_latest_html
msg "Done upload [%s]" "$1"
show_elapsed_time "${FUNCNAME}" "${timer_start}"
fi
done
}
sync_latest_html(){
msg2 "Sending download link ..."
local webserver=$(connect_webserver)
local htdocs="htdocs/${profile}"
local html="latest"
scp "${src_dir}/.${html}" "${webserver}/${htdocs}/${html}"
rm -f "${src_dir}/.${html}"
}