X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=client%2Fmake-request.sh;h=577ffcddaa9cbd06d6b5a7d2b2667b843938c8d7;hb=1b7332b1eeedc313bbef96e41ec44925d86cc96d;hp=2c753c9b88de497539cb098bbad4a459cab60d38;hpb=48833779774941e1ee019bf95395a8f67e414c52;p=tld-builder.git
diff --git a/client/make-request.sh b/client/make-request.sh
index 2c753c9..577ffcd 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,9 @@ send_request() {
;;
*)
msg "Sending using HTTP mode to $url"
- cat - | python -c '
-import sys, socket, urllib2, ssl
+ cat - | python3 -c '
+import sys, socket, ssl
+from urllib import request
try:
_create_unverified_https_context = ssl._create_unverified_context
@@ -112,16 +113,16 @@ else:
ssl._create_default_https_context = _create_unverified_https_context
try:
- data = sys.stdin.read()
+ data = sys.stdin.read().encode("utf-8")
url = sys.argv[1]
socket.setdefaulttimeout(30)
- req = urllib2.Request(url, data)
- f = urllib2.urlopen(req)
+ req = request.Request(url, data=data)
+ f = request.urlopen(req)
f.close()
-except Exception, e:
- print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
+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 +131,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 +178,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 atag pkg spec rpmdir
+# get package revision for specs
+get_pkgrevision() {
+ local pkgrev pkg spec rpmdir
rpmdir=$(rpm -E %_topdir)
for pkg in "$@"; do
@@ -206,12 +190,12 @@ get_autotag() {
# strip .spec extension
pkg=${pkg%.spec}
wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1
- atag=$(head -n 1 /tmp/$pkg.tags)
+ pkgrev=$(head -n 1 /tmp/$pkg.tags)
rm -f /tmp/$pkg.tags
- if [ "x$atag" = "x" ]; then
+ if [ "x$pkgrev" = "x" ]; then
echo "$pkg.spec"
else
- echo "$pkg.spec:$atag"
+ echo "$pkg.spec:$pkgrev"
fi
done
}
@@ -345,7 +329,7 @@ while [ $# -gt 0 ]; do
;;
-a)
- autotag=yes
+ pkgrevision=yes
;;
-m)
@@ -538,16 +522,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"
@@ -556,36 +540,36 @@ esac
# need to do this after dist selection
if [ "$skip" ]; then
- skip=$(skip="$skip" control_url="$control_url" python -c '
-import urllib2
+ skip=$(skip="$skip" control_url="$control_url" python3 -c '
import sys
-import StringIO
import gzip
import re
import os
import string
+from urllib import request
+from io import BytesIO
from xml.dom import minidom
skip = os.environ.get("skip").split(",");
control_url = os.environ.get("control_url")
-print >> sys.stderr, "* Check queue_id-s against %s" % control_url
+print("* Check queue_id-s against %s" % control_url, file=sys.stderr)
try:
headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
- req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
- f = urllib2.urlopen(req)
-except Exception, e:
- print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
+ req = request.Request(url=control_url + "/queue.gz", headers=headers)
+ f = request.urlopen(req)
+except Exception as e:
+ print("Fetch error %s: %s" % (control_url + "/queue.gz", e), file=sys.stderr)
sys.exit(1)
-sio = StringIO.StringIO()
+sio = BytesIO()
sio.write(f.read())
f.close()
sio.seek(0)
f = gzip.GzipFile(fileobj = sio)
-xml = re.compile("(.*?)", re.DOTALL).match(f.read()).group(1)
+xml = re.compile("(.*?)", re.DOTALL).match(f.read().decode("utf-8")).group(1)
d = minidom.parseString(xml)
q = []
@@ -597,13 +581,13 @@ for c in d.documentElement.childNodes:
err = 0
for s in skip:
if s not in q:
- print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
+ print("- Check %s: ERROR: Not valid queue-id" % s, file=sys.stderr)
err = 1
else:
- print >> sys.stderr, "- Check %s: OK" % s
+ print("- Check %s: OK" % s, file=sys.stderr)
if err == 1:
sys.exit(1)
-print string.join(skip, ",")
+print(",".join(skip))
') || exit $?
f_upgrade=no
build_mode=test
@@ -636,9 +620,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
@@ -737,7 +721,7 @@ gen_req() {
if [ "$command" ]; then
bid=$(uuidgen)
- echo -E >&2 "* Command: $command"
+ printf "%s\n" "* Command: $command" >&2
echo " "
echo " "
hsc "$command"
@@ -804,7 +788,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"