Die meisten Entwickler nutzen den Android-Emulator ja wahrscheinlich dafür, selbst entwickelte Programme komfortabel zu testen. Es gibt aber auch noch einen weiteren interessanten Einsatzzweck, den Gaby Becker in einem Blog-Beitrag beschrieben hat.

Es geht hierbei um die Möglichkeit, über den Android Market Apps im Emulator zu installieren und diese dann sowohl lokal zu nutzen oder für Präsentationen zu nutzen.

Gaby Becker: Präsentieren mit dem Emulator

 

OpenSolaris uses Sendmail as default Mail Transfer Agent (MTA) which seems to be designed as a admin-hell. I prefer Postfix with it’s easy to read config files.

As the package repository of OpenSolaris doesn’t provide a current Postfix, this HowTo explains a way to build Postfix from source and install it on your OpenSolaris system.

Basics

First step is to install/get a working GCC (preferred version >4.3). One possibility is to follow my Guide about GCC-4 on OpenSolaris or to use the package repository. In addition you will need gnu-make and wget.

root@test:~# pkg install gcc-43 wget nano developer/build/gnu-make

               Packages to install:    18
           Create boot environment:    No
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                18/18   3121/3121    71.5/71.5

PHASE                                        ACTIONS
Install Phase                              4183/4183

PHASE                                          ITEMS
Package State Update Phase                     18/18
Image State Update Phase                         2/2

root@test:~# PATH=/usr/bin:/usr/gcc/4.3/bin:$PATH

Preparations

Since the build environment is now set up, you can download the current postfix source release.

root@test:~# wget http://de.postfix.org/ftpmirror/official/postfix-2.8.5.tar.gz

--2011-10-04 22:38:09--  http://de.postfix.org/ftpmirror/official/postfix-2.8.5.tar.gz
Resolving de.postfix.org (de.postfix.org)... 141.42.206.35
Connecting to de.postfix.org (de.postfix.org)|141.42.206.35|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3647010 (3.5M) [application/x-gzip]
Saving to: `postfix-2.8.5.tar.gz'

100%[======================================>] 3,647,010    700K/s   in 5.6s    =

2011-10-04 22:38:15 (632 KB/s) - `postfix-2.8.5.tar.gz' saved [3647010/3647010]

root@test:~# tar xf postfix-2.8.5.tar.gz
root@test:~# cd postfix-2.8.5

One of the postfix scripts has an error and tries to use NIS and NIS+ with OpenSolaris which will result in a build-fail.

To fix it, remove the lines “#define HAS_NIS” and “#define HAS_NISPLUS” (line 403 and 404) from src/util/sys_defs.h or apply this path:

--- src/util/sys_defs.h.bak     Thu Jun 16 00:36:37 2011
+++ src/util/sys_defs.h Tue Oct  4 22:39:49 2011
@@ -400,8 +400,6 @@
 #define HAS_DBM
 #define DEF_DB_TYPE    "dbm"
 #define ALIAS_DB_MAP   "dbm:/etc/mail/aliases"
-#define HAS_NIS
-#define HAS_NISPLUS
 #define USE_SYS_SOCKIO_H               /* Solaris 2.5, changed sys/ioctl.h */
 #define GETTIMEOFDAY(t)        gettimeofday(t)
 #define ROOT_PATH      "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"

Building

Now you can start building Postfix.

root@test:~/postfix-2.8.5# gmake makefiles CCARGS='-DUSE_TLS \
 -lssl -lcrypto -DUSE_SASL_AUTH \
 -DUSE_CYRUS_SASL -I/usr/include/sasl' \
 AUXLIBS="-L/usr/lib -lsasl -lssl -lcrypto"

(echo "# Do not edit -- this file documents how Postfix was built for your machine.";
>makedefs.tmp
set +e; if cmp makedefs.tmp conf/makedefs.out; then rm makedefs.tmp; \
...

root@test:~/postfix-2.8.5# gmake

gmake -f Makefile.in MAKELEVEL= Makefiles
(echo "# Do not edit -- this file documents how Postfix was built for your machine.";
>makedefs.tmp
...

If you didn’t get an error, you can now check if libsasl was linked correctly:

root@test:~/postfix-2.8.5# ldd ./bin/postconf

        libsasl.so.1 =>  /usr/lib/libsasl.so.1
        libssl.so.0.9.8 =>       /lib/libssl.so.0.9.8
        libcrypto.so.0.9.8 =>    /lib/libcrypto.so.0.9.8
        libresolv.so.2 =>        /lib/libresolv.so.2
        libsocket.so.1 =>        /lib/libsocket.so.1
        libnsl.so.1 =>   /lib/libnsl.so.1
        libc.so.1 =>     /lib/libc.so.1
        libmd.so.1 =>    /lib/libmd.so.1
        libmp.so.2 =>    /lib/libmp.so.2
        libm.so.2 =>     /lib/libm.so.2

Create a OpenSolaris Package

There is a cool script available which takes the compiled Postfix sources and builds a OpenSolaris package with all required settings (e.g. users, service-definitions).

You can find the script on Ihsan Dogan’s website: http://ihsan.dogan.ch/postfix/

Directlink: http://ihsan.dogan.ch/postfix/downloads/makePostfixPkg.sh

root@test:~/postfix-2.8.5# wget http://ihsan.dogan.ch/postfix/downloads/makePostfixPkg.sh

--2011-10-04 22:42:35--  http://ihsan.dogan.ch/postfix/downloads/makePostfixPkg.sh
Resolving ihsan.dogan.ch (ihsan.dogan.ch)... 82.220.5.55
Connecting to ihsan.dogan.ch (ihsan.dogan.ch)|82.220.5.55|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21030 (21K) [application/x-sh]
Saving to: `makePostfixPkg.sh'

100%[======================================>] 21,030      --.-K/s   in 0.1s

2011-10-04 22:42:35 (205 KB/s) - `makePostfixPkg.sh' saved [21030/21030]

root@test:~/postfix-2.8.5# chmod +x makePostfixPkg.sh
root@test:~/postfix-2.8.5# ./makePostfixPkg.sh
...

This will result in a file named CNDpostfix-2.8.5,REV=111005-SunOS5.11-i386.pkg

Install Postfix

If you have a installed Sendmail, you need to remove it before the installation of postfix:

root@test:~/postfix-2.8.5# pkg uninstall sendmail

Now you can use pkgadd to install the package:

root@test:~/postfix-2.8.5# pkgadd -d CNDpostfix-2.8.5\,REV\=111005-SunOS5.11-i386.pkg

The following packages are available:
  1  CNDpostfix     Postfix MTA
                    (i386) 2.8.5r0.4.0,REV=111005

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: a

Processing package instance  from

Postfix MTA(i386) 2.8.5r0.4.0,REV=111005
http://www.postfix.org/ packaged by Ihsan Dogan
...

The final step is to configure your Postfix and activate it afterwards.

root@test:~/postfix-2.8.5# svcadm enable svc:/network/postfix:default
root@test:~/postfix-2.8.5# svcs -vx postfix
svc:/network/postfix:default (Postfix SMTP Server)
 State: online since Tue Oct  4 22:46:29 2011
   See: man -M /usr/share/man -s 1 postfix
   See: http://www.postfix.org/documentation.html
   See: /var/svc/log/network-postfix:default.log
Impact: None.

On September 14th 2011 the OpenIndiana Project announced the next development release of OpenIndiana (Build 151a). That’s a good reason to upgrade your system and it’s Zones.

The common way to upgrade your OpenIndiana System is to run the following command.

root@test:~# pkg image-update
                Packages to remove:     2
               Packages to install:    13
                Packages to update:   115
           Create boot environment:   Yes
...

This will result in a new snapshot on your disk and a new entry in the boot menu.

If you try to perform an Upgrade of a Zone this way, it will fail with the message:

pkg: Unable to clone the current boot environment.

Therefor the upgrade process has to be triggered from the global zone. Let’s say you want to upgrade the Zone “test” with the ZFS dataset under “/zones/test“. The Zone currently runs OpenIndiana Build 148 as we can see after the login:

root@global:~# zlogin test
[Connected to zone 'test' pts/2]
Last login: Wed Oct  4 22:32:48 on pts/2
OpenIndiana     SunOS 5.11      oi_148  November 2010

To perform the upgrade, we should halt the zone first.

root@global:~# zoneadm -z test halt
root@global:~# pkg -R /zones/test/root image-update -v
                Packages to remove:     2
               Packages to install:     13
                Packages to update:     115
           Create boot environment:     No
               Services to restart:     2
              Rebuild boot archive:     No
Changed fmris:
pkg://openindiana.org/runtime/perl-584@5.8.4,5.11-0.148:20101122T085618Z -> None
pkg://openindiana.org/runtime/perl-584/extra@5.8.4,5.11-0.148:20101122T085622Z -> None
...

If everything work fine, you should see this message:

DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                              130/130 15260/15260  106.7/106.7

PHASE                                        ACTIONS
Removal Phase                              4253/4253
Install Phase                            16931/16931
Update Phase                               5112/5112

PHASE                                          ITEMS
Package State Update Phase                   245/245
Package Cache Update Phase                   117/117
Image State Update Phase                         2/2

---------------------------------------------------------------------------
NOTE: Please review release notes posted at:

http://wiki.openindiana.org/oi/oi_151a+Release+Notes

---------------------------------------------------------------------------

root@global:~#

Now it’s time to restart your zone and check it’s status.

root@global:~# zoneadm -z test boot
root@global:~# zlogin test
[Connected to zone 'test' pts/2]
Last login: Wed Oct  4 23:10:48 on pts/2
OpenIndiana (powered by illumos)    SunOS 5.11    oi_151a    September 2011
root@test:~#

As you can see, the Zone now runs OpenIndiana Build 151a

If you develop a website or webapplication it’s always a good idea to reduce the number of HTTP requests by combining the Javascript and CSS into single files. In addition those files should be minimized.

There is a cool Java-tool available which can help you: YUI-Compressor. It can be used from the commandline and is able to minimize Javascript and CSS files. A document about the CSS minification can be found here.

To automate the process of concatination and minification I wrote a little ANT script.

Ant Script for CSS and JS concatination and minification

All settings can be found in the head, pathes can be either relational or absolut. You have to download a current version of YUI-Compressor from here:

Download YUI-Compressor.

<!-- Settings for CSS -->
<property name="css.src-dir" value="path-to-css-source"/>
<property name="css.dest-dir" value="path-to-css-destination"/>
<property name="css.files" value="
    css1.css,
    css2.css
"/>

<!-- Settings for JS -->
<property name="js.src-dir" value="path-to-js-source"/>
<property name="js.dest-dir" value="path-to-js-destination"/>
<property name="js.files" value="
    js1.js,
    js2.js
"/>

<!-- General settings -->
<property name="yuicompressor-jar" value="path-to-yuicompressor.jar"/>

I defined three targets to provide a maximum of flexibility:

  • all: Triggers css and javascript target
  • css: Processes CSS
  • javascript: Processes Javascript

Those targets can be called from commandline:

root@test:~# ant -f minify.xml TARGET

The CSS and Javascript target first concat the given CSS/JS files and then uses YUI-Compressor to minify them. The concated version will be deleted afterwards.

NOTE: YUI-Compressor version minor 2.4.4 have a bug which prevents the usage of Media-Queries in minified CSS!!!

In some cases, it’s neccessary to use a newer GCC compiler (Homepage) than the one provided via a package-manager. OpenSolaris currently provices a GCC 3.4.3 and GCC 4.3. This guide should help you to compile GCC 4 on OpenSolaris, in this case GCC 4.6.1.
The whole software compiled in this guide will be installed in /opt/local. As I don’t run OpenSolaris on a single-core machine, I’ll use the -j switch for make to compile multithreaded.

Basics

Like in most howtos, we need some basic packages from the repository. Those are required to compile GCC and it’s dependencies.

root@test:~# pkg install wget SUNWgcc SUNWgmake SUNWxcu4 system/library/math/header-math
               Packages to install:     7
           Create boot environment:    No
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  7/7   2393/2393    37.1/37.1

PHASE                                        ACTIONS
Install Phase                              3215/3215

PHASE                                          ITEMS
Package State Update Phase                       7/7
Image State Update Phase                         2/2

Building dependencies

The next step is to compile some dependencies of GCC. We could use OpenSolaris packages, but those are most likely outdated too.

binutils

The first part of software we will build are the binutils (Homepage). The current release is 2.21.1 and can be downloaded from here.

root@test:~# wget http://ftp.gnu.org/gnu/binutils/binutils-2.21.1.tar.gz
--2011-08-05 20:54:31--  http://ftp.gnu.org/gnu/binutils/binutils-2.21.1.tar.gz
Connecting to ftp.gnu.org|140.186.70.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25195472 (24M) [application/x-gzip]
Saving to: `binutils-2.21.1.tar.gz'

100%[==============================================>] 25,195,472   441K/s   in 58s

2011-08-05 20:55:29 (427 KB/s) - `binutils-2.21.1.tar.gz' saved [25195472/25195472]

root@test:~# tar xjf binutils-2.21.1.tar.gz
root@test:~# cd binutils-2.21.1
root@test:~/binutils-2.21.1# ./configure --prefix=/opt/local/gnu --disable-nls
checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
...

root@test:~/binutils-2.21.1# gmake -j 4 && gmake install
gmake[1]: Entering directory `/root/binutils-2.21.1'
Configuring in ./intl
...
gmake[1]: Nothing to be done for `install-target'.
gmake[1]: Leaving directory `/root/binutils-2.21.1'

root@test:~/binutils-2.21.1# gmake clean
gmake[1]: Entering directory `/root/binutils-2.21.1'
Doing clean in bfd
...

root@test:~/binutils-2.21.1# cd ..
root@test:~# rm -r binutils-2.21.1*
gmplib

Now we will compile three libraries, which depend on each other. The first one is gmp (Homepage) in version 5.0.2.

root@test:~# wget ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
--2011-08-05 22:13:01--  ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
           => `gmp-5.0.2.tar.bz2'
Resolving ftp.gmplib.org... 130.237.222.241
Connecting to ftp.gmplib.org|130.237.222.241|:21... #connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/gmp-5.0.2 ... done.
==> SIZE gmp-5.0.2.tar.bz2 ... 2024576
==> PASV ... done.    ==> RETR gmp-5.0.2.tar.bz2 ... done.
Length: 2024576 (1.9M) (unauthoritative)

100%[===============================================>] 2,024,576    195K/s   in 11s

2011-08-05 22:13:13 (187 KB/s) - `gmp-5.0.2.tar.bz2' saved [2024576]

root@test:~# tar xfj gmp-5.0.2.tar.bz2
root@test:~# cd gmp-5.0.2
root@test:~/gmp-5.0.2# ./configure --prefix=/opt/local/gmp/5.0.2 \
    --build=i386-pc-solaris2.11

checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
...

root@test:~/gmp-5.0.2# gmake -j 4
gcc -std=gnu99 `test -f 'gen-fac_ui.c' || echo './'`gen-fac_ui.c -o gen-fac_ui
gcc -std=gnu99 `test -f 'gen-fib.c' || echo './'`gen-fib.c -o gen-fib
...

root@test:~/gmp-5.0.2# gmake install
gmake  install-recursive
gmake[1]: Entering directory `/root/gmp-5.0.2'
...

root@test:~/gmp-5.0.2# gmake clean
Making clean in doc
gmake[1]: Entering directory `/root/gmp-5.0.2/doc'
...

root@test:~/gmp-5.0.2# cd ..
root@test:~# rm -r gmp-5.0.2*
root@test:~# ln -s /opt/local/gmp/5.0.2/lib/* /usr/lib/
mpfr

MPFR (Homepage) depends on GMP and is next on our list.

root@test:~# wget http://www.mpfr.org/mpfr-current/mpfr-3.0.1.tar.gz
--2011-08-05 21:09:42--  http://www.mpfr.org/mpfr-current/mpfr-3.0.1.tar.gz
Resolving www.mpfr.org... 152.81.144.6
Connecting to www.mpfr.org|152.81.144.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1478243 (1.4M) [application/x-gzip]
Saving to: `mpfr-3.0.1.tar.gz'

100%[================================================>] 1,478,243    412K/s   in 3.7s

2011-08-05 21:09:46 (394 KB/s) - `mpfr-3.0.1.tar.gz' saved [1478243/1478243]

root@test:~# tar xfj mpfr-3.0.1.tar.gz
root@test:~# cd mpfr-3.0.1
root@test:~/mpfr-3.0.1# ./configure --prefix=/opt/local/mpfr/3.0.1 \
    --build=i386-pc-solaris2.11 \
    --with-gmp=/opt/local/gmp/5.0.2

checking for a BSD-compatible install... ./install-sh -c
checking whether build environment is sane... yes
...

root@test:~/mpfr-3.0.1# gmake -j 4 install
gmake  install-recursive
gmake[1]: Entering directory `/root/mpfr-3.0.1'
...

root@test:~/mpfr-3.0.1# gmake clean
Making clean in tests
gmake[1]: Entering directory `/root/mpfr-3.0.1/tests'
..

root@test:~/mpfr-3.0.1# cd ..
root@test:~# rm -r mpfr-3.0.1*
root@test:~# ln -s /opt/local/mpfr/3.0.1/lib/* /usr/lib/
mpc

The final dependeny is mpc (Homepage) which depends on both GMP and MPFR. The current version is 0.9, but this one doesn’t compile on OpenSolaris. We will use 0.8.2 instead.

root@test:~# wget http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
--2011-08-05 21:32:50--  http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
Resolving www.multiprecision.org... 213.165.76.208
Connecting to www.multiprecision.org|213.165.76.208|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 548401 (536K) [application/x-tar]
Saving to: `mpc-0.8.2.tar.gz'

100%[=====================================================>] 548,401      265K/s   in 2.0s

2011-08-05 21:32:52 (265 KB/s) - `mpc-0.8.2.tar.gz' saved [548401/548401]

root@test:~# tar xfj mpc-0.8.2.tar.gz
root@test:~# cd mpc-0.8.2
root@test:~/mpc-0.8.2# ./configure --prefix=/opt/local/mpc/0.8.2 --build=i386-pc-solaris2.11 --with-gmp=/opt/local/gmp/5.0.2 --with-mpfr=/opt/local/mpfr/3.0.1
checking for a BSD-compatible install...
...

root@test:~/mpc-0.8.2# gmake -j 4 install
Making install in src
gmake[1]: Entering directory `/root/mpc-0.8.2/src'
...

root@test:~/mpc-0.8.2# gmake clean
Making clean in doc
gmake[1]: Entering directory `/root/mpc-0.8.2/doc'
...

root@test:~/mpc-0.8.2# cd ..
root@test:~# rm -r mpc-0.8.2*
root@test:~# ln -s /opt/local/mpc/0.8.2/lib/* /usr/lib/

GCC

Now we can finally begin to compile GCC. The current release is 4.6.1.

root@test:~# wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6.1/gcc-4.6.1.tar.gz
--2011-08-05 21:36:24--  ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.6.1/gcc-4.6.1.tar.gz
           => `gcc-4.6.1.tar.gz'
Resolving ftp.fu-berlin.de... 130.133.3.130
Connecting to ftp.fu-berlin.de|130.133.3.130|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /unix/languages/gcc/releases/gcc-4.6.1 ... done.
==> SIZE gcc-4.6.1.tar.gz ... 93426552
==> PASV ... done.    ==> RETR gcc-4.6.1.tar.gz ... done.
Length: 93426552 (89M) (unauthoritative)

100%[=================================================>] 93,426,552   348K/s   in 3m 57s

2011-08-05 21:40:21 (385 KB/s) - `gcc-4.6.1.tar.gz' saved [93426552]

root@test:~# tar xjf gcc-4.6.1.tar.gz
root@test:~# mkdir gcc-obj
root@test:~# cd gcc-obj/
root@test:~/gcc-obj# ../gcc-4.6.1/configure \
    --with-gmp=/opt/local/gmp/5.0.2 \
    --with-mpfr=/opt/local/mpfr/3.0.1 \
    --with-mpc=/opt/local/mpc/0.8.2 \
    --with-gnu-as \
    --with-as=/opt/local/gnu/bin/as \
    --enable-shared \
    --disable-nls \
    --enable-languages=c,c++,objc \
    --prefix=/opt/local/gcc/4.6.1

checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
...

root@test:~/gcc-obj# gmake -j 4
a lot of stuff, get a coffee...
...

root@test:~/gcc-obj# gmake install

root@test:~/gcc-obj# gmake clean

root@test:~/gcc-obj# cd ..
root@test:~/gcc-obj# rm -r gcc*

Now you have compiled your own GCC and can call it from /opt/local/gcc/4.6.1/bin.