Jun 24 2008

Daniel Burrows on cwidget-gtk

Category: Summer of Code, Uncategorized, debianObey Arthur Liu @ 5:28 am

Sometimes people propose other solutions to have the Aptitude-gtk project done, like :

I’d have thought that the most interesting way of doing aptitude-gtk would be to write a gtk backend for libcwidget. -Karellen

As this might be of interest to more people, I’ll repost Daniel Burrows‘ response :

Although I can see where you’re coming from, a GTK+ backend to cwidget would have no significant upsides and significant downsides.

The main upside to doing that from a practical point of view is that you would have only one piece of “driver” code for the GTK+ and curses interfaces. You wouldn’t have to rewrite the entire interface from scratch to create a GUI frontend.

But this is just an illusory benefit. cwidget is a terminal interface library and aptitude’s curses frontend is a terminal-based UI. From a practical point of view, this means that aptitude regularly assumes that, for instance, to clear out a line it’s sufficient to output $WIDTH space characters (ASCII 32) with the desired background style. A port of cwidget to GTK+ would have to introduce new, interface-independent abstractions for all operations like this and eliminate all direct use of terminal-based assumptions, at a significant cost in complexity for both cwidget and the aptitude frontend. In order to transition to these new conventions, I believe you would have to rewrite large portions of both cwidget *and* aptitude in order to make the interface abstraction layer work. (remember: the justification for doing this is to avoid having to rewrite aptitude!)

Furthermore, while this approach avoids reimplementing aptitude’s curses interface (sort of, except where it doesn’t — see above), it does so at the cost of requiring you to reimplement all of cwidget, for GTK+. I just did a quick line count (with “wc -l”): in all of cwidget there are 23,390 lines of code, while aptitude’s curses frontend has around 23,359 lines of code (some of which are actually shared with the other frontends but are in the curses directory due to the historical organization of the code tree). Not only is a rewrite of cwidget more involved, but the amount of code you’d have to replace is comparable to the amount implicated in a rewrite of aptitude itself!

Finally, even if these costs weren’t enough to eliminate the idea, it’s not at all clear to me that a GTK+ backend for cwidget is even desirable. Although aptitude has some superficial similarities to a GUI program, the process of designing an interface to run in a terminal (where the available input mechanisms are relatively restricted and all output is to a character-cell grid) is rather different from the process of designing a GUI. GUI programs can’t rely on some simplifying assumptions that terminal programs can, and at the same time they have a lot more options available to them (just to name a few: graphics, multiple windows, differing text sizes and rotated text). Trying to force everything through an abstraction designed for terminal output would require you to either

  1. eschew those options,
  2. provide abstract GUI components that somehow “fell back” to terminal rendering in a terminal, or
  3. add ways for the frontend to extend the abstract widgets with custom functionality.

1. is not an option because I (and, I think, Arthur) want to design a good GTK+ package manager, not a good GTK+ imitation of a console package manager. 2. and 3. amount, in my strong opinion, to writing two separate interfaces but intertwining their implementations in a mass of maintenance-resistant and extension-resistant spaghetti code.

At the end of the day, I think that having two separate frontends (sharing backend logic where appropriate, of course) is a far cleaner and more maintainable design, and also easier to create.

As I said earlier, I intend to go a little farther than just making a GTK+ “skin” over the curses interface. Think less like gvim and emacs and more like maybe ddd.

I should also add that the cwidget library is used by no major programs except Aptitude so few others would benefit from a GTK+ backend. As the cwidget library homepage says:

cwidget was originally an internal user interface library for the aptitude package manager. This means, on the one hand, that cwidget is known to work in the real world for a real application; on the other hand, it means that the feature set of cwidget is coextensive with the requirements of aptitude.


Jun 21 2008

State of the Aptitude

Category: Summer of Code, debianObey Arthur Liu @ 9:01 pm

I promised to post some updates about how the Aptitude project would be going so here it is.

Here’s what aptitude-gtk currently looks like :

Aptitude-gtk (20080621)

Well, nothing very special right now. It’s really only a testing interface. The final GUI will probably be different. Now you may be interested by what’s going on behind it ?

Where to start ?

Aptitude is written in C++ with varying dosages of OO coding depending on the age of the code :) .

For the most part, the code is neat, clean and easy to understand. Sometimes, it’s overengineered: the code that implements the progress status of packages downloads and actions is exhaustive enough to cover the setup phases of a hydraulic dam, although sometimes you can still see progress bars mysteriously going backwards. Sometimes, Daniel Burrows will be happy to provide you with complimentary barf bags while explaining some ungodly oddities that have existed for years because it’s easier to remember the ritual dances to do than to make stuff behave logically.

Currently Aptitude-gtk is able to execute the libapt-pkg initialization phase, load up repository lists and update lists (think “aptitude update”). The next big task will be to load up the installed packages list and display it. It involves quite a lot of code because of all the things that connect to it : incremental package searches, sorts, filters and so on.

It’s been very interesting so far.

By the way, the minesweeper feature is already implemented, courtesy of gnomine :)


Jun 11 2008

debian.org domainsquatted ? (1)

Category: debianObey Arthur Liu @ 4:56 pm

debian.org domain squatted

I was like “wtf?!”. Debian.org replaced by a link farm ?

debian.org being actually domainsquatted is highly unlikely, so I started searching how this could happen.

First, a little explanation of the setup :

  • I’m on a bullet train on my laptop, up-to-date Debian Lenny, 2.6.24
  • My laptop is connected to a 3G+ (HSDPA in the US) PDA phone with a USB cable
  • The phone appears to the computer as a network interface thanks to the usb-rndis-lite kernel module
  • The phone does NAT routing between my computer (192.168.0.100), himself (192.168.0.1) and a restricted network from my phone operator
  • The only host visible on this restricted network is a HTTP only proxy server that checks the user agent (Nokia is OK, Firefox means GO AWAY)
  • I connect through this proxy to a dedicated host through a OpenVPN tunnel masquerading as HTTP with a Nokia user agent
  • The dedicated host at the other side has special iptables rules to redirect requests coming from my mobile phone operator netblock on port 80 to the regular OpenVPN port.
  • The dedicated host does NAT for my computer to the real Internet.
  • The total latency varies from 120ms to 30 secs and the bandwidth from 2mbps to 8kbps depending on the coverage
  • The only DNS server on my laptop is set in resolv.conf to 192.168.5.1, the remote OpenVPN endpoint, the dedicated server
  • The dedicated server runs Bind and provides recursive resolution

Now there are some peculiarities to the situation :

  • It happens exactely once a week on the train from my home in Paris to the campus in Grenoble
  • It doesn’t happen the other way around or at any other time for that matter

Some hints :

  • My hostname at home is aeris.home.eu
  • My hostname on campus is aeris.liuo.res.rhb
  • I almost never shut down my computer, only hibernate
  • Jonathan Roes

Now for the challenge : how could this happen ?


Jun 06 2008

Coding somewhere (1)

Category: Summer of Code, debianObey Arthur Liu @ 8:53 pm

crw_28361

Coding and posting on a bullet train, while reading documentation on the net through a 3G wireless connection.

On the laptop is a proof of concept Aptitude GTK+ demonstration.