Compile script

From AzureusWiki

Jump to: navigation, search

Bash script for compiling Azureus2.jar

     By: Nolar
RE: How to compile Azureus?
2003-09-25 12:33
     Here's a copy of the script I use, hopefully it'll help:
It uses jars from the official CVS page http://azureus.sf.net/cvs/
and the swt.jar from an official Win32 package, as well as a couple others:
http://azureus.sf.net/cvs/seda.jar
http://azureus.sf.net/cvs/swt-pi-osx.jar
http://azureus.sf.net/cvs/apple-extensions.jar
http://azureus.sf.net/cvs/manifest.mf
     <verbatim>
        1. !/bin/bash
        1. I use this script to create an Azureus2.jar file for my Windows
        2. system from the latest CVS source code. Download the latest sources,
        3. copy this file and the swt and systray jars into the the source
        4. directory, and then run the script :)


        1. Location of your 1.4.x java binaries
     JAVADIR="/usr/java/j2sdk1.4.2_01/bin/"
        1. List of required external jar libraries
     REQUIRED="swt.jar log4j-1.2.8.jar commons-cli-1.0.jar seda.jar swt-pi-osx.jar apple-extensions.jar"
        1. Build the classpath
     CLASSPATH=""
     for FILE in $REQUIRED; do CLASSPATH="$CLASSPATH:$FILE"; done


        1. Check to make sure required external libraries are in current directory
     for CLASS in $REQUIRED; do
       if  ! -e $CLASS ; then
         echo "ERROR: Required class $CLASS must be in the current working directory."
         exit
       fi
     done


        1. Remove unneeded CVS directories
     CVS=`find -iname \CVS`
     rm -rf $CVS
        1. Remove currently unused code
     rm -rf plugins/
     rm -rf lib/
     rm -rf org/gudy/azureus2/platform/win32/access/impl/Debug
     rm -rf org/gudy/azureus2/platform/win32/access/impl/Release
        1. Compile the source code
     find -iname \*.java > sources.lst
     if ! ${JAVADIR}javac -verbose -classpath $CLASSPATH @sources.lst ; then
       echo "ERROR: Compile failed!"
       exit 1
     fi


        1. Package up the program into a single jar file
     find -iname \. | grep -v .java | grep -v .jar > resources.lst
     if ! ${JAVADIR}jar -cvmf manifest.mf Azureus2.jar @resources.lst ; then
       echo "ERROR: Packaging failed!"
       exit 1
     fi
     </verbatim>


Here's another version, courtesy of 'mrverbose':

#!/bin/bash

# I use this script to create an Azureus2.jar file.from the latest
# cvs source code.
# Simply start this script and it will download latest cvs sources
# Then it will give you time to modify those sources and compile
# Azureus afterwards.
# You may have to set the user settings below first.

# user settings
###############################################################################
# set this to the location of the REQUIRED jars (see below)
REQUIRED_LOCATION=${HOME}/projects/azureus/required

# List of required external jar libraries
REQUIRED="swt.jar log4j-1.2.8.jar commons-cli-1.0.jar seda.jar swt-pi-osx.jar apple-extensions.jar"
# List of currently unused code
REMOVE="org/gudy/azureus2/platform/win32/access/impl/Debug lib plugins org/gudy/azureus2/platform/win32/access/impl/Release"

# Location of your 1.5.x java binaries
JAVADIR="/usr/lib/java/bin/"
###############################################################################

CURRENTDIR=`pwd`

# Copy all required jar files to azureus2 directory
check_required() {
  for i in $REQUIRED; do
    if [ ! -f azureus2/$i ]; then
      if [ -f $REQUIRED_LOCATION/$i ]; then
        cp $REQUIRED_LOCATION/$i azureus2
      else
        echo "ERROR, $i is required but not found in $REQUIRED_LOCATION"
        exit
      fi
    fi
  done
}

# Run cvs commands on azureus repository
cvs_action() {
  cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/azureus login
  cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/azureus $1 azureus2
  cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/azureus $1 uis
  cp -rf uis/* azureus2
}

# Update/checkout/do nothing based on user input
update_azureus() {
  # Check if azureus2 dir found
  if [ -f azureus2/.cvsignore -a -f uis/.cvsignore ]; then
    echo -n "azureus already found, shall I run cvs update? [yes|no|cancel]: "
    read update
    case $update in
    yes|YES)
      # Update from cvs repository
      cvs_action update
      ;;
    no|NO)
      # Do nothing
      ;;
    cancel|CANCEL)
      exit
      ;;
    *)
      update_azureus
      ;;
    esac
  else
      # Checkout from cvs repository
      cvs_action checkout
  fi
}

update_azureus
check_required

# Go to azureus2 dir for compilation
cd azureus2

if [ ! -f manifest.mf ]; then
  # Generate manifest.mf
  echo "Manifest-Version: 1.0" >> manifest.mf
  echo "Main-Class: org.gudy.azureus2.ui.common.Main" >> manifest.mf
  echo "Class-Path: $REQUIRED" >> manifest.mf
fi

# Stop and wait until user has mad his changes
echo -n "Make your changes and press [ENTER]: "
read confirmation

# Build the classpath
CLASSPATH=""
for FILE in $REQUIRED; do CLASSPATH="$CLASSPATH:$FILE"; done

# Check to make sure required external libraries are in current directory
for CLASS in $REQUIRED; do
  if [ ! -e $CLASS ]; then
    echo "ERROR: Required class $CLASS must be in the current working directory."
    exit
  fi
done

# Remove unneeded CVS directories
CVS=`find -iname \CVS`
rm -rf $CVS

# Remove currently unused code
mkdir /tmp/azct
for i in $REMOVE; do
  mv $i /tmp/azct/
  moved=1
done

# Compile the source code
find -iname \*.java > sources.lst

if ! ${JAVADIR}javac -g:none -nowarn -verbose -classpath $CLASSPATH @sources.lst ; then
  echo "ERROR: Compile failed!"
  exit 1
fi

# Package up the program into a single jar file
find -iname \*.* | grep -v .java | grep -v .jar > resources.lst

if ! ${JAVADIR}jar -cvmf manifest.mf Azureus2.jar @resources.lst ; then
  echo "ERROR: Packaging failed!"
  exit 1
  else
    cp Azureus2.jar $CURRENTDIR
fi

# Move removed files back again
if [ "$moved" = "1" ]; then

  declare -a REMOVAL[]
  idx=1
  for i in $REMOVE; do
    REMOVAL[$idx]=$i
    let idx=$idx+1
  done

  idx=1
  ls /tmp/azct > /tmp/azctlist
  for i in $(echo `</tmp/azctlist`); do
    mv /tmp/azct/$i ${REMOVAL[$idx]}
    let idx=$idx+1
  done
  rm /tmp/azctlist
  rmdir /tmp/azct
fi

# go to directory where we started
cd $CURRENTDIR
Personal tools