9/29/2014

Using gcc48 to build ports on FreeBSD

cd /usr/ports/devel/binutils && make install
cd /usr/ports/lang/gcc48 && make install
Add this to /etc/make.conf:

.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc48)
.if empty(.CURDIR:M/usr/ports/net/openldap*) && empty(.CURDIR:M/usr/ports/xxx/yyy)
CC=gcc48
CXX=g++48
CPP=cpp48
CFLAGS+=-Ofast -fno-strict-aliasing -pipe  
CPUTYPE=corei7
.endif
.endif

Edit /etc/libmap.conf:
libgcc_s.so.1   gcc48/libgcc_s.so.1
libgomp.so.1    gcc48/libgomp.so.1
libobjc.so.3    gcc48/libobjc.so.2
libssp.so.0     gcc48/libssp.so.0
libstdc++.so.6  gcc48/libstdc++.so.6

References:
https://www.freebsd.org/doc/en/articles/custom-gcc/article.html

9/18/2014

Building and installing Apache Maven 3.0.5 from sources


cd ~/tools
wget http://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.0.5/apache-maven-3.0.5-src.tar.gz
tar xvzf apache-maven-3.0.5-src.tar.gz
cd apache-maven-3.0.5
#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.5/apache-maven/target/apache-maven-3.0.5-bin.tar.gz

9/10/2014

Regenerate hinting for all fonts

First you have to install TTF Autohinter.
sudo apt-get install libtool automake autoconf
cd ~/tools
git clone http://repo.or.cz/ttfautohint.git
cd ttfautohint/
./bootstrap
./configure
make
make install
Then it's so simple:
mkdir -p ~/.fonts
for file in $(find /usr/share -name '*.ttf'); do ~/tools/ttfautohint/frontend/ttfautohint -i $file ~/.fonts/${file##*/}; done
fc-cache -fv

9/09/2014

Installing Nexus OSS from sources

After all it's not that tricky. Build fails with Maven 3.0.x, make sure to use a later version, 3.2.3 seems to be working fine. You'll also need the http.ssl hacks.

Pre-requisities

You'll need git. Using Ubuntu/Debian, a
sudo apt-get install git
will do, or on FreeBSD you can use
sudo portmaster devel/git
And now the fun part:
cd ~/tools
wget http://apache.cu.be/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz
tar xvzf apache-maven-3.2.3-bin.tar.gz
ln -s ~/tools/apache-maven-3.2.3 ~/tools/maven
export PATH=~/tools/maven/bin:$PATH
export MAVEN_OPTS="-XX:PermSize=1500m -XX:MaxPermSize=1900m -Xmx1512m"

cd ~/dev
git clone https://github.com/sonatype/nexus-oss.git
cd nexus-oss
mvn -Dskip-testsuite -DskipTests -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
unzip -d ~/tools/nexus assemblies/nexus-base-template/target/nexus-base-template-*.zip

Autostart on Ubuntu/Debian

As of today, the wrapper service we can use in Karaf to autostart things does not work. As a workaround to autostart, create a /etc/init.d/nexus file:
#!/bin/bash

NEXUS_HOME=/home/neusoft/tools/nexus/nexus-base-template-3.0.0-SNAPSHOT

case "$1" in
  start)
    log_begin_msg "Starting Nexus OSS..."
        $NEXUS_HOME/bin/start
    log_end_msg 0
    ;;
  stop)
    log_begin_msg "Shutting down Nexus OSS..."
        $NEXUS_HOME/bin/stop
    log_end_msg 0
    ;;
  *)
  ;;
esac
...and execute this statement:
sudo update-rc.d nexus defaults 98 02

Autostart on FreeBSD

Start by putting the following script to /etc/rc.d/nexus:
#!/bin/sh

. /etc/rc.subr

name="nexus"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
export NEXUS_HOME=/opt/nexus
export JAVA_HOME=/usr/local/openjdk7

nexus_start() {
        $NEXUS_HOME/bin/start
}

nexus_stop() {
        $NEXUS_HOME/bin/stop
}

load_rc_config $name
run_rc_command "$1"
...and adapt appropriately to your system of course. You'll need to make it executable:
chmod +x /etc/rc.d/nexus

To activate it, you need to add the following to your /etc/rc.conf:
nexus_enable="YES"

Usage

To deploy to the locally installed Nexus, you can
  • - change your pom.xmls to refer to this local nexus for deployment
  • - change your settings.xml use the local nexus for deployment
  • <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">
    
       <mirrors>
            <mirror>
                <id>nexus</id>
                <name>nexus</name>
                <mirrorOf>external:*</mirrorOf>
                <url>http://127.0.0.1:8081/content/groups/public/</url>
            </mirror>
        </mirrors>
    
        <servers>
            <server>
                <id>jnc</id>
                <username>tomcat</username>
                <privateKey>${user.home}/.ssh/id_rsa</privateKey>
            </server>
            <server>
                <id>nexus</id>
                <username>admin</username>
                <password>{Oen5wNM4lygHMZ9vf+6T5qmsePRcQbWtrc2AWkTrpKg=}</password>
            </server>
            <server>
                <id>snapshots</id>
                <username>admin</username>
                <password>{Oen5wNM4lygHMZ9vf+6T5qmsePRcQbWtrc2AWkTrpKg=}</password>
            </server>
            <server>
                <id>releases</id>
                <username>admin</username>
                <password>{Oen5wNM4lygHMZ9vf+6T5qmsePRcQbWtrc2AWkTrpKg=}</password>
            </server>
        </servers>
    
        <profiles>
            <profile>
                <id>local</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
                <properties>
        <nexus.url>http://127.0.0.1:8081</nexus.url>
                    <repos.public.url>${nexus.url}/content/groups/public</repos.public.url>
                    <repos.release.url>${nexus.url}/content/repositories/releases</repos.release.url>
                    <repos.snapshot.url>${nexus.url}/content/repositories/snapshots</repos.snapshot.url>
                </properties>
                <repositories>
                    <repository>
                        <id>nexus</id>
                        <name>public</name>
                        <url>${repos.public.url}</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>${repos.snapshot.url}</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>${repos.release.url}</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>${repos.public.url}</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>${repos.snapshot.url}</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>${repos.release.url}</url>
                        <layout>default</layout>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                        <releases>
                            <enabled>true</enabled>
                            <updatePolicy>daily</updatePolicy>
                        </releases>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
        </profiles>
    </settings>
    
    
    ...and this goes to settings-security.xml, using the default password for authentication. If following this guide, on your local, firewalled server the default username/password combination might do. Otherwise change your password in nexus and update your settings.xml and settings-security.xml appropriately as described here.
    <settingsSecurity>
      <master>{KFp2s9kTyrcHsy+BT4dooaLri1eMcy+32raBPgydYvw=}</master>
    </settingsSecurity>
    
  • - use the following construct which overrides your default deployment directory:
    mvn clean deploy -DaltDeploymentRepository=nexus::default::http://127.0.0.1:8081/content/repositories/snapshots
    

Possible errors

Using Maven versions earlier than 3.2.3 may yield to the following error:
Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Fix Java font smoothing on Ubuntu: re-building OpenJDK 1.7 from sources with Infinality patches

First we need to install some pre-requisities:
sudo apt-get install libasound2-dev libcups2-dev libfreetype6-dev gawk g++ libxext-dev libxrender-dev libxtst-dev libfontconfig1-dev

export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64
Getting the sources:
cd ~/tools
mkdir jdk7u60
cd jdk7u60
hg clone http://hg.openjdk.java.net/jdk7u/jdk7u60 forest
cd forest
sh ./get_source.sh
Patching fonts with Infinality:
cd ~
git clone https://gist.github.com/2893461.git
mv 2893461/fontfix.patch ~/tools/jdk7u60/forest/jdk/
cd ~/tools/jdk7u60/forest/jdk/
patch -p1 < fontfix.patch
The actual build:
cd ~/tools/jdk7u60/forest
. jdk/make/jdk_generic_profile.sh
#make ALLOW_DOWNLOADS=true fastdebug_build
make all
Verifying:
build/linux-amd64-fastdebug/j2sdk-image/bin/java -version

9/08/2014

Fix Java font smoothing on FreeBSD: re-building the port tree's OpenJDK 1.7 from sources with Infinality patches

The current OpenJDK 7 available in FreeBSD's port tree lacks some eye-candy regarding font-rendering capabilities. Since Freetype2 already includes subpixel-rendering support, we just have to patch the JDK. So first we make an "extract patch" (e.g. no compile, only acquiring sources, applying official FreeBSD patches), then we'll patch with the Infinality patches available in the git repo below.
cd /usr/ports/java/openjdk7
sudo make extract patch
cd ~
git clone https://gist.github.com/2893461.git
sudo mv 2893461/fontfix.patch /usr/ports/java/openjdk7/work/openjdk/jdk/
cd /usr/ports/java/openjdk7/work/openjdk/jdk/
sudo patch -p1 < fontfix.patch
cd /usr/ports/java/openjdk7/
sudo make install clean
If you already have openjdk7 installed, you'll need to reinstall instead. In this case replace the last line with
sudo make deinstall reinstall clean

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