Linux actually has a protocol for installing software add-ons, if you decide that what's in your distro's repository is not enough for you. There are a few options.
- Find a PPA (Personal Package Archives for Ubuntu), add it and then install the package with apt-get. This will most likely install the package in /usr/, /usr/bin/, /usr/lib/, ... and take care of configuration and creating a desktop file so that you the application will appear in the unity dash (on Ubuntu) and you can add it to the launcher or launch files from Nautilus. This works for Sublime Text 2. PPA's are often listed on Launchpad.
- Build the code from source using autotools and it should install in /usr/local/, /usr/local/bin/, /usr/local/lib/, /usr/local/include/, ... but of course you will need to make sure that the application's dependencies are all satisfied and do not conflict with your distro. This can be a tough row to hoe.
- Find a pre-compiled package and drop it into your system's /opt directory, which is designated specifically for add-on software not provided by the system's package repositories. An alternative often used and actually my preference is to extract the new package into your home directory. This works, but to avoid cluttering $HOME I add a folder called ~/opt and drop the add-ons in there. Again, it is up to you to make sure that the software's dependencies are satisfied. For example, eclipse requires some jdk, whether it is from Oracle or the openJDK project, and it will need to be a version within the range specified by the add-on software, e.g. jdk >= 7.0 in the case of eclipse.
Now you need to integrate the add-on software into your system. Again you have some choices and it seems that there is some debate about what is the best course to take.
- The easiest thing to do is to run the application from the console, and don't integrate it into your desktop (Gnome) or file system browser (Nautilus), by opening a terminal window and typing ./<executable>. You may need to change the permissions first by using sudo chmod 755 <executable>.
- Another option that doesn't require you to edit your desktop files is to add the folder to your path, however, this may cause problems if there are filename conflicts, e.g. your system already has a libz.a but your new software does too. One safe way to deal with this is to add the new directory to the end of your path, or create a special shell for it. This way your default system files will always be used.
- Create a symlink to /home/<username>/bin/ which is always first on your path. This is my preferred method for several reasons. First it will survive an update because your personal profile is not altered during upgrades. Second, it only affects you, and not other users if you share your machine. Of course if your intent is to make the application usable for all users, then either you need to add it to all profiles or make a symlink to /usr/bin/. However, links in /usr/bin/ will probably not survive an upgrade because this is system file territory
- Create a gtk desktop file in /home/<username>/.local/share/applications/, as described in Desktop files: putting your application in the desktop menus, which again is my preferred method. I wrote a post on eclipse in Ubuntu that has an example of a desktop file. The reasons are the same as above. First it survives an upgrade and second it only affects you. You can customize the desktop file to have as many actions as you want, for example to have an option to open a new window by right clicking directly from the launcher icon, or to list all of your current eclipse profiles so that you can launch them directly. The desktop file is very flexible. You should now be able to find your application in the Unity dash (on Ubuntu) and once it runs you can lock it to the launcher. Also if you add the %f option after the location of the executable in the desktop file, then it will be available to Nautilus as well. Then you can right click and see other applications that can open a file associated with your new application. See this Ask Ubuntu answer on how to install the Sublime Text 2 editor. A lot of people have recommended editing the system wide desktop files, which are in /usr/share/applications/ but I don't recommend this as it will not survive an upgrade.
In general, I tend to be more conservative when it comes to editing system files and directories, preferring to keep my customization localized to my profile, and only deviating from that when absolutely necessary. But you may have a different use case which will necessitate a different approach.
No comments:
Post a Comment