[Yum] Patch for progress status
Najib Ninaba
najib at scs.com.sg
Wed Aug 28 09:07:42 UTC 2002
Hello Seth and list,
I've added a quick patch (a hack really) to show the transfer progress.
The yum code already has the progress hook in the clientStuff.py so I
mainly use that as a base.
It applies to the current stable version 0.9.2 and I've included an
updated yum spec file too.
Please use it at your own risk. I am not responsible for any damage done
directly or indirectly by this patch. It works well enough for me. That
being said, I don't mind comments or suggestions.
Regards,
--
Najib Ninaba
---
http://www.remorseful.org/
PGP fingerprint
3BA1 3A8C BA85 6CD8 9BD2 E0E2 6B7E 4151 C473 90A7
--
-------------- next part --------------
diff -urN yum-0.9.2-orig/clientStuff.py yum-0.9.2/clientStuff.py
--- yum-0.9.2-orig/clientStuff.py Tue Aug 27 11:45:31 2002
+++ yum-0.9.2/clientStuff.py Wed Aug 28 16:43:45 2002
@@ -248,6 +248,16 @@
if curbytes == total:
print ' '
+def transferprogresshook(blocks, blocksize, total):
+ curbytes=blocks*blocksize
+ # this little hack will show the total bytes when the file has
+ # finished transferring
+ if curbytes > total:
+ sys.stdout.write('\rProgress: %s/%s\r' % (descfsize(total), descfsize(total)))
+ else:
+ sys.stdout.write('\rProgress: %s/%s' % (descfsize(curbytes), descfsize(total)))
+ sys.stdout.flush()
+ sys.stdout.write('\r' + ' ' * 80)
def urlgrab(url, filename=None, nohook=None):
import urllib, rfc822, urlparse
@@ -257,7 +267,7 @@
if filename == None:
filename = os.path.basename(path)
try:
- (fh, hdr) = urllib.urlretrieve(url, filename)
+ (fh, hdr) = urllib.urlretrieve(url, filename,transferprogresshook)
except IOError, e:
errorlog(0, 'IOError: %s' % (e))
errorlog(0, 'URL: %s' % (url))
-------------- next part --------------
Summary: RPM installer/updater
Name: yum
Version: 0.9.2
Release: 2
License: GPL
Group: System Environment/Base
Source: %{name}-%{version}.tar.gz
Patch: transferprogress.patch
URL: http://www.dulug.duke.edu/yum/
BuildRoot: %{_tmppath}/%{name}-%{version}root
BuildArchitectures: noarch
BuildRequires: rpm-python python >= 1.5.2
Requires: rpm-python >= 4.0.4 perl python >= 1.5.2 rpm >= 4.0.4
Prereq: /sbin/chkconfig, /sbin/service
%description
Yum is a utility that can check for and automatically download and
install updated RPM packages. Dependencies are obtained and downloaded
automatically prompting the user as necessary.
%prep
%setup -q
%patch0 -p1
%build
%configure
make
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT/%{_sbindir}
cd $RPM_BUILD_ROOT/%{_sbindir}
ln -s ../bin/yum .
ln -s ../bin/yum-arch .
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%post
/sbin/chkconfig --add yum
/sbin/chkconfig yum on
/sbin/service yum condrestart >> /dev/null
exit 0
%preun
if [ $1 = 0 ]; then
/sbin/chkconfig --del yum
/sbin/service yum stop >> /dev/null
fi
exit 0
%files
%defattr(-, root, root)
%doc README AUTHORS COPYING TODO INSTALL
%config(noreplace) %{_sysconfdir}/yum.conf
%config %{_sysconfdir}/cron.daily/yum.cron
%config %{_sysconfdir}/init.d/%{name}
%config %{_sysconfdir}/logrotate.d/%{name}
%{_libdir}/yum/*
%{_sbindir}/yum
%{_sbindir}/yum-arch
%{_bindir}/yum
%{_bindir}/yum-arch
/var/cache/yum
%{_mandir}/man*/*
%changelog
* Wed Aug 28 2002 Najib Ninaba <najib at remorseful.org>
- added patch to show the file transfer progress
* Mon Aug 26 2002 Seth Vidal <skvidal at phy.duke.edu>
- bumped ver to 0.9.2
* Thu Jul 11 2002 Seth Vidal <skvidal at phy.duke.edu>
- bumped ver to 0.9.1
* Thu Jul 11 2002 Seth Vidal <skvidal at phy.duke.edu>
- bumped ver to 0.9.0
* Thu Jul 11 2002 Seth Vidal <skvidal at phy.duke.edu>
- added rpm require
* Sun Jun 30 2002 Seth Vidal <skvidal at phy.duke.edu>
- 0.8.9
* Fri Jun 14 2002 Seth Vidal <skvidal at phy.duke.edu>
- 0.8.7
* Thu Jun 13 2002 Seth Vidal <skvidal at phy.duke.edu>
- bumped to 0.8.5
* Thu Jun 13 2002 Seth Vidal <skvidal at phy.duke.edu>
- bumped to 0.8.4
* Sun Jun 9 2002 Seth Vidal <skvidal at phy.duke.edu>
- bumped to 0.8.2
* Thu Jun 6 2002 Seth Vidal <skvidal at phy.duke.edu>
- First packaging
More information about the Yum
mailing list