993373a
#!/bin/bash
f05b6fe
# Generates the 'source tarball' for JDK 8 projects.
f05b6fe
#
5ddc162
# Example:
acfc6fd
# When used from local repo set REPO_ROOT pointing to file:// with your repo
4118dbf
# If your local repo follows upstream forests conventions, it may be enough to set OPENJDK_URL
4118dbf
# If you want to use a local copy of patch PR3667, set the path to it in the PR3667 variable
f05b6fe
#
5ddc162
# In any case you have to set PROJECT_NAME REPO_NAME and VERSION. eg:
5ddc162
# PROJECT_NAME=jdk8u   OR   aarch64-port 
5ddc162
# REPO_NAME=jdk8u60    OR   jdk8u60 
5ddc162
# VERSION=jdk8u60-b27  OR aarch64-jdk8u65-b17 OR for head, keyword 'tip' should do the job there
5ddc162
# 
5ddc162
# They are used to create correct name and are used in construction of sources url (unless REPO_ROOT is set)
a875ea4
f05b6fe
# This script creates a single source tarball out of the repository
5ddc162
# based on the given tag and removes code not allowed in fedora/rhel. For
deb3d7b
# consistency, the source tarball will always contain 'openjdk' as the top
5ddc162
# level folder, name is created, based on parameter
5ddc162
#
f05b6fe
4118dbf
if [ ! "x$PR3667" = "x" ] ; then
4118dbf
  if [ ! -f "$PR3667" ] ; then
4118dbf
    echo "You have specified PR3667 as $PR3667 but it does not exists. exiting"
2ef1e20
    exit 1
2ef1e20
  fi
2ef1e20
fi
Jiri Vanek e19dada
set -e
Jiri Vanek e19dada
993373a
OPENJDK_URL_DEFAULT=http://hg.openjdk.java.net
993373a
COMPRESSION_DEFAULT=xz
2226621
# jdk is last for its size
2226621
REPOS_DEFAULT="hotspot corba jaxws jaxp langtools nashorn jdk"
993373a
993373a
if [ "x$1" = "xhelp" ] ; then
993373a
    echo -e "Behaviour may be specified by setting the following variables:\n"
993373a
    echo "VERSION - the version of the specified OpenJDK project"
993373a
    echo "PROJECT_NAME -- the name of the OpenJDK project being archived (optional; only needed by defaults)"
993373a
    echo "REPO_NAME - the name of the OpenJDK repository (optional; only needed by defaults)"
acfc6fd
    echo "OPENJDK_URL - the URL to retrieve code from (optional; defaults to ${OPENJDK_URL_DEFAULT})"
993373a
    echo "COMPRESSION - the compression type to use (optional; defaults to ${COMPRESSION_DEFAULT})"
993373a
    echo "FILE_NAME_ROOT - name of the archive, minus extensions (optional; defaults to PROJECT_NAME-REPO_NAME-VERSION)"
993373a
    echo "REPO_ROOT - the location of the Mercurial repository to archive (optional; defaults to OPENJDK_URL/PROJECT_NAME/REPO_NAME)"
4118dbf
    echo "PR3667 - the path to the PR3667 patch to apply (optional; downloaded if unavailable)"
2226621
    echo "REPOS - specify the repositories to use (optional; defaults to ${REPOS_DEFAULT})"
993373a
    exit 1;
f05b6fe
fi
993373a
993373a
5ddc162
if [ "x$VERSION" = "x" ] ; then
993373a
    echo "No VERSION specified"
993373a
    exit -2
5ddc162
fi
993373a
echo "Version: ${VERSION}"
993373a
    
993373a
# REPO_NAME is only needed when we default on REPO_ROOT and FILE_NAME_ROOT
993373a
if [ "x$FILE_NAME_ROOT" = "x" -o "x$REPO_ROOT" = "x" ] ; then
993373a
    if [ "x$PROJECT_NAME" = "x" ] ; then
993373a
	echo "No PROJECT_NAME specified"
993373a
	exit -1
993373a
    fi
993373a
    echo "Project name: ${PROJECT_NAME}"
993373a
    if [ "x$REPO_NAME" = "x" ] ; then
993373a
	echo "No REPO_NAME specified"
993373a
	exit -3
993373a
    fi
993373a
    echo "Repository name: ${REPO_NAME}"
993373a
fi
993373a
5ddc162
if [ "x$OPENJDK_URL" = "x" ] ; then
993373a
    OPENJDK_URL=${OPENJDK_URL_DEFAULT}
993373a
    echo "No OpenJDK URL specified; defaulting to ${OPENJDK_URL}"
993373a
else
993373a
    echo "OpenJDK URL: ${OPENJDK_URL}"
ff9254e
fi
ff9254e
5ddc162
if [ "x$COMPRESSION" = "x" ] ; then
5ddc162
# rhel 5 needs tar.gz
993373a
    COMPRESSION=${COMPRESSION_DEFAULT}
5ddc162
fi
993373a
echo "Creating a tar.${COMPRESSION} archive"
993373a
5ddc162
if [ "x$FILE_NAME_ROOT" = "x" ] ; then
5ddc162
    FILE_NAME_ROOT=${PROJECT_NAME}-${REPO_NAME}-${VERSION}
993373a
    echo "No file name root specified; default to ${FILE_NAME_ROOT}"
5ddc162
fi
5ddc162
if [ "x$REPO_ROOT" = "x" ] ; then
5ddc162
    REPO_ROOT="${OPENJDK_URL}/${PROJECT_NAME}/${REPO_NAME}"
993373a
    echo "No repository root specified; default to ${REPO_ROOT}"
5ddc162
fi;
f05b6fe
5ddc162
mkdir "${FILE_NAME_ROOT}"
5ddc162
pushd "${FILE_NAME_ROOT}"
f05b6fe
993373a
echo "Cloning ${VERSION} root repository from ${REPO_ROOT}"
5ddc162
hg clone ${REPO_ROOT} openjdk -r ${VERSION}
deb3d7b
pushd openjdk
5ddc162
	
58c4028
58c4028
if [ "x$REPOS" = "x" ] ; then
2226621
    repos=${REPOS_DEFAULT}
2226621
    echo "No repositories specified; defaulting to ${repos}"
58c4028
else
2226621
    repos=$REPOS
2226621
    echo "Repositories: ${repos}"
58c4028
fi;
26b1c68
26b1c68
for subrepo in $repos
Jiri Vanek e19dada
do
993373a
    echo "Cloning ${VERSION} ${subrepo} repository from ${REPO_ROOT}"
5ddc162
    hg clone ${REPO_ROOT}/${subrepo} -r ${VERSION}
Jiri Vanek work 2acb4a2
done
f05b6fe
58c4028
if [ -d jdk ]; then 
deb3d7b
echo "Removing EC source code we don't build"
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ec2.h
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ec2_163.c
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ec2_193.c
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ec2_233.c
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ec2_aff.c
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ec2_mont.c
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ecp_192.c
4118dbf
rm -vf jdk/src/share/native/sun/security/ec/impl/ecp_224.c
deb3d7b
deb3d7b
echo "Syncing EC list with NSS"
4118dbf
4118dbf
if [ "x$PR3667" = "x" ] ; then
4118dbf
# get pr3667.patch (from http://icedtea.classpath.org/hg/icedtea8) from most correct tag
4118dbf
# Do not push it or publish it (see http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=3667)
4118dbf
    wget http://icedtea.classpath.org/hg/icedtea8/raw-file/tip/patches/pr3667.patch
4118dbf
    patch -Np1 < pr3667.patch
4118dbf
    rm pr3667.patch
5ddc162
else
4118dbf
    echo "Applying ${PR3667}"
4118dbf
    patch -Np1 < $PR3667
5ddc162
fi;
58c4028
fi
0fb9d78
find . -name '*.orig' -exec rm -vf '{}' ';'
deb3d7b
f05b6fe
popd
acfc6fd
echo "Compressing remaining forest"
5ddc162
if [ "X$COMPRESSION" = "Xxz" ] ; then
5ddc162
    tar --exclude-vcs -cJf ${FILE_NAME_ROOT}.tar.${COMPRESSION} openjdk
5ddc162
else
5ddc162
    tar --exclude-vcs -czf ${FILE_NAME_ROOT}.tar.${COMPRESSION} openjdk
5ddc162
fi
f05b6fe
5ddc162
mv ${FILE_NAME_ROOT}.tar.${COMPRESSION}  ..
f05b6fe
popd
acfc6fd
echo "Done. You may want to remove the uncompressed version."
f05b6fe
5ddc162