2012-05-14

Solaris and libcrypt

Solaris 10 and libcrypt

As a reminder to myself, when you need to build something on Solaris and you get the following error:
fatal: libcrypt_d.so.1: open failed: No such file or directory

Then you need to install the Solaris 10 Encryption Kit (link)
File: sol-10-encrypt-GA-iso.zip

Just install the 3 packages from the iso and install them.

2012-02-19

xubuntu no window titles etc

On the kids laptop the Xubuntu session was seriously broken. Of course it being the kids laptop it's a bit mess anyway.
So I try to fix it - because it's *urgent* - they want to use tuxpaint. After moving and fiddling with the ~/.config directory and try one or two other things, it turns out it is as easy as removing the session cache.

rm -rf ~/.cache/sessions/*

2011-12-08

P4 and return codes

This just hit me.


>cat test.sh
#!/bin/sh
/usr/local/bin/p4 sync -n
rc=$?
echo "Returncode $rc"

>cat test2
#!/bin/sh
# \
exec tclsh "$0" "$@"
set rc [catch {exec -- /usr/local/bin/p4 sync -n} out]
puts "Return code: \"$rc\""
puts "out: \"$out\""


 >./test2
Return code: "1"
out: "File(s) up-to-date."

 >./test.sh
File(s) up-to-date.
Returncode 0

>/usr/local/bin/p4 sync -n
File(s) up-to-date.
>echo $?
0

>/usr/local/bin/p4 -s sync -n
error: File(s) up-to-date.
exit: 0

P4 knowledge base article regarding this:

"In general, you should not rely on a command exiting non-zero on "failure". Instead, use the global -s flag to help interpret the command output -- and parse that output in your scripts. Possible tags with the -s flag include info:, info1:, info2:, error:, and text:"

My kangaroo rating for this:
 [x] not funny!

2011-11-19

FreeBSD 9.0RC1 to RC2 upgrade

Finally had a little bit of time to deal with my laptop at home. As FreeBSD 9.0RC is out, I thought I'd give this a try by updating from 9.0 RC1.
Normally this works quite easily on FreeBSD by running the freebsd-update utility, but this time it failed.

So to get it work, see here.

In short:
# sed -i '' -e 's/=_/=%@_/' /usr/sbin/freebsd-update
# freebsd-update upgrade -r 9.0-RC2
 



2011-10-27

Import git to perforce

Import git to perforce

At work I have to use painforce, although I don't like it. So I decided to use it as kind of  a master repository for my git stuff. git-p4 is a python script that does most of what I want, however I wanted to keep the original commit date and hash. So here's a little patch to achieve this.
 
--- /usr/local/home/bjoern.henkel/git-p4.org    2011-10-27 11:56:05.351331262 +0900
+++ /usr/libexec/git-core/git-p4        2011-10-27 16:24:12.623302361 +0900
@@ -413,6 +413,14 @@
            continue

        logMessage += log
+
+    # I want to keep the original date when importing from git
+    logMessage += "\n"
+    logMessage += "Original commit date: "
+    cmd = 'git show -s --pretty="%ai (%ar) " ' + commit
+    logMessage += read_pipe(cmd)
+    logMessage += "commit: %s" % commit
+
     return logMessage

 def extractSettingsFromNotes(commit):

gitk in cygwin (with cygwin-ports)

gitk in cygwin (with cygwin-ports)

Recently I had problems with gitk not working. Turns out the fix for this is rather easy, see the diff below:

--- /home/bjoern.henkel/gitk.org        2011-10-26 15:44:27.096698500 +0900
+++ /usr/bin/gitk       2011-10-26 15:44:57.143573500 +0900
@@ -2367,7 +2367,7 @@
        }
     }

-    if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
+    if {[info exists geometry(state)] && $geometry(state) eq "normal"} {
         wm state . $geometry(state)
     }

2011-10-18

Changing /etc/fstab with puppet and augeas

Changing /etc/fstab with puppet and augeas

Puppet Augeas documentation

My case: Add tmpfs

Trying with augtool, and breaking my head on how to add an entry at the end of the file, I realized eventually figured out, that you don't have to care at all with augeas, just add a 01 prefixed value and it will be added to the end.

So to add I use:

defvar fstab /files/etc/fstab
set $fstab/01/spec tmpfs
set $fstab/01/file /dev/shm
set $fstab/01/vfstype tmpfs
set $fstab/01/opt defaults
set $fstab/01/dump 0
set $fstab/01/passno 0
save

But what if the entry already exists?
Since in fstab the entries are just numbered, it took a while to figure out how to use the last() function.

This should work (e.g. change option)

set $fstab/*[spec = 'tmpfs'][file = '/dev/shm']/opt size
set $fstab/*[spec = 'tmpfs'][file = '/dev/shm']/opt/value 12G

This will only change/add the option size=12G, where spec equals 'tmpfs' AND file equals '/dev/shm'.

Then, all left to do was finding a rule for puppet to not add a new line on each run, that's done quite easily with 'match':

match *[spec='tmpfs'][file = '/dev/shm']

So in puppet it looks like this:

    augeas{"Add tmpfs for case ${caseusername}@${hostname}":
        context => "/files/etc/fstab",
        changes => [
            "set 01/spec tmpfs",
            "set 01/file /dev/shm",
            "set 01/vfstype tmpfs",
            "set 01/opt size",
            "set 01/opt value ${shmem}",
            "set 01/dump 0",
            "set 01/passno 0",
            ],
        onlyif => "match *[spec='tmpfs'][file = '/dev/shm'] size == 0",
    }

    augeas{"change tmpfs size for ${caseusername}@${hostname} to ${shmem}":
        context => "/files/etc/fstab",
        changes => [
            "set *[spec = 'tmpfs'][file = '/dev/shm']/opt size",
            "set *[spec = 'tmpfs'][file = '/dev/shm']/opt/value ${shmem}",
            ],
        require => Augeas["Add tmpfs for case ${caseusername}@${hostname}"],
    }