diff --git a/beakerlib.spec b/beakerlib.spec index 840ade7..b81fb62 100644 --- a/beakerlib.spec +++ b/beakerlib.spec @@ -1,13 +1,17 @@ Name: beakerlib Summary: A shell-level integration testing library Version: 1.17 -Release: 16%{?dist} +Release: 19%{?dist} License: GPLv2 Group: Development/Libraries BuildArch: noarch URL: https://github.com/%{name} +Autoreq: 0 Requires: nfs-utils -Requires: python3 +Requires: /bin/bash +Requires: /bin/sh +Recommends: /usr/bin/python3 +Recommends: /usr/bin/perl Requires: grep Requires: sed Requires: net-tools @@ -16,7 +20,8 @@ Requires: tar Requires: gzip Requires: util-linux Requires: which -Requires: wget +Requires: (wget or curl) +Suggests: wget Recommends: python3-lxml Recommends: xmllint Conflicts: beakerlib-redhat < 1-30 @@ -28,25 +33,32 @@ BuildRequires: util-linux Source0: https://github.com/beakerlib/beakerlib/archive/%{name}-%{version}.tar.gz Source1: %{name}-tmpfiles.conf -Patch0: test-built-time.patch -Patch1: result-file.patch -Patch2: ifs-issue.patch -Patch3: journaling-fixes.patch -Patch4: get-text-journal-size.patch -Patch5: var-TEST.patch -Patch6: reduce-meta.patch -Patch7: enable-nested-phases.patch -Patch8: debug-to-console.patch -Patch9: phase-names-sanitization.patch -Patch10: reboot-in-phase.patch -Patch11: rxvt-terminals-coloring.patch -Patch12: persistent-data-load.patch -Patch13: final-summary-in-rlJournalEnd.patch -Patch14: extended-coloring-capabilities.patch -Patch15: unified-footer.patch -Patch16: rlRun-output.patch -Patch17: python2.patch -Patch18: python3.patch +Patch0: bugzilla-links.patch +Patch1: test-built-time.patch +Patch2: result-file.patch +Patch3: ifs-issue.patch +Patch4: journaling-fixes.patch +Patch5: get-text-journal-size.patch +Patch6: var-TEST.patch +Patch7: reduce-meta.patch +Patch8: enable-nested-phases.patch +Patch9: debug-to-console.patch +Patch10: phase-names-sanitization.patch +Patch11: reboot-in-phase.patch +Patch12: rxvt-terminals-coloring.patch +Patch13: persistent-data-load.patch +Patch14: final-summary-in-rlJournalEnd.patch +Patch15: extended-coloring-capabilities.patch +Patch16: unified-footer.patch +Patch17: rlRun-output.patch +Patch18: python2.patch +Patch19: python3.patch +Patch20: srpm-fetch.patch +Patch21: journalling-import-check.patch +Patch22: handle-missing-python.patch +Patch23: wget2curl-fallback.patch +Patch24: platform-python.patch +Patch25: meta-format-fix.patch %prep %autosetup -p1 @@ -67,6 +79,7 @@ The BeakerLib project means to provide a library of various helpers, which could be used when writing operating system level integration tests. %files +%defattr(-,root,root,-) %dir %{_datadir}/%{name} %dir %{_datadir}/%{name}/xslt-templates %dir %{_pkgdocdir} @@ -94,6 +107,16 @@ Files for syntax highlighting BeakerLib tests in VIM editor %{_datadir}/vim/vimfiles/after/syntax/beakerlib.vim %changelog +* Thu Oct 25 2018 Dalibor Pospisil - 1.17-19 +- fixed meta file generation +- follow url redirection when using curl +- fixed checking for python interpreter +- weak dependency on python3 +- handling of missing python +- fixed srpm fetching +- fallback to curl if wget is not available +- changed requirements structure + * Thu Jul 12 2018 Fedora Release Engineering - 1.17-16 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild diff --git a/bugzilla-links.patch b/bugzilla-links.patch new file mode 100644 index 0000000..0053eb3 --- /dev/null +++ b/bugzilla-links.patch @@ -0,0 +1,19 @@ +diff --git a/src/beakerlib.sh b/src/beakerlib.sh +index 3355fa4..ceafc44 100644 +--- a/src/beakerlib.sh ++++ b/src/beakerlib.sh +@@ -274,10 +274,14 @@ https://github.com/beakerlib/beakerlib/wiki/man + + =item Issues list + ++https://bugzilla.redhat.com/buglist.cgi?component=beakerlib&&order=bug_status%2Cassigned_to%2Cpriority ++ + https://github.com/beakerlib/beakerlib/issues + + =item Reporting issues + ++https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=beakerlib ++ + https://github.com/beakerlib/beakerlib/issues/new + + =back diff --git a/handle-missing-python.patch b/handle-missing-python.patch new file mode 100644 index 0000000..01f67b2 --- /dev/null +++ b/handle-missing-python.patch @@ -0,0 +1,52 @@ +diff -u b/src/journal.sh b/src/journal.sh +--- b/src/journal.sh ++++ b/src/journal.sh +@@ -283,8 +297,25 @@ + #=cut + + __INTERNAL_JournalXMLCreate() { +- [[ "$BEAKERLIB_JOURNAL" == "0" ]] || $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \ +- "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL" ++ local res=0 ++ [[ "$BEAKERLIB_JOURNAL" == "0" ]] || { ++ if which python &> /dev/null; then ++ $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \ ++ "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL" ++ res=$? ++ if [[ $res -eq 2 ]]; then ++ rlLogError "cannot create journal.xml due to missing some python module" ++ elif [[ $res -eq 3 ]]; then ++ rlLogError "cannot create journal.xml due to missing python lxml module" ++ elif [[ $res -ne 0 ]]; then ++ rlLogError "journal.xml creation failed!" ++ fi ++ else ++ rlLogError "cannot create journal.xml due to missing python interpreter" ++ let res++ ++ fi ++ } ++ return $res + } + + +diff -u b/src/python/journalling.py b/src/python/journalling.py +--- b/src/python/journalling.py ++++ b/src/python/journalling.py +@@ -30,11 +30,15 @@ + import six + import time + import base64 +- from lxml import etree + from optparse import OptionParser + except ImportError as e: + sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n") +- exit(1) ++ exit(2) ++try: ++ from lxml import etree ++except ImportError as e: ++ sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n") ++ exit(3) + + + xmlForbidden = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, diff --git a/journalling-import-check.patch b/journalling-import-check.patch new file mode 100644 index 0000000..520e305 --- /dev/null +++ b/journalling-import-check.patch @@ -0,0 +1,44 @@ +From 59f7e0b123fc9789538f610a89d350d76c35106b Mon Sep 17 00:00:00 2001 +From: Jakub Heger +Date: Wed, 22 Aug 2018 12:37:49 +0200 +Subject: [PATCH 2/4] journalling: try import + +imports are now in try block, exceptions cause unsuccessful exit with +error message printed +--- + src/python/journalling.py | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/src/python/journalling.py b/src/python/journalling.py +index 220d5d2..7a65d78 100755 +--- a/src/python/journalling.py ++++ b/src/python/journalling.py +@@ -23,14 +23,18 @@ + # TODO fix xml pretty print + + +-import os +-import re +-import sys +-import six +-import time +-import base64 +-from lxml import etree +-from optparse import OptionParser ++try: ++ import os ++ import re ++ import sys ++ import six ++ import time ++ import base64 ++ from lxml import etree ++ from optparse import OptionParser ++except ImportError as e: ++ sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n") ++ exit(1) + + + xmlForbidden = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, +-- +2.17.1 diff --git a/meta-format-fix.patch b/meta-format-fix.patch new file mode 100644 index 0000000..83da732 --- /dev/null +++ b/meta-format-fix.patch @@ -0,0 +1,30 @@ +diff -u a/src/journal.sh b/src/journal.sh +--- a/src/journal.sh ++++ b/src/journal.sh +@@ -918,13 +918,13 @@ + while [[ $# -gt 0 ]]; do + case $1 in + --) +- line+=" -- \"$(echo -n "$2" | base64 -w 0)\"" ++ line+=" -- $(echo -n "$2" | base64 -w 0)" + printf -v lineraw "%s -- %q" "$lineraw" "$2" + shift 2 + break + ;; + --*) +- line+=" $1=\"$(echo -n "$2" | base64 -w 0)\"" ++ line+=" $1=$(echo -n "$2" | base64 -w 0)" + printf -v lineraw "%s %s=%q" "$lineraw" "$1" "$2" + shift + ;; +@@ -944,8 +944,8 @@ + + printf -v indent '%*s' $__INTERNAL_METAFILE_INDENT_LEVEL + +- line="$indent${element:+$element }--timestamp=\"${__INTERNAL_TIMESTAMP}\"$line" +- lineraw="$indent${element:+$element }--timestamp=\"${__INTERNAL_TIMESTAMP}\"$lineraw" ++ line="$indent${element:+$element }--timestamp=${__INTERNAL_TIMESTAMP}$line" ++ lineraw="$indent${element:+$element }--timestamp=${__INTERNAL_TIMESTAMP}$lineraw" + [[ -n "$DEBUG" ]] && echo "#${lineraw:1}" >> $__INTERNAL_BEAKERLIB_METAFILE + echo "$line" >> $__INTERNAL_BEAKERLIB_METAFILE + } diff --git a/platform-python.patch b/platform-python.patch new file mode 100644 index 0000000..033342f --- /dev/null +++ b/platform-python.patch @@ -0,0 +1,12 @@ +diff -u a/src/journal.sh b/src/journal.sh +--- a/src/journal.sh ++++ b/src/journal.sh +@@ -285,7 +285,7 @@ + __INTERNAL_JournalXMLCreate() { + local res=0 + [[ "$BEAKERLIB_JOURNAL" == "0" ]] || { +- if which python &> /dev/null; then ++ if which python3 &> /dev/null; then + $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \ + "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL" + res=$? diff --git a/srpm-fetch.patch b/srpm-fetch.patch new file mode 100644 index 0000000..1176d0d --- /dev/null +++ b/srpm-fetch.patch @@ -0,0 +1,29 @@ +From 24d774fb27375f0848d56603be873937d23209cc Mon Sep 17 00:00:00 2001 +From: Zdenek Zambersky +Date: Thu, 2 Aug 2018 16:50:35 +0200 +Subject: [PATCH 1/4] rpms.sh: fixed search url for src rpms + +--- + src/rpms.sh | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/rpms.sh b/src/rpms.sh +index 66d9aa8..878abba 100644 +--- a/src/rpms.sh ++++ b/src/rpms.sh +@@ -671,7 +671,12 @@ __INTERNAL_rpmGetNextUrl() { + ;; + koji,nvra.rpm) + rlLogDebug "$FUNCNAME(): get rpm info" +- local rpm_info=$($__INTERNAL_WGET -O - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.$A.rpm") ++ local rpm_info ++ if [[ -n "$source" ]]; then ++ rpm_info=$($__INTERNAL_WGET -O - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.src.rpm") ++ else ++ rpm_info=$($__INTERNAL_WGET -O - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.$A.rpm") ++ fi + [[ $? -ne 0 || -z "$rpm_info" ]] && { + rlLogError "could not download rpm information" + let res++ +-- +2.17.1 diff --git a/wget2curl-fallback.patch b/wget2curl-fallback.patch new file mode 100644 index 0000000..4846026 --- /dev/null +++ b/wget2curl-fallback.patch @@ -0,0 +1,77 @@ +From 10520de65d10d2ab34329e24144aa922a430b229 Mon Sep 17 00:00:00 2001 +From: Dalibor Pospisil +Date: Wed, 22 Aug 2018 13:09:47 +0200 +Subject: [PATCH 4/4] use wget or curl for web download + +Now there's a fallback to curl if wget is not available. +Wget has still a preference as it has got better progress printing while +the output is redirected to a file. +--- + src/rpms.sh | 32 +++++++++++++++++++++++++++----- + 1 file changed, 27 insertions(+), 5 deletions(-) + +diff --git a/src/rpms.sh b/src/rpms.sh +index 878abba..e51dd4f 100644 +--- a/src/rpms.sh ++++ b/src/rpms.sh +@@ -630,7 +630,27 @@ __INTERNAL_rpmInitUrl() { + } + + +-__INTERNAL_WGET="wget -t 3 -T 180 -w 20 --waitretry=30 --no-check-certificate --progress=dot:giga" ++__INTERNAL_WGET() { ++ local QUIET ++ [[ "$1" == "--quiet" ]] && { QUIET=1; shift; } ++ local URL="$2" ++ local FILE="$1" ++ local res=0 ++ if which wget &> /dev/null; then ++ rlLogDebug "$FUNCNAME(): using wget for download" ++ QUIET="${QUIET:+--quiet}" ++ wget $QUIET -t 3 -T 180 -w 20 --waitretry=30 --no-check-certificate --progress=dot:giga -O $FILE $URL || let res++ ++ elif which curl &> /dev/null; then ++ rlLogDebug "$FUNCNAME(): using curl for download" ++ QUIET="${QUIET:+--silent}" ++ [[ -t 2 ]] || QUIET="${QUIET:---silent --show-error}" ++ curl $QUIET --location --retry-connrefused --retry-delay 3 --retry-max-time 3600 --retry 3 --connect-timeout 180 --max-time 1800 --insecure -o $FILE "$URL" || let res++ ++ else ++ rlLogError "$FUNCNAME(): no tool for downloading web content is available" ++ let res++ ++ fi ++ return $res ++} + + # __INTERNAL_rpmGetNextUrl N V R A | --source N V R + __INTERNAL_rpmGetNextUrl() { +@@ -673,9 +695,9 @@ __INTERNAL_rpmGetNextUrl() { + rlLogDebug "$FUNCNAME(): get rpm info" + local rpm_info + if [[ -n "$source" ]]; then +- rpm_info=$($__INTERNAL_WGET -O - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.src.rpm") ++ rpm_info=$(__INTERNAL_WGET - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.src.rpm") + else +- rpm_info=$($__INTERNAL_WGET -O - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.$A.rpm") ++ rpm_info=$(__INTERNAL_WGET - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.$A.rpm") + fi + [[ $? -ne 0 || -z "$rpm_info" ]] && { + rlLogError "could not download rpm information" +@@ -692,7 +714,7 @@ __INTERNAL_rpmGetNextUrl() { + rlLogDebug "$FUNCNAME(): extracted buildurl='$buildurl'" + [[ "$buildurl" =~ http ]] || buildurl="$base_url/$buildurl" + rlLogDebug "$FUNCNAME(): using buildurl='$buildurl'" +- local buildinfo=$($__INTERNAL_WGET -O - "$buildurl") ++ local buildinfo=$(__INTERNAL_WGET - "$buildurl") + [[ $? -ne 0 || -z "$buildinfo" ]] && { + rlLogError "could not download build information" + let res++ +@@ -752,7 +774,7 @@ __INTERNAL_rpmDirectDownload() { + url="$__INTERNAL_RETURN_VALUE"; unset __INTERNAL_RETURN_VALUE + local pkg=$(basename "$url") + rlLog "trying download from '$url'" +- if $__INTERNAL_WGET $quiet -O $pkg "$url"; then ++ if __INTERNAL_WGET $quiet $pkg "$url"; then + rlLogDebug "$FUNCNAME(): package '$pkg' was successfully downloaded" + echo "$pkg" + return 0 +-- +2.17.1