CREATION OF BINARY PACKAGES FOR YOUR LINUX DISTRIBUTION
=======================================================
Last updated in 2007-01-11 by William Spinelli, wspinell@elet.polimi.it
 
This is a simple HOWTO to create binary packages for your Linux distribution.
Currently both .deb packages (Debian/Ubuntu), and .rpm packages (Fedora/Suse)
are supported.

0. Compile OpenModelica, OMShell and OMNotebook as usual and then follow the
   steps


1. Install the required packages
      Debian/Ubuntu:    $ sudo apt-get install dpkg-dev fakeroot dpkg-sig
      Fedora (as root): $ sudo yum install rpmlint createrepo
      Suse:             install rpmlint and createrepo in YaST


2. Edit the build_deb.sh or build_rpm.sh script depending on the kind of
   package that you want to build

 * Update the variables pointing to the directories in the tree

   OPENMODELICAROOT is the root of the code tree (e.g.
      /home/william/dev/trunk or /home/william/dev/OPENMODELICA_1_4_2)
      
   MICOHOME is the prefix used for mico installation (e.g.
      /home/william/dev/mico-2.3.12)
   MICOVER is the version of MICO used (e.g. 2.3.12)

 * Update package name and version and set if the release type

   PACKAGENAME is the name of the package as listed by apt-get
      (e.g. openmodelica-1.4 or openmodelica-1.4-dev. Note that the dev suffix
      is automatically added if needed)
   VERSION is a more detailed version number
      (e.g. 1.4.2)
   RELEASE is the progressive number of the releases
      (e.g. 1)
   MYARCH is the architechture (e.g. i386, amd64, powerpc)

   nightlyBuild=0 to create a stable package
   nightlyBuild=1 to create a development package (omc, OMShell and OMNotebook 
      inherits a -dev suffix).


3. Run the build_deb.sh/build_rpm.sh script to create the package, which will
   be located in the "packages" directory. The name of the package will follow
   this pattern
      ${PACKAGENAME}_${VERSION}-${RELEASE}_${MYARCH}.deb
      ${PACKAGENAME}_${VERSION}-${RELEASE}.${MYARCH}.rpm
   (openmodelica-1.4_1.4.2-1_i386.deb, openmodelica-1.4-dev-1.4.3-1.i386.rpm)


4. To install the package run
      DEB package:            $ sudo dpkg -i packages/packagename.deb
      RPM package (as ROOT):  $ rpm -Uvh packages/packagename.rpm


5. To make available the packages through a repository you should digitally sign
   them. Generate a key with
      $ gpg --gen-key
   and list your signatures with
      $ gpg --list-sigs
    
   /home/william/.gnupg/pubring.gpg
   ----------------------------------
   pub   1024D/xxxxxxxx 2007-01-11
   uid                  William Spinelli <wspinell@elet.polimi.it>

   Now you need to generate a public key with the given uid
      $ gpg --armor --export "William Spinelli <wspinell@elet.polimi.it>" > RPM-GPG-KEY-openmodelica
   The public key should be imported by the user before installing the package
   
   DEB packages
   ------------
   Run the command
      $ dpkg-sig --sign ubuntu *.deb
   (The package is signed but the verification step fails)

   RPM packages
   ------------
   Edit the ~/.rpmmacros file and add
      %_signature gpg
      %_gpg_name William Spinelli <wspinell@elet.polimi.it>
      %_gpgbin /usr/bin/gpg
   and sign your rpm packages with
      $ rpm --addsign packagename.rpm


6. To create a repository

   DEB repository
   --------------
   * Create a local directory with all the .deb packages that you want to make
     available and in this directory run
      $ dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
   * Upload the debs and the file Packages.gz to a website
      (e.g. http://www.somewebsite.com/somedirectory/ubuntu)

   FEDORA repository
   -----------------
   * Create a local directory with all the .rpm packages that you want to make
     available and inside this directory run
      $ createrepo .

   * Upload the rpms, the repodata directory and the GPG key to a website
      (e.g. http://www.somewebsite.com/somedirectory/fedora)

   SUSE repository
   ---------------
   * Create a local directory with a subdirectory for each supported architecture
      +- i586/
              +- openmodelica-1.4-1.4.2-1.i586.rpm
              +- openmodelica-1.4-dev-1.4.3-1.i586.rpm

   * Inside this directory run
      $ createrepo .

   * To digitally sign the repository
      $ gpg -a --detach-sign repodata/repomd.xml
      $ gpg -a --export "William Spinelli <wspinell@elet.polimi.it>" > repodata/repomd.xml.key

   * Upload the rpms, the repodata directory and the GPG key to a website (preferably FTP)
      (e.g. ftp://ftp.somewebsite.com/somedirectory/suse)


7. To install the package through the repository
   With this solution all the dependencies of the package are automatically
   resolved and installed, so it should be preferred.
 
   DEB repository
   --------------
   * Add the OpenModelica repository to your sources: edit the file
      $ sudo gedit /etc/apt/sources.list
     as root and add the following lines

          # OpenModelica repository
          deb http://www.somewebsite.com/somedirectory/ubuntu ./

   * Add the GPG key
      $ wget http://www.somewebsite.com/somedirectory/ubuntu/RPM-GPG-KEY-openmodelica
      $ sudo apt-key add RPM-GPG-KEY-openmodelica

   * Install the package with
      $ sudo apt-get update
      $ sudo apt-get install openmodelica-1.4
      $ sudo apt-get install openmodelica-1.4-dev


   Currently the package signing doesn't work, so you have to say y when the
   following message appears
      Install these packages without verification [y/N]?
 
   FEDORA repository (as ROOT)
   ---------------------------
   * Import the GPG key
      $ rpm --import http://www.somewebsite.com/somedirectory/fedora/RPM-GPG-KEY-openmodelica
   
   * Add the openmodelica repository (with gedit or another editor)
      $ gedit /etc/yum.repos.d/openmodelica.repo
     and copy and paste the following lines

          [openmodelica]
          name=OpenModelica for Linux
          baseurl=http://www.somewebsite.com/somedirectory/fedora/
          enabled=1

   * Install the required packages
      $ yum install openmodelica-1.4
      $ yum install openmodelica-1.4-dev

   SUSE repository (as ROOT)
   -------------------------
   * Import the GPG key
      $ rpm --import http://www.somewebsite.com/somedirectory/suse/RPM-GPG-KEY-openmodelica
   * Add the directory as an installation source in
      YaST > Change Source of Installation
     Click the ADD button and as Media Type select HTTP/FTP, then enter
      Server Name:          www.somewebsite.com
      Directory on Server   /somedirectory/suse/
   * Install the packages in
      YaST > Software Management
     by searching them in the list



CUSTOMIZING YOUR PACKAGES
=========================
This package comes with the Modelica library 2.2 and with DrModelica 2006-09-07

To change them simply replace the file in the directories
   resources/modelica-2.2
   resources/drmodelica

Be sure that the permissions of the files in these directories are set as
g-w and o-w, otherwise lintian/rpmlint will probably complain when the package
is checked.

To preserve its meaning, update also the changelog files
   resources/doc/changelog.Debian (DEB)
or
   resources/SPECS/openmodelica.spec.xxx
After editing, remove any backup file.


NOTE: 
   If you run into problems during creation or customization of the packages
   send a description of the problem to William Spinelli
   [wspinell@elet.polimi.it] to get help.