buildiso: #238 add torrent option

deployiso: clean up code
This commit is contained in:
udeved 2016-07-12 22:27:23 +02:00
parent 7ad240f959
commit 6d850de033
10 changed files with 92 additions and 119 deletions

View file

@ -53,6 +53,11 @@ show_profile(){
msg2 "start_openrc_live: %s" "${start_openrc_live[*]}"
msg2 "disable_openrc: %s" "${disable_openrc[*]}"
fi
if ${is_torrent};then
msg2 "tracker_url: %s" "${tracker_url}"
msg2 "piece_size: %s" "${piece_size}"
msg2 "mktorrent_args: %s" "${mktorrent_args[*]}"
fi
fi
reset_profile
}
@ -81,6 +86,7 @@ display_settings(){
msg2 "images_only: %s" "${images_only}"
msg2 "iso_only: %s" "${iso_only}"
msg2 "sign: %s" "${sign}"
msg2 "is_torrent: %s" "${is_torrent}"
msg "DIST SETTINGS:"
msg2 "dist_name: %s" "${dist_name}"
@ -115,6 +121,7 @@ images_only=false
iso_only=false
verbose=false
sign=false
is_torrent=false
usage() {
echo "Usage: ${0##*/} [options]"
@ -134,6 +141,7 @@ 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'
@ -144,7 +152,7 @@ usage() {
orig_argv=("$@")
opts='p:a:b:r:t:k:i:czxsvqh'
opts='p:a:b:r:t:k:i:czxswvqh'
while getopts "${opts}" arg; do
case "${arg}" in
@ -159,6 +167,7 @@ while getopts "${opts}" arg; do
c) clean_first=false ;;
x) images_only=true ;;
z) iso_only=true ;;
w) is_torrent=true ;;
v) verbose=true ;;
q) pretend=true ;;
h|?) usage 0 ;;

View file

@ -22,6 +22,7 @@ import ${LIBDIR}/util-publish.sh
show_profile(){
prepare_transfer "$1"
info "Profile: [$1]"
msg2 "remote_project: %s" "${remote_project}"
msg2 "src_dir: ${src_dir}"
msg2 "remote_dir: ${remote_dir}"
}
@ -37,30 +38,20 @@ display_settings(){
msg2 "is_build_list: %s" "${is_build_list}"
msg "OPTIONS:"
# msg2 "arch: %s" "${target_arch}"
# msg2 "initsys: %s" "${initsys}"
msg2 "limit: %s kB/s" "${limit}"
msg "ARGS:"
msg2 "update: %s" "${update}"
msg2 "release_create: %s" "${release_create}"
# msg2 "torrent_create: %s" "${torrent_create}"
msg2 "verbose: %s" "${verbose}"
msg2 "rsync_args: %s" "${rsync_args[*]}"
# ${torrent_create} && msg2 "mktorrent_args: %s" "${mktorrent_args[*]}"
msg "HOST:"
msg2 "dist_release: %s" "${dist_release}"
msg "REMOTE:"
# msg2 "remote_url: %s" "${remote_url}"
msg2 "remote_project: %s" "${remote_project}"
# msg2 "remote_target: %s" "${remote_target}"
msg2 "remote_user: %s" "${remote_user}"
# if ${torrent_create};then
# msg2 "tracker_url: %s" "${tracker_url}"
# msg2 "piece_size: %s" "${piece_size}"
# fi
msg "UPLOAD QUEUE:"
run show_profile "${build_list_iso}"
}
@ -75,20 +66,15 @@ pretend=false
release_create=false
update=false
verbose=false
# torrent_create=false
rsync_args=(-aP --progress -e ssh)
# mktorrent_args=(-v -p)
usage() {
echo "Usage: ${0##*/} [options]"
echo " -p Source folder to upload [default:${build_list_iso}]"
# echo " -a Arch to upload [default:${target_arch}]"
# echo " -i The iso's init system [default:${initsys}]"
echo " -l Limit bandwidth in kB/s [default:${limit}]"
echo ' -c Create new remote release directory'
# echo ' -t Create a torrent from source folder'
echo ' -u Update remote iso'
echo ' -u Update remote directory'
echo ' -q Query settings and pretend upload'
echo ' -v Verbose output'
echo ' -h This help'
@ -102,11 +88,8 @@ opts='p:l:cuvqh'
while getopts "${opts}" arg; do
case "${arg}" in
p) build_list_iso="$OPTARG" ;;
# a) target_arch="$OPTARG" ;;
# i) initsys="$OPTARG" ;;
l) limit="$OPTARG" ;;
c) release_create=true ;;
# t) torrent_create=true ;;
u) update=true; rsync_args+=(-u) ;;
v) verbose=true; rsync_args+=(-v --stats) ;;
q) pretend=true; rsync_args+=(-n) ;;
@ -122,7 +105,6 @@ timer_start=$(get_timer)
eval_build_list "${list_dir_iso}" "${build_list_iso}"
rsync_args+=(--bwlimit=${limit})
# mktorrent_args+=(-l ${piece_size} -a ${tracker_url})
${pretend} && display_settings && exit 1

View file

@ -21,6 +21,12 @@
# use pxe
# pxe_boot="true"
# the torrent tracker urls, comma separated
# tracker_url=''
# Piece size, 2^n
# piece_size=21
################ install ################
# possible values: grub;systemd-boot

View file

@ -140,7 +140,13 @@
<listitem><para>Generate iso from already created images, for example created with the -x option.</para></listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><option>-w</option></term>
<listitem><para>Create a torrent from iso file.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<listitem><para>Verbose output to log file, show profile detail in combination with pretend.</para></listitem>

View file

@ -77,21 +77,10 @@
you will upload.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-a i686|x86_64</option></term>
<listitem><para>Architecture of the iso to upload. Can be i686 or x86_64.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-c</option></term>
<listitem><para>Create new remote edition_type with subtree.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-t</option></term>
<listitem><para>Create a torrent from the source directory.</para></listitem>
<listitem><para>Create new remote release.</para></listitem>
</varlistentry>
<varlistentry>

View file

@ -118,6 +118,21 @@
packages.
</para></listitem>
</varlistentry>
<!--<varlistentry>
<term><varname>remote_url=</varname></term>
<listitem><para>Default url to be used for upload.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>remote_target=</varname></term>
<listitem><para>Default server path to be used for upload.
</para></listitem>
</varlistentry>-->
</variablelist>
</refsect1>
@ -282,27 +297,6 @@
<variablelist>
<varlistentry>
<term><varname>remote_url=</varname></term>
<listitem><para>Default url to be used for upload.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>remote_project=</varname></term>
<listitem><para>Default project to be used for upload.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>remote_target=</varname></term>
<listitem><para>Default server path to be used for upload.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>remote_user=</varname></term>
@ -317,20 +311,7 @@
</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

@ -232,6 +232,21 @@
</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

@ -593,12 +593,25 @@ sign_iso(){
su ${OWNER} -c "signfile ${iso_dir}/$1"
}
make_torrent(){
msg2 "Creating torrent ..."
local name=$(gen_iso_fn).torrent
[[ -f ${iso_dir}/${name} ]] && rm ${iso_dir}/${name}
if [[ "${edition}" == 'official' ]];then
set_remote_project "${edition}"
local webseed_url="http://${remote_url}/projects/${remote_project}/${dist_release}/${profile}/${iso_file}"
mktorrent_args+=(-w ${webseed_url})
fi
mktorrent ${mktorrent_args[*]} -o ${iso_dir}/${name} ${iso_dir}
}
compress_images(){
local timer=$(get_timer)
run_safe "make_iso"
make_checksum "${iso_file}"
chown -R "${OWNER}:users" "${iso_dir}"
${sign} && sign_iso "${iso_file}"
${is_torrent} && make_torrent
show_elapsed_time "${FUNCNAME}" "${timer}"
}
@ -694,6 +707,8 @@ load_profile(){
iso_dir="${cache_dir_iso}/${edition}/${dist_release}/${profile}"
prepare_dir "${iso_dir}"
mktorrent_args=(-v -p -l ${piece_size} -a ${tracker_url})
}
get_edition(){

View file

@ -9,37 +9,6 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# create_subtree_ssh(){
# local tree=${remote_target}/${remote_project}/${remote_dir}
# ssh !${remote_user}@${shell_url} [[ ! -d $tree ]] && mkdir -pv $tree
# }
# gen_iso_fn(){
# local vars=() name
# vars+=("${iso_name}")
# [[ -n ${1} ]] && vars+=("${1}")
# [[ ${edition} == 'community' ]] && vars+=("${edition}")
# [[ ${initsys} == 'openrc' ]] && vars+=("${initsys}")
# vars+=("${dist_release}")
# vars+=("${target_arch}")
# for n in ${vars[@]};do
# name=${name:-}${name:+-}${n}
# done
# echo $name
# }
#
# create_torrent(){
# msg "Create %s.torrent" "$1"
# local name=$(gen_iso_fn "$1")
# [[ -f ${src_dir}/${name}.torrent ]] && rm ${src_dir}/${name}.torrent
# if [[ "${edition}" == 'official' ]];then
# local webseed_url="http://${remote_url}/projects/${remote_project}/${remote_dir}/${name}.iso"
# mktorrent_args+=(-w ${webseed_url})
# fi
# mktorrent ${mktorrent_args[*]} -o ${src_dir}/${name}.torrent ${src_dir}
# msg "Done %s.torrent" "$1"
# }
create_release(){
msg2 "Create release (%s) ..." "${dist_release}"
rsync ${rsync_args[*]} /dev/null ${sf_url}/${dist_release}/
@ -48,29 +17,23 @@ create_release(){
get_edition(){
local result=$(find ${run_dir} -maxdepth 3 -name "$1") path
[[ -z $result ]] && die "%s is not a valid profile or build list!" "$1"
# [[ -z $result ]] && die "%s is not a valid profile or build list!" "$1"
path=${result%/*}
path=${path%/*}
echo ${path##*/}
}
prepare_transfer(){
edition=$(get_edition $1)
case ${edition} in
'community'|'minimal') remote_project='manjaro-community' ;;
'official') remote_project='manjaro' ;;
esac
local edition=$(get_edition $1)
set_remote_project "${edition}"
sf_url=${remote_user},${remote_project}@frs.${remote_url}:${remote_target}/${remote_project}
# shell_url=${remote_user},${remote_project}@shell.${remote_url}
remote_dir="${dist_release}/$1"
src_dir="${run_dir}/${edition}/${remote_dir}"
}
sync_dir(){
prepare_transfer "$1"
# ${torrent_create} && create_torrent "$1"
${release_create} && create_release "$1"
msg "Start upload [%s] ..." "$1"
rsync ${rsync_args[*]} ${src_dir}/ ${sf_url}/${remote_dir}/

View file

@ -141,6 +141,13 @@ show_elapsed_time(){
info "Time %s: %s minutes" "$1" "$(elapsed_time $2)"
}
set_remote_project(){
case "$1" in
'community'|'minimal') remote_project='manjaro-community' ;;
'official') remote_project='manjaro' ;;
esac
}
lock() {
eval "exec $1>"'"$2"'
if ! flock -n $1; then
@ -226,6 +233,10 @@ init_common(){
[[ -z ${build_mirror} ]] && build_mirror='http://mirror.netzspielplatz.de/manjaro/packages'
[[ -z ${tmp_dir} ]] && tmp_dir='/tmp/manjaro-tools'
[[ -z ${remote_url} ]] && remote_url="sourceforge.net"
[[ -z ${remote_target} ]] && remote_target="/home/frs/project"
}
init_buildtree(){
@ -312,19 +323,9 @@ init_buildiso(){
init_deployiso(){
[[ -z ${remote_target} ]] && remote_target="/home/frs/project"
# [[ -z ${remote_project} ]] && remote_project="manjaro-testing"
[[ -z ${remote_user} ]] && remote_user="[SetUser]"
[[ -z ${remote_url} ]] && remote_url="sourceforge.net"
[[ -z ${limit} ]] && limit=100
# [[ -z ${tracker_url} ]] && tracker_url=""
#
# [[ -z ${piece_size} ]] && piece_size=21
}
load_config(){
@ -371,6 +372,8 @@ reset_profile(){
unset packages_custom
unset packages_mhwd
unset login_shell
unset tracker_url
unset piece_size
}
is_valid_bool(){
@ -458,6 +461,10 @@ load_profile_config(){
start_openrc_live=('manjaro-live' 'mhwd-live' 'pacman-init')
fi
[[ -z ${tracker_url} ]] && tracker_url=()
[[ -z ${piece_size} ]] && piece_size=21
check_profile_vars
return 0