Archive for the ‘Ant’ Category.

Ant script, build Apache 2.2 and Mod_ssl

A friend of mine wanted to run the latest Aspache Mod_ssl available as some vulnerable holes have been patched in OpenSsl, but in order to do that you need to build it your self. Can you take a look he said, sure why not, he gave me a couple of links for instructions which is really all you need.

Instructions
Apachelounge
Devside

Source code(s)
OpenSsl
Apache
Zlib

Now I’m expecting my friend will need to do this again with another version in the future. So I figured why don’t we just create Ant script out of it. That way next time around we only need to change a couple of params about the source packages and we are off to the races. One click ant script should do the trick.

There are a couple of things that you have to have installed first on your system before you start. One is perl, I’m using ActivePerl but you should also be able to use other compatible perl packages. Another is awk, you might have to use gawk which you can then rename as awk on you computer before you start. Both of those need to be installed and available in the system path. I also have Vs2005 installed and that’s the one that will be used to do the compile. Also Zdll.lib was extracted from the Zlib binary as I got up against naming conflict on that one, put that one in \lib\zlib

Of course a simple Ant script to compile those would be impossible without the instructions mentioned before. And of course above all the people that put in the work to create the make files etc. Without them I would still be lost !

Here is the Ant script,

<project name=“nativeIndian” default=“ApacheBuild” basedir=“.”>

        <!–
    11/2009 – ORN
    ===
    – Apache –
    http://www.apachelounge.com/viewtopic.php?t=778
    http://www.devside.net/guides/windows/apache
    –
    http://www.openssl.org/source/
    http://httpd.apache.org/download.cgi
    http://www.zlib.net/

    ****
      Note –
      ActivePerl and Awk need to be present and available in the path.
      VS2005 is used to compile.
    ****

    This script will attempt the following
    ==========================================
    * Unzip sources
    * Set sources in place for compile
    * Compile OpenSsl
    * Test OpenSsl
    * Compile Apache
        –>

        <!– set global properties for this build –>
  <property name=“ApacheName” value=“Apache22” />
  <property name=“srcDir” location=“${basedir}/../” />
  <property name=“libDir” location=“${basedir}/../lib/” />
  <property name=“zipLibDir” location=“${basedir}/../lib/zlib/” />
  <!– Source –>
  <property name=“OpenSslTop” value=“openssl-0.9.8l” />
  <property name=“OpenSslSourceGz” location=“${basedir}/../${OpenSslTop}.tar.gz” />
  <property name=“OpenSslSourceTar” location=“${basedir}/../${OpenSslTop}.tar” />
  <property name=“ZlibTop” value=“zlib-1.2.3” />
  <property name=“ZlibSourceGz” location=“${basedir}/../${ZlibTop}.tar.gz” />
  <property name=“ZlibSourceTar” location=“${basedir}/../${ZlibTop}.tar” />
  <property name=“ApacheSourceTop” value=“httpd-2.2.14” />
  <property name=“ApacheSource” location=“${basedir}/../${ApacheSourceTop}-win32-src.zip” />
  <property name=“ApacheBin” value=“Apache_bin.zip” />
  <!– Build dirs–>
  <property name=“buildDir” location=“${basedir}/aphache/” />
  <property name=“buildLibDir” location=“${buildDir}/${ApacheSourceTop}/srclib/” />
  <property name=“buildLibZlibDir” location=“${buildDir}/${ApacheSourceTop}/srclib/zlib/” />
  <property name=“buildLibOpenSslDir” location=“${buildDir}/${ApacheSourceTop}/srclib/OpenSsl/” />

  <!– Hardcoded, VS2005 location –>
  <property name=“VsEnvir” location=“D:\apps\dev\Ide\vs2005\VC\vcvarsall.bat” />

  <!– TIMESTAMPS –>
        <tstamp>
                <format property=“TheStartTime” pattern=“dd-MM-yyyy hh:mm aa” />
        </tstamp>

 
  <!– DEFAULT RUN TARGETS  –>
  <target name=“ApacheBuild” depends=“startme,cleanUp,setup,compile,zipbin” >
    <echo message=“– Ending=${TheStartTime}” />
    <echo message=“– Done !” />
  </target>

 
  <!– Startup –>
  <target name=“startme” >
    <echo message=“– Start startme:” />
    <echo message=“– ${TheStartTime}” />
    <mkdir dir=“${buildDir}” />
  </target>

  <!– Fails on cleanup, as it might be clean already, or never created –>
        <target name=“cleanUp” >
    <echo message=“– Start cleanup:” />
                <delete dir=“${buildDir}” failonerror=“yes”/>
    <delete file=“${basedir}/${ApacheBin}” />
        </target>

  <!– Unzip and copy –>
  <target name=“setup” >
    <echo message=“– Start setup:” />
   
    <!– make sure the build dir is present –>
    <mkdir dir=“${buildDir}” />
   
    <!– Apache source –>
    <unzip src=“${ApacheSource}” dest=“${buildDir}”/>
   
    <!– OpenSsl source –>
    <gunzip src=“${OpenSslSourceGz}”/>
    <untar src=“${OpenSslSourceTar}” dest=“${buildDir}”/>
    <!– Add openssl to source dir –>
    <move todir=“${buildLibOpenSslDir}”>
      <fileset dir=“${buildDir}/${OpenSslTop}”/>
    </move>

    <!– Zlib source –>
    <gunzip src=“${ZlibSourceGz}”/>
    <untar src=“${ZlibSourceTar}” dest=“${buildDir}”/>
    <!– Add Zlib to source dir –>
    <move todir=“${buildLibZlibDir}”>
      <fileset dir=“${buildDir}/${ZlibTop}”/>
    </move>
    <!– Add zlib lib to source dir as well –>
    <copy file=“${zipLibDir}/zdll.lib” todir=“${buildLibZlibDir}”/>

  </target>
 
 
 
  <!– Compile packages  –>
  <target name=“compile” >
    <echo message=“– Start compile:” />

    <!– Vs2005 environment variables –>
    <exec executable=“cmd”>
      <arg value=“/c”/>
      <arg value=“${VsEnvir}”/>
    </exec>

    <!– Build OpenSsl –>
    <echo message=“– Start compile OpenSsl:” />
    <exec executable=“cmd” dir=“${buildLibOpenSslDir}” >
      <arg value=“/c”/>
      <arg value=“perl Configure VC-WIN32”/>
    </exec>
    <exec executable=“cmd” dir=“${buildLibOpenSslDir}”>
      <arg value=“/c”/>
      <arg value=“ms\do_masm”/>
    </exec>
    <exec executable=“cmd” dir=“${buildLibOpenSslDir}”>
      <arg value=“/c”/>
      <arg value=“nmake -f ms\ntdll.mak”/>
    </exec>
    <!– Test OpenSsl –>
    <echo message=“– Start test OpenSsl:” />
    <exec executable=“cmd” dir=“${buildLibOpenSslDir}/out32dll”>
      <arg value=“/c”/>
      <arg value=“..\ms\test”/>
    </exec>

   
    <!– Build Apache with the default localhost, port 80 –>
    <echo message=“– Start compile Apache:” />
    <exec executable=“cmd” dir=“${buildDir}/${ApacheSourceTop}”>
      <arg value=“/c”/>
      <arg value=“nmake /f Makefile.win SERVERNAME=localhost PORT=80 INSTDIR=${buildDir}/../${ApacheName} installr”/>
    </exec>

  </target>

  <!– Zip up the Apache  –>
  <target name=“zipbin” >
    <zip
      destfile=“${basedir}/${ApacheBin}”
      basedir=“${buildDir}/../${ApacheName}”
    />

  </target>

</project>