Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (f750931ad7434be955a22d5141eed16ff68186cf)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (f750931ad7434be955a22d5141eed16ff68186cf)
  • Date: Thu, 6 Nov 2014 13:01:57 -0600

GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

ChangeLog | 3
usr/sbin/sorcery | 16 ++-
var/lib/sorcery/modules/dl_handlers/dl_curl | 147
++++++++++++++++++++++++++++
var/lib/sorcery/modules/libcodex | 6 -
4 files changed, 168 insertions(+), 4 deletions(-)

New commits:
commit f750931ad7434be955a22d5141eed16ff68186cf
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

codex_get_spells_in_section: quote more paths just in case

commit 1260fd00d011d14ce4457b13cb2a77124ba51682
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

codex_get_spells_in_section: do everything with awk

commit 8537c78444490f345a59eebe2db188f10df5936f
Author: Pol Vinogradov <vin.public AT gmail.com>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

dl_handlers/dl_curl: added cURL support

Signed-off-by: Pol Vinogradov <vin.public AT gmail.com>

diff --git a/ChangeLog b/ChangeLog
index 0374ab1..7080286 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2014-10-28 Pol Vinogradov <vin.public AT gmail.com>
+ * dl_handlers/dl_curl: added support for cURL
+
2014-03-20 Pol Vinogradov <vin.public AT gmail.com>
* libsummon: repo archive no longer should be compressed by bzip2
only,
any compressor known to tar works
diff --git a/usr/sbin/sorcery b/usr/sbin/sorcery
index 28965e0..e171c71 100755
--- a/usr/sbin/sorcery
+++ b/usr/sbin/sorcery
@@ -1476,6 +1476,7 @@ sorcery_devel_settings() {
function set_dl_handler() {
local W_HELP="Use wget to download from urls using the http/ftp/https
protocols"
local A_HELP="Use aria2 to download from urls using the http/ftp/https
protocols"
+ local C_HELP="Use cURL to download from urls using the http/ftp/https
protocols"

while
COMMAND=$(eval $DIALOG '--title "Currently using:
${HTTP_DL_HANDLER:-wget}" \
@@ -1486,7 +1487,8 @@ function set_dl_handler() {
"" \
0 0 0 \
"W" "wget (default)" "$W_HELP" \
- "A" "aria2" "$A_HELP"')
+ "A" "aria2" "$A_HELP" \
+ "C" "curl" "$C_HELP"')
do
case $COMMAND in
W) modify_local_config HTTP_DL_HANDLER wget &&
@@ -1503,6 +1505,18 @@ function set_dl_handler() {
modify_local_config HTTP_DL_HANDLER aria2 &&
HTTP_DL_HANDLER=aria2
fi ;;
+ C)
+ if ! spell_ok curl; then
+ local error_msg
+ error_msg="cURL is not installed on this system!\nIf you want"
+ error_msg="$error_msg to use it, cast it first, then revisit"
+ error_msg="$error_msg this menu.\n\nYour download handler choice"
+ error_msg="$error_msg has not been saved!"
+ eval "$DIALOG --msgbox \"\$error_msg\" 0 0"
+ else
+ modify_local_config HTTP_DL_HANDLER curl &&
+ HTTP_DL_HANDLER=curl
+ fi ;;
esac
break
done
diff --git a/var/lib/sorcery/modules/dl_handlers/dl_curl
b/var/lib/sorcery/modules/dl_handlers/dl_curl
new file mode 100755
index 0000000..209976e
--- /dev/null
+++ b/var/lib/sorcery/modules/dl_handlers/dl_curl
@@ -0,0 +1,147 @@
+#!/bin/bash
+#---------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Url handler functions for downloading http, https, and ftp urls
+##
+##=head1 DESCRIPTION
+##
+## This file contains functions for downloading and verifying
+## http, https, and ftp urls. This file uses the "curl" program.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2014 by the Source Mage Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#---------------------------------------------------------------------
+
+function dl_curl_get() {
+ debug libdownload "$FUNCNAME -- $@"
+ dl_command_check curl || return 254
+
+ local target=$1
+ local url_list=$2
+ local hints=$3
+ local dl_target=$4
+ local dl_type=$5
+ local rc=1 url
+
+ [[ $target ]] &&
+ dl_connect || return 255
+
+ for url in $url_list; do
+ local CURL_OPTIONS
+ dl_curl_set_options $url $hints
+ dl_curl_call_curl $target $url
+ rc=$?
+ [[ $rc == 0 ]] && break
+ done
+
+ dl_disconnect
+
+ eval "$dl_target=\"$target\""
+ eval "$dl_type=\"file\""
+ return $rc
+
+}
+
+#---------------------------------------------------------------------
+## dl_curl_call_curl <filename> <extension-less filename> <url>
+##
+## Private Function. Call curls to download the url.
+##
+#---------------------------------------------------------------------
+function dl_curl_call_curl() {
+ local FILE=$1
+ local URL=$2
+
+ debug 'dl_curl' "$funcname -- $@"
+
+ rm -f "$FILE"
+ curl $CURL_OPTIONS -o "$FILE" "$URL" 2>&1 &&
+ if ! test -f "$FILE" ; then
+ # stupid http site trying to be nice and re-direct us, this is a failure
+ # even though curl doesnt notice it...
+ rm -f "$FILE"*
+ return 1
+ fi
+}
+
+#---------------------------------------------------------------------
+## dl_curl_set_curl_options
+##
+## Private Function. Sets curl options
+##
+#---------------------------------------------------------------------
+function dl_curl_set_options() {
+ local URL=$1
+ local hints="$2"
+
+ if [ -n "$ACTIVE_FTP" ] ; then
+ unset PASSIVE
+ else
+ PASSIVE="--ftp-pasv"
+ fi
+
+ # Check for ? in the url, this seems to indicate that there may be
+ # some cgi redirection involved which means continued downloading would
+ # not work (bug 8993).
+ # The sourceforge check pre-dates that but is lacking any documentation,
+ # I suspect it is a less general attempt to solve the same problem.
+ # (afk 2005-06-25)
+ if grep -qE "(\?|sourceforge)" <<< "$URL"; then
+ unset CONTINUE
+ else CONTINUE="-C -"
+ fi
+
+ if [ -n "$DOWNLOAD_RATE" ] ; then
+ RATE="--limit-rate=${DOWNLOAD_RATE}"
+ fi
+
+ if [ -n "$URL_HTTP_FTP_TIMEOUT" ] ; then
+ URL_HTTP_TIMEOUT="--connect-timeout $URL_HTTP_FTP_TIMEOUT"
+ else
+ unset URL_HTTP_TIMEOUT
+ fi
+
+ if [ -n "$URL_HTTP_FTP_RETRIES" ] ; then
+ URL_HTTP_RETRIES="--retry $URL_HTTP_FTP_RETRIES"
+ else
+ URL_HTTP_RETRIES="--retry 3"
+ fi
+
+ local check_certificate
+ if list_find "$hints" no-check-certificate && [[ $(url_get_prefix "$URL")
== https ]]; then
+ check_certificate=--insecure
+ fi
+
+ REDIRECT="--location"
+
+ CURL_OPTIONS="$URL_HTTP_TIMEOUT $URL_HTTP_RETRIES $RATE $PASSIVE $CONTINUE
$REDIRECT $check_certificate"
+ debug 'dl_curl' "curl options: $CURL_OPTIONS"
+}
+#---------------------------------------------------------------------
+##=back
+##
+##=head1 LICENSE
+##
+## This software 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; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software 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.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libcodex
b/var/lib/sorcery/modules/libcodex
index d6abe64..7d1c50c 100755
--- a/var/lib/sorcery/modules/libcodex
+++ b/var/lib/sorcery/modules/libcodex
@@ -541,14 +541,14 @@ function codex_find_spell_by_name() {
#---------------------------------------------------------------------
function codex_get_spells_in_section() {
debug "libcodex" "codex_get_spells_in_section - $*"
- codex_is_canonicalized $1 || return 1
+ codex_is_canonicalized "$1" || return 1
local section="$(smgl_basename $1)"
local index="$(smgl_dirname $1)/$SPELL_INDEX_FILE"
- if ! test -r $index || ! test -s $index; then
+ if ! test -r "$index" || ! test -s "$index"; then
message "${PROBLEM_COLOR}${section:-<null>} is not a section
directory!${DEFAULT_COLOR}"
return 1
fi
- grep "/$section$" < $index | awk '{ print $2 "/" $1 }'
+ awk -v re="/$section\$" -- '$0 ~ re { print $2 "/" $1 }' "$index"

}




  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (f750931ad7434be955a22d5141eed16ff68186cf), Jaka Kranjc, 11/06/2014

Archive powered by MHonArc 2.6.24.

Top of Page