Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Dwarf Fortress starting during apt-get upgrade (askubuntu.com)
221 points by rayalez on Aug 16, 2017 | hide | past | favorite | 53 comments


The real WTF is that APT spawns an external process to check disk usage, instead of invoking statvfs() on its own.

Some cases are less clear-cut, however. For example, the Debian 'nodejs' package installs node.js binary as /usr/bin/nodejs and not /usr/bin/node because it conflicts with another package: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907#108

And let's not forget rename(1) from util-linux versus the Perl rename(1)...


It isn't `apt`. See how they mentioned that `mysql` packages were installing? Well, in the `preinst` shell script, in the .deb, there is the line:

`if LC_ALL=C BLOCKSIZE= df --portability $DATADIR/. | tail -n 1 | awk '{ exit ($4>1000) }'; then`

There's `df` being called without the full path and that's what would be spawning Dwarf Fortress.


That doesn't make it much better though. Parsing the output of df (with a useless tail -1) is kind of awful when you can use something like stat -f -c %a.


That has the same problem, just with a different name. So your solution solves a style complaint, not an actual functional problem.


I agree with your comment about it being functional. But wouldn't removing tail from the pipe remove complexity and speed up the processing(Arguably, most likely only by a small fraction)


How is the "tail -1" useless? The output of that df command is two lines, one contains the column headers and the next contains the data.


because `... | tail -n -1 | awk '{...}'` is the same as `... | awk 'END {...}'`.


On the node thing: that decision has recently been reversed by the technical committee, effective in the next release (it is in unstable now). See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862051 - nodejs will now simply be 'node'.


It could be called from a bash script rather than from within apt itself.


Using aliases in `~/.bashrc` rather than putting scripts or symlinks in $PATH is a good mean to avoid those kind of problems, provided bashrc includes code to quit if ran in non-interactive mode (default at least on ubuntu).

Many use aliases only to specify default command parameters, but it works just as well to provide an execution path, like, in this case:

    alias df=/home/my_user/games/dwarf_fortress/df
It would only be executed in interactive sessions, this way, which should guard well enough against system code interpreting it.

Of course, this still means user can't use system's `df` easily, but I guess they don't use it anyway since they did not realize the problem until that upgrade.


> this still means user can't use system's `df` easily

    \df
There you go.


Awesome, didn't know about that. Thanks!


They could still type /bin/df, and they could also use:

alias freespace=/bin/df

Though then they'd have to uninstall FreeSpace 2.


Why not name the alias something else than “df”? :) dfortress or something like that. Then it won’t collide with df(1).


This is by far the best approach, yes :)

My point was more to show a way this particular user could have achieved the same result without their problem.

Plus, we can't expect users to know all the system tools, this is a good way to isolate "user space" from "system space", so I guess taking the habit to use aliases rather than putting things in `/usr/local/bin/` makes sense by itself (except when we want indeed to override an executable provided by system, or we want indeed to provide a new system tool).


The fact that the dwarf fortress binary is just 'df' was asking for trouble. In hindsight seems amazing nobody reported this before.


That's how i feel about "convert" from imagemagick


Which is why I use graphicsmagick [1] instead. The imagamagick executables becomes options behind the 'gm' executable.

[1] http://www.graphicsmagick.org/


Can't believe I never heard of GraphicsMagick. Thanks for the heads up. I wonder if it has a Ruby interface.


IIRC yes but, since it leaked memory like a sieve, I did everything via system("gm ...")

(This memory is a few years out of date.)


And "import"!


Hate it when I'm starting a newly written python script, and have forgotten the hashbang. For some reason my mouse cursor turns into a cross, and the script does nothing!

Always takes me a couple of seconds to realize what's going on...


I have a similar issue where I tend to start typing python code in the shell without remembering to enter the repl first.


PostgreSQL's "initdb"!


That's still much better than their 'createuser'


`testparm` for Samba.


packer has a name collision, too.


http://pubs.opengroup.org/onlinepubs/009696799/utilities/df.... says what df does on any POSIX system. I love Dwarf Fortress but running it as root is more !!fun!! than I'm looking for.


When I did my first few programming courses we were using C and on Windows, and using system("pause"); was our way of keeping cmd from closing. So as a joke over the years I've made a pause script for Linux in Python, Perl and even bash just so I can make such code valid.

But putting a whole game in place of a standard Linux util sounds like awesome menace, reminds me of the sl command (steam locomotive) which you can install on Debian (and maybe other distros?) for those who may typo ls they'll get a fun surprise :)


wasnt getc() available on windows?


It was and still is, the name is _getch() from <conio.h>

However, I can see how for a beginner programmer system("pause"); is more intuitive than printf/_getch() combo. Especially if said programmer is already familiar with windows shell and its commands.


sl also starts for LS too in case you have capslock on.


Why not have some Fun while waiting for upgrades to install? The bug is that apt doesn't carry on in the background ;-)


Just wait till they release "Ground Control Center" (gcc) :-) For a long time there were two things called 'git' and installing the 'wrong' one invariably led to similar hijinks.


What was the other one?


I'm guessing the interactive fiction interpreter [1], which predated the version control system by a couple of years.

[1] http://web.archive.org/web/20120826174233/http://diden.net/i...



Don't trust $PATH in scripts. Use `/bin/df`.


But then it's not portable across distros and to BSD's. On FreeBSD, bash is in /usr/local/bin/bash (if it is installed)

Do you also write "if /usr/bin/[ $? != 0 ]; then ..." ?


df is a standard utility, like ls or cd. Invoking df on a POSIX system should do the expected thing, and if it doesn't it means something is broken.



On Unix/Linux, there is very little stopping the superuser from introducing new and inventive kinds of breakage, such as in this case. This one is just a little more amusing than most. But seriously, if root wants to install a new command called df and have it higher up in the PATH than the standard utility, why should the OS argue?


Note that the OS doesn't argue :)

But actually, it would be cool to have some kind of warning, like a POSIX linter that warns the user something broke the standard, and they can decide to ignore it and never hear about it again. I'm not a big fan of linters, usually, but it would make sense for end users tweaking their system.


Actually cd is a shell built in, not a separate binary


I didn't know Dwarf Fortress was packaged in Debian. The last time I tried playing it on Linux, it was annoyingly 32-bit.


The SO question doesn't imply that it is, just that it's installed on the user's machine.


> I didn't know Dwarf Fortress was packaged in Debian

well, goodbye productivity.

I wonder if I can run it on a production server without anyone noticing...


The text renderer seems to use considerably less CPU that the graphics one. I've been tempted to set up a docker image...


Yeah, there's a 64-bit version now.


It's not packaged.


Some programs are 32-bit, but not to such an annoying extent.


It's mostly about all necessary libraries being available for the same architecture as the binary.

This means either having separate 32bit libraries (typical for closed source applications shipping together with their libraries) or having multiarch libraries (as modern linux distros do).


I just spilled my coffee




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: