2015-11-12 19:03:21 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
2015-11-26 01:21:16 +01:00
|
|
|
create_subtree_ssh(){
|
2015-11-30 23:12:27 +01:00
|
|
|
local tree=${remote_target}/${remote_project}/${remote_dir}
|
2015-11-26 12:25:45 +01:00
|
|
|
ssh !${remote_user}@${shell_url} [[ ! -d $tree ]] && mkdir -pv $tree
|
2015-11-12 19:03:21 +01:00
|
|
|
}
|
|
|
|
|
2015-11-26 01:21:16 +01:00
|
|
|
create_subtree(){
|
2016-02-15 16:30:59 +01:00
|
|
|
msg2 "Create (%s) ..." "${edition}/$1/${dist_release}"
|
2015-12-04 23:08:27 +01:00
|
|
|
rsync ${rsync_args[*]} /dev/null ${sf_url}/${edition}/
|
|
|
|
rsync ${rsync_args[*]} /dev/null ${sf_url}/${edition}/$1/
|
|
|
|
rsync ${rsync_args[*]} /dev/null ${sf_url}/${edition}/$1/${dist_release}/
|
2015-11-27 12:22:38 +01:00
|
|
|
msg2 "Done"
|
2016-02-15 16:47:52 +01:00
|
|
|
show_elapsed_time "${FUNCNAME}" "${timer_start}"
|
2015-11-26 01:21:16 +01:00
|
|
|
}
|
|
|
|
|
2015-11-30 18:59:57 +01:00
|
|
|
prepare_transfer(){
|
2016-02-25 06:40:39 +01:00
|
|
|
edition=$(get_edition $1)
|
2016-06-06 20:08:09 +02:00
|
|
|
remote_dir="${edition}/$1/${dist_release}/${target_arch}"
|
2015-12-03 16:05:21 +01:00
|
|
|
src_dir="${run_dir}/${remote_dir}"
|
2015-11-30 18:59:57 +01:00
|
|
|
}
|
|
|
|
|
2016-02-18 22:02:01 +01:00
|
|
|
gen_iso_fn(){
|
|
|
|
local vars=() name
|
|
|
|
vars+=("${iso_name}")
|
|
|
|
[[ -n ${1} ]] && vars+=("${1}")
|
2016-02-25 18:54:25 +01:00
|
|
|
[[ ${edition} == 'community' ]] && vars+=("${edition}")
|
2016-02-18 22:02:01 +01:00
|
|
|
[[ ${initsys} == 'openrc' ]] && vars+=("${initsys}")
|
|
|
|
vars+=("${dist_release}")
|
2016-06-06 20:08:09 +02:00
|
|
|
vars+=("${target_arch}")
|
2016-02-18 22:02:01 +01:00
|
|
|
for n in ${vars[@]};do
|
|
|
|
name=${name:-}${name:+-}${n}
|
|
|
|
done
|
|
|
|
echo $name
|
|
|
|
}
|
|
|
|
|
2016-02-18 00:02:11 +01:00
|
|
|
create_torrent(){
|
2016-02-18 12:03:26 +01:00
|
|
|
msg "Create %s.torrent" "$1"
|
2016-02-18 22:02:01 +01:00
|
|
|
local name=$(gen_iso_fn "$1")
|
2016-02-26 17:53:50 +01:00
|
|
|
[[ -f ${src_dir}/${name}.torrent ]] && rm ${src_dir}/${name}.torrent
|
2016-02-18 19:15:40 +01:00
|
|
|
if [[ "${edition}" == 'official' ]];then
|
2016-02-18 22:02:01 +01:00
|
|
|
local webseed_url="http://${remote_url}/projects/${remote_project}/${remote_dir}/${name}.iso"
|
2016-02-18 19:15:40 +01:00
|
|
|
mktorrent_args+=(-w ${webseed_url})
|
|
|
|
fi
|
2016-02-18 20:17:35 +01:00
|
|
|
mktorrent ${mktorrent_args[*]} -o ${src_dir}/${name}.torrent ${src_dir}
|
2016-02-18 12:03:26 +01:00
|
|
|
msg "Done %s.torrent" "$1"
|
2016-02-18 00:02:11 +01:00
|
|
|
}
|
|
|
|
|
2015-11-17 17:04:04 +01:00
|
|
|
sync_dir(){
|
2015-12-04 23:08:27 +01:00
|
|
|
prepare_transfer "$1"
|
2016-02-18 00:02:11 +01:00
|
|
|
${torrent_create} && create_torrent "$1"
|
2015-12-04 23:08:27 +01:00
|
|
|
${remote_create} && create_subtree "$1"
|
2016-06-06 20:08:09 +02:00
|
|
|
msg "Start upload [%s] (%s) ..." "$1" "${target_arch}"
|
2015-12-04 23:08:27 +01:00
|
|
|
rsync ${rsync_args[*]} ${src_dir}/ ${sf_url}/${remote_dir}/
|
2016-02-15 16:30:59 +01:00
|
|
|
msg "Done upload [%s]" "$1"
|
2016-02-15 16:47:52 +01:00
|
|
|
show_elapsed_time "${FUNCNAME}" "${timer_start}"
|
2015-11-12 19:03:21 +01:00
|
|
|
}
|