Archive for the ‘howto’ tag
Importing History into Git
With my recent move over to Git for my VCS Home solution I decided to start afresh with new repositories and not migrating the history over, in the last few days i’ve noted that it was a very bad decision and having the full history will always be useful. Now i’m stuck in the situation of two repos with different histories. How do you reconcile these two trees into one full history tree?
First of all we need a working Git version of your existing repo, in my case, it’s in SVN, so I used the git-svn tool to import my svn repository.
$ cd ~/dev/ $ git svn clone http://tensixtyone.com/svn/home/trunk/bash
Git then downloads each SVN commit and imports it, this can be quite slow on large repositories but thankfully mine was only 20 or so commits. Now you have your originally repository in Git format the few final steps will bring in the changes you have done in the new repository.
To import the history we are going to generate a set of diffs, while this sounds less than ideal it is really the only clean way to get your new commits into your old repository, attempting to pull the commits in will throw errors as the commit hashes will not match.
First of all you need to find out the hash of your first commit in your new repository
$ cd ~/.dotfiles/bash
$ git log
...
commit ec508803a080f2146231fb4cd396cc18a2906a9b
Author: Andrew Williams
Date: Sat Apr 11 02:32:07 2009 +0100
Imported initial bash files
Then generate the diffs since that initial commit
$ git format-patch ec508803a080f2146231fb4cd396cc18a2906a9b..HEAD 0001-Added-bash_logout-file.patch 0002-Updated-bash-config-files.patch 0003-Updated-a-few-aliases.patch 0004-Updated-prompt-to-detect-if-we-re-using-vcsh.patch 0005-Fixed-nano-alias.patch
Now you have your fresh diffs, you need to import them into your existing repository. In addition i’m importing these into a new branch.
$ cd ~/dev/bash/ $ git branch new-bash $ git am ~/*.patch
The am command is mostly used to apply patches from a mailbox but for this case we can just tell it to use the patch files instead. After the command has completed you should be able to check git log and be able to see all the new commits.
Once your happy with the patches, it’s a case of switching to master and merging the changes.
$ git checkout master $ git merge new-bash
One thing to note, after this process the commits will have different hashes, so it wont be a simple case of pushing to your remote repo. I’d only recommend doing this if you have to, i’m sure that a better proceedure exists but this is what worked for me.
Howto: Send SMS using a Huawei E160G and Debian
People who use their Huawei E160G on Three will know that in the Windows client you can send and receive SMS, this will come at some minor cost of £0.10 per SMS, and you can add bundles onto your mobile broadband account to make this cheaper.
Similar functionality can be achieved in Linux, and it’s very useful if your like me and want to drop someone a message when you don’t have your phone around.
For this we’ll be using Gammu, which is a toolset for managing phones via the AT GSM command set. It was originally forked from Gnokii, which was a similar toolset for Nokia handsets. As the E160G opens a serial port with access to the AT command set this is a relatively easy tool to setup.
First of all, we need to grab the packages. As these are standard Debian packages you should have no issues.
# sudo apt-get install gammu
Next, we need to configure Gammu to pickup the correct device. Check your dmesg for the serial port:
$ dmesg|grep tty [12321.308078] usb 5-3: GSM modem (1-port) converter now attached to ttyUSB0 [12321.308275] usb 5-3: GSM modem (1-port) converter now attached to ttyUSB1
Edit ~/.gammurc, or run gammu-config to change the device settings. Your ~/.gammurc file should look similar to:
[gammu] port = /dev/ttyUSB0 model = connection = at19200 synchronizetime = yes logfile = logformat = nothing use_locking = gammuloc =
Give it a test by getting all the SMS from the device:
# gammu getallsms
This should bring back all the SMS currently stored on the stick, which should include your login details for the Three website (unless you’ve deleted them). To send a SMS use the “sendsms” command:
$ gammu sendsms text 07874454543 Enter message text and press ^D: Test Message!!!!!1! Sending SMS 1/1....waiting for network answer..OK, message reference=2
Gammu has a lot more tools and options to explore, now you have the basic config you can setup a SMSD, which can expose the ability to send SMS to a network. Also, Gammu has a python interface so you can possibly build your own frontend client for sending SMS. For more details explore the Gammu Wiki.
Dropbox on Debian
Dropbox is out of closed beta and is open for the public, but what is more interesting is that they now have a client for Linux. I’ve had a beta email sat in my inbox for about 3-4 months, but I’ve never got round to signing up as I couldn’t get a client for Linux.
Dropbox is one of the new wave of online storage, sort of a cross between WebDAV and SVN, in fact, I’d say its almost exactly like SVN, just with a nice GUI. I guess all it would need to take the “value-added” part of this product is for someone to develop a nice front end for Amazon S3, and by looking at their future prices it could be cheaper.
Anyway, picking out the bits of the service is not what I’m here to do. At the moment I run a Debian Testing/Unstable desktop machine, I was quite disappointed to not see a specific Debian package for their software on the website. I realised after a few dumb minutes that I could use the Ubuntu packages.
In sources.list, I referenced their Gusty archive
deb http://www.getdropbox.com/static/ubuntu gutsy main
Then in /etc/apt/preferences I set some basic package pinning to make sure that any packages didn’t collide with the existing Debian repository, not likely but you never know.
Package: * Pin: release a=gutsy Pin-Priority: 400
Do a “apt-get update” and you should have the “nautilus-dropbox” package available to install. Simple!
Remember, you’ll need to restart nautilus by either killing it (killall -9 nautilus) or restarting your Gnome session.
[edit: Fixed the first URL]
Howto: Debian Lenny & Huawei E160G
So, in my last post I described how it was using the E160G with Debian. All in all it’s very good and i’ve not experienced any major issues, bar a few minor apt-get and NetworkManager issues. So, heres a quick rundown of how to get it on your machine.
So first, you need to get the hardware to work correctly under Debian. Plug in your E160G and check dmesg to see if the device recognises correctly. If you see ttyUSB0/ttyUSB1 appear you can skip this step.
First, you need to download USB_Modeswitch:
# wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-0.9.4.tar.bz2 # tar jxvf usb_modeswitch-0.9.4.tar.bz2 # cd usb_modeswitch-0.9.4/ # ./compile.sh
Now you have the usb_modeswitch program, as this will be executed by udev it needs to be in a sensible location, personally i’d copy it to /usr/local/sbin/
# cp usb_modeswitch /usr/local/sbin/
Also, you need to grab the latest config file from the usb_modeswitch website and put it into /etc
# wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch.conf # sudo mv usb_modeswitch.conf /etc/
Now, by default the config file comes with the section commented out, so edit the file and uncomment the section for the E220 (which is essentially the same device).
# sudo $EDITOR /etc/usb_modeswitch.conf
One last step, you need to add a small configuration file to udev to detect the E160G and run usb_modeswitch, put this file in you /etc/udev/rules.d/ folder:
SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1",
RUN+="/usr/local/sbin/usb_modeswitch"
Restart udev, and plug in your E160G…
sudo /etc/init.d/udev restart
and you should see something similar to:
[ 16.085904] usb 5-3: GSM modem (1-port) converter now attached to ttyUSB0 [ 16.086033] usb 5-3: GSM modem (1-port) converter now attached to ttyUSB1
So, the device is detected and you have your USB ports, first a quick overview. The E160G shows two serial ports, one is a data port, the other is for control signals. NetworkManager only makes use of one of these ports but the Vodafone Connection Manager uses both. Now you have a choice, install Network Manager 0.7 to gain native GPRS/UMTS data support or use another package. I went for Network Manager, while it’s still in beta and i’ve had a few run-ins in the past with it I decided to give it a go.
So, it was a simple case of adding the 0.7 repositories to /etc/apt/sources.list, updating, then installing the needed packages.
# echo "deb http://debs.michaelbiebl.de/ unstable main" >> /etc/apt/sources.list # apt-get update # apt-get -t unstable install network-manager
You might need to remove any old Network Manager packages before you do this, as network-manager-openvpn collides with the new package.
Hopefully thats give you the overview you needed, and you should be up and running!
Using DVD Decrypter on Ubuntu/Wine
I’ve recently tried to get DVD Decrypter working on Wine, it may seem simple at first, i assure you, its not. Here’s a few quick steps to get you going in the right direction.
- Install DVD Decrypter (wine SetupDVDDecrypter_3.5.4.0.exe)
- Run winecfg, and add the installed DVD Decrypter as an application and set the version to NT4
- Go to the Drives tab and hit Autodetect
- Remove any unwanted drives but leave your CD drive (should be /media/cdrom0)
- Select the CD drive letter from the Drive Mappings box and click Show Advanced
- Change Type to CD-ROM and click OK
- Open a shell and go to your local wine config dosdevices (.wine/dosdevices)
- You should have a existing link for your CD-ROM, now make a softlink for that letter to your physical device, but put a extra colon after the drive letter. (ln -s /dev/hdc g::)
- Fire up DVD Decrypter, in the Settings and I/O tab, switch it to SPTI and tick on Show All Devices.
Bar a few minor errors you should detect the drive and be able to use it. This will also work for CrossOffice, but the config directory will be slightly different (.cxoffice/bottlename/)
