Blame generate_singlerepo_source_tarball.sh

Alex Kashchenko af80df
#!/bin/bash
Alex Kashchenko af80df
# Generates the 'source tarball' for JDK projects.
Alex Kashchenko af80df
#
Alex Kashchenko af80df
# Example:
Alex Kashchenko af80df
# When used from local repo set REPO_ROOT pointing to file:// with your repo
Alex Kashchenko af80df
# if your local repo follows upstream forests conventions, you may be enough by setting OPENJDK_URL
Alex Kashchenko af80df
# if you wont to use local copy of patch PR2126 set path to it to PR2126 variable
Alex Kashchenko af80df
#
Alex Kashchenko af80df
# In any case you have to set PROJECT_NAME REPO_NAME and VERSION. eg:
Alex Kashchenko af80df
# PROJECT_NAME=jdk
Alex Kashchenko af80df
# REPO_NAME=jdk
Alex Kashchenko af80df
# VERSION=tip
Alex Kashchenko af80df
# or to eg prepare systemtap:
Alex Kashchenko af80df
# icedtea7's jstack and other tapsets
Alex Kashchenko af80df
# VERSION=6327cf1cea9e
Alex Kashchenko af80df
# REPO_NAME=icedtea7-2.6
Alex Kashchenko af80df
# PROJECT_NAME=release
Alex Kashchenko af80df
# OPENJDK_URL=http://icedtea.classpath.org/hg/
Alex Kashchenko af80df
# TO_COMPRESS="*/tapset"
Alex Kashchenko af80df
# 
Alex Kashchenko af80df
# They are used to create correct name and are used in construction of sources url (unless REPO_ROOT is set)
Alex Kashchenko af80df
Alex Kashchenko af80df
# This script creates a single source tarball out of the repository
Alex Kashchenko af80df
# based on the given tag and removes code not allowed in fedora/rhel. For
Alex Kashchenko af80df
# consistency, the source tarball will always contain 'openjdk' as the top
Alex Kashchenko af80df
# level folder, name is created, based on parameter
Alex Kashchenko af80df
#
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ ! "x$PR2126" = "x" ] ; then
Alex Kashchenko af80df
  if [ ! -f "$PR2126" ] ; then
Alex Kashchenko af80df
    echo "You have specified PR2126 as $PR2126 but it does not exists. exiting"
Alex Kashchenko af80df
    exit 1
Alex Kashchenko af80df
  fi
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
Alex Kashchenko af80df
set -e
Alex Kashchenko af80df
Alex Kashchenko af80df
OPENJDK_URL_DEFAULT=http://hg.openjdk.java.net
Alex Kashchenko af80df
COMPRESSION_DEFAULT=xz
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ "x$1" = "xhelp" ] ; then
Alex Kashchenko af80df
    echo -e "Behaviour may be specified by setting the following variables:\n"
Alex Kashchenko af80df
    echo "VERSION - the version of the specified OpenJDK project"
Alex Kashchenko af80df
    echo "PROJECT_NAME -- the name of the OpenJDK project being archived (optional; only needed by defaults)"
Alex Kashchenko af80df
    echo "REPO_NAME - the name of the OpenJDK repository (optional; only needed by defaults)"
Alex Kashchenko af80df
    echo "OPENJDK_URL - the URL to retrieve code from (optional; defaults to ${OPENJDK_URL_DEFAULT})"
Alex Kashchenko af80df
    echo "COMPRESSION - the compression type to use (optional; defaults to ${COMPRESSION_DEFAULT})"
Alex Kashchenko af80df
    echo "FILE_NAME_ROOT - name of the archive, minus extensions (optional; defaults to PROJECT_NAME-REPO_NAME-VERSION)"
Alex Kashchenko af80df
    echo "REPO_ROOT - the location of the Mercurial repository to archive (optional; defaults to OPENJDK_URL/PROJECT_NAME/REPO_NAME)"
Alex Kashchenko af80df
    echo "TO_COMPRESS - what part of clone to pack (default is openjdk)"
Alex Kashchenko af80df
    echo "PR2126 - the path to the PR2126 patch to apply (optional; downloaded if unavailable)"
Alex Kashchenko af80df
    exit 1;
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ "x$VERSION" = "x" ] ; then
Alex Kashchenko af80df
    echo "No VERSION specified"
Alex Kashchenko af80df
    exit -2
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
echo "Version: ${VERSION}"
Alex Kashchenko af80df
    
Alex Kashchenko af80df
# REPO_NAME is only needed when we default on REPO_ROOT and FILE_NAME_ROOT
Alex Kashchenko af80df
if [ "x$FILE_NAME_ROOT" = "x" -o "x$REPO_ROOT" = "x" ] ; then
Alex Kashchenko af80df
  if [ "x$PROJECT_NAME" = "x" ] ; then
Alex Kashchenko af80df
    echo "No PROJECT_NAME specified"
Alex Kashchenko af80df
    exit -1
Alex Kashchenko af80df
  fi
Alex Kashchenko af80df
  echo "Project name: ${PROJECT_NAME}"
Alex Kashchenko af80df
  if [ "x$REPO_NAME" = "x" ] ; then
Alex Kashchenko af80df
    echo "No REPO_NAME specified"
Alex Kashchenko af80df
    exit -3
Alex Kashchenko af80df
  fi
Alex Kashchenko af80df
  echo "Repository name: ${REPO_NAME}"
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ "x$OPENJDK_URL" = "x" ] ; then
Alex Kashchenko af80df
    OPENJDK_URL=${OPENJDK_URL_DEFAULT}
Alex Kashchenko af80df
    echo "No OpenJDK URL specified; defaulting to ${OPENJDK_URL}"
Alex Kashchenko af80df
else
Alex Kashchenko af80df
    echo "OpenJDK URL: ${OPENJDK_URL}"
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ "x$COMPRESSION" = "x" ] ; then
Alex Kashchenko af80df
    # rhel 5 needs tar.gz
Alex Kashchenko af80df
    COMPRESSION=${COMPRESSION_DEFAULT}
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
echo "Creating a tar.${COMPRESSION} archive"
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ "x$FILE_NAME_ROOT" = "x" ] ; then
Alex Kashchenko af80df
    FILE_NAME_ROOT=${PROJECT_NAME}-${REPO_NAME}-${VERSION}
Alex Kashchenko af80df
    echo "No file name root specified; default to ${FILE_NAME_ROOT}"
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
if [ "x$REPO_ROOT" = "x" ] ; then
Alex Kashchenko af80df
    REPO_ROOT="${OPENJDK_URL}/${PROJECT_NAME}/${REPO_NAME}"
Alex Kashchenko af80df
    echo "No repository root specified; default to ${REPO_ROOT}"
Alex Kashchenko af80df
fi;
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ "x$TO_COMPRESS" = "x" ] ; then
Alex Kashchenko af80df
    TO_COMPRESS="openjdk"
Alex Kashchenko af80df
    echo "No to be compressed targets specified, ; default to ${TO_COMPRESS}"
Alex Kashchenko af80df
fi;
Alex Kashchenko af80df
Alex Kashchenko af80df
if [ -d ${FILE_NAME_ROOT} ] ; then
Alex Kashchenko af80df
  echo "exists exists exists exists exists exists exists "
Alex Kashchenko af80df
  echo "reusing reusing reusing reusing reusing reusing "
Alex Kashchenko af80df
  echo ${FILE_NAME_ROOT}
Alex Kashchenko af80df
else
Alex Kashchenko af80df
  mkdir "${FILE_NAME_ROOT}"
Alex Kashchenko af80df
  pushd "${FILE_NAME_ROOT}"
Alex Kashchenko af80df
    echo "Cloning ${VERSION} root repository from ${REPO_ROOT}"
Alex Kashchenko af80df
    hg clone ${REPO_ROOT} openjdk -r ${VERSION}
Alex Kashchenko af80df
  popd
Alex Kashchenko af80df
fi
Alex Kashchenko af80df
pushd "${FILE_NAME_ROOT}"
Alex Kashchenko af80df
    if [ -d openjdk/src ]; then 
Alex Kashchenko af80df
        pushd openjdk
Alex Kashchenko af80df
            echo "Removing EC source code we don't build"
Alex Kashchenko af80df
            CRYPTO_PATH=src/jdk.crypto.ec/share/native/libsunec/impl
Alex Kashchenko af80df
            rm -vrf $CRYPTO_PATH
Alex Kashchenko af80df
            echo "Syncing EC list with NSS"
Alex Kashchenko af80df
            if [ "x$PR2126" = "x" ] ; then
Alex Kashchenko af80df
                # orriginally for 8:
Alex Kashchenko af80df
                # get pr2126.patch (from http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=8d2c9a898f50) from most correct tag
Alex Kashchenko af80df
                # Do not push it or publish it (see http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2126)
Alex Kashchenko af80df
                # there is currnetly no "upstram version of this patch, hardcoding custom version
Alex Kashchenko af80df
                PR2126="../../pr2126-11.patch"
Alex Kashchenko af80df
            fi;
Alex Kashchenko af80df
            echo "Applying ${PR2126}"
Alex Kashchenko af80df
            patch -Np1 < $PR2126
Alex Kashchenko af80df
            find . -name '*.orig' -exec rm -vf '{}' ';'
Alex Kashchenko af80df
        popd
Alex Kashchenko af80df
    fi
Alex Kashchenko af80df
Alex Kashchenko af80df
    echo "Compressing remaining forest"
Alex Kashchenko af80df
    if [ "X$COMPRESSION" = "Xxz" ] ; then
Alex Kashchenko af80df
        SWITCH=cJf
Alex Kashchenko af80df
    else
Alex Kashchenko af80df
        SWITCH=czf
Alex Kashchenko af80df
    fi
Alex Kashchenko af80df
    tar --exclude-vcs -$SWITCH ${FILE_NAME_ROOT}.tar.${COMPRESSION} $TO_COMPRESS
Alex Kashchenko af80df
    mv ${FILE_NAME_ROOT}.tar.${COMPRESSION}  ..
Alex Kashchenko af80df
popd
Alex Kashchenko af80df
echo "Done. You may want to remove the uncompressed version - $FILE_NAME_ROOT."
Alex Kashchenko af80df
Alex Kashchenko af80df