UNB/ CS/ David Bremner/ tags/ linux

This feed contains pages with tag "linux".

You have a gitolite install on host $MASTER, and you want a mirror on $SLAVE. Here is one way to do that. $CLIENT is your workstation, that need not be the same as $MASTER or $SLAVE.

  1. On $CLIENT, install gitolite on $SLAVE. It is ok to re-use your gitolite admin key here, but make sure you have both public and private key in .ssh, or confusion ensues. Note that when gitolite asks you to double check the "host gitolite" ssh stanza, you probably want to change hostname to $SLAVE, at least temporarily (if not, at least the checkout of the gitolite-admin repo will fail) You may want to copy .gitolite.rc from $MASTER when gitolite fires up an editor.

  2. On $CLIENT copy the "gitolite" stanza of .ssh/config to gitolite-mirror to a stanza called e.g. gitolite-slave fix the hostname of the gitolite stanza so it points to $MASTER again.

  3. On $MASTER, as gitolite user, make passphraseless ssh-key. Probably you should call it something like 'mirror'

  4. Still on $MASTER. Add a stanza like the following to $gitolite_user/.ssh/config

      host gitolite-mirror
        hostname $SLAVE
        identityfile ~/.ssh/mirror
    

    run ssh gitolite-mirror at least once to test and set up any "know_hosts" file.

  5. On $CLIENT change directory to a checkout of gitolite admin from $MASTER. Make sure it is up to date with respect origin

     git pull
    
  6. Edit .git/config (or, in very recent git, use git remote seturl --push --add) so that remote origin looks like

     fetch = +refs/heads/*:refs/remotes/origin/*
     url = gitolite:gitolite-admin
     pushurl = gitolite:gitolite-admin
     pushurl = gitolite-slave:gitolite-admin
    
  7. Add a stanza

    repo @all
      RW+     = mirror
    

to the bottom of your gitolite.conf Add mirror.pub to keydir.

  1. Now overwrite the gitolite-admin repo on $SLAVE

    git push -f

    Note that empty repos will be created on $SLAVE for every repo on $MASTER.

  2. The following one line post-update hook to any repos you want mirrored (see the gitolite documentation for how to automate this) You should not modify the post update hook of the gitolite-admin repo.

    git push --mirror gitolite-mirror:$GL_REPO.git

  3. Create repos as per normal in the gitolite-admin/conf/gitolite.conf. If you have set the auto post-update hook installation, then each repo will be mirrored. You should only push to $MASTER; any changes pushed to $SLAVE will be overwritten.

Posted Sat 06 Mar 2010 08:52:00 AM Tags: /tags/linux

There have been several posts on Planet Debian planet lately about Netbooks. Biella Coleman pondered the wisdom of buying a Lenovo IdeaPad S10, and Russell talked about the higher level question of what kind of netbook one should buy.

I'm currently thinking of buying a netbook for my wife to use in her continuing impersonation of a student. So, to please Russell, what do I care about?

  • Comfortably running
    • emacs
    • latex
    • openoffice
    • iceweasel
    • vlc
  • Debian support
  • a keyboard my wife can more or less touch type on.
  • a matte screen
  • build quality

I think a 10" model is required to get a decentish keyboard, and a hard-drive would be just easier when she discovers that another 300M of diskspaced is needed for some must-have application. I realize in Tokyo and Seoul they probably call these "desktop replacements", but around here these are aparently "netbooks" :)

Some options I'm considering (prices are in Canadian dollars, before taxes). Unless I missed something, these are all Intel Atom N270/N280, 160G HD, 1G RAM.

| Mfr    | Model    | Price | Mass (6 cell) | Pros                                 | Cons                                  |
| Lenovo | S10-2    | $400  | 1.22          | build quality,                       | wireless is a bit of a hassle (1)     |
|        | S10e     | $400  | 1.38          | express card slot                    |                                       |
| Dell   | Mini 10v | $350  | 1.33          | price                                | memory upgrade is a hassle (2)        |
| Asus   | 1000HE   | $450  | 1.45kg        | well supported in debian (3), N280   | price                                 |
| Asus   | 1005HA   | $450  | 1.27kg        | wireless OK, ore likes the keyboard, | wired ethernet is very new (4), price |
| MSI    | U100     | $400  | 1.3kg         | "just works" according debian wiki   | availability   (5)                    |
  1. Currently needs non-free driver broadcom-sta. On the other hand, the broadcom-sta maintainer has one. Also, bt43 is supposed to support them pretty soonish.

  2. There are web pages describing how, but it looks like it probably voids your warranty, since you have to crack the case open.

  3. I don't know if the driver situation is so much better (since asus switches chipsets within the same model), but there is an active group of people using Debian on these machines.

  4. Very new as in currently needs patches to the Linux kernel.

  5. These seem to be end-of-lifed; stock is very limited. Price is for a six cell battery for better comparison; 9-cell is about $50 more.

Posted Sat 08 Aug 2009 12:03:00 PM Tags: /tags/linux

OK, so tell me if you think this is a graceful failure mode. I have some logfiles owned by a non-root user, with a non-default group (mail). Logrotate is running as that user. Logrotate wants to preserve the group, but can't (which is lame to start with, since chgrp manages fine). OK, I don't really care what group owns the log files I think to myself, on to more pressing things like writing rants in my blog. Some months later I notice that when the chown fails, logrotate compresses my file to zero bytes.. For those of you who slept through information theory, that means the file is toast.

The upshot is I have acquired an inexplicable interest in alternatives to logrotate. In no particular order, I noticed

Also, I learned about the rm command, which duplicates the functionality of logrotate, but is much easier to configure.

Posted Fri 06 Jun 2008 12:00:00 AM Tags: /tags/linux

I could not find any nice examples of using the vobject class to filter an icalendar file. Here is what I got to work. I'm sure there is a nicer way. This strips all of the valarm subevents (reminders) from an icalendar file.

import vobject
import sys

cal=vobject.readOne(sys.stdin)

for ev in cal.vevent_list:
    if ev.contents.has_key(u'valarm'):
       del ev.contents[u'valarm']

print cal.serialize()
Posted Sun 01 Jun 2008 12:00:00 AM Tags: /tags/linux

To convert an svn repository containing only "/debian" to something compatible with git-buildpackage, you need to some work. Luckily zack already figured out how.

#

package=bibutils
version=3.40
mkdir $package
cd $package
git-svn init --stdlayout --no-metadata svn://svn.debian.org/debian-science/$package
git-svn fetch
# drop upstream branch from svn
git-branch -d -r upstream

# create a new upstream branch based on recipe from  zack
# 
git-symbolic-ref HEAD refs/heads/upstream
git rm --cached -r .
git commit --allow-empty -m 'initial upstream branch'
git checkout -f master
git merge upstream
git-import-orig --pristine-tar --no-dch ../tarballs/${package}_${version}.orig.tar.gz

If you forget to use --authors-file=file then you can fix up your mistakes later with something like the following. Note that after some has cloned your repo, this makes life difficult for them.

#!/bin/sh

project=vrr
name="David Bremner"
email="bremner@unb.ca"

git clone alioth.debian.org:/git/debian-science/packages/$project $project.new
cd $project.new
git branch upstream origin/upstream
git branch pristine-tar origin/pristine-tar
git-filter-branch --env-filter "export GIT_AUTHOR_EMAIL='bremner@unb.ca' GIT_AUTHOR_NAME='David Bremner'" master upstream pristine-tar
Posted Fri 23 May 2008 12:00:00 AM Tags: /tags/linux

I am in the process of migrating (to git) some debian packages from a subversion repository created with svn-inject -l 2, namely

/trunk/package 
/branches/upstream/package/ 
/tags/package

Here is a script I wrote that seems to do the trick

#!/bin/sh

package=$1
stage=$1.from-svn
set -x
# my debian packages live under $SVNROOT/debian, with layout 2
mkdir $stage
cd $stage
git-svn init --no-metadata \
    --trunk $SVNROOT/debian/trunk/$package \
    --branches $SVNROOT/debian/branches/upstream/$package \
    --tags $SVNROOT/debian/tags/$package 
git-svn fetch 
git branch -r upstream current
 cd ..
# git clone --bare loses some gunk from git-svn. Anyway we need a bare repo
git clone --bare $stage $1.git

rm -rf $stage

Your mileage may vary of course.

UPDATED Apparently 'git branch -r upstream current' no longer works, if it ever did. If anyone can psychically figure out what I wanted to do there, I'm happy to translate that into git.

Posted Sat 01 Mar 2008 12:00:00 AM Tags: /tags/linux

So you have a pdf form, and you want to fill it in on linux. You hate acrobat reader. Ok, so all six of you read on.

First install pdftk. If you are using debian,

apt-get install pdftk

If you are not using debian, first install debian :-).

Now you need a pdf file with form data. We suppose for the sake of argument that your file is foo.pdf. Try

pdftk foo.pdf dump_data_fields

Yes, the order of arguments is goofy. You should get some output that looks like

FieldType: Text
FieldName: M3
FieldFlags: 4194304
FieldJustification: Left
---
FieldType: Text
FieldName: D3
FieldFlags: 4194304
FieldJustification: Left

M3 and D3 are your field names. Now get my script which can convert this output into something useful. At this point you may want to reconsider how much you hate acrobat. Or investigate okular. Assuming you are still here, run

pdftk foo.pdf dump_data_fields | perl fields2pl.pl > foo.pl

This will give you a template that you can fill in. If you have to fill out the same form many times (e.g. an expense form), save this template somewhere. Now to fill in your form, you need a FDF file. One way to make one is to edit the template I made you create above, and then convert it to FDF. First install the FDF converter.

apt-get install libpdf-fdf-simple-perl

Now use something like genfdf.pl to make an fdf file.

perl genfdf.pl foo.pl > foo.fdf

You are almost there. To actually fill in the form, you use the command

pdftk foo.pdf fill_form foo.fdf output filled.pdf

If you do this all many times, consider making a Makefile. Here is a fragment

.SUFFIXES: .pdf .fdf .csv .gnumeric .pl


.fdf.pdf:
    pdftk Expenses.pdf fill_form $< output $@ 


.pl.fdf:
    genfdf.pl $< > $@


example.pdf: example.fdf
example.fdf: example.pl
Posted Sun 06 Jan 2008 04:09:00 PM Tags: /tags/linux

Like several people out there, I wanted to have user (non-root) scripts run when NM changed state.

I decided to write a quick python script to snoop the dbus, and call a function when an interface is brought up or down. Maybe somebody else will find this useful.

Instead of a director of scripts, just place a file called .nmdispatchrc in the home directory, containing python code which defines functions ifup and ifdown. e.g.

:def ifup(interface,*args)

   print 'interface '+interface 'brought up'

:def ifdown(interface,*args)

   print 'interface '+interface+ ' brought down'

The actual daemon is only slightly longer than the MIT license it is distributed under. You are looking at the only known documentation. You will need dbus-python

Posted Thu 13 Dec 2007 07:27:00 AM Tags: /tags/linux

Another sad software story, with a happy ending.

  • pushmi provides a read/write mirror of an svn repository.

  • My repository is svn+ssh://, which normally works fine with ssh-agent.

  • Unfortunately pushmi relies on svn hooks to update the master repository, and svn in its wisdom does not preserve any environment variables, thus making ssh-agent not work very well.

  • A solution is to install the package keychain, which writes the ssh-agent environment variables out to disk (this sounds trivial, but it also finds the running ssh-agent without any configuration).
  • to both $REPOSITORY/hooks/pre-commit and $REPOSITORY/hooks/post-commit, add the following snippet to the beginning of the script

      KEYCHAINFILE=/home/bremner/.keychain/`hostname`-sh
      if [ -f $KEYCHAINFILE ]; then
        . $KEYCHAINFILE
      fi
    
  • You might need to adjust the path if you are not me.

  • UPDATED You need the option --inherit local or --inherit all to keychain to get it to overwrite the previous version of its files.

Posted Mon 10 Sep 2007 06:39:00 PM Tags: /tags/linux

OK, this is just lame, and I don't mean the software. Following a post by /merrikson/ on amarok forums, I had to edit the mp3 profile in

~/.kde/share/apps/amarok/scripts-data 

so that it read

[Amarok TTMD - mp3]
encode_type=FAAC
extension=m4a
naming_scheme=/tmp/kde-bremner/transkode-%{artist}-%{title}.%{dst_ext}
show=false
switches=-q 100

Now amarok thinks its transcoding files to mp3 for my ipod (why do people want this?) but is really using m4a. I've submitted a feature request to make this less lame.

Posted Sat 08 Sep 2007 09:09:00 AM Tags: /tags/linux

I recently downloaded (and paid for!) some audio files in flac format. These files had malformed metadata: it turns out that the flac standard requires the STREAMINFO block to be first, but these files had album cover art as the first metadata block. This causes difficulties for many programs; in particular it makes it difficult to fix the metadata because /metaflac/ does not want to delete the first block. I finally worked around the problem by recompressing the files. Since /flac/ is lossless, this is not such a tragedy as it is with e.g. mp3 or most video codecs. Here is the script.

#!/bin/sh



temp=`mktemp reflacXXXXXX`
bak=$temp-"$1".bak
cp "$1" "$bak"


metaflac --no-utf8-convert --export-tags-to=$temp.tags  "$bak"
metaflac --export-picture-to=$temp.pic "$bak"
flac --silent -d -o - "$bak" | flac -o $temp.flac -
metaflac --no-utf8-convert --import-tags-from`$temp.tags --import-picture-from`$temp.pic $temp.flac
mv $temp.flac "$1"
rm $temp.tags $temp.pic
rm $temp

Update

: added --no-utf8-convert

Posted Thu 06 Sep 2007 10:14:00 PM Tags: /tags/linux

Suspend to disk works ok out of the box, if you type (as root)

  echo -n disk > /sys/power/state

I like the command line and all, but somehow this is a bit tedious. To get Fn-F12 working, one has to first load the thinkpad-acpi module

modprobe thinkpad-acpi

Next, one has to enable the hotkey subdriver

echo enable > /proc/acpi/ibm/hotkey

These two steps can be automated by creating /etc/acpi/start.d/40-thinkpad-acpi.sh Finally, workaround a problem with the default /etc/acpi/hibernatebtn.sh. For some reason, acpi_fakekey is not doing its magic thing, so I replaced it with a call to hibernate.sh. There are already some bug reports about this in debian. Now that we enabled thinkpad-acpi hotkeys, we have to the same hack to /etc/acpi/sleepbtn.sh

Be warned, this will may not play nicely with the kde/gnome gui suspend/resume tools

Posted Wed 29 Aug 2007 04:14:00 AM Tags: /tags/linux

First install the firmware:

 apt-get install firmware-iwlwifi

Next, rebuild the kernel and reboot (this is not strictly necessary, but it is what I did; other people can tell you other ways), so that you have the source for the kernel you are currently running available.

Download the latest kernel module source from intellwireless.org

Unpack, make (probably twice) su, make install

Update

To avoid recompiling your kernel, you can follow the steps from Stuart Prescott

Posted Tue 28 Aug 2007 07:47:00 PM Tags: /tags/linux

Calm down, then type (as the other user) xhost +local:root

Posted Tue 28 Aug 2007 07:34:00 PM Tags: /tags/linux

Out of the box, it will go to sleep (suspend to ram) when you hit Fn-F4, but on wakeup the backlight.
Based on a Ubuntu bug report (which I've now lost track of) that mentioned switching virtual terminals turned the backlight back on, I created /etc/apci/resume.d/99-switchvt.sh to automate that Not the most beautiful solution in the world, but it works. I have submitted a [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439914][debian bug]]

  • UPDATED Another workaround is to add the kernel parameter
    acpi_sleep=s3_bios
Posted Tue 28 Aug 2007 05:24:00 PM Tags: /tags/linux

(lenny/sid) on a thinkpad x61. Initially I was running the stock 2.6.22-1-686 kernel; to get wifi going I decided to rebuild the kernel. I have installed the acpi-support package, which then requires some hacking. The various issues are tagged x61

Posted Tue 28 Aug 2007 03:43:00 PM Tags: /tags/linux