Using gtkpod with an iPhone or iPod Touch in Debian

You will need to initialize your iphone/ipod-touch with iTunes on Mac or Windows and transfer at least one track first.

Make sure there are deb-src lines in your /etc/apt/sources.list for your main deb lines.

Install some packages:

sudo apt-get build-dep gtkpod
sudo apt-get build-dep libgpod
sudo aptitude install build-essential git stow ifuse libusb-1.0-0-dev libimobiledevice-dev libplist-dev

Build and install libgpod:

git clone git://gtkpod.git.sourceforge.net/gitroot/gtkpod/libgpod libgpod
cd libgpod
sh ./autogen.sh
make
sudo make install

You can make uninstall to remove it later when needed, don't remove the source directory.

Make sure your user LD_LIBRARY_PATH lists /usr/local/lib before /usr/lib. It should look something like this:

export LD_LIBRARY_PATH=~/lib:/usr/local/lib:/lib:/usr/lib

Build and install gtkpod:

git clone git://gtkpod.git.sourceforge.net/gitroot/gtkpod/gtkpod gtkpod
cd gtkpod
sh ./autogen.sh
make
sudo mkdir -p /usr/local/stow/gtkpod-git
sudo make install prefix=/usr/local/stow/gtkpod-git
sudo rm /usr/local/stow/gtkpod-git/share/icons/hicolor/icon-theme.cache
(cd /usr/local/stow; sudo stow gtkpod-git)

Use stow -D to uninstall later.

Connect your iphone via USB and mount it:

mkdir ~/mnt
ifuse ~/mnt/ipod

You can unmount with fusermount -u ~/mnt/ipod.

Now you need your iphone firewire ID. In the sudo lsusb -v output, for the Apple, Inc. device, look for the second number following iSerial, it should look something like 1dfb33113eff41bc1e99ef98b0cb103a02322c4c .

Create this directory on your iphone:

mkdir ~/mnt/ipod/iTunes_Control/Device

Now set up the "extended sys info:"

/usr/local/bin/ipod-read-sysinfo-extended 1dfb33113eff41bc1e99ef98b0cb103a02322c4c ~/mnt/ipod

Use the firewire ID you got earlier, not the one in the example!

Now launch gtkpod and select your model; transferring music should work properly.

Big thanks to teuf on freenode #gtkpod (Christophe Fergeau) for helping me get this to work.

1 comment | Read more...

Last modified: 2010-6-7 (月) at 6:27 pm

Installing Informix on Linux

Here I'll go through the steps to install the Informix (http://www.informix.com/) RDBMS on Linux.

This guide is based on http://webxpert.wordpress.com/how-to-install-informix-dynamic-server-in-redhat-linux/.

Download Informix

On the informix website go to: Support & Downloads -> Downloads -> Trials and Demos

Under I click on Informix Dynamic Server.

Download either IBM Informix Dynamic Server Express Edition or IBM Informix Dynamic Server Developer Edition.

Create Informix User and Group

addgroup informix
adduser --ingroup informix informix

Run GUI Installer

Extract the tarball, then as root (with a working X $DISPLAY) run:

./ids_install -gui -javahome none

Choose /home/informix as the installation path.

Do not create the sample database, it will likely fail anyway, we will do that later.

Configure 'informix' User Environment

Log in as the informix user:

sudo su - informix

Edit the .bashrc and add the following at the bottom:

export INFORMIXDIR=/home/informix
export INFORMIXSERVER=demo_on
export ONCONFIG=onconfig
export INFORMIXTERM=terminfo

Relogin.

Configure Informix

Copy etc/onconfig.std to etc/onconfig and make the following changes:

--- onconfig.std        2009-04-14 23:02:02.000000000 -0400
+++ onconfig    2010-03-26 04:00:41.000000000 -0400
@@ -40,11 +40,11 @@
 ###################################################################
   

 ROOTNAME rootdbs
-ROOTPATH $INFORMIXDIR/tmp/demo_on.rootdbs
+ROOTPATH /home/informix/dbspaces/online_root
 ROOTOFFSET 0
 ROOTSIZE 200000
 MIRROR 0
-MIRRORPATH $INFORMIXDIR/tmp/demo_on.root_mirror
+MIRRORPATH /home/informix/mirrors/root_mirror
 MIRROROFFSET 0
   

 ###################################################################
@@ -123,7 +123,7 @@
 # CONSOLE      - The path of the IDS console message file
 ###################################################################
   

-MSGPATH $INFORMIXDIR/tmp/online.log
+MSGPATH /home/informix/logs/online.log
 CONSOLE $INFORMIXDIR/tmp/online.con
   

 ###################################################################
@@ -198,7 +198,7 @@
 ###################################################################
   

 SERVERNUM 0
-DBSERVERNAME 
+DBSERVERNAME demo_on
 DBSERVERALIASES
   

 ###################################################################
@@ -398,7 +398,7 @@
 #                positive integral multiple of LTAPEBLK.
 ###################################################################
   

-LTAPEDEV /dev/tapedev
+LTAPEDEV /dev/null
 LTAPEBLK 32
 LTAPESIZE 0

Copy etc/sqlhosts.std to etc/sqlhosts and add the following line:

demo_on         onipcshm        localhost           demo_on

Change localhost to the host name of the machine.

Make some directories and files:

cd ~
mkdir dbspaces mirrors logs
cd dbspaces
touch online_root
chmod 660 online_root

Create and start the instance:

oninit -iv

To optionally create a sample database, run dbaccessdemo7 or dbaccessdemo9.

Starting and Stopping

To start the instance, run:

oninit

To stop, run:

onmode -ky

I'll provide an init script once I write one.

Create a Database

The sample database is not created with logging, this makes it not very useful for use with e.g. DBD::Informix.

To create a database, first log in as informix and run the dbaccess command.

Go to Database -> Create, type in the name you want; then go to Log -> Buffered_log; then Exit -> Create-new-database .

Configure your User Environment

In your .bashrc or whatever, put:

export INFORMIXDIR=/home/informix
export INFORMIXSERVER=demo_on
export INFORMIXTERM=terminfo
export DBD_INFORMIX_DATABASE=stores_demo
export DELIMIDENT=y

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/informix/lib:/home/informix/lib/esql
export PATH=$PATH:/home/informix/bin

You can now use the dbaccess command as a shell to run SQL queries. Unfortunately, it's a menu-driven program.

Build DBD::Informix for Perl

With the environment set as above, just install DBD::Informix as normally from CPAN. Or just perl Makefile.PL; make; sudo make install. The DBD_INFORMIX_DATABASE environment variable should be set to a database that exists, you have stores_demo if you ran dbaccessdemo7 or 9.

Verify that it works:

perl -MDBI -le 'my $dbh = DBI->connect("dbi:Informix:stores_demo", "", ""); print for $dbh->selectrow_array("select today from sysmaster:sysdual")'

Replace stores_demo with the name of the logged database you created earlier.

Setting up TCP Connection Support

This information taken from http://database.itags.org/informix/57440/.

Login as the user informix.

Edit etc/onconfig.

Find the DBSERVERALIASES line and change it to:

DBSERVERALIASES hlaghdb_tcp

Edit etc/sqlhosts and add the line:

hlaghdb_tcp    onsoctcp    localhost    informix_tcp

replace localhost with your hostname.

As root, edit /etc/services and add:

informix_tcp   33333/tcp

or whatever port you want to use.

Restart informix:

onmode -ky
oninit

Your DBI DSN becomes:

dbi:Informix:hlaghdb@hlaghdb_tcp

SQL Shell

You can use the dbaccess program to run SQL statements against your DBs, but it's some sort of very cumbersome, ancient terminal GUI.

I use the DBI::Shell CPAN module: http://search.cpan.org/perldoc?DBI::Shell.

Unfortunately DBI::Shell does not have history support, so I use rlwrap to add one.

Putting it all together:

alias informix="rlwrap -a -N -t dumb -i -f ~/.informix_dbish_history -H ~/.informix_dbish_history -s 30000 dbish dbi:Informix:hlaghdb@hlaghdb_tcp"

Statements end with ; like in SQL*Plus, use /quit to quit. Readline uses emacs keybindings by default, but you can change this in your ~/.inputrc.

no comments | Read more...

Last modified: 2010-5-17 (月) at 9:19 pm

DB2 Init Script

Here's an init script you can use for DB2 Express-C (maybe other versions.)

You can download the free database at:

http://www-01.ibm.com/software/data/db2/express/download.html

To create a database just:

sudo su - db2inst1
db2 CREATE DATABASE foo PAGESIZE 32768

This will take quite a while. The PAGESIZE is recommended by waveform on freenode #db2.

The init script:

#!/bin/sh
#
# Startup script for DB2 Personal Edition
# 
# description: DB2 RDBMS System
# processname: dataserver

DB2_USER=db2inst1

# Find the name of the script
NAME=`basename $0`

# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
        SU=runuser
else
        SU=su
fi

# Find home
DB2_HOME=`$SU $DB2_USER -c 'echo \$HOME'`

start() {
    DB2_START=$"Starting ${NAME} service: "

    $SU $DB2_USER -c '. $DB2_HOME/sqllib/db2profile; \
        $DB2_HOME/sqllib/adm/db2start > /dev/null'

    ret=$? 
    if [ $ret -eq 0 ]
    then
            echo "$DB2_START Success."
    else
            echo "$DB2_START Failed!"
            exit 1
    fi
    echo
}

stop() {
    echo -n $"Stopping ${NAME} service: "

    $SU $DB2_USER -c '. $DB2_HOME/sqllib/db2profile; \
        $DB2_HOME/sqllib/adm/db2stop > /dev/null'

    ret=$?
    if [ $ret -eq 0 ]
    then
            echo "Success."
    else
            echo "Failed!"
            exit 1
    fi
    echo
}

restart() {
    stop
    start
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac
exit 0

2 comments | Read more...

Last modified: 2010-2-3 (水) at 2:16 am

Sybase SQL Anywhere

I will briefly discuss setting up the development version of Sybase SQL Anywhere (ASA) on linux (or similar) and using it with Perl.

You can download it from:

http://www.sybase.com/detail?id=1016644

Go through the install process, and make a separate user for it (e.g. sybase-asa).

In the .bashrc for the user, add:

. /opt/sqlanywhere11/bin32/sa_config.sh 

Change to that user, and now lets create a database:

mkdir logs
dbinit -t ./logs/hlaghdb.log -p 4096 -dba DBA,SQL hlaghdb.db

This sets the username to DBA and the password to SQL.

Let's make an init script. Note that you should not install the init script to run automatically because of the obnoxious agree to license prompt on startup, use it as just a utility for starting the database. Edit the part at the top.

#!/bin/sh
#
# Startup script for Sybase SQL Anywhere
# 
# description: Sybase SQL Anywhere RDBMS System
# processname: dbsrv11

ASA_USER=sybase-asa
ASA_BIN=/opt/sqlanywhere11/bin32/
DB_FILE=hlaghdb.db
SRV_NAME=ASA

# Find the name of the script
NAME=`basename $0`

# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
        SU=runuser
else
        SU=su
fi

# Find home
ASA_HOME=`$SU $ASA_USER -c 'echo \$HOME'`

start() {
    ASA_START=$"Starting ${NAME} service: "

    $SU $ASA_USER -c ". $ASA_BIN/sa_config.sh; $ASA_BIN/dbsrv11 -ud -n $SRV_NAME $ASA_HOME/$DB_FILE"

    ret=$? 
    if [ $ret -eq 0 ]
    then
            echo "$ASA_START Success."
    else
            echo "$ASA_START Failed!"
            exit 1
    fi
    echo
}

stop() {
    echo -n $"Stopping ${NAME} service: "

    pkill dbsrv11

    ret=$?
    if [ $ret -eq 0 ]
    then
            echo "Success."
    else
            echo "Failed!"
            exit 1
    fi
    echo
}

restart() {
    stop
    start
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac
exit 0

SQL Anywhere comes with a GUI and a Curses SQL shell, named dbisql and dbisqlc respectively.

Since it uses the TDS protocol, you can also use the ASE isql with rlwrap or the freely available sqsh utility.

To use sqsh, first set the SYBASE environment variable to some directory, for example $HOME/sybase. In that directory make a file called interfaces that contains the following:

ASA
        master tcp ether localhost 2638
        query tcp ether localhost 2638

Then to connect use:

sqsh -S ASA -D hlaghdb -U DBA -P SQL

statements are executed by typing go on a new line. To quit type quit on a new line.

To make a non-DBA user, use the following commands in a SQL shell:

grant connect to hlagh identified by dongs
grant resource to hlagh

Now install the DBD::SQLAnywhere perl driver.

Source the sa_config.sh and make a copy of the /opt/sqlanywhere11/sdk/perl directory. Change to the directory and:

perl Makefile.PL
make
sudo make install

Do not use the DBD::SQLAnywhere on CPAN, it is outdated and doesn't work.

Add /opt/sqlanywhere11/lib32 to your LD_LIBRARY_PATH, and try connecting from DBI:

perl -MDBI -le 'my $dbh = DBI->connect(
  "dbi:SQLAnywhere:ASA", "DBA", "SQL"); \
  print for $dbh->selectrow_array("select 42")'

DBIx::Class support for both the DBD and via DBD::ODBC is available in the current version.

DBIx::Class::Schema::Loader support is available as of version 0.05002.

To use with unixODBC, add the following to /etc/odbcinst.ini:

[SybASA]
Description = Sybase SQL Anywhere
Driver = /opt/sqlanywhere11/lib32/libdbodbc11.so
Setup = /opt/sqlanywhere11/lib32/libdbodbc11.so
FileUsage = 1

There are also _r versions of the drivers in that directory, these are the threaded libraries.

Then to connect from Perl:

perl -MDBI -le 'my $dbh = DBI->connect( \
  "dbi:ODBC:driver=SybASA;ENG=ASA", \
  "DBA", "SQL"); \
  print for $dbh->selectrow_array("select 42")'

no comments | Read more...

Last modified: 2010-2-15 (月) at 10:59 am

DBIx::Class::Schema::Loader 0.05000

DBIx::Class::Schema::Loader current, more than a year in the making, is finally out in an official release:

http://search.cpan.org/~rkitover/DBIx-Class-Schema-Loader-0.05000/lib/DBIx/Class/Schema/Loader.pm

It:

  • makes nicer relationship names
  • singularizes class names for tables
  • supports more databases (MSSQL and Sybase ASE)
  • generates more accurate column data, moreso for some of the backends like Pg and Sybase than others, but still more accurate for all backends than 0.04006.
  • uses might_have instead of has_many for FKs to a unique constraint
  • generates POD also incorporating COMMENT metadata for Pg
  • has full backward compatibility and upgrade/downgrade code
  • various improvements for the backends
  • conversion of the repo to git thanks to ilmari (doing the conversion) and nothingmuch (for git-svn-abandon). The new repo is at:

    http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class-Schema-Loader.git;a=summary

Some of the things on the TODO list for later in the 0.05 series:

  • accurate data_type/size/default_value for all backends (currently true for Pg and Sybase.)

    This should allow schemas to round trip through SQLT ->deploy.
  • options for timezone and locale, for better InflateColumn::DateTime support (which will be available through the Catalyst helper.)
  • introspecting COMMENT metadata for POD for backends other than Pg
  • Sybase SQL Anywhere (ASA) support, possibly other new backends (Informix, Firebird ...)
  • making ::View classes for views with the defining SQL so they can be properly deployed
  • going through the huge RT queue
  • optimizing things (dumping e.g. a large mssql schema can take hours I hear.)
  • lots of other misc. crap (like refactoring my horrible backcompat tests.)

Longer term, we'd like to eventually merge some of the functionality of the new SQL::Translator Justin Hunter (arcanez) is working on with the loader (and vice-versa.)

The Catalyst tutorial should be updated soon to make use of the new Loader and SQLite foreign keys (though the current version will work just fine.)

4 comments | Read more...

Last modified: 2010-2-3 (水) at 12:36 am