X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=client%2Fmake-request.sh;h=fdb750b506a28727301954c3645c9bf1b8eba93f;hb=b06ac0a74084c2ed513ecead310ea47208344d14;hp=e3fa52de698e842e3ce4d8d630a1a31dbe7215ea;hpb=c960542e97b68c03a825532c77de56ee7070efd4;p=tld-builder.git diff --git a/client/make-request.sh b/client/make-request.sh index e3fa52d..fdb750b 100755 --- a/client/make-request.sh +++ b/client/make-request.sh @@ -17,11 +17,11 @@ dist= url= no_depend=no verbose=no -autotag=no +pkgrevision=no requester_override= relup=no -if [ -x /usr/bin/python ]; then +if [ -x /usr/bin/python3 ]; then send_mode="python" else echo "No python present, using mail mode" @@ -45,7 +45,7 @@ url="$url" mailer="/usr/lib/sendmail -t" gpg_opts="" dist=ti -url="https://kraz.tld-linux.org:1241/" +url="https://src.tld-linux.org:1241/" # defaults: f_upgrade=yes @@ -101,8 +101,8 @@ send_request() { ;; *) msg "Sending using HTTP mode to $url" - cat - | python -c ' -import sys, socket, urllib2, ssl + cat - | python3 -c ' +import sys, socket, urllib3, ssl try: _create_unverified_https_context = ssl._create_unverified_context @@ -115,13 +115,12 @@ try: data = sys.stdin.read() url = sys.argv[1] socket.setdefaulttimeout(30) - req = urllib2.Request(url, data) - f = urllib2.urlopen(req) - f.close() -except Exception, e: - print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e) + http = urllib3.PoolManager(cert_reqs="CERT_NONE") + http.request("POST",url, body=data) +except Exception as e: + print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr) sys.exit(1) -print >> sys.stdout, "Request queued via HTTP." + print("Request queued via HTTP.", file=sys.stdout) ' "$url" ;; esac @@ -130,7 +129,7 @@ print >> sys.stdout, "Request queued via HTTP." # htmlspecialchars: escape <, > and & hsc() { local input=$1 - echo -E "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g' + printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g' } # simple df_fetcher, based on packages/fetchsrc_request @@ -177,26 +176,9 @@ df_fetch() { done } -# autotag from rpm-build-macros -# displays latest used tag for a specfile -autotag() { - local out s - for s in "$@"; do - # strip branches - s=${s%:*} - # ensure package ends with .spec - s=${s%.spec}.spec - git fetch --tags - out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \ - --format='%(refname:short)') - echo "$s:$out" - done -} - -# get autotag for specs -# WARNING: This may checkout some files from VCS -get_autotag() { - local pkg spec rpmdir +# get package revision for specs +get_pkgrevision() { + local pkgrev pkg spec rpmdir rpmdir=$(rpm -E %_topdir) for pkg in "$@"; do @@ -205,16 +187,13 @@ get_autotag() { pkg=${pkg%:*} # strip .spec extension pkg=${pkg%.spec} - # checkout only if missing - if [ ! -e $pkg/$pkg.spec ]; then - $rpmdir/builder -g $pkg -ns -r HEAD 1>&2 - fi - if [ ! -e $pkg/$pkg.spec ]; then - # just print it out, to fallback to base pkg name - echo "$pkg" + wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1 + pkgrev=$(head -n 1 /tmp/$pkg.tags) + rm -f /tmp/$pkg.tags + if [ "x$pkgrev" = "x" ]; then + echo "$pkg.spec" else - cd $pkg - autotag $pkg.spec + echo "$pkg.spec:$pkgrev" fi done } @@ -348,7 +327,7 @@ while [ $# -gt 0 ]; do ;; -a) - autotag=yes + pkgrevision=yes ;; -m) @@ -541,16 +520,16 @@ done case "$dist" in ti) - builder_email="builderti@kraz.tld-linux.org" + builder_email="builderti@src.tld-linux.org" default_builders="ti-*" - url="https://kraz.tld-linux.org:1241/" - control_url="http://kraz.tld-linux.org/~builderti" + url="https://src.tld-linux.org:1241/" + control_url="http://src.tld-linux.org/~builderti" ;; ti-dev) - builder_email="buildertidev@kraz.tld-linux.org" + builder_email="buildertidev@src.tld-linux.org" default_builders="ti-dev-*" - url="https://kraz.tld-linux.org:1242/" - control_url="http://kraz.tld-linux.org/~buildertidev" + url="https://src.tld-linux.org:1242/" + control_url="http://src.tld-linux.org/~buildertidev" ;; *) die "dist \`$dist' not known" @@ -559,7 +538,7 @@ esac # need to do this after dist selection if [ "$skip" ]; then - skip=$(skip="$skip" control_url="$control_url" python -c ' + skip=$(skip="$skip" control_url="$control_url" python3 -c ' import urllib2 import sys import StringIO @@ -639,9 +618,9 @@ if [ "$relup" = "yes" ]; then relup ${message:+-m "$message"} $specs fi -if [ "$autotag" = "yes" ]; then - msg "Auto autotag build enabled" - specs=$(get_autotag $specs) +if [ "$pkgrevision" = "yes" ]; then + msg "Package revision build enabled" + specs=$(get_pkgrevision $specs) fi if [ "$df_fetch" = "yes" ]; then @@ -740,7 +719,7 @@ gen_req() { if [ "$command" ]; then bid=$(uuidgen) - echo -E >&2 "* Command: $command" + printf "%s\n" "* Command: $command" >&2 echo " " echo " " hsc "$command" @@ -807,7 +786,7 @@ gen_req() { if [ "$no_depend" = yes ]; then depend= fi - echo -E >&2 "* Post-Command: $post_command" + printf "%s\n" "* Post-Command: $post_command" >&2 echo " " echo " " hsc "$post_command"