Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

5/18/2017

Building IntelliJ Idea Community edition on Ubuntu 16.10

Building IntelliJ Idea on Ubuntu is just a bit more complex than simply executing ant.

Acquiring dependencies

The commented lines below are required if you wish to use jdk1.6; in practice, things seem to build without (as of May, 2017 at least)

#sudo add-apt-repository ppa:webupd8team/java
#sudo apt-get update
#sudo apt-get install oracle-java6-installer
#sudo update-alternatives --config java
sudo apt-get install zlib1g-dev ant git
mkdir $HOME/tools
cd $HOME/tools
git clone git://git.jetbrains.org/idea/community.git idea
cd idea
./getPlugins.sh 
build/conf/install_nsis3.sh $HOME/tools/idea

If the build finishes with

...
scons: done building targets.
...the build of dependencies finished successfully.

Starting the build

If you've installed JDK1.6 (the commented lines above), here we need to refer to it (first line below). Again, IntelliJ Idea Community Edition builds without this, so left it commented out.

#export JDK_16_x64=/usr/lib/jvm/java-6-oracle
cd $HOME/tools/idea
ant

9/10/2014

Regenerate hinting for all fonts

First you have to install TTF Autohinter.
sudo apt-get install libtool automake autoconf qt4-qmake automoc imagemagick inkscape pandoc help2man
cd ~/tools
git clone http://repo.or.cz/ttfautohint.git
cd ttfautohint/
./bootstrap
./configure --with-doc=no
make
make install
Under Ubuntu 12.04, you will need to download and compile harfbuzz:
wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.26.tar.bz2
tar xf harfbuzz-0.9.26.tar.bz2
cd harfbuzz-0.9.26
./configure && make && sudo make install
sudo ldconfig
Under later versions you may try sooner or later
sudo apt-get install harfbuzz
Then it's so simple:
mkdir -p ~/.fonts
for file in $(find /usr -name '*.ttf'); do ttfautohint -c -d -i --hinting-range-min=6 -i $file ~/.fonts/${file##*/}; done
fc-cache -fv

9/05/2014

Installing JDK 1.6, JDK 1.7 and JDK 1.8 from binary

You never know which one you need. Obviously if you have the luxury of a package manager, that will be better, especially if the PM supports multiple versions. Here I didn't have root permissions on a PC still I needed all versions; the switch can be made by sim-linking the proper version to ~/tools/jdk. Don't forget to download the files first - can't do wget since we have to accept the license agreement. Here we go:

JDK1.6

mv ~/Downloads/jdk-6u45-linux-x64.bin .
chmod +x jdk-6u45-linux-x64.bin
./jdk-6u45-linux-x64.bin

JDK1.7

mv ~/Downloads/jdk-7u67-linux-x64.tar.gz ~/tools
tar xvzf jdk-7u67-linux-x64.tar.gz

JDK1.8

mv ~/Downloads/jdk-8u11-linux-x64.tar.gz .
tar xvzf jdk-8u11-linux-x64.tar.gz
If you add ~/tools/jdk/bin to your PATH (via ~/.profile?), here's how touse jdk 1.8 as default:
ln -s ~/tools/jdk1.8.0_11 ~/tools/jdk

Building and installing PostgreSQL 9.3.5 from sources (no sudo needed)

cd ~/dev
wget http://ftp.postgresql.org/pub/source/v9.3.5/postgresql-9.3.5.tar.gz
tar xvzf postgresql-9.3.5.tar.gz
ln -s postgresql-9.3.5 postgresql
cd postgresql-9.3.5/
./configure --without-readline --prefix=$HOME/tools/postgresql
make
make install
~/tools/postgresql/bin/initdb -D ~/tools/postgresql/data
~/tools/postgresql/bin/pg_ctl -D ~/tools/postgresql/data -l ~/tools/postgresql/postgresql.log start
~/tools/postgresql/bin/createdb mydatabasename
To autostart the server, add this to a startup script:
~/tools/postgresql/bin/pg_ctl -D ~/tools/postgresql/data -l ~/tools/postgresql/postgresql.log start

Building and installing Apache Tomcat 7.0 from sources (no sudo needed)

You will need ant though. If you have a package manager and the appropriate rights it's super easy, either "apt-get install ant" on Ubuntu or "portmaster devel/apache-ant" on FreeBSD - or download and put ant to ~/tools. You will also need to update your PATH so that ant can be found.
cd ~/tools
svn co http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk ~/tools/apache-tomcat-7-sources
cd ~/tools/apache-tomcat-7-sources
ant -Dbase.path=~/tools/apache-tomcat-7-sources/base download-compile
ant -Dbase.path=~/tools/apache-tomcat-7-sources/base deploy
mkdir -p ~/tools/apache-tomcat-7
mv ~/tools/apache-tomcat-7-sources/output/build/* ~/tools/apache-tomcat-7/
ln -s ~/tools/apache-tomcat-7 ~/tools/tomcat
That concludes the installation. In case you need some JDBC drivers and alike (unfortunately Tomcat 7 does not manage our dependencies like Karaf), here is a sample:
cd ~/tools/tomcat/lib/
wget http://repo1.maven.org/maven2/org/hsqldb/hsqldb/2.3.2/hsqldb-2.3.2.jar
wget http://repo1.maven.org/maven2/org/postgresql/postgresql/9.3-1102-jdbc41/postgresql-9.3-1102-jdbc41.jar
wget http://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar
wget http://repo1.maven.org/maven2/javax/mail/mail/1.5.0-b01/mail-1.5.0-b01.jar
You may need to add this to ~/.profile file:
export JAVA_HOME=$HOME/tools/jdk

Building and installing Apache Karaf from sources (no sudo needed)

Once upon a time I was working for a company where sudo rights weren't given to developers. So I had to spend a significant fraction of my time finding workarounds, how silly is that. The no-sudo-needed series is the result of all these efforts: I've saved the process, so next time it is needed, it's easy to get back to it.

The point here is to be able to install them just by copying and pasting the code below. Things change around us though, so whatever may build today might just stop working tomorrow. Thus I do my best to keep these code snippets up-to-date.

Like today I need Karaf again. Building from source feels very appropriate, so even though I have sudo on my computers since leaving that company, I still keep coming back here for the "easy builds". Today I updated with Karaf 2.3.11, it is currently building in another window. If succeeds, I'll create another snippet for it. If you need it, feel free to get it!

Building Apache Karaf 2.3.11 from sources

wget http://apache.belnet.be/karaf/2.3.11/apache-karaf-2.3.11-src.tar.gz
tar xvzf apache-karaf-2.3.11-src.tar.gz
cd apache-karaf-2.3.11/src
mvn clean install -DskipTests
mv assemblies/apache-karaf/target/apache-karaf-2.3.11.tar.gz ~/tools
cd ~/tools
tar xvzf apache-karaf-2.3.11.tar.gz
ln -s apache-karaf-2.3.11 karaf

Building Apache Karaf 2.3.6 from sources

wget http://apache.belnet.be/karaf/2.3.6/apache-karaf-2.3.6-src.tar.gz
tar xvzf apache-karaf-2.3.6-src.tar.gz
cd apache-karaf-2.3.6/src
mvn clean install -DskipTests
mv assemblies/apache-karaf/target/apache-karaf-2.3.6.tar.gz ~/tools
cd ~/tools
tar xvzf apache-karaf-2.3.6.tar.gz
ln -s apache-karaf-2.3.6 karaf

Building Apache Karaf 4.0 from sources

git clone https://git-wip-us.apache.org/repos/asf/karaf.git
cd karaf
git checkout karaf-4.0.0
# to avoid "Detected JDK Version: 1.6.0-65 is not in the allowed range [1.7,1.9)" on osx, can only build with 1.7
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
mvn clean install -DskipTests

Building Karaf 4.0.10 from sources, checking out given branch only, building with java 1.8 on OSX:

git clone -b karaf-4.0.10 --single-branch https://github.com/apache/karaf.git
cd karaf
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
mvn clean install -DskipTests -DskipITs

Building and installing Apache Karaf 2.2.5 or 2.3.11 from sources (no sudo needed)

In my ~/.m2/settings.xml, I have a separate profile which uses a local Nexus repository as a proxy to all the remotes. It is not active by default, only activated with the -P local switch. Thus please don't update your settings.xml like this if you don't have a local Nexus proxy (and you won't need the "-P local" switch later neither in this case). The relevant part of my settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <profiles>
        <profile>
            <id>local</id>
            <!--<activation>-->
            <!--<activeByDefault>true</activeByDefault>-->
            <!--</activation>-->
            <properties>
                <repos.release.url>http://127.0.0.1:8081/content/groups/public</repos.release.url>
                <repos.snapshot.url>http://127.0.0.1:8081/content/groups/public</repos.snapshot.url>
            </properties>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <name>public</name>
                    <url>http://127.0.0.1:8081/content/groups/public</url>
                    <layout>default</layout>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </releases>
                </repository>
                <repository>
                    <id>snapshots</id>
                    <name>snapshots</name>
                    <url>http://127.0.0.1:8081/content/repositories/snapshots</url>
                    <layout>default</layout>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <enabled>false</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </releases>
                </repository>
                <repository>
                    <id>releases</id>
                    <name>releases</name>
                    <url>http://127.0.0.1:8081/content/repositories/releases</url>
                    <layout>default</layout>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </releases>
                </repository>
            </repositories>

            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <name>public</name>
                    <url>http://127.0.0.1:8081/content/groups/public</url>
                    <layout>default</layout>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </releases>
                </pluginRepository>
                <pluginRepository>
                    <id>snapshots</id>
                    <name>snapshots</name>
                    <url>http://127.0.0.1:8081/content/repositories/snapshots</url>
                    <layout>default</layout>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <enabled>false</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </releases>
                </pluginRepository>
                <pluginRepository>
                    <id>releases</id>
                    <name>releases</name>
                    <url>http://127.0.0.1:8081/content/repositories/releases</url>
                    <layout>default</layout>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </releases>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
</settings>

...and the script for the build for version 2.2.5:
mkdir -p ~/tools
cd ~/tools
wget http://archive.apache.org/dist/karaf/2.2.5/apache-karaf-2.2.5-src.tar.gz
tar xvzf apache-karaf-2.2.5-src.tar.gz
cd apache-karaf-2.2.5/src
mvn clean install -DskipTests -P local
sudo mkdir -p /opt
cd /opt
sudo tar xvzf ~/tools/apache-karaf-2.2.5/src/assemblies/apache-karaf/target/apache-karaf-2.2.5.tar.gz
sudo ln -s apache-karaf-2.2.5 karaf

For version 2.3.11

mkdir -p ~/tools
cd ~/tools
wget http://archive.apache.org/dist/karaf/2.3.11/apache-karaf-2.3.11-src.tar.gz
tar xvzf apache-karaf-2.3.11-src.tar.gz
cd apache-karaf-2.3.11/src
mvn clean install -DskipTests -P local
sudo mkdir -p /opt
cd /opt
sudo tar xvzf ~/tools/apache-karaf-2.3.11/src/assemblies/apache-karaf/target/apache-karaf-2.3.11.tar.gz
sudo ln -s apache-karaf-2.3.11 karaf

Autostart on Ubuntu: to wrap or not to wrap

If you try to install the wrapper to achieve autostart, everything seems to be fine, but the wrapper segfaults on subsequent reboots, at least that's the sad situation on Ubuntu 12.04.5. This used to work before.
Still it has to work, so the workaround is to create a /etc/init.d/karaf script with this content:
#!/bin/bash

KARAF_HOME=/home/neusoft/tools/karaf

case "$1" in
  start)
    log_begin_msg "Starting Karaf..."
        $KARAF_HOME/bin/start
    log_end_msg 0
    ;;
  stop)
    log_begin_msg "Shutting down Karaf..."
        $KARAF_HOME/bin/stop
    log_end_msg 0
    ;;
  *)
  ;;
esac
To register the file with the system
sudo update-rc.d karaf defaults 98 02

Autostart on FreeBSD

Using FreeBSD, autostarting the service is different:

echo 'karaf_enable="YES"' | sudo tee -a /etc/rc.conf > /dev/null

The rc.conf entry will start the script under /etc/rc.d. And the contents of the /etc/rc.d/karaf file:

#!/bin/sh
. /etc/rc.subr
export KARAF_OPTS="-Dkey=value"
start_cmd="karaf_start"
stop_cmd="karaf_stop"
karaf_start() {
        export JAVA_HOME=/usr/local/openjdk7
        /opt/karaf/bin/start
}
karaf_stop() {
        export JAVA_HOME=/usr/local/openjdk7
        /opt/karaf/bin/stop
}
load_rc_config $name
run_rc_command "$1"

Then you just have to make it executable:

sudo chmod +x /etc/rc.d/karaf

Or even make a symbolic link for the ones expect logs to be at standard places:

sudo ln -s /opt/karaf/data/log /var/log/karaf

Gotchas

Building on OSX Yosemite with Apple's JDK 1.6 succeeds, but logging on shows that we have a crippled container:

# features:addurl http://repo1.maven.org/maven2/org/apache/felix/org.apache.felix.ipojo.features/1.12.0/org.apache.felix.ipojo.features-1.12.0.xml
# Command not found: features:addurl

Investigating /opt/karaf/data/log/karaf.log shows us the cause of the error:

"Bundle org.apache.karaf.features.command is waiting for dependencies [(objectClass=org.apache.karaf.features.FeaturesService)]"

Installing Oracle JDK 1.7 & setting JAVA_HOME appropriately fixes the problem.

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
...
(rebuild the whole shebang)
...

Building and installing Apache Maven from sources (no sudo needed)

Maven 3.0.3

Maven 3.0.4 is known for it's incompatibilities connecting to self signed certificates, which can be solved by a small patch. If you don't depend on this version, it's even easier not to use the broken version at all. Here's how to build from sources:
mkdir -p ~/tools
cd ~/tools
wget http://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.0.3/apache-maven-3.0.3-src.tar.gz
tar xvzf apache-maven-3.0.3-src.tar.gz
cd apache-maven-3.0.3
#for the next line to succeed, you need a binary maven version in the path
mvn clean install -DskipTests
cd ..
tar xvzf apache-maven-3.0.3/apache-maven/target/apache-maven-3.0.3-bin.tar.gz

Maven 3.2.3

mkdir -p ~/tools
cd ~/tools
wget http://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.2.2/apache-maven-3.2.2-src.tar.gz
tar xvzf apache-maven-3.2.2-src.tar.gz
cd apache-maven-3.2.2
#for the next line to succeed, you need a binary maven version in the path
mvn clean install -DskipTests
cd ..
tar xvzf apache-maven-3.2.2/apache-maven/target/apache-maven-3.2.2-bin.tar.gz

2/27/2014

Dual booting Ubuntu 12.04 and FreeBSD 10

Well first install Ubuntu, creating a separate /boot partition with 256MB space, a 10GB-ish Ubuntu partition, and leave free space at the end of the hard drive for FreeBSD.
Now install FreeBSD. Boot from USB Disk, chose Install FreeBSD, partitioning for beginners. This will auto-detect the space you've left out earlier for FreeBSD; don't type anything to the Mount Path, it will automatically create a master partition, where it handles the mount points automatically. Unless of course, you want a different partition-setup which you do with the tool here.
Be sure to have the / mounted to a UFS-formatted partition (this should be done for you automatically if you've followed the earlier steps), and proceed with the installation.
After the FreeBSD installer finished and you reboot your computer, you'll get the Linux bootloader, of course with no option to start FreeBSD. So here we go, let's fix GRUB:
sudo grub-probe -d /dev/sda1 -t fs_uuid  
should tell you the disk you have a UUID for. That should be your FreeBSD disk - now replace my UUID with yours for grub:
sudo vi /etc/grub.d/40_custom
should fire you up VI, here's my file:
menuentry 'FreeBSD' {
   insmod ufs2
   insmod bsd
   search --fs-uuid --no-floppy --set=root 011c86ed-6f2d-48a0-a132-f020c23a045c
   kfreebsd /boot/kernel/kernel
   kfreebsd_loadenv /boot/device.hints
   set FreeBSD.vfs.root.mountfrom=ufs:/dev/ufsid/011c86ed-6f2d-48a0-a132-f020c23a045c
   set FreeBSD.vfs.root.mountfrom.options=rw
}
Exit vi with :wq, update grub on disk:
sudo update-grub
Reboot your computer and you should be able to select FreeBSD in Grub now. Drop me a comment how it worked. Cheers!

12/28/2013

Building http://bellebonnesage.sourceforge.net/ generates fatal error: 'freetype/ftglyph.h' file not found

If you are on Mac OS, and trying to build Belle, Bonne, Sage from sources, you may experience the following error:

#svn co https://bellebonnesage.svn.sourceforge.net/svnroot/bellebonnesage/trunk bbs
#cd bbs
#./Scripts/MakeAll

Cleaning Build
Building Beaming
Building BlankPage
Building Chopin
Building Color
Building ConvertFont
Building Graph
Building Image
Building Spiral
Building Springs
Building Springs2
Building Text
Building Tutorial0
Building Tutorial1
Building Tutorial2
Building Tutorial3
In file included from ../Examples/Color.cpp:40:
In file included from ../Examples/../BelleBonneSage.h:95:
../Examples/../Modules/FreeType.h:48:10: fatal error: 'freetype/ftglyph.h' file not found
#include 
         ^
In file included from ../Examples/ConvertFont.cpp:40:
In file included from ../Examples/../BelleBonneSage.h:95:
../Examples/../Modules/FreeType.h:48:10: fatal error: 'freetype/ftglyph.h' file not found
#include 
         ^

That's because you don't have the ftgl library installed:

#brew install ftgl

3/05/2010

Make Ubuntu or FreeBSD look like OSX

Installing the Aurora Leopard BSM Theme

The Aurora Leopard BSM Theme provides a beautiful, minimalistic appearance. This is how it looks like:

Ubuntu

First we have to install the GTK engine. The steps to take:

sudo apt-get install build-essential libgtk2.0-dev gconf-editor
wget http://gnome-look.org/CONTENT/content-files/56438-aurora-1.5.1.tar.bz2
tar -xvjf 56438-aurora-1.5.1.tar.bz2
tar xvzf aurora-gtk-engine-1.5.tar.gz
cd aurora-1.5
./configure --prefix=/usr --enable-animation
make
sudo make install

FreeBSD

On FreeBSD, install the devel/glib20 and the aurora port instead:
sudo portmaster devel/glib20 x11-themes/gtk-aurora-engine

Both OS: drag the theme

Now we can install the theme, by downloading it from here. Save it to the desktop, then open System->Preferences->Appearance, and drag&drop the downloaded file to this window. Ubuntu will install the theme for us.

Looks a bit like OSX? Indeed it does. To go one step further,  we can change the order of the buttons too (this is a copy from here):
1 - Press "Alt + F2"
2 - Type "gconf-editor" and press "Enter"
3 - Browse to "Apps -> metacity -> general"
4 - On right panel, double click on "button_layout"
5 - Change the value to "close,minimize,maximize:menu"
6 - Press "OK"

Now we have the chance to install their icon-libraries. I ended up using a built-in icon library instead. This is how it looks like:

To install it on Ubuntu:
sudo apt-get install gnome-human-icon-theme
Or, here's a nice one for FreeBSD:
sudo portmaster /usr/ports/x11-themes/gnome-icons-dropline-neu

Now if you click "Customize" under System->Preferences->Appearance->Aurora Leopard BSM, under the Icons tab you'll find GNOME-Human (or Dropline...)

One more thing. You can use the (already enabled by default) desktop effects if you like, but after a while it can become disturbing, so I usually disable it under System->Preferences->Appearance->Visual Effects (not to mention that Desktop Effects still have some compatibilty issues, if I'm not mistaken Google Earth didn't like it).

Still, compositing makes the user-interface snappier; if you go back to gconf-editor, at the same place where you've had the button_layout (apps->metacity->general), you can enable the compositing_manager by checking it. This is the setting I've found the most performing; let me know if you think otherwise or if you've found some other hacks!

Hope you like it! Cheers!
Lajos