]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - client/make-request.sh
- merged PLD changes, now it works with python 3.x
[tld-builder.git] / client / make-request.sh
index a14bd7c5ffadd4308f3f7a125f7f5e4f3d094988..d83e7aca6c8a784652e00c2c8387c81380c5cfd2 100755 (executable)
@@ -17,7 +17,7 @@ dist=
 url=
 no_depend=no
 verbose=no
-autotag=no
+pkgrevision=no
 requester_override=
 relup=no
 
@@ -45,7 +45,7 @@ url="$url"
 mailer="/usr/lib/sendmail -t"
 gpg_opts=""
 dist=ti
-url="http://kraz.tld-linux.org:1231/"
+url="https://src.tld-linux.org:1241/"
 
 # defaults:
 f_upgrade=yes
@@ -102,7 +102,14 @@ send_request() {
        *)
                msg "Sending using HTTP mode to $url"
                cat - | python -c '
-import sys, socket, urllib2
+import sys, socket, urllib2, ssl
+
+try:
+    _create_unverified_https_context = ssl._create_unverified_context
+except AttributeError:
+    pass
+else:
+    ssl._create_default_https_context = _create_unverified_https_context
 
 try:
         data = sys.stdin.read()
@@ -111,7 +118,7 @@ try:
         req = urllib2.Request(url, data)
         f = urllib2.urlopen(req)
         f.close()
-except Exception, e:
+except Exception as e:
         print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
         sys.exit(1)
 print >> sys.stdout, "Request queued via HTTP."
@@ -123,7 +130,7 @@ print >> sys.stdout, "Request queued via HTTP."
 # htmlspecialchars: escape <, > and &
 hsc() {
        local input=$1
-       echo -E "$input" | sed -e 's,&,\&amp;,g;s,<,\&lt;,g;s,>,\&gt;,g'
+       printf "%s\n" "$input" | sed -e 's,&,\&amp;,g;s,<,\&lt;,g;s,>,\&gt;,g'
 }
 
 # simple df_fetcher, based on packages/fetchsrc_request
@@ -170,26 +177,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
@@ -198,16 +188,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
 }
@@ -341,7 +328,7 @@ while [ $# -gt 0 ]; do
                        ;;
 
                -a)
-                       autotag=yes
+                       pkgrevision=yes
                        ;;
 
                -m)
@@ -534,16 +521,16 @@ done
 
 case "$dist" in
 ti)
-       builder_email="builderti@kraz.tld-linux.org"
+       builder_email="builderti@src.tld-linux.org"
        default_builders="ti-*"
-       url="http://kraz.tld-linux.org:1231/"
-       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="http://kraz.tld-linux.org:1232/"
-       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"
@@ -632,9 +619,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
@@ -733,7 +720,7 @@ gen_req() {
 
        if [ "$command" ]; then
                bid=$(uuidgen)
-               echo -E >&2 "* Command: $command"
+               printf "%s\n" "* Command: $command" >&2
                echo "  <batch id='$bid' depends-on=''>"
                echo "           <command flags='$command_flags'>"
                hsc "$command"
@@ -800,7 +787,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 "  <batch id='$bid' depends-on='$depend'>"
                echo "           <command flags='$command_flags'>"
                hsc "$post_command"