Autopackage

Starez uses autopackages to install and patch games.

Creating Starez Autopackages

Starez autopackages are the same as regular autopackages except for one thing: Starez autopackages need to install .strz files. .strz files are XML files that contain information about the autopackage, such as the program-name, version and icon location(the xml fields are identical to the xml fields of games.xml).

The filename of .strz file should be like this: autopackage-shortname.strz In the default.apspec file for your autopackage you need to specify a ShortName in the Meta section, that's the shortname you should use. the .strz file should be installed in $PREFIX/share/starez/temp

You can use the following code for your default.apspec file to create a Starez compatible autopackage:

[BuildPrepare]
mkdirs $build_root/share/starez
mkdirs $build_root/share/starez/temp
cp $SHORTNAME.strz $build_root/share/starez/temp
# The following should be at the end of the BuildPrePare section:
# Comment the following out if you want to create a patch:
# bash autopackage/CreatePatch.sh $build_root my_package_to_patch_against.package  

[..]

[Install]
installData share/starez

[..]

Example.strz: An example .strz file to demonstrate how sucha file looks like.

<?xml version="1.0" ?>
<game>
        <program>my_game</program>
        <launch_params>-cheats</launch_params>
        <icon>%s/share/my_game/my_game.xpm</icon>
        <version>1.0.2</version>
</game>

In case you want to make patches using CreatePatch.sh, you need to create a file called CreatePath.sh in your autopackage directory with the following contents:

#!/bin/bash
# Created by Hylke Donker
if [ ! $1 ] || [ ! $2 ]; then # if either of the arguments is not available
echo "CreatePatch.sh requires atleast two parameters: "
echo "CreatePatch.sh dir autopackage"
exit 1
fi

patch_dir=$1
autopackage=$2

# create temporary directory
tmpdir=`mktemp -d` || exit 1
cp $autopackage $tmpdir
autopackage_file=`basename $2`
chmod +x $tmpdir/$autopackage_file
bash $tmpdir/$autopackage_file -x
rm $tmpdir/$autopackage_file

extracted_dir=$tmpdir/`ls $tmpdir`

function dir_recursive
{
        for file in `ls $1`; do
                if [ -z $1 ]; then
                        relative_path=$file
                else
                        relative_path=$1/$file
                fi

                # if file is directory
                if [ -d $relative_path ]; then
                        dir_recursive $relative_path
                else
                        # If the file used to exist
                        if [ -a $extracted_dir/$relative_path ]; then
                                original=`md5sum $extracted_dir/$relative_path | cut -d " " -f1`
                                new=`md5sum $patch_dir/$relative_path | cut -d " " -f1`
                                # If we already have the same exact file, then remove it
                                if [ $original == $new ]; then
                                        rm $patch_dir/$relative_path
                                fi
                        fi
                fi
        done
}
cd $patch_dir
echo "Removing unmodified files..."
dir_recursive ""

Under the hood

As said, the Starez client uses autopackage to do all the installation related stuff. How this exactly works is actually a little harder then you would think.

|—–←→—– Autopackage-fifo

Starez-Client –> package install my.package → fake-frontend.py

|—←— autopackage.temp ———————————-|

So what happens is, the Starez-client spawns a new process: “package install my.package” with the autopackage-frontend environment-variable set to fake-frontend.py. What happens is, autopackage starts the autopackage-frontend(fake-frontend.py), and fake-frontend.py writes the location to the autopackage-fifo(which is used to communicate between the frontend and backend of autopackage) to a temporary file(autopackage.temp). The Starez-client reads autopackage.temp so it nows where the autopackage-fifo is located, and now acts as the autopackage-frontend.

 
developer/autopackage.txt · Last modified: 2008/04/21 19:22 by 81.71.182.26
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki