[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:kbulgrien

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Tue May 12 22:44:55 CDT 2009


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2009/05/12 22:44
User        : kbulgrien
Edit Summary: Replace the entire build procedure with a script.  Update other content to.

@@ -25,14 +25,8 @@
  ====Portable C/C++====
      * [[http://www.gnu.org/software/automake/manual/autoconf/Portable-C-and-C_002b_002b.html#Portable-C-and-C_002b_002b|Automake Manual Chapter]]
  
  =====SVN Scripts=====
- 
- 
- 
- 
- 
- 
  
  ====svn-co.sh====
  
  This script can do svn 1.5.x sparse checkouts or pre-1.5 checkouts.  The script defaults to using subversion 1.5+ sparse checkouts.  If the older checkout style is desired, the script must be edited to change "if false" to "if true".
@@ -143,8 +137,33 @@
    # Link the arch directory into the server directory tree.
    #
    unlink $(pwd)/server/${COTYPE}/lib/arch 2>/dev/null
    ln -s $(pwd)/arch/${COTYPE} $(pwd)/server/${COTYPE}/lib/arch
+   echo
+ 
+ ==svn-up.sh==
+ 
+ When using SVN 1.5 sparse checkouts built by the above **svn-co.sh**, this script is not needed.  With a sparse checkout, one merely changes to the **crossfire** directory and issues an **//svn update//** command.
+ 
+ Before sparse checkouts were supported, it was common to checkout the various subdirectories of the project separately so that **//svn update//** did not result in the download of all tags, branches, etc.  In lieu of manually updating the many directories separately, this script performed an update operation for each separate svn workspace checked out:
+ 
+   #!/bin/bash
+   #
+   CWD=$(pwd)
+   for co in arch client maps server sounds
+   do
+     for dir in trunk
+     do
+       WORKING=${co}/${dir}
+       if [ -d ${CWD}/${WORKING} ]
+       then
+         echo; echo ${WORKING}; echo
+         cd ${CWD}/${WORKING}
+         svn update
+         cd ${CWD}
+       fi
+     done
+   done
    echo
  
  =====Configure Scripts=====
  
@@ -175,8 +194,27 @@
      bash ./autogen.sh ${CFOPTS} --prefix=/usr/local/games/crossfire
      # --enable-maintainer-mode
    fi
  
+ ====config.sh====
+ 
+ Create yet another shell script called **config.sh** as follows:
+ 
+   #!/bin/bash
+   #
+   export CFLAGS="-ggdb -g -O0"
+   PWD=`pwd`
+   if [ "${PWD/client/}" != "${PWD}" ]
+   then
+     aclocal -I macros --install
+     autoheader
+     automake -a -c
+     autoreconf
+     ./configure --prefix=/home/devel/crossfire/prerelease --enable-cfgtk2
+   else
+     bash autogen.sh --prefix=/home/devel/crossfire/prerelease ${*}
+   fi
+   echo
  
  =====Mandriva 2009.0=====
  
  ====Trunk Client====
@@ -306,190 +344,390 @@
  =====Pre-Release Preparation=====
  
  The directions use SVN trunk as the example release.  The instructions presume you start in the top level SVN directory (the one that contains the arch, client, maps, server) for each phase (arch, client, maps, server)
  
+ This procedure assumes that release operations are done in the ''/home/devel/crossfire/rpmbuild'' directory.
  
- ====Set Up a Pre-Release Workspace====
+ The RPMs build in this procedure may be installed by a user without using **sudo** or root permissions.  The RPMs will be build to install in the user's home directory (**${HOME}/usr/local/games/crossfire**).  This path is chosen so it is clearer how to modify the procedure to build RPMs that install into **/usr/local/games/crossfire**.
  
- Change the following directory to suit:
+ ====Set Up RPM Build Configuration====
  
-   export RELDIR=/home/devel/crossfire/prerelease
-   mkdir -p ${RELDIR}
-   cd ${RELDIR}
+ ===.rpmmacros===
  
- Place these scripts in the pre-release workspace.
+ A key to building RPMs without using sudo or root is centered around creating a .rpmmacros file in the builder's home directory:
  
- ===Scripts to Support Pre-Releasing===
+   # /etc/rpm/macros # (c) GPL 2003 Tero.Karvinen at-sign iki.fi
+   %packager %(echo "$USER")
+   %_topdir /home/devel/crossfire/rpmbuild
+   # %_rpmtopdir %{_topdir}/%{name}/RPM
+   %_rpmtopdir %{_topdir}/RPM
+   %_builddir %{_rpmtopdir}/BUILD
+   %_rpmdir %{_rpmtopdir}/RPMS
+   %_sourcedir %{_rpmtopdir}/SOURCES
+   %_specdir %{_rpmtopdir}/SPECS
+   %_srcrpmdir %{_rpmtopdir}/SRPMS
+   %_tmppath %{_rpmtopdir}/TMP
+   %_buildroot %{_tmppath}/%{name}-root
+   
+   %_datadir %(echo "$HOME")/usr/local/games/crossfire
+   
+   # Build rpms in your home directory, without root priviledges
+   # Users can copy this file to $HOME/.rpmmacros to override
+   # settings, such as packager to "Firstname Lastname email".
+   # Example of typical directory and file hierarchy for
+   # rpm building:
+   #  ~/rpmbuild/
+   #  ~/rpmbuild/nano/ # replace nano with rpm name
+   #  ~/rpmbuild/nano/TMP/
+   #  ~/rpmbuild/nano/BUILD/ # user must create this dir
+   # and files (can be extracted from a source rpm with
+   #  rpm2cpio *.src.rpm |cpio -dvi
+   #   ~/rpmbuild/nano/nano-1.2.tar.gz
+   #   ~/rpmbuild/nano/nano.spec
+   # Then you can build your rpm with
+   #  rm -rf TMP/* BUILD/* ; rpmbuild -ba *.spec 2>&1 |tee rpmbuild.log
+   # For more information, see www.iki.fi/karvinen
  
- This example will presume the use of //trunk// sources.  Feel free to deviate from these instructions to reduce the size of the workspace and the amount of data that must be downloaded.
+ ====Set Up the Pre-Release Workspace====
  
- Create a shell script called **svn-co.sh** with the contents shown [[user:kbulgrien#svn-co.sh|above]].
+   export RELDIR=/home/devel/crossfire/rpmbuild
+   mkdir -p ${RELDIR}
+   cd ${RELDIR}
  
- Create **svn-up.sh** only if **svn-co.sh** was modified to do non-sparse checkouts.
+ ===Scripts to Support Pre-Releasing===
  
- ==svn-up.sh==
+ Place these scripts in the pre-release workspace.
  
-   #!/bin/bash
-   #
-   CWD=$(pwd)
-   for co in arch client maps server sounds
-   do
-     for dir in trunk
-     do
-       WORKING=${co}/${dir}
-       if [ -d ${CWD}/${WORKING} ]
-       then
-         echo; echo ${WORKING}; echo
-         cd ${CWD}/${WORKING}
-         svn update
-         cd ${CWD}
-       fi
-     done
-   done
-   echo
+ This example presumes the use of //trunk// sources, but the scripts support both branch and trunk.  Feel free to deviate from these instructions to reduce the size of the workspace and the amount of data that must be downloaded.
  
- ==config.sh==
+ ==svn-co.sh==
  
- Create yet another shell script called **config.sh** as follows:
+ Place **svn-co.sh**, with the contents shown [[user:kbulgrien#svn-co.sh|above]], in **/home/devel/crossfire/rpmbuild**.
+ 
+ ==prerelease.sh==
  
    #!/bin/bash
    #
-   export CFLAGS="-ggdb -g -O0"
-   PWD=`pwd`
-   if [ "${PWD/client/}" != "${PWD}" ]
+   # A Crossfire RPG project RPM build utility.
+   #
+   # $RCSfile: prerelease.sh,v $ $Revision: 1.9 $ $Date: 2009/05/13 01:56:41 $
+   #
+   # Guess a reasonable default e-mail address for the RPM packager.
+   #
+   export RELWHO="${USER}@$(hostname)"
+   
+   # Determine what to build based on the command-line parameters.
+   #
+   if [ "${1}" = "trunk" ]
    then
-     aclocal -I macros --install
-     autoheader
-     automake -a -c
-     autoreconf
-     ./configure --prefix=/home/data/svn/crossfire/prerelease --enable-cfgtk2
+     REL="trunk"
+     RELVER="2.0"
+     RELTYP="${REL}"
+     shift 1
+   elif [ "${1}" = "branch" ]
+   then
+     REL="branch"
+     if [ -z "${2}" ]
+     then
+       echo -e "\nprerelease.sh: Error: Specify branch version.\n"
+       exit 1;
+     else
+       RELVER="${2}"
+       shift 2
+     fi
+     RELTYP=branches/${RELVER}
    else
-     bash autogen.sh --prefix=/home/data/svn/crossfire/prerelease ${*}
+     echo -e "\nprerelease.sh: Usage:\n"
+     echo -e "  prerelease.sh trunk [email]"
+     echo -e "  prerelease.sh branch 1.xx [email]\n"
+     echo -e "  Where:"
+     echo -e "    xx is the branch number,"
+     echo -e "    email is the RPM packager (default: ${RELWHO})"
+     echo -e "    Suggested e-mail format is \"First I. Last <user at domain>\"\n"
+     exit 1;
    fi
-   echo
- 
- ====SVN Checkout====
- 
-    * Checkout a copy of the relevent portions of the repository.  The rest of this procedure assumes use of the above documented svn-co.sh script, and assumes that trunk is used to build pre-releases in preparation for a real release.
- 
-       bash svn-co.sh
- 
-    * Set up an environment variable that contains the revision information for the SVN Checkout.
- 
-     RELREV=`svnversion arch`
- 
- =====Pre-Release Procedure=====
- 
- ====Arch & Maps====
- 
- The process for both the arch and maps directory is the same - the only difference is the name of the files/paths.
- 
-   * Make an archive of arch directory.  Note we want the arch directory called 'arch' in the archive, hence the symlink.  Gnu tar is used:
- 
+   #
+   # The value to set the RPM Packager property.  Usually this is an e-mail
+   # address:
+   #
+   if [ -z "${1}" ]
+   then
+     export RELWHO="${USER}@${HOSTNAME}.${DOMAINNAME}"
+   else
+     export RELWHO="${1}"
+     shift
+   fi
+   
+   # The working directory in which the build process is done:
+   #
+   export RELDIR=$(pwd)
+   
+   # The rm -rf commands in this script are dangerous.  Manage the risk by
+   # requiring the current run path to contain rpmbuild to assure safety in the
+   # event the script is inadvertently run from somewhere else.  This is a bit
+   # arbitrary.  While unnecessary when the build is done as a user, it is very
+   # wise to limit the script (mis)behavior in the event that it is run with sudo
+   # or with root permissions.
+   #
+   if [ "${RELDIR}" = "${RELDIR//rpmbuild/}" ]
+   then
+     echo -e "\n$(basename ${0}): Error: Run from inside an rpmbuild directory\n"
+   fi
+   
+   # Clean up the local build area by removing files produced while building a
+   # prior snapshot.
+   #
+   cd ${RELDIR}
+   rm -rf bin
+   rm -rf RPM
+   rm -f crossfire-*.gz
+   rm -f crossfire-*.bz2
+   rm -f crossfire-*.tar
+   rm -rf /tmp/crossfire-images
+   
+   # Revert any client files we edit during the release process.
+   #
+   if [ -d client ]
+   then
+     if [ "${REL}" = "trunk" ]
+     then
+       svn revert client/${RELTYP}/configure.ac
+     else
+       svn revert client/${RELTYP}/configure.ac
+     fi
+     svn revert client/${RELTYP}/crossfire-client.spec
+   fi
+   mkdir -p bin RPM/BUILD RPM/RPMS RPM/SOURCES RPM/SPECS RPM/SRPMS
+   
+   # Initialize (first time SVN checkout) the work area as needed.
+   #
+   if [ ! -e .svn ]
+   then
+     rm -rf arch client maps server sounds
+     bash ${RELDIR}/svn-co.sh ${RELTYP//\// }
+     if [ "${?}" -ne 0 ]
+     then
+       exit
+     fi
+   else
+     cd ${RELDIR}/server/${RELTYP}
+     # Clean up files leftover from a prior build.
+     make maintainer-clean
+     cd ${RELDIR}/client/${RELTYP}
+     # Clean up files leftover from a prior build.
+     make maintainer-clean
+     # By this time, there should be no modified files in the build area!  We do
+     # not want to have to handle conflicts in the script.
+     #
+     cd ${RELDIR}
+     svn update
+     # bash ${RELDIR}/svn-up.sh
+   fi
+   
+   # The build area is up to date with SVN, so extract the SVN revision level to
+   # use for this build.
+   #
+   export RELREV=$(svnversion ${RELDIR}/client/${RELTYP} | sed -e 's/[A-Z]//')
+   
+   # Create an arch tarball
+   #
    cd ${RELDIR}/arch
-   ln -s trunk arch
+   if [ ! -e arch ]
+   then
+     ln -s ${RELTYP} arch
+   fi
    gtar -chvz --exclude=.svn \
-     -f ${RELDIR}/crossfire-2.0.0-r${RELREV}.arch.tar.gz arch
- 
-   * Make an archive of the maps directory.  Again, note the naming of paths in the archive is achieved with a symlink:
- 
+     -f ${RELDIR}/RPM/SOURCES/crossfire-${RELVER}.r${RELREV}.arch.tar.gz arch
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   
+   # Create a maps tarball
+   #
    cd ${RELDIR}/maps
-   ln -s trunk maps
+   if [ ! -e maps ]
+   then
+     ln -s ${RELTYP} maps
+   fi
    gtar -chvz --exclude=.svn \
-     -f ${RELDIR}/crossfire-2.0.0-r${RELREV}.maps.tar.gz maps
- 
-   * Make a bzip2 copy of the maps because it saves considerable space.  This may take a little while depending on speed of your system.
- 
-   cd ${RELDIR}
-   gunzip -c crossfire-2.0.0-r${RELREV}.maps.tar.gz \
-   | bzip2 -c9 > crossfire-2.0.0-r${RELREV}.maps.tar.bz2
- 
-   * Pre-release of arch and maps is now complete.
-     
- ====Client====
- 
-   * Update various files with the new version number.  Change the "dev" portion of the 2.0.dev settings to match the actual revision of the checkout.
- 
-   cd ${RELDIR}/client/trunk
-   ex +/AC_INIT.*2.0.dev +s at dev@r${RELREV}@ +:wq configure.ac
-   ex +/%define.*2.0.dev +s at dev@r${RELREV}@ \
-      +/%define.basedir +s@/export/home/crossfire@${RELDIR}@ \
-      +/%define._source +s@/Crossfire@@ +:wq crossfire-client.spec
- 
-   * Reconfigure the client.
- 
-   bash ${RELDIR}/config.sh
- 
-    * Verify the ./configure report indicates ''yes'' for all Build and Scripting options before proceeding to the next step.
- 
-   * Create a crossfire-client-2.0.r${RELREV}.tar.gz.
- 
+     -f ${RELDIR}/RPM/SOURCES/crossfire-maps-${RELVER}.r${RELREV}.tar.gz maps
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   
+   # Create a bz2 version of the maps tarball
+   #
+   if false
+   then
+     cd ${RELDIR}/RPM/SOURCES
+     echo -ec "\nmaps bzip2..."
+     gunzip -c crossfire-${RELVER}.r${RELREV}.maps.tar.gz \
+     | bzip2 -c9 > crossfire-${RELVER}.r${RELREV}.maps.tar.bz2
+     echo -e "\n"
+     if [ "${?}" -ne 0 ]
+     then
+       exit
+     fi
+   fi
+   # Edit the client configure.ac file to insert the revision
+   # information.
+   #
+   cd ${RELDIR}/client/${RELTYP}
+   if [ "${REL}" = "trunk" ]
+   then
+     ex +/AC_INIT.*2.0.dev +s at dev@r${RELREV}@ +:wq configure.ac
+   else
+     ex +/AC_INIT.*${RELVER}.0 +s@${RELVER}.0@${RELVER}.r${RELREV}@ +:wqconfigure.ac
+   fi
+   
+   # Create a client source tarball
+   #
+   bash ${RELDIR}/${RELTYP%%es/*}.config.sh
    make dist
-   mv crossfire-client-2.0.r${RELREV}* ${RELDIR}
- 
-   * Unpack the archive, and verify it works:
- 
-   cd ${RELDIR}
-   gtar xvfz crossfire-client-2.0.r${RELREV}.tar.gz
-   cd crossfire-client-2.0.r${RELREV} 
-   ./configure --prefix=${RELDIR} --enable-cfgtk2
-   make -s
- 
-     * Make sure there are no errors.
- 
-   make install
- 
-     * Run each of the clients and verify they are not brain dead - able to connect to a server and log in.
- 
-   cd ${RELDIR}/bin
-   ./crossfire-client-x11
-   ./crossfire-client-gtk
-   ./crossfire-client-gtk2
-   cd ${RELDIR}
- 
-   * Make sounds archive
- 
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   mv crossfire-client-${RELVER}.r${RELREV}.tar.gz ${RELDIR}/RPM/SOURCES
+   
+   # Normally this is disabled.  It is not useful for automatic
+   # builds, and mostly documents some of the validation that is
+   # done during the release procedure.
+   #
+   if false
+   then
+     # Unpack the client sources.
+     #
+     cd ${RELDIR}/RPM/SOURCES
+     gtar xvfz crossfire-client-${RELVER}.r${RELREV}.tar.gz
+     if [ "${?}" -ne 0 ]
+     then
+       exit
+     fi
+   
+     # Do a preliminary build to show errors.
+     #
+     cd crossfire-client-${RELVER}.r${RELREV}
+     ./configure --prefix=${RELDIR} --enable-cfgtk2
+     make -s
+     if [ "${?}" -ne 0 ]
+     then
+       exit
+     fi
+   
+     # While prior commands could be transformed to scan for
+     # errors, it makes absolutely no sense to launch the
+     # clients during automated builds.
+     #
+     if false
+     then
+       make install
+   
+       cd ${RELDIR}/bin
+       ./crossfire-client-x11
+       ./crossfire-client-gtk
+       ./crossfire-client-gtk2
+     fi
+   
+     # Clean up after the build tests.
+     #
+     cd ${RELDIR}/RPM/SOURCES
+     rm -rf crossfire-client-${RELVER}.r${RELREV}
+   fi
+   
+   # Create a sound file tarball.
+   #
    cd ${RELDIR}/sounds
-   ln -s trunk sounds
+   if [ ! -e sounds ]
+   then
+     ln -s trunk sounds
+   fi
    gtar -chvz --exclude=.svn \
-     -f ../crossfire-client-sounds-2.0.r${RELREV}.tar.gz sounds
- 
-   * Make an image archive for the client.  Needed for RPM building.  Need a server tree with a properly linked arch tree.
- 
-   cd ../server
-   ln -s trunk server
+     -f ${RELDIR}/RPM/SOURCES/crossfire-client-sounds-${RELVER}.r${RELREV}.tar.gz sounds
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   
+   # Create the bmaps.paths file so that image collection will
+   # succeed.
+   #
+   cd ${RELDIR}/server
+   if [ ! -e server ]
+   then
+     ln -s ${RELTYP} server
+   fi
    cd server
-   bash ../../config.sh
-   make
+   bash ${RELDIR}/${RELTYP%%es/*}.config.sh
    cd lib
-   ln -s ../../../arch/trunk arch
+   if [ ! -e arch ]
+   then
+     ln -s ${RELDIR}/arch/${RELTYP} arch
+   fi
+   make
+   
+   # Collect images for the client, and make a tarball.
+   #
    adm/collect_images.pl -archive
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
    cd ..
-   mv crossfire-images.tar ../../crossfire-client-images-2.0.r${RELREV}.tar
-   gzip -v9 crossfire-client-images-2.0.r${RELREV}.tar
+   mv crossfire-images.tar ${RELDIR}/RPM/SOURCES/crossfire-client-images-${RELVER}.r${RELREV}.tar
+   gzip -v9 ${RELDIR}/RPM/SOURCES/crossfire-client-images-${RELVER}.r${RELREV}.tar
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   
+   # Edit the RPM spec file to match local build conditions instead of using the
+   # release specs in SVN.
+   #
+   cp ${RELDIR}/client/${RELTYP}/crossfire-client.spec ${RELDIR}/RPM/SPECS
+   cd ${RELDIR}/RPM/SPECS
+   if [ "${REL}" = "trunk" ]
+   then
+     ex +/%define.*${RELVER}.dev +"s at dev@r${RELREV}@" \
+       +/%define.*packager +"s/.*/%define packager ${RELWHO}/" \
+       +wq crossfire-client.spec
+   else
+     ex +/%define.*version +"s@${RELVER}.0@${RELVER}.r${RELREV}@" \
+        +/%define.*sndver  +"s@${RELVER}.0@${RELVER}.r${RELREV}@" \
+        +/%configure.*     +"s@%configure@%configure --enable-cfgtk2@" \
+        +wq crossfire-client.spec
+   fi
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   ex +/%define._sourcedir +":d 10" \
+     +:wq crossfire-client.spec
+   if [ "${?}" -ne 0 ]
+   then
+     exit
+   fi
+   
+   # Build the RPMS
+   #
+   cd ${RELDIR}
+   rpmbuild -ba ${RELDIR}/RPM/SPECS/crossfire-client.spec
  
- ===Client RPM Files===
+ ==svn-up.sh (optional)==
  
-   * The client archives above must be built prior to creating RPMs.
-   * Make crossfire-client.spec is up to date.  Not that it is likely some of the paths near the top of the file may need to be changed depending on your filesystem layout.
+ Place **svn-up.sh**, with the contents shown [[user:kbulgrien#svn-up.sh|above]], only if **svn-co.sh** is modified to do non-sparse checkouts.
  
-   cd ${RELDIR}/client/trunk
-   ex +/%define.*2.0.dev +s at dev@r${RELREV}@ +:wq crossfire-client.spec
-   ex +/%define._sourcedir +s@/export/home/crossfire/Crossfire@${RELDIR}@ \
-     +/%define._srcrpmdir +s@/export/home/crossfire@${RELDIR}@ \
-     +/%define._rpmdir +s@/export/home/crossfire@${RELDIR}@ \
-     +/%define._topdir +s@/export/home/crossfire@${RELDIR}@ +:wq crossfire-client.spec
+ ====Build Procedure====
  
-   * Build the RPMs:
- 
-   cd ${RELDIR}
-   rpmbuild -ba client/trunk/crossfire-client.spec
+   bash prerelease.sh trunk "Kevin R. Bulgrien <kbulgrien aat att daht net>"
  
    * If there are errors, rpmbuild will tell you.
-   * RPMs will be put in _rpmdir/<architecture>
+   * RPMs will be put in RPM/RPMS/<architecture>
+   * SRPM will be located in RPM/SRPMS
  
  ======Bug Triage======
- 
  
  =====crossfire-client-gtk2=====
  
  ====Client | Save window position====


IP-Address  : 68.90.128.197
Old Revision: http://wiki.metalforge.net/doku.php/user:kbulgrien?rev=1242015170
New Revision: http://wiki.metalforge.net/doku.php/user:kbulgrien

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list