Wednesday, November 3, 2010

Setting up Flash Builder in Ubuntu 10.10

Adobe Flash Builder 4
Ubuntu 10.10 Maverick Meerkat

In a very sad news, Adobe has officially terminated the Linux Flex Builder project, which has stagnated in alpha status for more than three years now, olny receiving updates to extend the termination date. Regardless of the stated alpha status, the Linux Flex Builder plugin was very usable and quite stable, provided, of course, that you used it with Eclipse 3.3.

Since the current alpha 5 of the Linux Flex Builder plugin terminates at the end of this year and as Adobe has no intentions to allow anyone to use it past that termination date, I had to find an alternative.

Although JetBrains is welcoming all Flex programmers in Linux to switch to IntelliJ IDEA, I didn't want to learn yet an another IDE, especially one that is not open source nor free.

And finally I found the fb4linux project which works great (including the debugging).

The following is mostly a copy of the project wiki with only some additions to make it work with the Eclipse installed from Ubuntu repository.
  1. Install Eclipse 3.5.x from Ubuntu repository;
  2. Download the four FB4Linux* files from the fb4linux project download section, concatenate them to form FB4Linux.tar.bz2 and extract it somewhere.
  3. Run Eclipse as root!
    sudo su; cd; eclipse
  4. Select Window / Preferences and open the General / Capabilities section in the Preferences window.
  5. Verify that Classic Update option is checked and close the preferences window.
  6. Select Help / Software Updates / Manage Configuration
  7. Right-click, select Add / Extension location... and browse to the Adobe Flash Builder 4 directory you extracted above.
  8. Restart Eclipse as per its demands.
That's it, you can now open Eclipse from your user account and start coding Flex and AIR applications!

Tuesday, June 8, 2010

Small RegExp to reformat curly brackets Flex style

Adobe Flex 3

Find: [^( *)(.*)(\S+) *\{$]
Replace: [\1\2\3\n\1{]

In order to differentiate between Java code and JavaScript/ActionScript code I have defined for myself, that in Java the opening curly bracket should be at the end of the line where it starts, like this:
if (true) {
    System.out.println("true");
}


And in JavaScript/ActionScript code it should be alone in the next line, like this:
if (true)
{
    System.out.println("true");
}


The above code I am using in Eclipse to replace all such instances in the JavaScript/ActionScript code which does not conform to this rule.

Tuesday, May 25, 2010

How to remove higher version packages installed from another source in Ubuntu.

Ubuntu 10.04 Lucid Lynx
Linux Mint 9 Isadora

I am currently torn between plain Ubuntu 10.04 Lucid Lynx and Linux Mint 9 Isadora. Previously I have had both Linux Mint 7 Gloria and Linux Mint 8 Helena installed and liked them a lot. The main attraction for me is the MintMenu.

The last one was actually Ubuntu 9.10 with Linux Mint 8 repository set up and the packages from there installed over the Ubuntu packages. The reason for this was technical - I decided to try and set up RAID 0 array with my dual 750GB hard drives and unfortunately only Ubuntu had the so called alternate install available needed to install on RAID while the normal installer in Linux Mint 8 did not recognize this, even if it had been previously created.

Ubuntu 10.04 has made some considerable improvements in many areas over the previous version:
  • My SB Audigy 2 ZS card works fine now even with the 5.1 setup switched on.
  • The 3D desktop with my Radeon HD3870 works also out of the box (though it still recommends the ATI driver, but I have decided not to install it, see the next one for why).
  • The LCD display powerdown works now (saving the backlight) with the automatic Mesa DRI R600 driver.
    Previously the ATI driver broke this LCD powerdown leaving the backlight on and I'm afraid it is still not fixed.
  • The CD/DVD automatic mounting works now with correct volume labels appearing in /media instead of using the cdrom0, cdrom1 and cdrom2 directories previously (yes, I have three drives).
    The volume label automatic creation worked also in prior Ubuntu version but this functionality disappeared mysteriously after I installed Linux Mint packages over Ubuntu ones.
  • The switching between text-mode and graphics is almost instantaneous - I wonder if the kernel graphics mode swithcing is already supported with ATI graphics or is this just very good MESA driver...?
  • The resolution of the text-mode is perfect using the whole 1920x1200 screen with 240x75 characters!
    Previously in Linux Mint 8 or perhaps instead because of the ATI driver, the text-mode was an awful 80x25 and switching back messed up the graphics mode aswell...

After trying out the newly released Linux Mint 9 I felt that it looked and worked very similarly to the previous Linux Mint 8 while the Ubuntu 10.04 was considerable jump forward from 9.10 and therefore I decided to do similar configuration as before (though I'm not using RAID this time) to install Ubuntu 10.04 and then include the MintMenu from the Linux Mint 9 repositories.

What happened, unfortunately, is that I accidentally installed a lot of Linux Mint packages including grub and plymouth related things that affect the booting. I decided to remove these packages but alas, this seemed to be impossible without complete reinstall.
Most of the packages depended on others that depended finally on nearly all of the packages (the list was in hundreds of packages).
While each of these packages had counterpart in Lucid repositories, they all outranked the Lucid ones with higher version numbers.

The apt-get does not provide any way to downgrade nor to use different repository for reinstallation, the dpkg can reinstall any version, including downgrading to an earlier versions, but needs physical .deb files.

The answer was the forgotten aptitude package manager, which has somewhat similar syntax and with simple tasks can be used in place of apt-get, while having considerably more power.

And here is the step-by-step list of how I reverted these packages back to their Lucid Lynx counterpars:
  1. First, in order to know which packages I need to switch back to Ubuntu versions, I listed those packages with dpkg:

    sudo dpkg --list | grep mint

  2. Second, I downloaded the physical .deb files from lucid repository:

    aptitude -t lucid download libplymouth2 plymouth plymouth-label plymouth-theme-ubuntu-logo plymouth-theme-ubuntu-text plymouth-x11 python-software-properties software-properties-gtk

  3. Third, I installed these versions with dpkg:

    sudo dpkg --install *.deb

That's it.

Sunday, November 15, 2009

Quick howto: 32bit Firefox 2 within 64bit openSUSE 11.1

openSUSE 11.1

I am currently in the process of creating myself my very own openSUSE distribution using the excellent SUSE Studio.

As I've written previously, I am still using the old Firefox 2, which allows me to integrate with the KDE's excellent kprinter, something that was killed in the Firefox 3 branch.
Trying the distribution with VirtualBox I stumbled upon a problem with the Firefox 2 which I have actually seen previously. This 32bit Firefox 2 is unable to connect to any website when run from 64bit openSUSE 11.1 (probably in other versions as well).

The solution, however, is an easy one. The openSUSE is remarkably different from for example Ubuntu, as they actually include the 32bit environment out of the box in 64bit systems. This means that some 32bit versions of the various libraries are automatically installed. However, the distribution maintainers in openSUSE have, for some unknown reason, left out one of the necessary 32bit libraries: nss-mdns-32bit. Install this and the 32bit Firefox 2 works!

Saturday, September 26, 2009

Gnome with Compiz and disabling Focus Prevention

Linux Mint 7 "Gloria"

One thing I've always hated about new Gnome after switching from openSuse and KDE is the focus prevention. I'm doing Flex development with Eclipse and whenever I run my application, a Firefox window is opened with the Flex compiled Flash file inside. The Compiz focus prevention, however, makes sure that the Firefox window is opened in the background. Also any and all Flash error dialogs (from the debug Flash player) appear only as the flashing taskbar button. It is ridiculous that I need to click on them to bring them forward.

Notoriously, neither Gnome nor Compiz ever mention the Focus Prevention in their setups. KDE 3.5 allowed the focus prevention settings in great detail to be modified via the KDE control center. Now, however, I've dug a bit deeper and I've found a rather simple solution to the problem.

It seems that all the hidden features are still present in Gnome and accessible via an app called gconf-editor. Just search for "prevention" in there (be sure to check the "Search also in key names" checkbox) and you should find a few matches.

Go to the key /apps/compiz/general/screen0/options/focus_prevention_level and change that value to zero to turn off the focus prevention. It's that simple!

Sunday, September 20, 2009

How to make MPlayer from SVN work with Compiz?

Linux Mint 7 "Gloria"

One of the bigger problems when enabling Compiz for all these fancy UI tricks is the sad fact that video display will become, depending on which video output method your video player uses, either flashy, very slow or just totally unusable.

The root cause for this comes from the video output method. Those video output devices that render the graphics directly to the graphics card usually create a lot of flickering, since they effectively overwrite the rendered 3D graphics which in turn then overwrite the video window. The other video output methods think they render into a window become slow, since compiz will then have to copy the window contents to a 3D texture to be rendered by the video card.

With the Ubuntu 9.04 or (in my case) Linux Mint 7 "Gloria" x64 Edition the graphics driver installation is almost too trivial. At my workplace, with the ATI's Radeon X1650 card, the DRI R300 driver was installed automatically and effects were enabled out of the box with Gloria. At home I have ATI's Radeon HD3870 in which case I only had to confirm the installation of ATI's own Linux Catalyst drivers. The 3D effects along with full Compiz Fusion was already installed and ready to be swithced on.

But now became the real problem, how to make sure that watching video would still be possible with Compiz being active? I had heard a long time ago, at the dawn of Compiz, that there was one video player, which was patched to work with Compiz... I searched for it and was glad to find out that the player in question was MPlayer which is what I've always used in the past.

Since the patch is meant to modify source code, I had compile a patched version of MPlayer.

The compilation, however, blew up with some errors. The first error came from a module called IVTV... whatever that was I did not know. I simply disabled it with --disable-ivtv switch for ./configure script. The web told that there was a patch also to fix this, but I didn't care about that. The next error came from the x264 module which is a far worse thing, as this is one of the cornerstones of free MPEG-4 video. The web tells that this incompatibility of MPlayer 1.0rc2 and x264 is based on the fact that the aformentioned MPlayer source is outdated and does not support the much evolved current x264 version anymore. The only solution would be to compile the newest version of MPlayer, which currently is only available via an anonymous Subversion repository.

And here is the catch -- how to enable the fast Compiz video, yet keep x264 support also? The Compiz video patch is for the old MPlayer source, while the newer source supports the new x264?

I decided that the fortune favors the bold and tried to see if the patch could in any way be adopted to the new MPlayer source. The file in question is libvo/vo_xv.c. Of course there were numerous differences between the old and new versions of this file and this level of C code is well beyond my understanding (I generally dislike C).

Then I decided that it's worth a try to include the patched old vo_xv.c file with the rest of the new source code taken from Subversion. I expected it to blow up at ./configure script right away - it did not. I expected it to at least bail out with errors at compilation - it did not. It surely will crash once run - it does not. It works!

Since the following sources do a superb job at explaining at detail what packages you need to install, how to patch the file and how to compile the MPlayer, I will not copy their explanations, but merely add some remarks:
  • A post in Ubuntu forums describing the original 1.0rc2 patching and compilation. Note that the patch file is no longer available from the link in that post (see below).

  • A post in SmSpillaz with similar contents, but with a working link to the patch file. You can of course always use your friend Google to find alternate links to this file.

  • An MPlayer download page with details how to download the new MPlayer from Subversion.
All you need to do really, is follow the first post up to the point of patching the original libvo/vo_xv.c file, back up the patched file, download the SVN version of MPlayer, copy the patched old file into libvo directory of the new source code overwriting the SVN version and follow the rest of the configuration, compilation and installation instructions from the first post but now within the new source code directory.

There's only one more glitch which needs to be rooted out. The fullscreen mode of MPlayer uses different screen mode which does not work anymore (reliably anyway). The solution is to turn off the special fullscreen mode by setting the property fstype=none. The only downside is that the Gnome panels remain visible that way.

Sunday, June 14, 2009

I hate scripts and script languages!

Ubuntu 9.04

One of the big strengths of Linux is its open nature and the capabilities to customize everything to your personal needs and taste. Most of the times it requires a bit of learning, but other times it is a blessing to be able to create the needed tool yourself knowing that probably you are alone with your weird requirement anyway :-)

One way to make tasks less taxing and more convenient for yourself in Linux is to create scripts which do the tedious jobs for you. It is well known that in stark contrast to the Windows world, where the user interface of an app you see is the whole app, in Linux many apps you are using in the graphical desktop are actually only shells and the real work is done by other, command line apps. One of the better examples of this kind of shell is K3B, the KDE's CD and DVD burning application, which uses command line utilities such as cdrdao, wodim, growisofs, etc. to do all the dirty work.

This also means that you can use these same command line utilities to do that work directly without even launching the GUI or you can also create your own GUI if you prefer it that way. One big helper in creating scripts with better usability has been the kdialog command, giving a nice graphical touch.

During my time with Linux I have created a lot of scripts for various things I do. Since these scripts have been part of my activities for a number of years already, many having seen several revisions becoming more and more robust, I had no choice but to bring them all over to Ubuntu now that I'm using it. And this brings me to the point of this post - I hate scripts and script languages!

Though there are other bad traits with the scripts such as the lack of strong typing of variables, the most I hate scripts for their loose bindings. At its simplest a script -- as opposed to a compiled language program -- is a list of commands to be run in sequence.

But what happens if one of the commands is not installed and hence unavailable? Or if the command is of the wrong version and does not have the behavior you are using in your script? Or if the command itself depends on your environment and simply works differently? What if the command expects a file or directory to be at one place but in your OS they have been moved or installed in a different location? And since the UNIX doctrine specifies text to be the default data transmission medium, the commands become dependent on your current charset - is your $LANG set to UTF-8 or simply ISO-8859-1 or perhaps even ASCII instead?

Now, in case of a compiled program (unless it too uses external commands which is very unlikely), it should run just fine under different conditions (my experience here comes from years of Pascal and Delphi programming).
But in case of a script, you are most probably busted! Unless of course you test for every possible thing that can go wrong, but in such case you have probably spent 80% of time to write 80% of code that does not do what you wanted to do with your script in the first place. And the main power of the script is meant to be the speed and simplicity of doing what you want to do!

After my move from openSUSE to Ubuntu, I have stumbled upon this script nuisance several times already. The list of either direct or indirect problems encountered so far:

  1. The regular expression [a-z] does not cover all of the alphabet if $LANG is set to et_EE.UTF-8 (as I've written before).

  2. The KDE4 version of kdialog does not work with keyboard anymore (as I've also written before).

  3. Ubuntu includes version 6.10 of the GNU's cut utility (used to cut chars away from a line of text) which does not work in UTF-8 space - special characters are counted as two. The solution is to get at least version of 6.11, which already supports UTF-8.

  4. The KDE4 version of kfmclient (K File Manager) has a reduced set of commands. While previous KDE3.5 version could be used in scripts as the main file manipulation tool (coping, moving, renaming, etc.) the current version can only be used to open Konqueror browser windows. The new tool for file manipulation is kioclient and there's no backward compatibility - you have to change your scripts if you wish to port them to KDE4!

The fortunate thing is that KDE4 is installed directly into /usr, while KDE3 was always installed into /opt/kde3. So you can always install the KDE3.5 environment and point your $PATH first to /opt/kde3 to pick up the KDE3 version first. If for any reason you need to run KDE4 version, just use the full path, for example /usr/bin/konqueror.

Thats it for today.