deployiso: move torrent code from buildiso to deployiso

This commit is contained in:
udeved 2017-02-12 19:19:18 +01:00
parent e4ffa593b5
commit fbf83b913e
13 changed files with 87 additions and 79 deletions

View file

@ -129,6 +129,12 @@ overriding
# set upload bandwidth limit in kB/s
# limit=100
# the torrent tracker urls, comma separated
# tracker_url='udp://mirror.strits.dk:6969'
# Piece size, 2^n
# piece_size=21
~~~
###2. buildpkg
@ -222,7 +228,6 @@ Usage: buildiso [options]
-x Build images only
-z Generate iso only
Requires pre built images (-x)
-w Create iso torrent
-v Verbose output to log file, show profile detail (-q)
-q Query settings and pretend build
-h This help
@ -371,6 +376,7 @@ Usage: deployiso [options]
-l Limit bandwidth in kB/s [default:80]
-c Create new remote release directory
-u Update remote directory
-t Create iso torrent
-q Query settings and pretend upload
-v Verbose output
-h This help

View file

@ -60,10 +60,6 @@ show_profile(){
msg2 "enable_openrc_live: %s" "${enable_openrc_live[*]}"
[[ -n ${disable_openrc[*]} ]] && msg2 "disable_openrc: %s" "${disable_openrc[*]}"
fi
if ${torrent};then
msg2 "tracker_url: %s" "${tracker_url}"
msg2 "piece_size: %s" "${piece_size}"
fi
fi
reset_profile
}
@ -92,7 +88,6 @@ display_settings(){
msg2 "images_only: %s" "${images_only}"
msg2 "iso_only: %s" "${iso_only}"
msg2 "persist: %s" "${persist}"
msg2 "torrent: %s" "${torrent}"
msg "DIST SETTINGS:"
msg2 "dist_name: %s" "${dist_name}"
@ -124,7 +119,6 @@ pretend=false
images_only=false
iso_only=false
verbose=false
torrent=false
persist=false
usage() {
@ -145,7 +139,6 @@ usage() {
echo ' -x Build images only'
echo ' -z Generate iso only'
echo ' Requires pre built images (-x)'
echo ' -w Create iso torrent'
echo ' -v Verbose output to log file, show profile detail (-q)'
echo ' -q Query settings and pretend build'
echo ' -h This help'
@ -156,7 +149,7 @@ usage() {
orig_argv=("$@")
opts='p:a:b:r:t:k:i:czxmwvqh'
opts='p:a:b:r:t:k:i:czxmvqh'
while getopts "${opts}" arg; do
case "${arg}" in
@ -171,7 +164,6 @@ while getopts "${opts}" arg; do
x) images_only=true ;;
z) iso_only=true ;;
m) persist=true ;;
w) torrent=true ;;
v) verbose=true ;;
q) pretend=true ;;
h|?) usage 0 ;;

View file

@ -46,6 +46,12 @@ display_settings(){
msg2 "release: %s" "${release}"
msg2 "verbose: %s" "${verbose}"
msg2 "rsync_args: %s" "${rsync_args[*]}"
msg2 "torrent: %s" "${torrent}"
if ${torrent};then
msg2 "tracker_url: %s" "${tracker_url}"
msg2 "piece_size: %s" "${piece_size}"
fi
msg "REMOTE:"
msg2 "account: %s" "${account}"
@ -66,6 +72,7 @@ release=false
update=false
verbose=false
exists=false
torrent=false
rsync_args=(-aP --progress -e ssh)
@ -75,6 +82,7 @@ usage() {
echo " -l Limit bandwidth in kB/s [default:${limit}]"
echo ' -c Create new remote release directory'
echo ' -u Update remote directory'
echo ' -t Create iso torrent'
echo ' -q Query settings and pretend upload'
echo ' -v Verbose output'
echo ' -h This help'
@ -83,7 +91,7 @@ usage() {
exit $1
}
opts='p:l:cuvqh'
opts='p:l:cuvtqh'
while getopts "${opts}" arg; do
case "${arg}" in
@ -91,6 +99,7 @@ while getopts "${opts}" arg; do
l) limit="$OPTARG" ;;
c) release=true ;;
u) update=true; rsync_args+=(-u) ;;
t) torrent=true ;;
v) verbose=true; rsync_args+=(-v --stats) ;;
q) pretend=true; rsync_args+=(-n) ;;
h|?) usage 0 ;;

7
data/deploy.map Normal file
View file

@ -0,0 +1,7 @@
# srv path : version attribute
release:none
candidates:rc[0-9]
development:alpha,beta

View file

@ -79,3 +79,8 @@
# set upload bandwidth limit in kB/s
# limit=100
# the torrent tracker urls, comma separated
# tracker_url='udp://mirror.strits.dk:6969'
# Piece size, 2^n
# piece_size=21

View file

@ -14,14 +14,6 @@
# use extra packages as defined in pkglist to activate a full profile
# extra="false"
################ torrent ################
# the torrent tracker urls, comma separated
# tracker_url='udp://mirror.strits.dk:6969'
# Piece size, 2^n
# piece_size=21
################ install ################
# default displaymanager: none

View file

@ -145,12 +145,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<listitem><para>Generate iso from already created images, for example created with the -x option.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-w</option></term>
<listitem><para>Create a torrent from iso file.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>

View file

@ -95,6 +95,12 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<listitem><para>Update remote iso.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-w</option></term>
<listitem><para>Create a torrent from iso file.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>

View file

@ -261,6 +261,21 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>tracker_url=</varname></term>
<listitem><para>Default tracker announce for the torrent.
The tracker url can also contain comma separated urls.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>piece_size=</varname></term>
<listitem><para>Default priece size for the torrent in 2^n.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

View file

@ -242,21 +242,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>tracker_url=</varname></term>
<listitem><para>Default tracker announce for the torrent.
The tracker url can also contain comma separated urls.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>piece_size=</varname></term>
<listitem><para>Default priece size for the torrent in 2^n.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

View file

@ -462,18 +462,9 @@ check_requirements(){
import ${LIBDIR}/util-iso-${iso_fs}.sh
}
make_torrent(){
local fn=${iso_file}.torrent
msg2 "Creating (%s) ..." "${fn}"
[[ -f ${iso_dir}/${fn} ]] && rm ${iso_dir}/${fn}
mktorrent ${mktorrent_args[*]} -o ${iso_dir}/${fn} ${iso_dir}/${iso_file}
}
compress_images(){
local timer=$(get_timer)
run_safe "make_iso"
${torrent} && make_torrent
user_own "${iso_dir}" "-R"
show_elapsed_time "${FUNCNAME}" "${timer}"
}
@ -555,18 +546,6 @@ get_pacman_conf(){
echo "$conf"
}
gen_webseed(){
local webseed url project=$(get_project "${edition}")
url=${host}/project/${project}/${dist_release}/${profile}/${iso_file}
local mirrors=('heanet' 'jaist' 'netcologne' 'iweb' 'kent')
for m in ${mirrors[@]};do
webseed=${webseed:-}${webseed:+,}"http://${m}.dl.${url}"
done
echo ${webseed}
}
load_profile(){
conf="${profile_dir}/profile.conf"
@ -591,8 +570,6 @@ load_profile(){
prepare_dir "${iso_dir}"
user_own "${iso_dir}"
mktorrent_args=(-v -p -l ${piece_size} -a ${tracker_url} -w $(gen_webseed))
}
prepare_profile(){

View file

@ -29,12 +29,44 @@ connect(){
echo "${account},$1@frs.${host}:${home}/$1"
}
get_project(){
local project
case "$1" in
'community') project='manjarolinux-community' ;;
'manjaro') project='manjarolinux' ;;
'sonar') project='sonargnulinux' ;;
esac
echo ${project}
}
gen_webseed(){
local webseed url project=$(get_project "${edition}")
url=${host}/project/${project}/${dist_release}/${profile}/${iso_file}
local mirrors=('heanet' 'jaist' 'netcologne' 'iweb' 'kent')
for m in ${mirrors[@]};do
webseed=${webseed:-}${webseed:+,}"http://${m}.dl.${url}"
done
echo ${webseed}
}
make_torrent(){
local fn=${iso_file}.torrent
msg2 "Creating (%s) ..." "${fn}"
[[ -f ${iso_dir}/${fn} ]] && rm ${iso_dir}/${fn}
mktorrent ${mktorrent_args[*]} -o ${iso_dir}/${fn} ${iso_dir}/${iso_file}
}
prepare_transfer(){
local edition=$(get_edition $1)
project=$(get_project "${edition}")
url=$(connect "${project}")
mktorrent_args=(-v -p -l ${piece_size} -a ${tracker_url} -w $(gen_webseed))
target_dir="${dist_release}/$1"
src_dir="${run_dir}/${edition}/${target_dir}"
${torrent} && make_torrent
}
sync_dir(){

View file

@ -133,16 +133,6 @@ show_elapsed_time(){
info "Time %s: %s minutes" "$1" "$(elapsed_time $2)"
}
get_project(){
local project
case "$1" in
'community') project='manjarolinux-community' ;;
'manjaro') project='manjarolinux' ;;
'sonar') project='sonargnulinux' ;;
esac
echo ${project}
}
lock() {
eval "exec $1>"'"$2"'
if ! flock -n $1; then
@ -317,6 +307,10 @@ init_deployiso(){
[[ -z ${account} ]] && account="[SetUser]"
[[ -z ${limit} ]] && limit=100
[[ -z ${tracker_url} ]] && tracker_url='udp://mirror.strits.dk:6969'
[[ -z ${piece_size} ]] && piece_size=21
}
load_config(){
@ -440,10 +434,6 @@ load_profile_config(){
enable_systemd+=("$(get_svc)")
fi
[[ -z ${tracker_url} ]] && tracker_url='udp://mirror.strits.dk:6969'
[[ -z ${piece_size} ]] && piece_size=21
[[ -z ${netinstall} ]] && netinstall='false'
[[ -z ${chrootcfg} ]] && chrootcfg='false'
@ -494,8 +484,6 @@ reset_profile(){
unset packages_desktop
unset packages_mhwd
unset login_shell
unset tracker_url
unset piece_size
unset netinstall
unset chrootcfg
unset netgroups