Adding Progress Bars to cp and mv in Gutsy
Notice that I can do a -g for a progess bar! Yay! Now for an action shot:
hank@rofl:~/tmp/coreutils-6.7$ cp -g coreutils_6.7-1_i386.deb /nexus/mod0/www/deb/binary/
coreutils_6.7-1_i386.deb | 48% | 3.2 MiB | 118 KiB/s | ETA
The Easy Way
Hopefully coming soon…
The Hard Way
WARNING! PROCEED AT YOUR OWN RISK! THIS BROKE MY SYSTEM AND I WENT BACK TO THE DEFAULT COREUTILS PACKAGE
-
Get coreutils 6.7
-
Edit
patch/generic/001_all_coreutils-gen-progress-bar.patchwith vim:
:%s/coreutils\///g
-
Patch the tree with
patch -p0 < patch/generic/001_all_coreutils-gen-progress-bar.patch -
Run a magical loop:
# From http://ubuntuforums.org/showpost.php?p=3691686&postcount=2
for file in src/{copy,touch}.c lib/utimens.{c,h} ; do \
cp -v $file{,.orig}
sed 's/futimens/gl_&/' $file.orig > $file
done
./configure --prefix=/ && make && sudo checkinstall- Restart your terminal
Make sure you don’t completely hose your system and end up having to do this:
hank@rofl:~/tmp/coreutils-6.7/src$ sudo ./cp rm cp mv /bin/
Yes, that’s me using the cp binary from the current working directory to copy itself and some friends to /bin to resurrect my coreutils…
Also, I found out that there is a core package that externally manages the hostname command exclusively, and dpkg whines when you try to overwrite it with the awesome coreutils one. I don’t currently know how to make dpkg just do it’s job. Here’s the output:
hank@rofl:~/tmp/coreutils-6.7$ sudo dpkg -i coreutils_6.7-1_i386.deb
(Reading database ... 235274 files and directories currently installed.)
Preparing to replace coreutils 5.97-5.3ubuntu3 (using coreutils_6.7-1_i386.deb) ...
Unpacking replacement coreutils ...
dpkg: error processing coreutils_6.7-1_i386.deb (--install):
trying to overwrite `/bin/hostname', which is also in package hostname
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
coreutils_6.7-1_i386.deb
If I can get that small bug fixed, I can actually implement the Easy Way. I ended up conceeding to a dirty, dirty make install. I also found out that you need a Depends: entry in each deb package even if it just contains bash. Apt is apparently pretty stupid about parsing Package files from repositories.
The Result
hank@rofl:~$ mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY
or: mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-f, --force do not prompt before overwriting
-g, --progress show a progress bar if operation is going to
take a long time
# ...
Notice that I can do a -g for a progess bar! Yay! Now for an action shot:
hank@rofl:~/tmp/coreutils-6.7$ cp -g coreutils_6.7-1_i386.deb /nexus/mod0/www/deb/binary/
coreutils_6.7-1_i386.deb | 48% | 3.2 MiB | 118 KiB/s | ETA
And then I rebooted
I rebooted, and all hell broke loose. I couldn’t get permissions for various devices in /dev, etc. There must be some dependency on ubuntu or debian patches in the boot process. Yuck.


Anonymous
November 11, 2007 at 7:07 AM
You can use rsync as a replacement for cp and get the progress bar. Here’s how: http://geek00l.blogspot.com/2007/05/rsync-copy.html HTH
bishop
November 11, 2007 at 7:07 AM
yo,
You probably should have left the system cp, rm, and mv in place and put your new ones there as vcp vrm vmv (or something else) and setup aliases for the accounts (root & your user) to use those for the cp, rm, and mv commands. That way scripts and such that attempt to use those commands dont’ get extraneous output given to them when they do commands and such.
That might avoid the breaking of your system you experienced.