urxvt scrollback (and rebuilding SRPM’s)

urxvt (rxvt-unicode) is the terminal emulator I tend to use with X. Since I’m really used to be working with shells through the Windows program PuTTY, I try to get urxvt to resemble PuTTY as much as possible.

One thing that I recently noticed was that when running the clear command (or pressing Ctrl+L in a bash shell), everything that was previously showing on the screen got completely wiped, instead of just being pushed into the scrollback like it does with PuTTY (and KDE’s konsole actually, but I don’t want to use that one).

This was pretty annoying because I press Ctrl+L really often, and if I’d scroll up to check my history, it wasn’t all there. Confusing.

Apparently, I wasn’t alone thinking like this. But that wasn’t very useful.

I did however find some very useful posts over at the Arch Linux’s forums, which led me to a patch for urxvt created by jjacky (thanks!). Here’s a mirror.

I downloaded the urxvt source, patched and compiled it. It worked just like I wanted it to. Awesome.

So let’s rebuild the Fedora 17 rpm package for rxvt-unicode while we’re at it.

  1. Install common build environment packages.

    ~$ sudo yum groupinstall 'Development Tools'
    ~$ sudo yum install rpm-build

  2. Create an rpm build environment.

    ~$ mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
    ~$ echo '%_topdir %(echo $HOME)/rpm' > .rpmmacros

  3. Download the SRPM for rxvt-unicode from the currently activated yum repositores.

    ~$ yumdownloader --source rxvt-unicode

  4. Verify the SRPM (signature/hash and build dependencies).

    ~$ rpm -Vp -vv rxvt-unicode-9.15-1.fc17.src.rpm

  5. Install the build dependencies.

    ~$ sudo yum-builddep rxvt-unicode-9.15-1.fc17.src.rpm

  6. “Unpack” the SRPM into the previously created rpm directories.

    ~$ rpm -U rxvt-unicode-9.15-1.fc17.src.rpm

  7. List the unpacked files.

    ~$ cd rpm
    ~/rpm$ find . -type f
    ./SPECS/rxvt-unicode.spec
    ./SOURCES/rxvt-unicode-256color.desktop
    ./SOURCES/rxvt-unicode-scroll-modupdown.patch
    ./SOURCES/rxvt-unicode-ml.desktop
    ./SOURCES/rxvt-unicode.desktop
    ./SOURCES/rxvt-unicode-9.15.tar.bz2
    ./SOURCES/rxvt-unicode-256color-ml.desktop
    ./SOURCES/rxvt-unicode-tabbed-newterm.patch

  8. Download the patch.

    ~/rpm$ cd SOURCES
    ~/rpm/SOURCES$ wget -O rxvt-unicode-clear.patch http://entropux.net/stor/urxvt-scrollback-and-rebuilding-srpms/rxvt-unicode-clear.patch

  9. Make sure the downloaded file is a diff and that it has the right content etc.

    ~/rpm/SOURCES$ file rxvt-unicode-clear.patch
    rxvt-unicode-clear.patch: unified diff output, ASCII text
    ~/rpm/SOURCES$ cat rxvt-unicode-clear.patch

  10. Increase the release number (+add tag) in the spec file.

    ~/rpm/SOURCES$ cd ../SPECS/
    ~/rpm/SPECS$ grep ^Release rxvt-unicode.spec
    Release: 1%{?dist}
    ~/rpm/SPECS$ sed -i -r 's/^(Release:[^0-9]+)[0-9]+(.*$)/\12\2.entropux/' rxvt-unicode.spec
    ~/rpm/SPECS$ grep ^Release rxvt-unicode.spec
    Release: 2%{?dist}.entropux

  11. Add the patch to the spec file.

    ~rpm/SPECS$ grep ^Patch rxvt-unicode.spec
    Patch0: rxvt-unicode-scroll-modupdown.patch
    Patch1: rxvt-unicode-tabbed-newterm.patch
    ~rpm/SPECS$ sed -i '/^Patch1:/aPatch2:\t\trxvt-unicode-clear.patch' rxvt-unicode.spec
    ~rpm/SPECS$ grep ^Patch rxvt-unicode.spec
    Patch0: rxvt-unicode-scroll-modupdown.patch
    Patch1: rxvt-unicode-tabbed-newterm.patch
    Patch2: rxvt-unicode-clear.patch

  12. Also make sure the patch will be applied.

    ~/rpm/SPECS$ grep ^%patch rxvt-unicode.spec
    %patch0 -p1 -b .scroll-modupdown
    %patch1 -p1 -b .tabbed-newterm
    ~/rpm/SPECS$ sed -i '/^%patch1 /a%patch2 -p1 -b .clear' rxvt-unicode.spec
    ~/rpm/SPECS$ grep ^%patch rxvt-unicode.spec
    %patch0 -p1 -b .scroll-modupdown
    %patch1 -p1 -b .tabbed-newterm
    %patch2 -p1 -b .clear

  13. Build a new SRPM.

    ~/rpm/SPECS$ rpmbuild -bs rxvt-unicode.spec
    Wrote: /rw/home/user/rpm/SRPMS/rxvt-unicode-9.15-2.fc17.entropux.src.rpm

  14. Build a new RPM based on the SRPM (actually, this could’ve been accomplished by using the -ba argument instead of -bs in the previous step).

    ~/rpm/SPECS$ cd ../SRPMS/
    ~/rpm/SRPMS$ rpmbuild --rebuild rxvt-unicode-9.15-2.fc17.entropux.src.rpm

  15. Find out which packages that have been built.

    ~/rpm/SRPMS$ cd ../RPMS/x86_64/
    ~/rpm/RPMS/x86_64$ ls -1
    rxvt-unicode-256color-9.15-2.fc17.entropux.x86_64.rpm
    rxvt-unicode-256color-ml-9.15-2.fc17.entropux.x86_64.rpm
    rxvt-unicode-9.15-2.fc17.entropux.x86_64.rpm
    rxvt-unicode-debuginfo-9.15-2.fc17.entropux.x86_64.rpm
    rxvt-unicode-ml-9.15-2.fc17.entropux.x86_64.rpm

  16. Install and replace the currently installed package.

    $ sudo rpm -Uvh rxvt-unicode-9.15-2.fc17.entropux.x86_64.rpm
    Preparing... ########################################### [100%]
    1:rxvt-unicode ########################################### [100%]

Was it successful? Is urxvt’s scrollback working like expected? Yup.

UPDATE: 2013-04-02
Fedora updated the package to version 9.16 of urxvt and unfortunately the new package was installed in my system and I lost the properly working scrollback. The procedure described in this article works flawlessly with the new SRPM as well (rxvt-unicode-9.16-1.fc17.src.rpm). Adding urxvt to the exclusion list in /etc/yum.conf might be wise to prohibit the urxvt package from being updated in the future.

With Qubes you could update your Fedora template like this:

~# grep rxvt-unicode /etc/yum.conf
~# sed -i -r 's/^(exclude[[:space:]]*=.*$)/\1, rxvt-unicode-*/' /etc/yum.conf
~# grep rxvt-unicode /etc/yum.conf
exclude = *.i386, *.i486, *.i586, *.i686, kernel, xorg-x11-drv-*, xorg-x11-drivers, xorg-x11-server-*, rxvt-unicode-*
# yum install rxvt-unicode
Loaded plugins: langpacks, post-transaction-actions, presto, refresh-packagekit, yum-qubes-hooks
Nothing to do

Leave a Reply

Your email address will not be published. Required fields are marked *