#11 Import C9S changes
Merged a year ago by ngompa. Opened a year ago by yselkowitz.
rpms/ yselkowitz/rpmdevtools rawhide  into  rawhide

file added
+133
@@ -0,0 +1,133 @@ 

+ #!/usr/bin/python3

+ # -*- coding: utf-8 -*-

+ #

+ # A simple text-based progress bar, compatible with the basic API of:

+ # https://github.com/WoLpH/python-progressbar

+ #

+ # Copyright (C) 2021  Red Hat, Inc.

+ # 

+ # This program is free software; you can redistribute it and/or

+ # modify it under the terms of the GNU General Public License

+ # as published by the Free Software Foundation; either version 2

+ # of the License, or (at your option) any later version.

+ # 

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU General Public License for more details.

+ # 

+ # You should have received a copy of the GNU General Public License

+ # along with this program; if not, write to the Free Software

+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,

+ # USA.

+ 

+ 

+ import shutil

+ import sys

+ import time

+ 

+ 

+ class ProgressBar:

+     FORMAT = '{value:>10} / {max_value:<10} [{bars}]'

+     BARS = '= '

+     SPINLEN = 5

+ 

+     def __init__(self, stream=sys.stderr, max_width=80, fps=10):

+         self._stream = stream

+         self._max_width = max_width

+         self._min_delay = 1 / fps

+ 

+     @staticmethod

+     def _format_value(value):

+         raise NotImplementedError()

+ 

+     def start(self, max_value):

+         self._value = 0

+         self._max_value = max_value or 0

+         self._status = dict()

+         self._spinner = 0

+         self._timestamp = 0

+         self.update(0)

+ 

+     def update(self, value):

+         self._value = value

+         if value > self._max_value:

+             self._max_value = 0

+ 

+         ts = time.time()

+         if (ts - self._timestamp) < self._min_delay:

+             return

+         self._timestamp = ts

+ 

+         status = {'value': self._format_value(value),

+                   'max_value': self._format_value(self._max_value) \

+                                if self._max_value else '???',

+                   'bars': ''}

+ 

+         termw = min(shutil.get_terminal_size()[0], self._max_width)

+         nbars = max(termw - len(self.FORMAT.format(**status)), 0)

+         nfill = nskip = 0

+ 

+         if self._max_value:

+             nfill = round(nbars * value / self._max_value)

+         elif nbars > self.SPINLEN:

+             nfill = self.SPINLEN

+             nskip = self._spinner % (nbars - self.SPINLEN)

+             self._spinner = nskip + 1

+ 

+         status['bars'] = self.BARS[1] * nskip + \

+                          self.BARS[0] * nfill + \

+                          self.BARS[1] * (nbars - nfill - nskip)

+ 

+         if status == self._status:

+             return

+         self._status = status

+ 

+         self._stream.write('\r')

+         self._stream.write(self.FORMAT.format(**self._status))

+         self._stream.flush()

+ 

+     def finish(self):

+         self._max_value = self._value

+         self._timestamp = 0  # Force an update

+         self.update(self._value)

+ 

+         self._stream.write('\n')

+         self._stream.flush()

+ 

+ 

+ class DataTransferBar(ProgressBar):

+     @staticmethod

+     def _format_value(value):

+         symbols = ' KMGTPEZY'

+         depth = 0

+         max_depth = len(symbols) - 1

+         unit = 1024.0

+ 

+         # 1023.95 should be formatted as 1.0 (not 1024.0)

+         # More info: https://stackoverflow.com/a/63839503

+         thres = unit - 0.05

+ 

+         while value >= thres and depth < max_depth:

+             depth += 1

+             value /= unit

+         symbol = ' %siB' % symbols[depth] if depth > 0 else ''

+ 

+         return '%.1f%s' % (value, symbol)

+ 

+ 

+ if __name__ == '__main__':

+     # Show a dummy bar for debugging purposes

+ 

+     bar = DataTransferBar()

+     size = 50*1024*1024

+     chunk = 1024*1234

+     recvd = 0

+ 

+     bar.start(size)

+     while recvd < (size - chunk):

+         recvd += chunk

+         bar.update(recvd)

+         time.sleep(0.1)

+     bar.update(size)

+     bar.finish()

@@ -0,0 +1,21 @@ 

+ diff -up rpmdevtools-9.5/Makefile.am.orig rpmdevtools-9.5/Makefile.am

+ --- rpmdevtools-9.5/Makefile.am.orig	2021-12-10 11:37:29.889405680 +0100

+ +++ rpmdevtools-9.5/Makefile.am	2021-12-10 11:37:34.637495820 +0100

+ @@ -1,4 +1,4 @@

+ -SUBDIRS = emacs qa-robot

+ +SUBDIRS = emacs

+  

+  pkgsysconfdir = $(sysconfdir)/rpmdevtools

+  bashcompdir = @bashcompdir@

+ diff -up rpmdevtools-9.5/Makefile.in.orig rpmdevtools-9.5/Makefile.in

+ --- rpmdevtools-9.5/Makefile.in.orig	2021-12-10 11:37:31.073428158 +0100

+ +++ rpmdevtools-9.5/Makefile.in	2021-12-10 11:37:38.304565439 +0100

+ @@ -317,7 +317,7 @@ target_alias = @target_alias@

+  top_build_prefix = @top_build_prefix@

+  top_builddir = @top_builddir@

+  top_srcdir = @top_srcdir@

+ -SUBDIRS = emacs qa-robot

+ +SUBDIRS = emacs

+  pkgsysconfdir = $(sysconfdir)/rpmdevtools

+  bin_SCRIPTS = rpmdev-newinit rpmdev-newspec rpmdev-rmdevelrpms

+  dist_bin_SCRIPTS = rpmdev-checksig rpmdev-diff rpmdev-extract rpmdev-md5 \

file modified
+30 -17
@@ -7,11 +7,16 @@ 

  License:        GPLv2+ and GPLv2

  URL:            https://pagure.io/rpmdevtools

  Source0:        https://releases.pagure.org/rpmdevtools/%{name}-%{version}.tar.xz

+ Source1:        progressbar.py

  

  # Fedora-specific downstream patches

  ## Force legacy datestamp by default until rhbz#1715412 is resolved

  Patch1001:      0001-Force-legacy-datestamp-while-RHBZ-1715412-is-still-a.patch

  

+ # RHEL-specific downstream patches

+ ## Remove fakeroot dependency (rhbz#1905465)

+ Patch2001:      rpmdevtools-9.5-no_qa_robot.patch

+ 

  BuildArch:      noarch

  # help2man, pod2man, *python for creating man pages

  BuildRequires:  make
@@ -21,38 +26,37 @@ 

  # python dependencies for spectool

  # spectool is executed for creating man page

  BuildRequires:  python3-devel

+ %if ! 0%{?rhel}

  BuildRequires:  python3dist(progressbar2)

+ %endif

  BuildRequires:  python3dist(requests)

  BuildRequires:  python3dist(rpm)

  # emacs-common >= 1:22.3-3 for macros.emacs

  BuildRequires:  emacs-common >= 1:22.3-3

  BuildRequires:  bash-completion

- %if 0%{?fedora} && 0%{?fedora} < 36

- # xemacs-common >= 21.5.29-8 for macros.xemacs

- BuildRequires:  xemacs-common >= 21.5.29-8

- %endif

  Requires:       curl

  Requires:       diffutils

+ %if ! 0%{?rhel}

  Requires:       fakeroot

+ %endif

  Requires:       file

  Requires:       findutils

  Requires:       gawk

  Requires:       grep

  Requires:       rpm-build >= 4.4.2.3

  Requires:       python3dist(argcomplete)

+ %if ! 0%{?rhel}

  Requires:       python3dist(progressbar2)

+ %endif

  Requires:       python3dist(requests)

  Requires:       python3dist(rpm)

  Requires:       sed

  Requires:       emacs-filesystem

- %if 0%{?fedora} && 0%{?fedora} < 36

- Requires:       xemacs-filesystem

- %endif

  # Optionally support rpmautospec

  Recommends:     python%{python3_version}dist(rpmautospec)

  

  %description

- This package contains scripts and (X)Emacs support files to aid in

+ This package contains scripts and Emacs support files to aid in

  development of RPM packages.

  rpmdev-setuptree    Create RPM build tree within user's home directory

  rpmdev-diff         Diff contents of two archives
@@ -70,10 +74,22 @@ 

  

  

  %prep

- %autosetup -p1

+ %autosetup -N

+ %autopatch -p1 %{!?rhel:-M2000}

  grep -lF "%{_bindir}/python " * \

  | xargs sed -i -e "s|%{_bindir}/python |%{_bindir}/python3 |"

  

+ %if 0%{?rhel}

+ # Let spectool find the bundled progressbar2 implementation

+ cp %{SOURCE1} .

+ sed -i \

+ 's|^\(import progressbar\)$|'\

+ 'import sys\n'\

+ 'sys.path.insert(1, "%{_datadir}/rpmdevtools")\n'\

+ '\1\nsys.path.pop(1)|' \

+ rpmdev-spectool

+ %endif

+ 

  

  %build

  %configure --libdir=%{_prefix}/lib
@@ -87,11 +103,7 @@ 

  [ -d %{buildroot}%{_sysconfdir}/bash_completion.d ] && \

  echo %%{_sysconfdir}/bash_completion.d > %{name}.files

  

- %if 0%{?fedora} && 0%{?fedora} < 36

- for dir in %{_emacs_sitestartdir} %{_xemacs_sitestartdir} ; do

- %else

  for dir in %{_emacs_sitestartdir} ; do

- %endif

    install -dm 755 %{buildroot}$dir

    ln -s %{_datadir}/rpmdevtools/rpmdev-init.el %{buildroot}$dir

    touch %{buildroot}$dir/rpmdev-init.elc
@@ -101,6 +113,11 @@ 

  ln -sr %{buildroot}%{_bindir}/rpmdev-spectool %{buildroot}%{_bindir}/spectool

  echo ".so man1/rpmdev-spectool.1" > %{buildroot}%{_mandir}/man1/spectool.1

  

+ %if 0%{?rhel}

+ cp %{SOURCE1} %{buildroot}%{_datadir}/rpmdevtools/

+ %py_byte_compile %{python3} %{buildroot}%{_datadir}/rpmdevtools/

+ %endif

+ 

  

  %files -f %{name}.files

  %license COPYING
@@ -110,10 +127,6 @@ 

  %{_bindir}/*

  %{_emacs_sitestartdir}/rpmdev-init.el

  %ghost %{_emacs_sitestartdir}/rpmdev-init.elc

- %if 0%{?fedora} && 0%{?fedora} < 36

- %{_xemacs_sitestartdir}/rpmdev-init.el

- %ghost %{_xemacs_sitestartdir}/rpmdev-init.elc

- %endif

  %{_mandir}/man[18]/*.[18]*

  

  

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/837581d444c74de2b2fb72126486126a

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/c92f2400835f4abca0dff9e1fa680221

Why are we filtering out progressbar2 in RHEL?

Why are we filtering out progressbar2 in RHEL?

See https://bugzilla.redhat.com/show_bug.cgi?id=1927784

This bug is restricted, I cannot see it.

In short, it has a bunch of unwanted dependencies, namely python-freezegun, python-utils, python-pytest-asyncio, and more.

Pull-Request has been merged by ngompa

a year ago