5ddc162
#!/bin/bash -x
5ddc162
# Generates the 'source tarball' for JDK 8 projects and update spec infrastructure
5ddc162
# By default, this script regenerate source as they are currently used. 
5ddc162
# so if the version of sources change, this file changes and is pushed
5ddc162
#
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
# If you don't, default are used and so already uploaded tarball regenerated
5ddc162
# They are used to create correct name and are used in construction of sources url (unless REPO_ROOT is set)
5ddc162
# 
5ddc162
# For other useful variables see generate_source_tarball.sh
5ddc162
#
5ddc162
# the used values are then substituted to spec and sources
5ddc162
2ef1e20
if [ ! "x$PR2126" = "x" ] ; then
2ef1e20
  if [ ! -f "$PR2126" ] ; then
2ef1e20
    echo "You have specified PR2126 as $PR2126 but it does not exists. exiting"
2ef1e20
    exit 1
2ef1e20
  fi
2ef1e20
fi
2ef1e20
5ddc162
set -e
5ddc162
5ddc162
if [ "x$PROJECT_NAME" = "x" ] ; then
5ddc162
    PROJECT_NAME="aarch64-port"
5ddc162
fi
5ddc162
if [ "x$REPO_NAME" = "x" ] ; then
c40ae54
    REPO_NAME="jdk8u-shenandoah"
5ddc162
fi
5ddc162
if [ "x$VERSION" = "x" ] ; then
c40ae54
    VERSION="aarch64-shenandoah-jdk8u181-b15"
5ddc162
fi
5ddc162
5ddc162
if [ "x$COMPRESSION" = "x" ] ; then
5ddc162
# rhel 5 needs tar.gz
5ddc162
    COMPRESSION=xz
5ddc162
fi
5ddc162
if [ "x$FILE_NAME_ROOT" = "x" ] ; then
5ddc162
    FILE_NAME_ROOT=${PROJECT_NAME}-${REPO_NAME}-${VERSION}
5ddc162
fi
5ddc162
if [ "x$PKG" = "x" ] ; then
5ddc162
    URL=`cat .git/config  | grep url`
5ddc162
    PKG=${URL##*/}
5ddc162
fi
5ddc162
if [ "x$SPEC" = "x" ] ; then
5ddc162
    SPEC=${PKG}.spec
5ddc162
fi
5ddc162
if [ "x$RELEASE" = "x" ] ; then
5ddc162
    RELEASE=1
5ddc162
fi
5ddc162
5ddc162
FILENAME=${FILE_NAME_ROOT}.tar.${COMPRESSION}
5ddc162
5ddc162
if [ ! -f ${FILENAME} ] ; then
5ddc162
echo "Generating ${FILENAME}"
5ddc162
. ./generate_source_tarball.sh
5ddc162
else 
5ddc162
echo "${FILENAME} already exists, using"
5ddc162
fi
5ddc162
5ddc162
5ddc162
echo "Touching spec: $SPEC"
c40ae54
echo sed -i "s/^%global\s\+project.*/%global project         ${PROJECT_NAME}/" $SPEC 
c40ae54
echo sed -i "s/^%global\s\+repo.*/%global repo            ${REPO_NAME}/" $SPEC 
c40ae54
echo sed -i "s/^%global\s\+revision.*/%global revision        ${VERSION}/" $SPEC 
5ddc162
# updated sources, resetting release
c40ae54
echo sed -i "s/^Release:.*/Release: $RELEASE.%{buildver}%{?dist}/" $SPEC
58c4028
5ddc162
echo "New sources"
5ddc162
cat sources
2ef1e20
a_sources=`cat sources | sed "s/.*(//g" | sed "s/).*//g" | sed "s/.*\s\+//g"`
5ddc162
echo "    you can get inspired by following %changelog template:"
5ddc162
user_name=`whoami`
5ddc162
user_record=$(getent passwd $user_name)
5ddc162
user_gecos_field=$(echo "$user_record" | cut -d ':' -f 5)
5ddc162
user_full_name=$(echo "$user_gecos_field" | cut -d ',' -f 1)
5ddc162
spec_date=`date +"%a %b %d %Y"`
5ddc162
# See spec:
58c4028
revision_helper=`echo ${MAIN_VERSION%-*}`
5ddc162
updatever=`echo ${revision_helper##*u}`
58c4028
buildver=`echo ${MAIN_VERSION##*-}`
07a5b28
echo "* $spec_date $user_full_name <$user_name@redhat.com> - 1:1.8.0.$updatever-$RELEASE.$buildver" 
58c4028
echo "- updated to $MAIN_VERSION (from $PROJECT_NAME/$MAIN_REPO_NAME)"
58c4028
echo "- updated to $VERSION (from $PROJECT_NAME/$REPO_NAME) of hotspot"
5ddc162
echo "- used $FILENAME as new sources"
58c4028
echo "- used $FILENAME_SH as new sources for hotspot"
5ddc162
5ddc162
echo "    execute:"
5ddc162
echo "fedpkg/rhpkg new-sources "$a_sources
5ddc162
echo "    to upload sources"
5ddc162
echo "you can verify by fedpkg/rhpkg prep --arch XXXX on all architectures: x86_64 i386 i586 i686 ppc ppc64 ppc64le s390 s390x aarch64 armv7hl"
5ddc162