Automatically set terminal title in X
I’ve been using the Mercurial Shell Prompt hack for a while until I got annoyed at it. It caused a Python interpeter to start at every prompt, which is expansize especially if your system is already under strain.
This new shell hack is a lot faster much more generic. This small snippet is used to dynamically set the title of the terminal window in the following situation:
- if the terminal is at the prompt, set the title of the window to the name of the current directory
- if a program is running, set the title of the window to the name of the running program
The code is pretty straightforward. It uses prompt expansion and a magical escape sequence which is understood by the terminal.
case $TERM in
xterm*)
precmd () {print -Pn "\e]0;%1~\a"}
preexec () {print -n "\e]0;$1\a"}
;;
esac
This is for Zsh. See this page for how to do the same with Bash and other shells.
There are a lot of variants you can make in the format of the title. Check your shell manual for more information.
If you use Konsole or GNOME Terminal, make sure they are configured to actually use what the emulated terminal dumps. Konsole has an option to set the terminal name to what you want so I suppose the GNOME Terminal has a similar feature.
As usual, I’m not claiming I’ve invented this. I probably read this on a blog somewhere, but I don’t remember where. This is too bad for me because I missing on possible pingbacks. Kudos to whoever I’ve picked this from.
Zsh manual links
Good safeguards
In my last post I’ve shown that some people are annoyed at the fact that they can no longer erase their root directory simply by typing rm -rf /. I’m happy that this possibility is removed. I’m not scared that means Linux is being dumbed down. There are already some safeguards in Linux and nobody is complaining about them because they guard even seasoned users to do things that are dangerous or silly.
Proper safeguards
dpkg won’t remove itself
Erasing the primary package manager on your system prevents your from installing any other package. It is hard to argue that it is a good thing to let that happen without warnings.
fdgonthier@moka:~/ > sudo dpkg --purge dpkg dpkg: error processing dpkg (--purge): This is an essential package - it should not be removed. Errors were encountered while processing: dpkg
You can still erase dpkg if you want by using the --force-remove-essential option. I can actually think of reasons somebody might want to do that but this is a bad idea, and probably a mistake, most of the time its attempted. dpkg and apt protect essential and important packages on a Debian system by asking for obscure force options or confirmation, depending on what is attempted.
You can’t unmount /
fdgonthier@moka:~/ > sudo umount / umount: /: device is busy umount: /: device is busy
That is akin to removing the wheels of a running car. You can’t even force-unmount it.
You really shouldn’t fsck a drive in use
It is possible to do that, but when you call fsck.ext3 on a mounted partition, it will ask you with a rather serious prompt if you really want to proceed. fsck.ext3 has a force option but it has no effects on this prompt. This speaks volume about how much doing this is discouraged.
In good Unix fashion it is still possible to do it if you really want to but the developer of fsck.ext3 has made clear in the man page that you don’t want to do that.
Some kernel modules can’t be unloaded
modprobe has a force option (-f) too. It can be used to unload reluctant modules. It is clearly documented in modprobe manual page that removing by force may crash your system. I’ve used it a few times, it worked a few times, it crashed a few times, but most of the time it will not work if the module is important.
Why should it be possible to remove the module for the computer chipset while it is running? The answer is left to the imagination of the reader. I think its a good thing this kind of module won’t unload.
You can’t kill the init process
kill -9 1 will do nothing. This is actually hardcoded in the Linux kernel. The init process is the mother of all process in the system. Without it, you won’t be able to boot, or reboot, or use your virtual consoles. It is the reaper of zombies so if it dies, prepare for zombie invasion. There is really no reason to kill this process, ever.
You can’t format a mounted filesystem
fdgonthier@moka:~/ > sudo mkfs.ext3 /dev/sda1 mke2fs 1.41.5 (23-Apr-2009) /dev/sda1 is mounted; will not make a filesystem here!
mkfs.ext3 offers a way to force this but you have to use the force option (-F)twice.
Files in /dev are dynamically recreated
The health of your system is no longer tied to what is in the mysterious /dev directory. You can delete those files if you wan’t, and, depending what you erase, your currently running system may or may not be affected, but those problems will not survive a reboot or the invocation of /etc/init.d/udev restart.
GUI environment won’t let you in the dark
This is something common now. If for some reason, you change your resolution to something your monitor can’t support and your screen goes blank, desktop environment will automatically switch to your last used resolution. This is a safety mechanism preventing desktop users to set their screen to a resolution that leaves them without graphic display. Any resolution can still be configured statically into the system-wide xorg.conf if necessary.
Conclusion
All the safeguards and behaviors I’ve described above go against the Do What I Mean (DWIM) philosophy of Unix, and the something against the semantic of some option of the command: the kernel won’t let you unload your chipset module because it won’t work without it, mkfs.ext3 won’t let your format a partition that is in use because it’s certainly not what you want to do, dpkg won’t let your remove itself because there is a chance you won’t be able to reinstall it after it was removed.
If you think doing anything of what I’ve named above would be totaly stupid anyway, then you are right. Good safeguards aren’t there to nag you, and won’t ask you to double check everything you do. They simply prevent you from doing things that are possibly catastrophically detrimental to your system. Stop thinking rm -rf / should work because the Unix pilosophy about DYIM, because some command you can type have might no meaning at all.
Then a few things surprised me…
While testing potentially destructive commands in my test virtual machine, I’ve found I was able to do things I think I shouldn’t have. There might be some reason those things are possible. If you know why, please comment.
deluser: delete the root user
You can run deluser root as root without problems. This is of no consequences to the system because the root user is always the user with UID 0, but I think many scripts would be broken by that.
mkfs.ext3: tries to formats a directory
I don’t think a directory can hold a ext3 filesystem, yet mkfs.ext3 /etc will still try to proceed, and fail, after showing a warning telling that will probably won’t work.
fdgonthier@moka:~/ > sudo mkfs.ext3 /etc
[sudo] password for fdgonthier:
mke2fs 1.41.5 (23-Apr-2009)
/etc is not a block special device.
Proceed anyway? (y,n) y
mkfs.ext3: Device size reported to be zero. Invalid partition specified, or
partition table wasn't reread after running fdisk, due to
a modified partition being busy and in use. You may need to reboot
to re-read your partition table.
Should it even bother to try?
fdisk: delete an active, mounted partition
fsck.ext3 detects that if targeted partition is mounted. I don’t see why fdisk couldn’t do that. I think there is a good chance that deleting a mounted partition is a mistake and there is not even a warning before proceeding.
unmount /proc and /sys
Those pseudofilesystem have become necessary to a lot of program. It’s a bit weird that you can just unmount them without warnings.
More silly things…
cat /dev/urandom > /dev/mem will very quickly crashes your system. There are multiple variant to that, which are all as efficient as rm -rf / at causing harm to a Linux system.
Those silly commands are unlikely to outside forum of Linux users that love to abuse n00bs, so safeguarding against them is of little importance. Still, why should a superuser shell should have such a raw access to disk devices? Is it necessary? Is there a way to mitigate that?
If you like that post, please subscribe to my
RSS feed. More readers would motivate me to keep writing at least once a week.
Arrogant Linux Elitists
A followup…
This entry now has a followup: Good safeguards.
Update
It was pointed to me from Reddit and from a commenter that the -f flag in rm -rf is the force flag and isn’t part of the command. I’m willing to admit I’m wrong and probably overuse the force flag, but I didn’t remember how I got that bad habit.
I then retried the rm -r command on a directory in /tmp. This directory is owned by me but happens to include some files owned by root. I’m allowed to erase those files, but for each file I don’t own, I get a prompt asking me to confirm. This gets annoying quickly and had this not been a test I would have hit Ctrl+C and re-run the command with -f. If you often work with directories with mixed permissions (and I do), you can quicly get into the habit of running rm using the force flag.
This weakens the value of the -f flag for protecting against the huge mistake that is erasing /.
Original post
Did you know that rm -rf / no longer works on recent Ubuntu version? I bet you did not because this command tends to be a bit destructive.
I did not know that. I’ve never been bitten by an accidental rm -rf / but the possibility scares the hell out of me whenever I do a command in my root directory or whenever I write scripts thats erase files.
I’m a seasoned Linux user, yet I was pleased to know that Ubuntu now has that command refuse to work by default. rm -rf / now comes with the implied --preserve-root switch which returns an error when it attemps to erase the root directory.
I’m happy because that command has little reasons to exists beyond the mere fact that rm -rf is meant to unconditionnally erases files and directory: ie, a sole rmsysroot command would not exists. It would make as much sense as a car designed to only crash into the first tree.
Yet, some people oppose such a safeguard. The people that oppose this are probably the kind that made some people come up with sarcasms such as this lovely t-shirt.
LWN’s John Corbet has made a pretty good article about why its a good thing that rm -rf / is safeguarded against errors so I’m not going to rewrite a whole article about that. Let’s just repeat what I find important:
- unguarded
rm -rf /might not just happen on the command line, but in scripts too, and at times where you can’t just hit Ctrl+C to save a part of your day - its just too easy to make a syntax error in a command and type
rm -rf / tmp/*when you meant to typerm -rf /tmp/* - if you really want to remove /, you can use the
--no-preserve-rootswitch.
Now let’s just look at the people who opposes this. Here are some pearls form people complaining about this new feature. I’ve found them on the Launchpad bug report and a blog funnily named Ubuntard. I think naming the authors of those quotes is useless. Suffice to know and weep that they exists.
Also, this directly conflicts with the functionality of the ‘-f’ switch, without which there ALREADY IS CONFIRMATION OF EVERY DELETION.
Bullshit. The -f is not a confirmation, it’s part of the command. Confirmation should come after the command.
So, what’s next? Patch dd to prevent it from wiping your partition?
Well, yes, dd sucks indeed should probably changed. But that’s the subject for another blog post. The point is that I use rm -rf at work up to several times per hour, and I use dd a few times per year. I doubt this is generalizing to say that rm has a much higher potential for errors for every Linux shell users than dd ever has and ever will.
Couldn’t agree more with you. If people don’t know what they are doing, they shouldn’t be working the command line anyway.[...]
rm is not a gun, dynamite, or C4. It erases files. I’ve got 172583 files on this small computer, chances are some of them are superflous and need to be erased. There should not be any remote risk that I erase all my disk if I want to remove just one.
Safety if for bitches. Knowledge is for winners.
No comments. Let’s just say that I hope this person finds a creative, unsafeguarded, way to nuke his system.
[...] come to think of it, if I’d been given a stupid error message telling me not to do that, I’d probably have punched a hole in my CRT instead.
… or yeah, he can do that too! I could go on for quite a while, but the pearl, that is actually repeated more than once, is the invocation of the “Unix philsophy”.
Changes of this nature are destructive to the philosophy of *nix, and is a step closer to the laughable click-the-dialog-box security of Windows Vista.
This is a safeguard; a satefy cushion. This is the program saying “You can’t really be that stupid so I’m not letting you do that!”
Don’t tell me about this so called Unix philosophy! Unix is evolving and when technology evolves, it also tends to grow features that keep people from shooting themselves in the foot. This is why cars have airbags, this is why some laptops have spill guards and free-fall sensors, and also why your water heater doesn’t blow up your house.
Just like people that want to drive without airbags can just remove them, Unix doesn’t bolt the --preserve-root option onto the rm command. It’s probably easy enough to take the coreutils package, change its build options to disable --preserve-root. I could probably write some instructions to do that in a few paragraphs, but since I think doing that would be stupid, I won’t!
This blog is 250% more interesting than the competition
Some other people have mastered the art of pulling numbers out of their ass. This is deadly common on commercial TV where marketers just say things like it improves your performance by 200% percent, or this vaccum sucks twice as good as the other brand. Marketers may have a basis for this number, but they certainly won’t explain them in their costly 30 second break, won’t they?
But commercial break at the time you get up and take a leak afterall, nevermind their content…
What is more worring is when the mainstream media starts throwing numbers around the same way as they are in marketing. This is not a rant about how statistics can be manipulated at anyone’s profit. I’m talking about the generally bad habit the media have to cite number that are totally meanlingless for people uninitiated to the source of the data, that is, most people.
You can compare that to shopping for something without any prior knowledge of the value of the item you are aiming to buy. You usually compare prices of similar items to discover the scale of the numbers. Yet, the media keep throwing at us numbers that are meanlingless for most people.
This is specially obvious lately with the swine flu scare, but as my friend Steven said, and as I will repeat below, we are not coughing up bacon yet.
Here are a few example of numbers cited with comparison, which means, that for most people they could as well have been pulled from thin air.
From CBC:“Around the world, the number of confirmed swine flu cases stood at 1,490, with 29 deaths related to the outbreak of the new H1N1 virus, Keiji Fukuda, assistant director-general of the World Health Organization, said Tuesday.”
Like said above, the estimated number of death of regular flu every where, in US, is 36000. More people die of car bomb in Iraq, daily. Yes, Iraq is far away, but we can also ask ourselves if the deaths are directly or indirectly attributable to swine flu?
From Alternet.org:“the results of a study indicating that 200,000 two- to four-year-olds had been prescribed Ritalin for an “attention disorder” from 1991 to 1995.”.That certainly seems a lot, but it means nothing if I don’t know how many two to four-years old have not been prescribed ritaling.
Finally, you can find at various places that the Iraq War, or that fixing Global Warming, would cost trillions of dollars.
A trillion of dollar is a number very few people can size. You can’t look at anything in the world and say hey, this is worth a trillion bucks. Those numbers are so high that you can theorize that they are subject of heavy estimation, or obtained by calculation so complex that it makes the margin of error of the final result totally uncountable. Anybody can doubt the process by which such a number obtained, even if its by reputable persons or institutions. This weakens the position of whoever put forward such an huge number as an argument in a debate.
At this scale, people comprehend better if you say a shitload of money instead of whatever big number you calculated. Afterall, the shitload might be a relative quantity, but its near the top of the scale for everybody, from the poorest to the richest.
Database design tools
I have been looking for database design application on Linux for a while. I even recently started searching for something compatible with Linux through Wine too. The Ubuntu and Debian package database is devoid of anything useful beyond Dia, which I hate for reasons that do not belong to this rant-free blog. There are some tools around for MySQL but it is not the SGDB I’m the most found of. I’m particularily interested in PostgreSQL
It was a revelation to me when I found 2 free (as in beer) design application on the PostgreSQL Wiki. I was even more surprised that both loaded and seemed to work out of the box in just about 30 seconds after their download. I’m not sure about the licensing terms but they certainly look safe to use for FOSS development.
I have not tried either extensively. I just believe both application needs to be linked since they seem to be hard to find. I might review one of them here some day.
Open System Architect
This has an impressive number of button, menus and and various gadgets. It is in fact pretty intimidating at first. It has the feel of a professionally developed application.
It is open-source but sadly does not seem to be actively maintained. This is something I fear I might discover after some prolongued use.
SQLPower Power*Architect
This simple looking application is in Java, which is a showstopper for some people. A good Java application isn’t something that stops me, but I admit Java applications sometimes have problem at setup time if they are not properly packaged.
This application doesn’t have that problem. It run fine when started with a canonical java -jar file.jar command.
The application does look funky a bit on my computer. The fonts are serif and heavily anti-aliased. It look clunky a bit. The screenshots on the site don’t have that problem. It might be a quirk related to my Java distribution or my some font handling problem on my Linux distribution. I need to investigate. That aside, the GUI is simple and no as scary as Open System Architect. If I could fix the font glitch, it will be sweet.
This is also open source. They have a Google Code project.
Interesting Bash snippet
This little Bash snippets scans the Debian dpkg database for packages whose configurations files have been modified.
This only touches configurations files which are packaged and made known to dpkg. Some package manually handle their configuration file in maintainer scripts. A good example of that is /etc/network/interfaces which is an important configuration file but not automatically handled by dpkg.
This is as useful as you want to make it. I use it to track changes I’ve done which could end up with a conflict during a package upgrade. If you want a more thorough tracking of configuration changes, use something like etckeeper.
Notice I took some care to use more Bash’isms, to optimize the script. I was able to optimize by just a few percents. The bulk of the time must spent calculating MD5 sums.
#!/bin/bash
for pkg in /var/lib/dpkg/info/*.conffiles; do
p1=${pkg#/var/lib/dpkg/info/}
p=${p1%%.conffiles}
IFS=$'n'
for cfsum in $(dpkg-query -W -f='${Conffiles}' $p); do
IFS=' '
c=($(eval "echo $cfsum"))
if [ -r ${c[0]} ]; then
sum=${c[1]}
cur_sum=($(eval "md5sum ${c[0]}"))
if [ $sum != ${cur_sum[0]} ]; then
echo "$p: ${c[0]}"
fi
else
echo "Can't access file: ${c[0]}." > /dev/stderr
fi
done
done
This will output something like this:
$ ./check_changed bash: /etc/bash.bashrc console-tools: /etc/console-tools/config libldap2: /etc/ldap/ldap.conf ntp: /etc/ntp.conf ...
Why patch distributed software?
I will not go over the story of the OpenSSL fiasco again. Let’s just say that a developer inserted a particular patch in Debian OpenSSL package that he shouldn’t have. The patch was flawed in ways subtile enough that it escaped review 2 years. Long story short, Debian was left in a rather immense accumulation of fecal matter.
This was bad and made a lot of people object to the fact that software are patched in Linux distributions. It is true that software developers usually are the best person to fix the bugs in their software. What is still true but perhaps less obvious, is that most software developers are not ready or able to work in close cooperation with distribution developers so that their software are perfectly packaged without bugs and in time for a distribution release.
Distribution developers need to patch software for various, good, reasons, to ensure the best quality software distribution to their users, in a timely fashion.
Today I will examine three different kind of patch and try to justify why Debian developers, or distribution developers in general, will develope them. What is very important to note is that Debian, and probably most other distributions, wants that the patch the developers produce are sent to the original developers in the software they are packaging. In the case of the Debian distribution, this is mandated by the Debian Policy Manual, in section 4.3. That way, the patch can be eventually integrated in a future release, and the patch removed for the package for that new release.
The lesser divergence from upstream, the better. The OpenSSL fiasco is certainly a proof of that.
Plain bugfixes
It is a frequent occurance that packages are patched to fix small software bug. It is often inconvenient for a software packager to wait for a new release each time a bug is reported in the software they are responsible of. In some case, that release may come after several months (years), during which the bug will stay unfixed, which may in some case make the package unusable.
Patches are often pulled from the development repository of the software, if they can be backported to the version currently in the distribution.
Debian developers will then patch software when they can, to the best of their knowledge. It is recommended that they consult with the maintainer of the software before uploading their change to the distribution.
Patch example
http://patch-tracking.debian.net/patch/series/view/nano/2.0.7-4/ja_help_freeze.patch
In the case of the nano package, the existance of the patch is documented in the changelog of the package.
Compiler fixes
Like all other package in the distribution, compilers evolve and are eventually upgraded. Debian usually test new compilers ahead of time so they can stamp out compilation bugs early.
In case compilation fails for a package with a new version of a compiler, Debian developers will sometimes prefer to patch the program instead of asking the upstream developer to build his program with a recent or possibly unreleased version of the a compiler. They will patch the program to make it work with the new compiler and transmit the patch to the original developers for their future use.
Patch example
http://patch-tracking.debian.net/patch/series/view/qtodo/0.1.2-5/20-gcc.dpatch
This patch adapts the program to a newer than the one that was probably used to develop the package.
FHS bugfixes
The Debian distribution try to closely follow the Filesystem Hierarchy Standard (FHS). This is actually mandated in the Debian Policy Manual, section 9.1 so, if a program puts a file in a wrong place, it is viewed as a important bug.
Fortunately, most developers will follow the FHS, by habit or consciously. This simplify the packaging process, most program won’t need to be changed to be compliant. Sometimes though, some developers consider that it is not improper that a global configuration file is put outside /etc, or that image files can be put in /var.
Patch example
http://patch-tracking.debian.net/patch/series/view/trac/0.10.3-1etch4/01_use_global_config
This patch tells the Trac web application to look for its configuration file in /etc instead of /usr/share.
That will be enough for today. I think I’m already beyond the “tl;dr” level for most people. I will try to find some more example of types of patch done by packagers in another blog post.
iRiver LPlayer in Linux
The player
I’ve got this little device recently to replace my 256mb MP3 player. I was pleased that I got it pretty cheap during Black Friday from NewEgg Canada. NewEgg “leaked” their Black Friday rebates to Canada and reduced the price of that player to 85 CAN$ which is pretty cheap for a 8gb model.
At first, I must admit I was a bit sad with bugs and some missing features of the player. It is obviously an entry-level player. I’ve managed to find a satisfying way to work around all the bugs and uploaded 8gb of music to it and I’m happy since. I did not realize 8gb was that much content.
This post is a concentrate of the bugs I’ve found on the player and how I work around them. If you have better solutions, please comment on this post.
The bugs
MTP support
This is not really a bug, since this device works in UMS/MSC mode. Since I like to explore the capacities of my devices, I’ve nonetheless tried to get it to work.
For most Linux users, this player won’t work in MTP mode. I’ve only managed to make it work on very recent snapshots of libmtp. I got it to upload, but not to delete. I have not investigated that. Don’t count on MTP to work well until the next major Ubuntu release, Jaunty Jackalope. If MTP support was good, the most important bug on this player would be alleviated, but as it is not the case, please read on.
Bad sorting
The first and by far most annoying bug I’ve found is that the player doesn’t sort the ID3 tags on the player. The music files are displayed in the order they are uploaded on the player. If the player worked well with MTP, this wouldn’t be a problem because the media player will upload the files to the player in the correct order. File manager such as Konqueror don’t do that as it’s possibly slower to get the files from the disk in any kind of order. They are also multithreaded so that multiple files are copied at the same time. So if you upload on the player using Konqueror, the order will be screwed up. With file managers, the only options would be to copy files one by one by hand. This is obviously not a scalable process.
I’m satisfied to use rsync to copy files from my MP3 directory to my player. rsync copy and write the file in order.
rsync --verbose \
--recursive \
--times \
--whole-file \
--delay-updates \
--modify-window=1 \
--delete-before ~/Media/mp3/* .
I’m not exactly sure how this work and I now that my music is on the player, I don’t care enough to investigate it. Of course, I this probably is not perfect. I think that if I make changes inside an album, then rsync will just sync the changed file and thus the order inside the album will be screwed up. This could be automated but order will never be quite right. The only solution is correct sorting on the firmware, but, until that is fixed by iRiver, I’ll be happy to just reformatted the player and redo the copy overnight with rsync when I want to change the content of the player.
ID3v2.3 vs ID3v2.4
Most of my MP3 were correctly tagged using ID3v2 tags, but I initially did not know there were several incompatible versions of ID3v2. Amarok, as most MP3 players, read any ID3v2 versions, but writes only ID3v2.4 tags. The device simply cannot read those tags and will put files tagged in such way in the “Unknown Artist/Unknown Album” bunch, which is a PITA.
The first solution I’ve found was to use Kid3. It has a function to convert tags back and from ID3v2.3 and ID3v2.4. Kid3 is a fine program despite some UI shortcomings, but it doesn’t scale to gigabytes of files.
The next best thing was to use the EyeD3 library. EyeD3 is a simple Python program and library to manage ID3 tags. It includes features to convert between ID3v2 versions. I’ve lost the small script I’ve done to mass convert my MP3 files to ID3v2.3, but it looked a bit like that (untested) snippet.
tag.link("/some/file.mp3", eyeD3.ID3_V2)
tag.update(eyeD3.ID3_V2_3)
If I ever rewrite the script, I’ll post it here.
.ogg and Vorbis tags
The device doesn’t read Vorbis tags. For some people, this would be a total let-down. Not for me. I re-encoded I had as OGG to MP3. I have not investigated this further.
Playlists
The device uses .PLA playlists. The format of .PLA playlists is detailed here. I have not yet found the time look at this as playlists are not a killer feature for me.
LPlayer for the rest of us
I don’t consider I’ve discovered anything. All that informations I list here was scattered around the net. If you want more informations, please do Google and you will eventually find some.
The most important page I’ve found for LPlayer owner is LPlayer for the rest of us, which is a blog post similar to mine. I’ve tested all the information he has posted there and managed tp update my firmware, and encode a video to play on the player. Kudos to Tim De Pauw.
Annoying non-breakable spaces in Bash/Zsh
This is an annoyance I found got around to solve. In Konsole, with a basic X configuration, when you type AltGr Space, you get a non-breakable space. It might happen in other things X terminal/shell combo, or the both of them might not matter at all.
If you are an heavy shell user, you might hit the AltGr Space combo by accident. This wouldn’t be bad if the shell made it somehow obvious that what you entered in a non-breakable space. The fact is that it doesn’t and it’s then totally impossible to distinguish a regular space with a non-breakable space after it was typed in the shell.
cd $HOME zsh: no such file or directory: cd /home/fdgonthier
After typing such a command quickly, I was often left wondering what the hell was wrong with my command, since, as far as I could see, it was syntaxically correct.
The problem is that since there is a non-breakable space between cd and $HOME, Zsh wants to execute the whole command as a single command. Since I didn’t know I could even type non-breakable space in X, I checked what the hell the shell was doing by using strace. strace is my favorite diagnosis tool for any kind of problems in Linux. Programs don’t lie when they are spied with strace. The problem is obvious:
execve("cd\302\240/home/fdgonthier", ["cd\302\240/home/fdgonthier"], [/* 30 vars */]) = -1 ENOENT (No such file or directory)
It took me a while but I’ve found that \302\240 is the Unicode sequence for non-breakable space. Once I have found that, I Google search lead me to Launchpad bug 218637.
On this page, you see that you can disable non-breakable space using a xkb option in xorg.conf. Simply add the following in the InputDevice section related to your keyboard.
... Option "XkbOptions" "nbsp:none" ...
or use
setxkbmap -option "nbsp:none"
in a console, your favorite initialization file, or elsewhere.
Partial Debian Mirrors
The following is a description of the technique I’ve used to create partial Debian mirrors. I have damn near mastered that technique that is not immediately obvious if you don’t know the tool. Nothing there is black magic though, as you will see.
The following example will use the programs called reprepro and
germinate. Both are available on several versions of Ubuntu, Debian Lenny and Debian Sid. I’m not going to explain either in great details. They are well documented in the case of reprepro, and there is enough documentation in germinate.
Required steps
This configuration is necessary in both case.
reprepro is by far my favorite Debian repository manager. It has a steep learning curve at first but once you get past the initial configuration and the first few commands you’ll see it cannot really be made easier.
The first step is to create the directory that will contain the mirror. In that directory create a directory called conf.
In that directory, edit a file named distribution in your favorite editor At this point I usually pop-open the man page for reprepro. Write the following in that file:
Codename: etch Architectures: amd64 source Description: Debian Etch (required package only) Components: main Update: debian-etch-update
That’s all we need in that file right now. This describes what distribution this mirror will include. You can have several distributions in a mirror. Most field are self explanatory except perhaps the Updates field which will explain below.
Partial mirror, using reprepro only
The next step explain how to create a partial mirror using just reprepro. reprepro is powerful enough to select a subset of a whole package archive.
Name: debian-etch-update Method: http://gulus.usherbrooke.ca/debian Components: main Architectures: amd64 source FilterFormula: Priority (==required)
The content above is the content of your conf/updates file. It includes all the rules needed to update the distributions configured in the distributions file. The distribution etch we created in is linked to its respective update rule by the Update configuration field.
The key to partial mirroring in this case is the FilterFormula field, which selects just the Debian package in required in a very basic installation. There is also a FilterList field which can select just the set of package you list. This is the basis of the next section.
To start mirroring, go in the mirror directory and do:
reprepro -V update etch
and reprepro will start downloading packages. The -V argument activates verbose mode. After successfully creating the archive, you can reuse the same command to update your mirror.
Germinate and reprepro
germinate is an oddball program which, given a set of package, will recursively find all packages a set of package depend on.
As a simple example, if you tell germinate to germinate the dependencies from the package python, it will list libssl, libreadline and will eventually find libc6. It can also fetch build dependencies if you want everything needed to build the package you want.
We will use germinate to create a Debian repository that mirrors just the set of package the python2.5 package depends on.
germinate is a very specialised tool which sees little use outside making new Debian and Ubuntu derivative distributions. It’s very powerful but a bit confusing. I’ll give the basic recipe you need to know to accomplish our current goal. If there is enough or any interest, I give more use cases for germinate.
-
Create directories called
seedsandgerminate. The former will include the files we give as input togerminate. The later will includegerminate’s output. -
In the
seedsdirectory, create files calledblacklist,required,STRUCTUREandsupported. Theblacklistandrequiredwill stay empty. -
In the
STRUCTUREfile, put the following:required: supported:
-
In the
requiredfile, put the following:* python2.5
Don’t forget the space at the start of the line.
-
You can then run
germinate.(MIRROR=http://gulus.usherbrooke.ca/debian cd germinate && \ germinate -v \ -m $MIRROR \ -d etch \ -c main \ -s seeds \ -S file:///tmp/temp-distro \ --no-rdepends)where you can replace
/tmp/temp-distrowith the base directory of your mirror.
You should see a bunch of files created in the germinate directory. The only file we are interested in is germinate/required.
germinate output is meant to be human-readable so we need a bit of parsing to extract the required information.
The following Bash magic does the trick:
for pkg in $(cat germinate/required \ | tail -n +3 \ | head -n -2 \ | cut -d '|' -f 1); do\ echo $pkg install; \ done > mirror.packages
The resulting mirror.package is now suitable to act as a filter for reprepro.
Replace the FilterFormula line in conf/updates by:
FilterList: purge ../mirror.packages
purge tells reprepro not to do anything for packages not in the list.
Then run:
reprepro -V update etch
to create your mirror.
