XOrg server modularized packages – Thank you Ubuntu

I really like that Ubuntu is splitting out xserver modules into separate packages coming in the breezy release. I was hoping I’d save a bit more disk space, but 37.5MB helps.

I remember looking at absolutely minimal distribution installations with Mandrake 9.2. I was able to run with 92MB with urpmi installed, and ~45MB without urpmi. Of course, I don’t really consider a distribution usable without good package management. I find myself cursing far too often, and feeling like I’m using Solaris or AIX.

jrwren@utonium:~ $ sudo `dpkg –get-selections xserver-xorg* | grep driver | grep -v — “-nv” | cut -f1 | xargs echo apt-get remove`
Reading package lists… Done
Building dependency tree… Done
The following packages will be REMOVED:
x-window-system-core xorg-driver-synaptics xserver-xorg
xserver-xorg-driver-apm xserver-xorg-driver-ark xserver-xorg-driver-ati
xserver-xorg-driver-chips xserver-xorg-driver-cirrus
xserver-xorg-driver-cyrix xserver-xorg-driver-dummy
xserver-xorg-driver-fbdev xserver-xorg-driver-glide
xserver-xorg-driver-glint xserver-xorg-driver-i128 xserver-xorg-driver-i740
xserver-xorg-driver-i810 xserver-xorg-driver-imstt xserver-xorg-driver-mga
xserver-xorg-driver-neomagic xserver-xorg-driver-newport
xserver-xorg-driver-nsc xserver-xorg-driver-rendition xserver-xorg-driver-s3
xserver-xorg-driver-s3virge xserver-xorg-driver-savage
xserver-xorg-driver-siliconmotion xserver-xorg-driver-sis
xserver-xorg-driver-tdfx xserver-xorg-driver-tga xserver-xorg-driver-trident
xserver-xorg-driver-tseng xserver-xorg-driver-v4l xserver-xorg-driver-vesa
xserver-xorg-driver-vga xserver-xorg-driver-via xserver-xorg-driver-vmware
0 upgraded, 0 newly installed, 36 to remove and 2 not upgraded.
Need to get 0B of archives.
After unpacking 32.3MB disk space will be freed.
Do you want to continue [Y/n]?

(apt-listchanges:14229): Gdk-WARNING **: locale not supported by Xlib

(apt-listchanges:14229): Gdk-WARNING **: cannot set locale modifiers
(Reading database … 132080 files and directories currently installed.)
Removing x-window-system-core …
Removing xorg-driver-synaptics …
Removing xserver-xorg …
xserver-xorg prerm warning: X server provided by xserver-xorg package is
being removed; setting /etc/X11/X to point to /bin/true
Removing xserver-xorg-driver-apm …
Removing xserver-xorg-driver-ark …
Removing xserver-xorg-driver-ati …
Removing xserver-xorg-driver-chips …
Removing xserver-xorg-driver-cirrus …
Removing xserver-xorg-driver-cyrix …
Removing xserver-xorg-driver-dummy …
Removing xserver-xorg-driver-fbdev …
Removing xserver-xorg-driver-glide …
Removing xserver-xorg-driver-glint …
Removing xserver-xorg-driver-i128 …
Removing xserver-xorg-driver-i740 …
Removing xserver-xorg-driver-i810 …
Removing xserver-xorg-driver-imstt …
Removing xserver-xorg-driver-mga …
Removing xserver-xorg-driver-neomagic …
Removing xserver-xorg-driver-newport …
Removing xserver-xorg-driver-nsc …
Removing xserver-xorg-driver-rendition …
Removing xserver-xorg-driver-s3 …
Removing xserver-xorg-driver-s3virge …
Removing xserver-xorg-driver-savage …
Removing xserver-xorg-driver-siliconmotion …
Removing xserver-xorg-driver-sis …
Removing xserver-xorg-driver-tdfx …
Removing xserver-xorg-driver-tga …
Removing xserver-xorg-driver-trident …
Removing xserver-xorg-driver-tseng …
Removing xserver-xorg-driver-v4l …
Removing xserver-xorg-driver-vesa …
Removing xserver-xorg-driver-vga …
Removing xserver-xorg-driver-via …
Removing xserver-xorg-driver-vmware …
jrwren@utonium:~ $ sudo `dpkg –get-selections xserver-xorg* | grep input | grep -v — “-mouse” | cut -f1 | xargs echo apt-get remove`
Reading package lists… Done
Building dependency tree… Done
The following packages will be REMOVED:
xserver-xorg-input-acecad xserver-xorg-input-aiptek
xserver-xorg-input-calcomp xserver-xorg-input-citron
xserver-xorg-input-digitaledge xserver-xorg-input-dmc
xserver-xorg-input-dynapro xserver-xorg-input-elographics
xserver-xorg-input-fpit xserver-xorg-input-hyperpen xserver-xorg-input-kbd
xserver-xorg-input-magellan xserver-xorg-input-microtouch
xserver-xorg-input-mutouch xserver-xorg-input-palmax
xserver-xorg-input-penmount xserver-xorg-input-spaceorb
xserver-xorg-input-summa xserver-xorg-input-tek4957 xserver-xorg-input-void
xserver-xorg-input-wacom
0 upgraded, 0 newly installed, 21 to remove and 2 not upgraded.
Need to get 0B of archives.
After unpacking 5226kB disk space will be freed.
Do you want to continue [Y/n]?

(apt-listchanges:14908): Gdk-WARNING **: locale not supported by Xlib

(apt-listchanges:14908): Gdk-WARNING **: cannot set locale modifiers
(Reading database … 131839 files and directories currently installed.)
Removing xserver-xorg-input-acecad …
Removing xserver-xorg-input-aiptek …
Removing xserver-xorg-input-calcomp …
Removing xserver-xorg-input-citron …
Removing xserver-xorg-input-digitaledge …
Removing xserver-xorg-input-dmc …
Removing xserver-xorg-input-dynapro …
Removing xserver-xorg-input-elographics …
Removing xserver-xorg-input-fpit …
Removing xserver-xorg-input-hyperpen …
Removing xserver-xorg-input-kbd …
Removing xserver-xorg-input-magellan …
Removing xserver-xorg-input-microtouch …
Removing xserver-xorg-input-mutouch …
Removing xserver-xorg-input-palmax …
Removing xserver-xorg-input-penmount …
Removing xserver-xorg-input-spaceorb …
Removing xserver-xorg-input-summa …
Removing xserver-xorg-input-tek4957 …
Removing xserver-xorg-input-void …
Removing xserver-xorg-input-wacom …

Ooops… had better put back that input-kbd package if I want to be able to type!

StreamReader.Peek can block!

Yes, I said it! Even though the entire point of Peek is to be non-blocking, there is a certain case under which Peek will block. Of course I am talking about the .NET Framework, and I am using version 1.1 from Microsoft. I should really try this same situation under Mono.

What lead me to make this statement so boldly is taking a look at the Rotor source code. Now I realize that Rotor is not what MS uses, but I figured it is good enough to give me some insight.

It turns out that if the stream is empty, that is, it is never streamed anything (haha, that sounds funny), then the Peek function will block. It is obvious from the Rotor source when looking at the implementation of Peek. A stream starts off in a non-blocked status. The charPos and charLen are both zero. They correspond to how much of the stream has been read by the SteamReader consumer, and how much has been buffered by the StreamReader itself. These start off equal, so the implementation of Peek calls a Read. Of course there is nothing to read, so the Read function blocks. This results in Peek being equivalent to a Read on the first (or zeroth? if nothing is ever read) byte read in terms of blocking.

How did I run into this? Well, I’m reading from StandardOutput and StandardError as created by a System.Diagnostics.Process. If a command runs successfully, it usually doesn’t output anything on stderr. The catch is that stderr cannot be ignored. If there is data to read on stderr, it will block stdout, and visa versa, so both streams must be read. What is worse is that if you start reading both streams, stderr blocks immediately. The solution??? Spawn threads to read each, and abort the thread which is blocked on the read from stderr.

If anyone has a better solution, I could really use it. Right now I’m limited to using a time out to trigger the abort on my threads. I’d rather have something which ends sooner.

RE: Neat nuggets of .NET – The Conditional attribute

I wish I had known about this a while ago… I knew it was possible, I just l ways thought it would look more like traditional C/C++ w/ #ifdefs

Ever wanted different behavior between DEBUG and RELEASE builds?  But without having to fork your code or have to result to preprocessor directives?  Well let me introduce you to the Conditional attribute.

The Conditional attribute is simple: the method isn’t executed unless a particular string is defined at compile time.  Let’s look at an example:

using System.Diagnostics;

[

Conditional(“DEBUG”)]
static private void method1()
{
   
Console.WriteLine(“This only works in DEBUG mode.”);
}

[Conditional(“custom”)]
static private void method2()
{
   Console.WriteLine(“This only works when ‘custom’ is defined”);
}

By default Visual Studio defines “DEBUG” for debug builds, so method1 would work.  But method2 would be replaced with a noop unless “custom” was defined during the build process.  (You can add your custom symbols on the Build application designer page.)

This way you can change program behavior with a simple build flag, which can be extremely useful in certain situations. 

[Via Chris Smith’s completely unique view]