RunningWinefromGitOffALiveUSB

This article describes the way to launch applications through Wine working out of Git without having to boot from HDD or LiveCD. The base operation system on the top of which Wine runs is KNOPPIX.

Setting up for remastering

Mounting external partition to prepare KNOPPIX in

Boot from the Knoppix CD Open a root shell: Menu->Accessories->Root Shell (or launch a shell in usual mode and type "su -") Configure your Internet connection. If you use DHCP, it should already be configured.

{i} Note: Run ifconfig to check.

Find the partition you will use to work on. In this example it is called sda1 . The partition should have a minimum of 5 GB free space.

Run this command to learn which partitions are seen in your system:

blkid -c /dev/null

The output will look like this:

/dev/sdc1: LABEL="BACKUP" UUID="66E4DC83E4DC56C1" TYPE="ntfs"

Create a directory to mount the partition:

mkdir /media/Data

Now, add such a value to the end of fstab by means of redirection output, having replaced parameters with your own:

echo "UUID=66E4DC83E4DC56C1 /media/Data ntfs defaults,nls=utf8,uid=1000,umask=077 0 0" >> /etc/fstab

Explanations: uid describes by whom the partition is owned, specify a numeric value or a user name, uid=1000 means that you are owner; umask=077 sets permissions: the first figure means permissions for the owner, the second - for the group, the third - for somebody else but root. There are the following variants:

  • 0 – read, write and execute
  • 1 – read and write
  • 2 – read and execute
  • 3 – read only
  • 4 – write and execute
  • 5 – write only
  • 6 – execute only
  • 7 – no permissions

{i} Note: After Wine is complied, wineserver may throw an error in case somebody else besides the current owner has access to the partition, so umask=077 is recommended.

Test the added partitions for errors and mount them:

mount -a

You need a root directory /knx to work in; if you put all your files here it will be easy to clean up. Two sub-directories will be used, one for the Master-CD

mkdir -p /media/Data/knx/master

Creating a swapfile

cd /media/Data/knx
dd if=/dev/zero of=swapfile bs=1M count=500
mkswap swapfile ; swapon swapfile

Copying of KNOPPIX source files into the working directory

Make a sub-directory for the source:

mkdir -p /media/Data/knx/source/KNOPPIX

Now, copy the KNOPPIX files to your source directory :

{i} Note: This will take a long time (you are copying 2.4 GB).

cp -rp /KNOPPIX/* /media/Data/knx/source/KNOPPIX

Additionally, copy the files to build the ISO later:

rsync -aH --exclude="KNOPPIX/KNOPPIX" /mnt-system/* /media/Data/knx/master

Preparing the environment for chroot

Installing dchroot

In order to get Wine properly working in the isolated environment, chroot, we must not have root priveleges there; this is where dchroot comes in - it enables us to work in the isolated environment as a regular user. First, run

apt-get update

Now, install dchroot by:

apt-get install dchroot

Edit the dchroot configuration file, so as we could access KNOPPIX that is being remastered by name, as a regular user:

echo "KNOPPIX /media/Data/knx/source/KNOPPIX" >> /etc/dchroot.conf

Mounting /dev, /proc, /sysfs

mount --bind /dev /media/Data/knx/source/KNOPPIX/dev
mount -t proc proc /media/Data/knx/source/KNOPPIX/proc
mount -t sysfs sysfs /media/Data/knx/source/KNOPPIX/sys

Preparing X11

Make the X server of the host operation system accessible via Unix domain sockets from within chroot:

mkdir -p /media/Data/knx/source/KNOPPIX/tmp/.X11-unix
mount --bind /tmp/.X11-unix /media/Data/knx/source/KNOPPIX/tmp/.X11-unix

Allow processes within chroot to use the display:

xhost + local:

Next, make sure the DISPLAY environment variable is set and matches what is used by your terminal and other X11 apps. Lastly, to copy over the .Xauthority, use xauth. You need to find the matching cookie for your X11 session and this cookie will be different for every session. Use xauth list $DISPLAY to print out cookies for your DISPLAY. The name will look like host:? or host/unix:? where host is the hostname of the computer and ? is the display number. The display number can be retrieved with echo $DISPLAY and it will be the number following the colon (:) and before any period (.) To copy over the Xauthority, use something like this:

xauth extract /media/Data/knx/source/KNOPPIX/.Xauthority host/unix:?

On my machine, it looked in the following way:

xauth extract /media/Data/knx/source/KNOPPIX/.Xauthority Microknoppix/unix:0
xauth -f /media/Data/knx/source/KNOPPIX/.Xauthority list

The second command simple list the copied entries. If you need to copy while using sudo or other command to change users, try something like this:

xauth extract - host/unix:1 | sudo xauth -f /path/to/chroot/.Xauthority merge -

If the place you put the .Xauthority file is not the home directory for the chrooted user, you will have to set the XAUTHORITY environment variable:

export XAUTHORITY=/media/Data/knx/source/KNOPPIX/.Xauthority

Copying needed configuration files to get Internet working in chroot

To use the Internet you need to edit 'resolv.conf' to add your nameserver or copy the outer 'resolv.conf' into the chroot folder:

rm -f /media/Data/knx/source/KNOPPIX/etc/resolv.conf
cp /etc/resolv.conf /media/Data/knx/source/KNOPPIX/etc/resolv.conf

In case of proxies (a.k.a. doing it at work) you can type:

export http_proxy="http://myProxy:8080"

alternative

export http_proxy="http://username:password@myProxy:8080

Also change smb.conf to your MS group if you want smbd support (MSHOME is XP Home ed. usually, and WORKGROUP is 9x Windows)

Working in chroot

Switching into the Chroot Environment

Now you can "chroot" into the copied KNOPPIX:

chroot /media/Data/knx/source/KNOPPIX

{i} Note: Remember that anything you do or create in the chrooted environment will get burned to the CD.

Setting up X in chroot

DISPLAY property

Set your DISPLAY variable and use the number of display according to what you got when ran "echo $DISPLAY"

export DISPLAY=:0

Checking if glxgears works in chroot

glxgears

Having a look at glxinfo

glxinfo

Installing needed packages

Solving the mesa problem

libgl1-mesa-glx has unmet dependencies; if you want to use OpenGL, work around this problem by replacing it with the alternative package and then install libgl1-mesa-dev, which provides you with the correct version of libgl1-mesa-glx; but run "apt-get update" before:

apt-get update
apt-get install libgl1-mesa-swx11
apt-get install libgl1-mesa-dev

libglu1-mesa has unmet dependencies as well; I could not solve this issue

Installing packages needed to compile Wine in git

apt-get install git-core bison flex libfreetype6-dev libx11-dev libasound2-dev gettext libfontconfig1-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev libxt-dev libxxf86vm-dev libtiff-dev libjpeg62-dev libpng15-dev liblcms2-dev libgsm1-dev libgphoto2-dev libusb-dev libssl-dev libv4l-dev libhal-dev libdbus-1-dev libsane-dev

Fetching wine source code from remote Git

Download the source code and go to the created folder, which has got the name "wine-git"

git clone git://source.winehq.org/git/wine.git wine-git
cd wine-git

Configuring and compiling wine

Run the configure script and check if there are lacking libraries needed to correctly compile Wine.

./configure --verbose
make

Trying to launch an application

Switching into dchroot

Go to dchroot you created before so as to get into the isolated environment without root privileges

dchroot -c KNOPPIX -d

Installing and launching some application through Wine

Pass Wine the path to the application you want to install

./wine /path/to/some/program\ which\ has\ whitespaces\ in\ its\ name.exe

Go to the directory you installed the program to and try to start it

cd $HOME/.wine/drive_c/Program\ Files/the\ directory\ of\ the\ program\ you\ installed/program.exe

Preparing ISO

We've finished customizing and ready to burn! First do some cleanup in '/media/Data/knx/source/KNOPPIX/tmp/'

KNOPPIX Compressed Image

Now we'll make the big KNOPPIX file which is an ISO 9660 filesystem compressed for use by the cloop driver.

{i} Hint: Copy and paste each of the three following command lines in the root shell in a single line.

genisoimage -R -U -V "KNOPPIX.net filesystem" -publisher "KNOPPIX www.knoppix.net" -no-bak -quiet /media/Data/knx/source/KNOPPIX | /usr/bin/create_compressed_fs -B 65536 -f /media/Data/knx/isotemp - /media/Data/knx/master/KNOPPIX/KNOPPIX

Live CD ISO

First, update the file hashes used by the "testcd" boot option:

cd /media/Data/knx/master ; find -type f -not -name sha1sums -not -name boot.cat -not -name isolinux.bin -exec sha1sum '{}' \; >> KNOPPIX/sha1sums

Now to create the image; for Knoppix:

genisoimage -l -r -J -V "KNOPPIX" --publisher "KNOPPIX www.knoppix.net" -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c boot/isolinux/boot.cat -o /media/Data/knx/remasterd.iso /media/Data/knx/master

The ISO is stored in '/mnt/sda1/knx/remastered.iso'

{i} Hint: Test the ISO for example with VirtualBox before burning with your favorite tools.

Converting and writing the ISO to the Flash image

Obtain Unetbootin at http://unetbootin.sourceforge.net/ and start the application; click the Diskimage radio box and browse to select your ISO, then set your target USB drive, then click OK to start the creation.

Issues

In spite of working glxgears, many OpenGL functions do not work (most likely, due to "solving the mesa problem"); this is still uncomplete and needs looking into.

libxslt, libxml, libgstreamer-plugins-base0.10 are uninstallable.

RunningWinefromGitOffALiveUSB (last edited 2011-08-05 20:13:03 by Bruni)