X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=client%2Fmake-request.sh;h=06e3445cba934b297c435ac715a9bfb697597d8e;hb=HEAD;hp=493432c438f611d059e50780634fae7cc3e49a8c;hpb=3d4e503a79ceec757a378a14892f59efcf482337;p=tld-builder.git diff --git a/client/make-request.sh b/client/make-request.sh index 493432c..06e3445 100755 --- a/client/make-request.sh +++ b/client/make-request.sh @@ -1,4 +1,6 @@ #!/bin/sh +# vim:noet:ts=4:sw=4 +VERSION=1.89 # prevent "*" from being expanded in builders var set -f @@ -15,13 +17,15 @@ 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" - send_mode="mail" + echo "No python3 present, aborting" + exit 1 fi if [ -n "$HOME_ETC" ]; then @@ -34,14 +38,13 @@ if [ ! -f "$USER_CFG" ]; then echo "Creating config file $USER_CFG. You *must* edit it." cat > $USER_CFG <> 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 } -# simple df_fetcher, based on packages/fetchsrc_request -# TODO: tcp (smtp) mode -# TODO: adjust for ~/.requestrc config -df_fetch() { - local specs="$@" - - # Sending by - local MAILER='/usr/sbin/sendmail' - # MAILER='/usr/bin/msmtp' - # Sending via - local VIA="SENDMAIL" - #VIA="localhost" - local VIA_ARGS="" - #VIA_ARGS="some additional flags" - # e.g. for msmtp: - # VIA_ARGS='-a gmail' - # - # DISTFILES EMAIL - local DMAIL="distfiles@pld-linux.org" - - local HOST=$(hostname -f) - local LOGIN=${requester%@*} - - for spec in $specs; do - local SPEC=$(echo "$spec" | sed -e 's|:.*||') - local BRANCH=$(echo "$spec" | sed -e 's|.*:||') - echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}" - cat <<-EOF | "$MAILER" -t -i $VIA_ARGS - To: $DMAIL - From: $LOGIN <$LOGIN@$HOST> - Subject: fetchsrc_request notify - X-CVS-Module: SPECS - X-distfiles-request: yes - X-Login: $LOGIN - X-Spec: $SPEC - X-Branch: $BRANCH - X-Flags: force-reply - - . - EOF - done +# htmlspecialchars: escape <, > and & +hsc() { + local input=$1 + printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g' } -# 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 - out=$(cvs status -v $s | awk "!/Sticky/&&/auto-$dist-/{if (!a++) print \$1}") - echo "$s:$out" - done -} - -# get autotag for specs -# WARNING: This may checkout some files from CVS -get_autotag() { - local pkg spec rpmdir +# get package revision for specs +get_pkgrevision() { + local pkgrev pkg spec rpmdir rpmdir=$(rpm -E %_topdir) - cd $rpmdir for pkg in "$@"; do + cd $rpmdir # strip branches 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 - autotag $pkg/$pkg.spec + echo "$pkg.spec:$pkgrev" fi done } +relup() { + local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh + $script -u -i "$@" +} + usage() { cat <> 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 = [] @@ -563,13 +518,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 @@ -587,29 +542,24 @@ specs=`for s in $specs; do # skip marker - pass it along echo $s ;; - *.spec:*) # spec with branch - basename $s - ;; - *.spec) # spec without branch - echo $(basename $s):$branch - ;; *:*) # package name with branch - basename $s | sed -e 's/:/.spec:/' + _specfile=$(basename ${s%:*}) + echo ${_specfile%.spec}.spec:${s##*:} ;; *) # just package name - echo $(basename $s).spec:$branch + echo $(basename ${s%.spec}).spec:$branch ;; esac done` -if [ "$autotag" = "yes" ]; then - msg "Auto autotag build enabled" - specs=$(get_autotag $specs) +if [ "$relup" = "yes" ]; then + msg "Auto relup enabled" + relup ${message:+-m "$message"} $specs fi -if [ "$df_fetch" = "yes" ]; then - df_fetch $specs - exit 0 +if [ "$pkgrevision" = "yes" ]; then + msg "Package revision build enabled" + specs=$(get_pkgrevision $specs) fi if [ "$upgrade_macros" = "yes" ]; then @@ -619,8 +569,16 @@ if [ "$upgrade_macros" = "yes" ]; then build_mode=test fi +if [ "$upgrade_scripts" = "yes" ]; then + command="cd ~/rpm/rpm-build-tools && git pull" + command_flags=as-builder + builders="$dist-src" + f_upgrade=no + build_mode=test +fi + if [[ "$requester" != *@* ]] ; then - requester="$requester@pld-linux.org" + requester="$requester@tld-linux.org" fi if [ -z "$builders" ] ; then @@ -664,11 +622,7 @@ gen_req() { msg "Using jobs $jobs" echo " $jobs" fi - if [ -z "$url" ]; then - msg "Using email $builder_email" - else - msg "Using URL $url" - fi + msg "Using URL $url" if [ "$build_mode" = "ready" ]; then msg "Build mode: $(tput setaf 2)$build_mode$c_norm" @@ -676,12 +630,16 @@ gen_req() { msg "Build mode: $(tput setaf 3)$build_mode$c_norm" fi + if [ -n "$requester_override" ] ; then + echo " $requester_override" + fi + msg "Queue-ID: $id" echo # job to depend on local depend= - local b i=1 + local b i=1 val local name branch builders_xml for b in $builders; do @@ -691,10 +649,10 @@ gen_req() { if [ "$command" ]; then bid=$(uuidgen) - echo -E >&2 "* Command: $command" + printf "%s\n" "* Command: $command" >&2 echo " " echo " " - echo -E "$command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g' + hsc "$command" echo "" echo " " echo "$builders_xml" @@ -725,6 +683,17 @@ gen_req() { echo " $branch" echo " ${kernel:+$kernel}" echo " ${target:+$target}" + + oIFS=$IFS; IFS=$cr + for b in $define; do + [ -z "$b" ] && continue + value=${b#*=} + b=${b%%=*} + echo " $(hsc "$value")" + msg "- define $b=$value" + done + IFS=$oIFS + echo " " echo for b in $with; do @@ -747,10 +716,10 @@ 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 " " - echo -E "$post_command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g' + hsc "$post_command" echo "" echo " " echo "$builders_xml" @@ -776,8 +745,8 @@ gen_email () { To: $builder_email Subject: build request Message-Id: <$id@$(hostname)> - X-New-PLD-Builder: request - X-Requester-Version: \$Id$ + X-New-TLD-Builder: request + X-Requester-Version: $VERSION EOF