Thursday, 15 March 2012

Star Wars: The Old Republic under Linux & Mac OS X!

Finally, SWTOR is playable under most Linux distributions, including Ubuntu, Debian, Arch Linux, Gentoo and even Mac OS X.

It seems that newer version of gcc (4.6.x) would not allow us to compile wine properly. That's why I've made a package on the AUR called gcc45-multilib (Mainly for Arch Linux x86_64 users, but you can use this in another distro as well by simply downloading all the tarballs and running ./configure and make).

If you use Arch Linux x86, you can simply use gcc45 package from the AUR.

1) To get things started, first get a hold of wine's source from git:

$ git clone git://source.winehq.org/git/wine.git ~/wine-git
$ cd ~/wine-git

2) Then download this patch and apply it (thanks to Carsten):

$ wget bugs.winehq.org/attachment.cgi?id=39208 -O proof_of_concept.patch
$ cat proof_of_concept.patch |patch -p1

3) Almost ready. Now you need to download and install the older version of gcc. If you're on a different distribution, downgrade your gcc to version 4.5.2-3 for this. If you're on arch, you can simply install

on x86: 'gcc45' package from AUR
on x86_64: 'gcc45-multilib' package from AUR

4) Now time to compile using this older version of gcc:

$ cd ~/wine-git
$ ./configure --prefix=/opt/wine CC=gcc-4.5.2 CXX=c++-4.5.2 CPP=cpp-4.5.2
$ sudo make

Depending on your system, this will take anywhere from 20 minutes up to an hour.

5) Finally when compiling is done, cd into swtor directory and launch the new version of wine (assuming you've already installed the game. If not you can simply cd into the windows directory of the game):

$ cd ~/.wine/drive_c/Program\ Files/Electronic\ Arts/BioWare/Star\ Wars\ -\ The\ Old\ Republic/
$ $HOME/wine-git/wine explorer /desktop=SWTOR,1024x768 launcher.exe

If you want a better resolution, change the line above to the desired value.

Later

Tuesday, 28 February 2012

Clevo laptops & Linux

In 2008 I believe I made the worst purchase of my life. Yet.

If you can't be bothered reading, tldr;

A Greek company called "Plaisio" produces the so called "Turbo-X" laptops, which are manufactured by Clevo. The only thing that attracted me to this at the time was it's incredibly low price, compared to the hardware it had. At the time laptops with an nvidia 9xxxGT graphics card, a Core 2 Dual processor and 4 gigs of DDR2 ram would cost more than 1300 euro, but this one cost 700ish.

After I became familiar with Linux, and turned into sort of a linux fanboi, I decided I wanted to install linux on my laptop. The easiest choice at the time was Ubuntu (7.10 or 8.04, can't remember which one).

(Note: I searched on forums even a while ago, and I don't think anybody cared enough to try and install linux on those machines yet).

And so the hazzard began:
  1. Booting from a flash drive was never supported by this laptop, up until today. Neither company ever cared to upgrade the BIOS and support USB booting. Only options were DVD drive, network boot and regular HDD boot.
  2. Burned ubuntu on a cd, tried to boot from it. No luck. As soon as any graphics (apart from a virtual termianl) was needed, kernel panics. I asked for support from both companies, and they simply claimed their laptops do not support linux, only Windows Vista.
  3. Disappointed and with limited knowledge at the point, I decided to give up on the idea of having linux on my laptop. The laptop came with a 1 year warranty, and roughly 20 months after I bought it the screen's "panel" broke, making the laptop unusable and the repair would cost 300 euro. Completely pissed at them for this, I decided to just go for a proper laptop from an actual tech company, such as HP.
A few months ago, I decided to see how this old laptop would now run. Windows Vista took a few minutes to completely start, so I decided to try once again and work my way into installing linux on this laptop I hated so much, because I needed a web server machine (it's specs are way good for a simple webserver). This time I decided to go with my current favourite linux distro, Arch Linux.

Burnt a CD with the < 200 MB archlinux iso, which also has no graphics pre-installed. Everything is done through terminals. This helps a lot in this case, as the graphics seemed to be messing up everything. After I installed everything, I also installed the Open Source nvidia drivers, Nouveau. As soon as I rebooted, kernel panics were happening and there was nothing I could do but re-install (could not chroot either, as something was way messed up).

This time, I decided to take the hard drive off this horrible laptop, and put it on my HP laptop, install everything and put it back into the old laptop.

Everything worked just fine. I installed nvidia's proprietary drivers, I had to do a bit of debugging and regenerate my boot image with some modules that were somehow missing. The laptop uses KDE 4.6, and is completely stable. If only I had known of Arch in 2008 :(

Lesson learned.

tldr; Try to install from command line, and manually install your proprietary vga drivers. If you use the opensource drivers, kernel panics.

Monday, 27 February 2012

Setting up J2ME and WTK.


Trying to develop an app for J2ME is quite a pain, as a lot of time will be spent in setting up this very outdated piece of software. In this guide I assume readers will be using a Unix based operating system, and have basic knowledge of using the terminal.

No matter what architecture you have (x86 or x64), you will need to download everything in x86. Therefore I suggest creating a new workspace if using eclipse, otherwise it will mess up with things you don't want it to.

In this guide I am assuming you use /opt/ as your base directory, but feel free to replace that with any directory.

Now, Sun's WTK only runs with a 32bit JRE, you need to manually download Sun/Oracle JRE but for x86 and extract it to a local folder.
(http://www.oracle.com/technetwork/java/javase/downloads/jre-6u31-download-1501637.html)

Then you also need to manually download Sun Java Wireless Toolkit 2.5.2_01 from sun's website and extract it. I used /opt/wtk/
(http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javame-419430.html#sun_java_wireless_toolkit-2.5.2_01b-oth-JPR)

After that, cd to ~/Downloads and:

$ chmod +x sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh
$ chmod +x jre-6u31-linux-i586.bin

so you can execute both files.

First:

$ ./jre-6u31-linux-i586.bin

and install the JRE (I installed it in /opt/bin32-jre/ ), and then

$ ./sun_java_wireless_toolkit-2.5.2_01-linuxi486.bin.sh

and follow the on-screen instructions to install the WTK. I installed the WTK in /opt/wtk/ . The WTK will ask you for your JRE directory, but it actually needs the bin directory of your jre. Therefore link it to /opt/bin32-jre/jre/bin/ , or without the final / if it doesn't work. Again, if it still gives you errors try /opt/bin32-jre/jre/ and again then without the final slash.

After you are done with the installation, you will need to make sure the correct JRE is being used. Manually edit /opt/wtk/bin/emulator and /opt/wtk/bin/ktoolbar with your favourite text editor as follows:

javapathtowtk=/opt/bin32-jre/jre/bin/

Note that you will need that last / after bin.
If either file doesn't have this variable, you will need to manually edit the path 4 lines from the bottom:

"/opt/bin32-jre/jre/bin/java" -Dkvem.home="${KVEM_HOME}" \     -Djava.library.path="${KVEM_HOME}/bin" \     -cp "${KVEM_LIB}/kenv.zip:${KVEM_LIB}/ktools.zip:${KVEM_LIB}/customjmf.     com.sun.kvem.environment.EmulatorWrapper "$@" 0

so that the beginning of the line has the exact path to your java executable, in the 32 bit JRE folder.

Finally, within eclipse (assuming you have installed JavaME plugin) you need to go to Window -> Preferences and click J2ME, then add the path to their WTK Root: /opt/wtk/ and the path to your Antenna JAR (mine was /home/silentz0r/.eclipse/org.eclipse.platform_3.6.1_1543616141/plugins/antenna.preprocessor.v2_1.7.7.jar ).

Feel free to ask any questions, Hope this helps.

Thursday, 9 February 2012

Nuked the partition table & trying to save all data.

A while ago I tried to dd an .iso on my flash drive, but of course I didn't pay attention and just copied someone else's code without even reading it, just figuring it would work :) And it did, though it worked on the wrong /dev/sdX. The result: I nuked the partition table of (first 512 bytes) of my /dev/sdb. Note that this 500GB hard drive had ALL my personal data in it, including old photos, savegames, VERY old games and backups from all my computers.


The good thing about this was that the partition with all my data was still there, but the hard drive didn't know where it started. That's when I started panicking. The only -safe- solution would be to dd an image of my hard drive to another hard drive, and try to save my partition after having a backup. The problem: I didn't have another 500GB drive. Problem officer?


The code I used to do this magical thing was:

dd if=/dev/zero of=/dev/sdX bs=512 count=1

but replacing X with b. I replaced b with X just in case someone follows my retardation and copies this as well. The above command will write 0's to the first 512 bytes of your hard drive, which is where the partition table is at (i.e. it tells the hard drive where each partition is stored).

Luckily, I only had one large NTFS partition on this hard drive, so it was easier to save.

Desperately trying to save my partition, I asked around in forums and got quite a few replies for using gpart, testdisk and more software. I decided to stick with good old parted, because I read on their page about a magical "rescue" command, which seemed like what I wanted. After a few days of agony, I figured what the hell, I'll just try parted and hope it doesn't fail me. And here's what I did:

First, fdisk -l to make sure which /dev/sdX I wanted to use (in my case /dev/sdb). After that, it was all magic. Using mklabel to make a new partition table in parted, and then using rescue with two random values that I thought were the beginning and the end of my partition. Parted then looks around those blocks to see if a partition exists. See for yourselves:


parted /dev/sdb
GNU Parted 3.0
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: /dev/sdb: unrecognised disk label
(parted) mklabel
(parted) mklabel msdos
(parted) rescue
Start? 0
End? 976773168 // This was just a random guess.
Information: A ntfs primary partition was found at 32.3kB -> 500GB. Do you want to add it to the partition table?
Yes/No/Cancel? yes
(parted) quit
Information: You may need to update /etc/fstab.


And I lived happily ever after:


fdisk -l
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f059d

Device Boot Start End Blocks Id System
/dev/sdb1 * 63 976768063 488384000+ 7 HPFS/NTFS/exFAT


Hope this helps someone save their partition after being stupid like me :)

Reinstall grub after it is overwritten.

If you have linux on a hard drive and for some reason you have overwritten grub (e.g. installed windows on a partition of the same hard drive) you will notice that grub doesn't appear at all. I had a bit of trouble re-installing legacy grub after I had to do a quick format on a windows partition, so I looked a bit into it. Following the next steps will work on most cases.

  1. Burn any linux distro that comes with a live boot option on a flash drive/cd and boot.
  2. Run fdisk -l and find  which is your root partition, which is your boot partition and which hard drive you're using (e.g. /dev/sda1)
  3. If you still have linux installed on your system, make a temp directory (e.g. /mnt/root ), and mount your root ( / ) partition on it, then mount your boot ( /boot ) partition on /mnt/root/boot (assuming you mounted the correct root partition, /mnt/root/boot will exist).
  4. mount /mnt/root/dev and /mnt/root/proc (explained later)

  5. chroot to /mnt/root

  6. reinstall grub to /dev/sdX NOT /dev/sdX1 or any other number. Grub should install on the physical drive, not on partitions.

Here's the code I use for it: (if you're not root, you will need to put 'sudo' before each command).

fdisk -l
mkdir /mnt/root
mount /dev/sda2 /mnt/root
mount /dev/sda1 /mnt/root/boot
mount -t proc none /mnt/root/proc
mount -o bind /dev /mnt/root/dev
chroot /mnt/root
grub-install --recheck /dev/sda

After that reboot and you should see grub (remove the live medium!)

Hello World

cout << "hello world" << endl;