Hello community, here is the log from the commit of package obs-service-set_version for openSUSE:Factory checked in at 2017-12-21 11:29:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/obs-service-set_version (Old) and /work/SRC/openSUSE:Factory/.obs-service-set_version.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "obs-service-set_version" Thu Dec 21 11:29:30 2017 rev:32 rq:558810 version:0.5.8 Changes: -------- --- /work/SRC/openSUSE:Factory/obs-service-set_version/obs-service-set_version.changes 2017-11-14 13:02:41.646943843 +0100 +++ /work/SRC/openSUSE:Factory/.obs-service-set_version.new/obs-service-set_version.changes 2017-12-21 11:29:37.806711100 +0100 @@ -1,0 +2,15 @@ +Mon Dec 11 15:50:24 UTC 2017 - fschrei...@suse.de + +- Update to version 0.5.8: + * fixes boo#1072359 + * code cleanup and some refactoring + * cli options --debug and --regex + * new targets (test/clean) for Makefile + * initial .gitignore + * Mention that tests may take some time in README.md + * Fix pip/zypper tests for python3 + * enforce files to be decoded as UTF-8 + * Don't let version check get beyond path boundary + * Slightly reorganize README.md file + +------------------------------------------------------------------- Old: ---- obs-service-set_version-0.5.7.tar.gz New: ---- obs-service-set_version-0.5.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ obs-service-set_version.spec ++++++ --- /var/tmp/diff_new_pack.Ur2BF9/_old 2017-12-21 11:29:38.498677360 +0100 +++ /var/tmp/diff_new_pack.Ur2BF9/_new 2017-12-21 11:29:38.502677165 +0100 @@ -19,7 +19,7 @@ %define service set_version Name: obs-service-%{service} -Version: 0.5.7 +Version: 0.5.8 Release: 0 Summary: An OBS source service: Update spec file version License: GPL-2.0+ ++++++ PKGBUILD ++++++ --- /var/tmp/diff_new_pack.Ur2BF9/_old 2017-12-21 11:29:38.530675800 +0100 +++ /var/tmp/diff_new_pack.Ur2BF9/_new 2017-12-21 11:29:38.530675800 +0100 @@ -1,5 +1,5 @@ pkgname=obs-service-set_version -pkgver=0.5.7 +pkgver=0.5.8 pkgrel=0 pkgdesc="An OBS source service: Update spec file version" arch=('i686' 'x86_64') ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Ur2BF9/_old 2017-12-21 11:29:38.554674630 +0100 +++ /var/tmp/diff_new_pack.Ur2BF9/_new 2017-12-21 11:29:38.558674435 +0100 @@ -1,5 +1,5 @@ <servicedata> <service name="tar_scm"> <param name="url">g...@github.com:openSUSE/obs-service-set_version.git</param> - <param name="changesrevision">98641aeb28f887737a293a46f6f0c091fe81af0a</param></service> + <param name="changesrevision">5fabceedf07f6a8597b510e16993b613eded4655</param></service> </servicedata> \ No newline at end of file ++++++ debian.dsc ++++++ --- /var/tmp/diff_new_pack.Ur2BF9/_old 2017-12-21 11:29:38.574673654 +0100 +++ /var/tmp/diff_new_pack.Ur2BF9/_new 2017-12-21 11:29:38.578673459 +0100 @@ -1,6 +1,6 @@ Format: 1.0 Source: obs-service-set_version -Version: 0.5.7-0 +Version: 0.5.8-0 Binary: obs-service-set_version Provides: obs-service-set_version Maintainer: Adrian Schroeter <adr...@suse.de> ++++++ obs-service-set_version-0.5.7.tar.gz -> obs-service-set_version-0.5.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/Makefile new/obs-service-set_version-0.5.8/Makefile --- old/obs-service-set_version-0.5.7/Makefile 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/Makefile 2017-12-11 13:06:13.000000000 +0100 @@ -15,6 +15,7 @@ clean: find -name "*.pyc" -exec rm {} \; + find -name '*.pyo' -exec rm {} \; rm -rf set_versionc .PHONY: all install test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/README.md new/obs-service-set_version-0.5.8/README.md --- old/obs-service-set_version-0.5.7/README.md 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/README.md 2017-12-11 13:06:13.000000000 +0100 @@ -1,10 +1,10 @@ # set_version (OBS source service) [![Build Status](https://travis-ci.org/openSUSE/obs-service-set_version.svg?branch=master)](https://travis-ci.org/openSUSE/obs-service-set_version) -This service updates a RPM spec or Debian changelog according to the existing files. -The service can be used in combination with other services like [download_files](https://github.com/openSUSE/obs-service-download_files) -or [tar_scm](https://github.com/openSUSE/obs-service-tar_scm). -This is the git repository for [openSUSE:Tools/obs-service-set_version](https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-set_version). -The authoritative source is https://github.com/openSUSE/obs-service-set_version +This is an [Open Build Service](http://openbuildservice.org/) source service. It updates an RPM spec or Debian changelog according to the existing files. + +This is the git repository for [openSUSE:Tools/obs-service-set_version](https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-set_version). The authoritative source is https://github.com/openSUSE/obs-service-set_version + +The service can be used in combination with other services like [download_files](https://github.com/openSUSE/obs-service-download_files), [tar_scm](https://github.com/openSUSE/obs-service-tar_scm), [recompress](https://github.com/openSUSE/obs-service-recompress) or [extract_file](https://github.com/openSUSE/obs-service-extract_file) e.g. within the [GIT integration](https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService#Example_2:_GIT_integration) workflow. ## Dependencies Install the following deps: @@ -20,13 +20,21 @@ If the dependencies are not installed, some tests are skipped. `zypper` itself is also needed for the tests with python packages and PEP440 compatible versions. -To run the testsuite, execute: +To run the full testsuite, execute: python -m unittest discover tests/ -The testrun may take some time. Don't forget to run also +If ```zypper``` and/or ```dpkg``` are installed, theses tests take some time, +but you can specify a filename pattern, which test files should be run. + + python -m unittest discover -p test_b*.py tests/ + +Don't forget to run also flake8 set_version tests/ +or simply use + make test +to run all linters and tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/set_version new/obs-service-set_version-0.5.8/set_version --- old/obs-service-set_version-0.5.7/set_version 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/set_version 2017-12-11 13:06:13.000000000 +0100 @@ -22,6 +22,7 @@ import sys import tarfile import zipfile +import codecs try: from packaging.version import LegacyVersion, Version, parse @@ -34,6 +35,8 @@ HAS_PACKAGING = True +DEBUG = False + outdir = None suffixes = ('obscpio', 'tar', 'tar.gz', 'tgz', 'tar.bz2', 'tbz2', 'tar.xz', 'zip') @@ -49,36 +52,60 @@ class VersionDetector(object): - @staticmethod - def _autodetect(files, basename): - version = VersionDetector._get_version_via_obsinfo( - files, basename) + def __init__(self, regex=None, file_list=(), basename=''): + self.regex = regex + self.file_list = file_list + self.basename = basename + + def autodetect(self): + if DEBUG: + print("Starting version autodetect") + + version = self._get_version_via_obsinfo() if not version: - version = VersionDetector._get_version_via_archive_dirname( - files, basename) + if DEBUG: + print("Could not find version via obsinfo") + version = self._get_version_via_archive_dirname() if not version: - version = VersionDetector._get_version_via_filename( - files, basename) + if DEBUG: + print("Could not find version via archive dirname") + version = self._get_version_via_filename() if not version: - version = VersionDetector._get_version_via_debian_changelog( - "debian.changelog") + if DEBUG: + print("Could not find version via filename") + version = self.get_version_via_debian_changelog("debian.changelog") + if not version: + if DEBUG: + print("Could not find version via debian changelog") return version - @staticmethod - def _get_version_via_filename(files, basename): + def _get_version_via_filename(self): """ detect version based on file names""" - for f in files: - regex = r"^%s.*[-_]([\d].*)\.(?:%s)$" % (re.escape(basename), - suffixes_re) + if DEBUG: + print("detecting version via files") + for f in self.file_list: + if DEBUG: + print(" - checking file ", f) + if self.regex: + if DEBUG: + print(" - using regex: ", self.regex) + regex = self.regex + else: + regex = r"^%s.*[-_]([\d].*)\.(?:%s)$" % ( + re.escape(self.basename), + suffixes_re) m = re.match(regex, f) if m: return m.group(1) # Nothing found return None - @staticmethod - def __get_version(str_list, basename): - regex = "%s.*[-_]([\d][^\/]*).*" % basename + def __get_version(self, str_list): + if self.regex: + regex = self.regex + else: + regex = "%s.*[-_]([\d][^\/]*).*" % self.basename + for s in str_list: m = re.match(regex, s) if m: @@ -86,31 +113,29 @@ # Nothing found return None - @staticmethod - def _get_version_via_archive_dirname(files, basename): + def _get_version_via_archive_dirname(self): """ detect version based tar'd directory name""" - for f in filter(lambda x: x.endswith(suffixes), files): + for f in filter(lambda x: x.endswith(suffixes), self.file_list): # handle tarfiles if tarfile.is_tarfile(f): with tarfile.open(f) as tf: - v = VersionDetector.__get_version(tf.getnames(), basename) + v = self.__get_version(tf.getnames()) if v: return v # handle zipfiles if zipfile.is_zipfile(f): with zipfile.ZipFile(f, 'r') as zf: - v = VersionDetector.__get_version(zf.namelist(), basename) + v = self.__get_version(zf.namelist()) if v: return v # Nothing found return None - @staticmethod - def _get_version_via_obsinfo(files, basename): - join_suffix = basename + ".obsinfo" - for filename in filter(lambda x: x.endswith(join_suffix), files): - if os.path.exists(filename): - with open(filename, "r") as fp: + def _get_version_via_obsinfo(self): + join_suffix = self.basename + ".obsinfo" + for fname in filter(lambda x: x.endswith(join_suffix), self.file_list): + if os.path.exists(fname): + with codecs.open(fname, 'r', 'utf8') as fp: for line in fp: if line.startswith("version: "): string = line[9:] @@ -120,7 +145,7 @@ return None @staticmethod - def _get_version_via_debian_changelog(filename): + def get_version_via_debian_changelog(filename): # from http://anonscm.debian.org/cgit/pkg-python-debian/\ # python-debian.git/tree/lib/debian/changelog.py topline = re.compile(r'^(\w%(name_chars)s*) \(([^\(\) \t]+)\)' @@ -128,7 +153,7 @@ % {'name_chars': '[-+0-9a-z.]'}, re.IGNORECASE) if os.path.exists(filename): - with open(filename, "r") as f: + with codecs.open(filename, 'r', 'utf8') as f: firstline = f.readline() topmatch = topline.match(firstline) if topmatch: @@ -140,7 +165,7 @@ def _get_version_via_debian_dsc(filename): version = re.compile(r'^Version:([ \t\f\v]*)[^%\n\r]*', re.IGNORECASE) if os.path.exists(filename): - with open(filename, "r") as f: + with codecs.open(filename, 'r', 'utf8') as f: for line in f: versionmatch = version.match(line) if versionmatch: @@ -150,6 +175,7 @@ class PackageTypeDetector(object): + # pylint: disable=too-few-public-methods @staticmethod def _get_package_type(files): pt_found = False @@ -177,7 +203,7 @@ def _replace_define(filename, def_name, def_value, add_if_missing=True): # first, modify a copy of filename and then move it - with open(filename, 'r+') as f: + with codecs.open(filename, 'r+', 'utf8') as f: contents = f.read() f.seek(0) contents_new, subs = re.subn( @@ -200,7 +226,7 @@ def _replace_spec_setup(filename, version_define): # first, modify a copy of filename and then move it - with open(filename, 'r+') as f: + with codecs.open(filename, 'r+', 'utf8') as f: contents = f.read() f.seek(0) # %setup without "-n" uses implicit "-n" as "%{name}-%{version}" @@ -223,7 +249,7 @@ def _replace_tag(filename, tag, string): # first, modify a copy of filename and then move it - with open(filename, 'r+') as f: + with codecs.open(filename, 'r+', 'utf8') as f: contents = f.read() f.seek(0) if filename.endswith("PKGBUILD") or filename.endswith("build.collax"): @@ -243,12 +269,11 @@ f.write(contents_new) -def _replace_debian_changelog_version(filename, version_new): +def _replace_debian_changelog_version(fname, version_new): # first, modify a copy of filename and then move it # get current version - version_current = VersionDetector._get_version_via_debian_changelog( - filename) - with open(filename, 'r+') as f: + version_current = VersionDetector.get_version_via_debian_changelog(fname) + with codecs.open(fname, 'r+', 'utf8') as f: content_lines = f.readlines() f.seek(0) content_lines[0] = content_lines[0].replace( @@ -282,6 +307,15 @@ return version_rpm +def _version_detect(args, files_local): + vdetect = VersionDetector(args['regex'], files_local, args["basename"]) + ver = vdetect.autodetect() + if DEBUG: + print("Found version '%s'" % ver) + + return ver + + if __name__ == '__main__': parser = argparse.ArgumentParser( @@ -299,20 +333,28 @@ parser.add_argument('--file', action='append', help='modify only this build description. ' 'maybe used multiple times.') + parser.add_argument('--debug', default=False, + help='Enable more verbose output.') + parser.add_argument('--regex', + help='regex to be used by autodetect') args = vars(parser.parse_args()) version = args['version'] - files_local = _get_local_files() - outdir = args['outdir'] if not outdir: print("no outdir specified") sys.exit(-1) + if args['debug']: + print("Running in debug mode") + DEBUG = True + + files_local = _get_local_files() + if not version: - version = VersionDetector._autodetect(files_local, args["basename"]) + version = _version_detect(args, files_local) if not version: print("unable to detect the version") @@ -355,7 +397,7 @@ for f in filter(lambda x: x.endswith(("debian.changelog")), files): filename = outdir + "/" + f shutil.copyfile(f, filename) - if "-" in VersionDetector._get_version_via_debian_changelog(filename): + if "-" in VersionDetector.get_version_via_debian_changelog(filename): _replace_debian_changelog_version(filename, version + "-0") else: _replace_debian_changelog_version(filename, version) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/set_version.service new/obs-service-set_version-0.5.8/set_version.service --- old/obs-service-set_version-0.5.7/set_version.service 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/set_version.service 2017-12-11 13:06:13.000000000 +0100 @@ -12,5 +12,9 @@ <parameter name="file"> <description>Update only the given file.</description> </parameter> + <parameter name="regex"> + <description>This regex can be used to autodetect the version from the source dir +inside the source file or the source file directly.</description> + </parameter> </service> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/tests/fixtures/broken-utf8.spec new/obs-service-set_version-0.5.8/tests/fixtures/broken-utf8.spec --- old/obs-service-set_version-0.5.7/tests/fixtures/broken-utf8.spec 1970-01-01 01:00:00.000000000 +0100 +++ new/obs-service-set_version-0.5.8/tests/fixtures/broken-utf8.spec 2017-12-11 13:06:13.000000000 +0100 @@ -0,0 +1,69 @@ +# +# spec file for package rawspeed +# +# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +Name: rawspeed +Version: 0 +Release: 0 +License: LGPL-2.1 +Summary: Fast raw decoding library +Url: https://github.com/darktable-org/rawspeed +Group: System/Libraries +Source: %{name}-%{version}.tar.xz +BuildRequires: cmake >= 3 +BuildRequires: gcc-c++ >= 4.9 +BuildRequires: libxml2-tools +BuildRequires: pkgconfig +BuildRequires: pugixml-devel +BuildRequires: libjpeg-devel +BuildRequires: zlib-devel +BuildRequires: googletest-source +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +RawSpeed… + +- is capable of decoding various images in RAW file format. +- is intended to provide the fastest decoding speed possible. +- supports the most common DSLR and similar class brands. +- supplies unmodified RAW data, optionally scaled to 16 bit, or normalized to 0->1 float point data. +- supplies CFA layout for all known cameras. +- provides automatic black level calculation for cameras having such information. +- optionally crops off “junk” areas of images, containing no valid image information. +- can add support for new cameras by adding definitions to an xml file. +- ~~is extensively crash-tested on broken files~~. +- decodes images from memory, not a file stream. You can use a memory mapped file, but it is rarely faster. +- open source under the LGPL v2 license. + +%prep +%setup -q + +%build +%cmake -DGOOGLETEST_PATH:PATH=%{_datadir}/googletest-source/ -DBUILD_SHARED_LIBS:BOOL=OFF +make %{?_smp_mflags} + +%check +%ctest + +%install +%cmake_install + +%files +%defattr(-,root,root) +%{_bindir}/rs-identify +%dir %{_datadir}/rawspeed/ +%{_datadir}/rawspeed/cameras.xml +%{_datadir}/rawspeed/showcameras.xsl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/tests/test_base.py new/obs-service-set_version-0.5.8/tests/test_base.py --- old/obs-service-set_version-0.5.7/tests/test_base.py 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/tests/test_base.py 2017-12-11 13:06:13.000000000 +0100 @@ -248,3 +248,20 @@ self.assertEqual(len(current_lines), len(expected_lines)) for nbr, l in enumerate(current_lines): self.assertEqual(l, expected_lines[nbr]) + + def test_autodetect_filename(self): + dname = os.path.join(self._tmpdir, "test-v1.2.3") + os.chdir(self._tmpdir) + os.mkdir(dname) + subprocess.call(['tar', '-cf', 'test-v1.2.3.tar', 'test-v1.2.3']) + files_local = ['test-v1.2.3.tar'] + + # checking dirname in archive detection + args = {'regex': '^test-v(.*)', 'basename': ''} + ver = sv._version_detect(args, files_local) + self.assertEqual(ver, '1.2.3') + + # checking archive filename detection + args = {'regex': '^test-v(.*).tar', 'basename': ''} + ver = sv._version_detect(args, files_local) + self.assertEqual(ver, '1.2.3') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/tests/test_python_pip2rpm.py new/obs-service-set_version-0.5.8/tests/test_python_pip2rpm.py --- old/obs-service-set_version-0.5.7/tests/test_python_pip2rpm.py 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/tests/test_python_pip2rpm.py 2017-12-11 13:06:13.000000000 +0100 @@ -65,13 +65,22 @@ class ZypperVersionCompare(VersionCompareBase): """ class to compare version strings with zypper""" - def __cmp__(self, other): + def _do_compare(self, other): # zypper's return val is negative if v1 is older than v2. # See 'man zypper' ret = subprocess.check_output("zypper --terse versioncmp %s %s" % ( self.version_str, other.version_str), shell=True) return int(ret) + def __lt__(self, other): + return self._do_compare(other) < 0 + + def __gt__(self, other): + return self._do_compare(other) > 0 + + def __eq__(self, other): + return (self._do_compare(other) == 0) + class DpkgVersionCompare(VersionCompareBase): def __do_compare(self, other, op): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-service-set_version-0.5.7/tests/test_rpmspec.py new/obs-service-set_version-0.5.8/tests/test_rpmspec.py --- old/obs-service-set_version-0.5.7/tests/test_rpmspec.py 2017-11-06 10:15:46.000000000 +0100 +++ new/obs-service-set_version-0.5.8/tests/test_rpmspec.py 2017-12-11 13:06:13.000000000 +0100 @@ -17,6 +17,7 @@ import os import imp +import shutil from ddt import data, ddt, file_data, unpack from test_base import SetVersionBaseTest @@ -56,7 +57,8 @@ def test_version_from_obsinfo(self): obsinfo = self._write_obsinfo("test.obsinfo", "0.0.1") files = [obsinfo] - ver = sv.VersionDetector._get_version_via_obsinfo(files, '') + vdetector = sv.VersionDetector(None, files, '') + ver = vdetector._get_version_via_obsinfo() self.assertEqual(ver, "0.0.1") @file_data("data_test_from_commandline.json") @@ -260,3 +262,11 @@ self.assertEqual(len(current_lines), len(expected_spec_lines)) for nbr, l in enumerate(current_lines): self.assertEqual(l, expected_spec_lines[nbr]) + + def test_broken_utf8_spec(self): + fn = os.path.join(os.path.dirname(__file__), 'fixtures', + 'broken-utf8.spec') + nfn = fn + "1" + shutil.copyfile(fn, nfn) + sv._replace_spec_setup(nfn, '0.0.1') + os.unlink(nfn)