English | Deutsch
Home » Community

Building of Gpg4win under Windows
via virtual GNU/Linux

Warning: The instructions are unmaintained and may not work anymore. Please refer to the GnuPG Wiki for maintained build instrucions.

Hints: Building under GNU/Linux in more detail and installation of Debian GNU/Linux Etch 4.0 within a virtual QEMU machine illustrated as screenshot-series..

Back to the overview on building Gpg4win

Contents

Introduction

I - Installation of Debian GNU/Linux Etch 4.0 in a virtual environment
I-1 - Installation of QEMU
I-2 - Installation of PuTTY
I-3 - Getting a Debian Etch boot medium
I-4 - Open a CMD Shell
I-5 - Create the hard disk image
I-6 - Starting the Etch installation
I-7 - Finalize the Etch installation

II - Build of Gpg4win
II-1 - Start the virtual machine
II-2 - Installation of important packages for building Gpg4win
II-3 - Building Gpg4win installation packages
II-4 - Extraction of the final installation packages

References (URLs)

Introduction

The building process of Gpg4win is aligned to a cross-compiling under GNU/Linux. The creation of a suitable building environment under MS Windows or for other operating system is possible in principle, but requires comprehensive adjustment work on the modules integrated in Gpg4win. The installation of a virtual GNU/Linux system is substantially simpler within Windows, in which the building process can be accomplished then.

This manual describes, how such a virtual GNU/Linux can be installed with Free Software and used for building of installation packages. QEMU 0.9.0 [1], standing under GNU GPL, is used as a virtual machine. Debian Etch 4.0 [2] is used as GNU/Linux distribution.

This manual is divided in two parts:

  1. The first part describes, how one installs the software QEMU for virtualisation in the MS-Windows-environment,creates a virtual disk and installs a minimum Debian Etch there.
  2. The second part describes, how the actual building process is supposed to work. This corresponds to the building process under GNU/Linux, which has already been documented. However, it is here again for the sake of completeness.

I - Installation of Debian GNU/Linux Etch 4.0 in a virtual environment

The result of this section is a file, which will contain a partition image of a rudimentary Debian Etch for QEMU (Virtual Machine monitor). The final image file will need approximately 250MB. For the whole process at least 1.5GB disk space should be available on the host system.

I-1 - Installation of QEMU

QEMU is actually a hardware emulator. In other words, QEMU interprets the machine code of the simulated guest system and executes it on the host system. This would also allow to accomplish the building of Gpg4win-packages on a PPC system under Mac OS X-host. In case of an installation under MS Windows on a x86-architecture it is advisable to install the virtualisation module KQEMU, the QEMU accelerator, addtional to the actual emulator. It provides for a direct execution of the guest-system's machine code on the host system, which accelerates the execution enormously, if the guest system likewise has a x86-architecture.

On the 'QEMU for Windows' [3] page you can get compiled installation binaries for QEMU [4] and KQEMU [5]. After downloading the two Binaries they must be simply executed, in order to install them. Please note the path for QEMU installation (e.g. thus: C:\Programs\QEMU).

I-2 - Installation of PuTTY

In order to be able to exchange data between host and guest system, there are several possibilities. In this manual it is suggested to install a Open SSH server on the guest system. In order to be able to communicate with this, an appropriate client software is needed. PuTTY [6] is well suitable for this. A Windows installer can be found here [7]. The installation is also started through file-execution. After the installation it is recommended to extend the PATH variable by the path of Putty installation. Later on the tools 'putty.exe' and 'pscp.exe' will be used.

I-3 - Getting a Debian Etch boot medium

A fast Internet connection is assumed for downloading the packages necessary to build Gpg4win anyway. It is sufficient to have the minimum x86-Net-Installation-Image debian-40r0-i386-netinst.iso (159MB) or the even smaller Business Card image debian-40r0-i386-businesscard.iso (32MB) and to reload the rest of the Debian system during the installation over the net. The Net-Installation image can be found under [8] and the Business image under [9] or alternatively over the appropriate Debian Mirrors.

It is not necessary to burn those images on CD since QEMU can also boot directly from them.

I-4 - Open a CMD-shell

In Start-> Run-dialog please enter 'cmd' and confirm. Enter the following lines in the CMD Shell:

   cd /d <working directory>
   set QEMU=C:\Programs\Qemu
   set PATH=%QEMU%;%PATH%

Whereas <working directory> should be the directory, in which the disk image is. E.g. C:\temp

I-5 - Create the hard disk image

Enter the following in the opened CMD-shell:


   qemu-img create -f qcow2 install.img 2500M

This sets a virtual disk file of the maximum size of 2500MB. The file is only increased to this size if necessary.

I-6 - Start the Etch installation

Enter the following command in one line in the shell


   qemu -k de -m 256 -boot d -L %QEMU%\pc-bios -hda install.img
        -cdrom debian-40r0-i386-businesscard.iso -kernel-kqemu

This starts a virtual PC with 256MB RAM, which boots the net installation image and which gets the evenly produced virtual disk assigned. The path to the boot image should be adapted certainly. The option '-k us' selects the english keyboard layout. The '-kernel kqemu' option activates the full virtualisation of the emulated system, this increases/boosts the performance drastically. If one gets during the start-up/boot-process messages of the form 'hda: lost interrut', one should supplement additionally the option '-no-acpi'. If it should come beyond that to unexpected problems with the virtual machine, the flag should be removed '-kernel kqemu'. Details can be found in the documentation to QEMU.

Now there should be a boot prompt of Debian installation in a actually opened window. This can be started by confirming with the RETURN key. The installation should be kept minimal. After choice of the language the complete virtual disk should be used for the installation. A ext3-partition+swap are fully sufficient for our purposes. The standard network configuration is sufficient likewise.

Beside the root user, a user account 'gpg4win' should be created. This user account is used to complete the building process.

I-7 - Finalize the Etch installation

The current security updates should be installed: 'apt-get update && apt-get upgrade'

Optionally for providing a reusable image: 'apt-get clean; apt-get auto-clean' These commands deletes the cached downloads.

The guest system can be shut down now with: 'shutdown -h now'

If one wants to produce a reusable base image, you should clean and transparently compress the image. The time and size of the image depends on, whether you want to use Gpg4win permanently or only to try out on Windows. This can be accomplished on CMD-shell with the following commands:


   qemu-img convert -f qcov2 install.img -O qcow2 -c temp.img
   copy temp.img install.img

One should keep a copy of this image and supply regularly with security updates.

II - Construction of Gpg4win

II-1 - Starting the virtual machine

Please enter the following line in an open CMD-shell:


   qemu -redir tcp:5555::22 -m 256 -boot c -L %QEMU%\pc-bios
        -hda install.img -kernel-kqemu

The '-redir'-option ensures for the fact that TCP inquiries to the host port 5555 are passed on to the host port 5555 to the guest port 22 (SSH). If necessary, the firewall of Windows XP will ask whether the port 5555 is to be blocked. You can confirm this, if you want to access the virtual machine only from the local computer. Otherwise you should allow to pass the inquiries.

II-2 - Installation of important packages for building Gpg4win

After that, as a root user, one should get the sytem up-to-date with the following commands: 'apt-get update && apt-get upgrade'


   apt-get install \
     subversion autoconf automake gettext \
     mingw32 nsis stow unzip texinfo imagemagick \
     libglib2.0-dev tetex-bin tetex-extra gs-common hyperlatex \
     make bzip2 gcc openssh-server

Subversion (or the command svn) belonged to the source code management system used for Gpg4win. It is needed only if one wants to build Gpg4win directly from the svn source-code management system. If you use archive files (ending .tar.gz or .tar .bz2) of a published version, then one can do without subversion.

The OpenSSH-Server facilitates communication with the virtual machine. You could log-in with PuTTY as well as copy files with pscp in and out. The first method offers quite usable working environment (e.g. copy & paste), the latter allows to easily retrieve the resulting new installation packages.

If OpenSSH server is installed on the guest system and PuTTY on the host system, one can log in with PuTTY into the guest. The connecting data reads: gpg4win@localhost, port: 5555. The password in the case of the finished image is 'gpg4win'.

In order to avoid problems with the 'Locale' (these are the settings for the support of your language and other language specific settings), it is recommendable to produce e.g. the de_DE-Locale (support for german as it is used in Germany). For this please enter the following as root user:


  dpkg-reconfigure locales

and tick the check mark of de_DE set.

II-3 - Building Gpg4win installation packages

Logs in as user 'gpg4win' and enter the following on the Linux Shell, in case you want to build Gpg4win out of the SVN repository:


  export LANG=de_DE
  svn co https://svn.wald.intevation.org/svn/gpg4win/trunk
  cd trunk/packages
  sh download.sh
  cd ..
  ./autogen.sh
  ./autogen.sh --build-32 --enable-maintainer-mode
  make

When this was completed successfully, the new installation packages are available under trunk/src.

II-4 - Extraction of the final installation packages

Please enter the following command on a CMD Shell in the Windows host system:


  pscp -P 5555 gpg4win@localhost:trunk/src/gpg4win-*.exe .

It is assumed that pscp.exe is in the PATH. After the successful transfer was successfully locked, the guest Linux system can be shutdown.

References (URLs)

[1] http://fabrice.bellard.free.fr/qemu/
[2] http://www.debian.org/
[3] http://www.h7.dion.ne.jp/~qemu-win/
[4] http://www.h6.dion.ne.jp/~kazuw/qemu-win/Qemu-0.9.0-install.exe
[5] http://www.h6.dion.ne.jp/~kazuw/qemu-win/Kqemu-1.3.0pre11-install.exe
[6] http://www.chiark.greenend.org.uk/~sgtatham/putty
[7] http://www.tartarus.org/~simon/putty-snapshots/x86/putty-installer.exe
[8] http://cdimage.debian.org/debian-cd/4.0_r0/i386/iso-cd/debian-40r0-i386-netinst.iso
[9] http://cdimage.debian.org/debian-cd/4.0_r0/i386/iso-cd/debian-40r0-i386-businesscard.iso