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