ff16d76
#!/bin/bash
ff16d76
ff16d76
# Copyright (C) 2019 Red Hat, Inc.
ff16d76
# Written by Andrew John Hughes <gnu.andrew@redhat.com>.
ff16d76
#
ff16d76
# This program is free software: you can redistribute it and/or modify
ff16d76
# it under the terms of the GNU Affero General Public License as
ff16d76
# published by the Free Software Foundation, either version 3 of the
ff16d76
# License, or (at your option) any later version.
ff16d76
#
ff16d76
# This program is distributed in the hope that it will be useful,
ff16d76
# but WITHOUT ANY WARRANTY; without even the implied warranty of
ff16d76
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ff16d76
# GNU Affero General Public License for more details.
ff16d76
#
ff16d76
# You should have received a copy of the GNU Affero General Public License
ff16d76
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
ff16d76
Andrew John Hughes e70d9ec
ICEDTEA_USE_VCS=true
Andrew John Hughes e70d9ec
ff16d76
ICEDTEA_VERSION=3.15.0
ff16d76
ICEDTEA_URL=https://icedtea.classpath.org/download/source
ff16d76
ICEDTEA_SIGNING_KEY=CFDA0F9B35964222
ff16d76
Andrew John Hughes e70d9ec
ICEDTEA_HG_URL=https://icedtea.classpath.org/hg/icedtea11
Andrew John Hughes 68acf88
ff16d76
set -e
ff16d76
Andrew John Hughes e70d9ec
RPM_DIR=${PWD}
Andrew John Hughes e70d9ec
if [ ! -f ${RPM_DIR}/jconsole.desktop.in ] ; then
Andrew John Hughes e70d9ec
    echo "Not in RPM source tree.";
Andrew John Hughes e70d9ec
    exit 1;
Andrew John Hughes e70d9ec
fi
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
if test "x${TMPDIR}" = "x"; then
Andrew John Hughes e70d9ec
    TMPDIR=/tmp;
Andrew John Hughes e70d9ec
fi
Andrew John Hughes e70d9ec
WORKDIR=${TMPDIR}/it.sync
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
echo "Using working directory ${WORKDIR}"
Andrew John Hughes e70d9ec
mkdir ${WORKDIR}
Andrew John Hughes e70d9ec
pushd ${WORKDIR}
Andrew John Hughes e70d9ec
ff16d76
if test "x${WGET}" = "x"; then
ff16d76
    WGET=$(which wget);
ff16d76
    if test "x${WGET}" = "x"; then
ff16d76
	echo "wget not found";
ff16d76
	exit 1;
ff16d76
    fi
ff16d76
fi
ff16d76
ff16d76
if test "x${TAR}" = "x"; then
ff16d76
    TAR=$(which tar)
ff16d76
    if test "x${TAR}" = "x"; then
ff16d76
	echo "tar not found";
Andrew John Hughes e70d9ec
	exit 2;
ff16d76
    fi
ff16d76
fi
ff16d76
ff16d76
echo "Dependencies:";
ff16d76
echo -e "\tWGET: ${WGET}";
ff16d76
echo -e "\tTAR: ${TAR}\n";
ff16d76
Andrew John Hughes e70d9ec
if test "x${ICEDTEA_USE_VCS}" = "xtrue"; then
Andrew John Hughes e70d9ec
    echo "Mode: Using VCS";
ff16d76
Andrew John Hughes e70d9ec
    if test "x${GREP}" = "x"; then
Andrew John Hughes e70d9ec
	GREP=$(which grep);
Andrew John Hughes e70d9ec
	if test "x${GREP}" = "x"; then
Andrew John Hughes e70d9ec
	    echo "grep not found";
Andrew John Hughes e70d9ec
	    exit 3;
Andrew John Hughes e70d9ec
	fi
Andrew John Hughes e70d9ec
    fi
ff16d76
Andrew John Hughes e70d9ec
    if test "x${CUT}" = "x"; then
Andrew John Hughes e70d9ec
	CUT=$(which cut);
Andrew John Hughes e70d9ec
	if test "x${CUT}" = "x"; then
Andrew John Hughes e70d9ec
	    echo "cut not found";
Andrew John Hughes e70d9ec
	    exit 4;
Andrew John Hughes e70d9ec
	fi
Andrew John Hughes e70d9ec
    fi
ff16d76
Andrew John Hughes e70d9ec
    if test "x${TR}" = "x"; then
Andrew John Hughes e70d9ec
	TR=$(which tr);
Andrew John Hughes e70d9ec
	if test "x${TR}" = "x"; then
Andrew John Hughes e70d9ec
	    echo "tr not found";
Andrew John Hughes e70d9ec
	    exit 5;
Andrew John Hughes e70d9ec
	fi
Andrew John Hughes e70d9ec
    fi
ff16d76
Andrew John Hughes e70d9ec
    if test "x${HG}" = "x"; then
Andrew John Hughes e70d9ec
	HG=$(which hg);
Andrew John Hughes e70d9ec
	if test "x${HG}" = "x"; then
Andrew John Hughes e70d9ec
	    echo "hg not found";
Andrew John Hughes e70d9ec
	    exit 6;
Andrew John Hughes e70d9ec
	fi
Andrew John Hughes e70d9ec
    fi
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Dependencies:";
Andrew John Hughes e70d9ec
    echo -e "\tGREP: ${GREP}";
Andrew John Hughes e70d9ec
    echo -e "\tCUT: ${CUT}";
Andrew John Hughes e70d9ec
    echo -e "\tTR: ${TR}";
Andrew John Hughes e70d9ec
    echo -e "\tHG: ${HG}";
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Checking out repository from VCS...";
Andrew John Hughes e70d9ec
    ${HG} clone ${ICEDTEA_HG_URL} icedtea
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Obtaining version from configure.ac...";
Andrew John Hughes e70d9ec
    ROOT_VER=$(${GREP} '^AC_INIT' icedtea/configure.ac|${CUT} -d ',' -f 2|${TR} -d '[][:space:]')
Andrew John Hughes e70d9ec
    echo "Root version from configure: ${ROOT_VER}";
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    VCS_REV=$(${HG} log -R icedtea --template '{node|short}' -r tip)
Andrew John Hughes e70d9ec
    echo "VCS revision: ${VCS_REV}";
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    ICEDTEA_VERSION="${ROOT_VER}-${VCS_REV}"
Andrew John Hughes e70d9ec
    echo "Creating icedtea-${ICEDTEA_VERSION}";
Andrew John Hughes e70d9ec
    mkdir icedtea-${ICEDTEA_VERSION}
Andrew John Hughes e70d9ec
    echo "Copying required files from checkout to icedtea-${ICEDTEA_VERSION}";
Andrew John Hughes e70d9ec
    # Commented out for now as IcedTea 6's jconsole.desktop.in is outdated
Andrew John Hughes e70d9ec
    #cp -a icedtea/jconsole.desktop.in ../icedtea-${ICEDTEA_VERSION}
Andrew John Hughes e70d9ec
    cp -a ${RPM_DIR}/jconsole.desktop.in icedtea-${ICEDTEA_VERSION}
Andrew John Hughes e70d9ec
    cp -a icedtea/tapset icedtea-${ICEDTEA_VERSION}
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    rm -rf icedtea
Andrew John Hughes e70d9ec
else
Andrew John Hughes e70d9ec
    echo "Mode: Using tarball";
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    if test "x${ICEDTEA_VERSION}" = "x"; then
Andrew John Hughes e70d9ec
	echo "No IcedTea version specified for tarball download.";
Andrew John Hughes e70d9ec
	exit 3;
Andrew John Hughes e70d9ec
    fi
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    if test "x${CHECKSUM}" = "x"; then
Andrew John Hughes e70d9ec
	CHECKSUM=$(which sha256sum)
Andrew John Hughes e70d9ec
	if test "x${CHECKSUM}" = "x"; then
Andrew John Hughes e70d9ec
	    echo "sha256sum not found";
Andrew John Hughes e70d9ec
	    exit 4;
Andrew John Hughes e70d9ec
	fi
Andrew John Hughes e70d9ec
    fi
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    if test "x${PGP}" = "x"; then
Andrew John Hughes e70d9ec
	PGP=$(which gpg)
Andrew John Hughes e70d9ec
	if test "x${PGP}" = "x"; then
Andrew John Hughes e70d9ec
	    echo "gpg not found";
Andrew John Hughes e70d9ec
	    exit 5;
Andrew John Hughes e70d9ec
	fi
Andrew John Hughes e70d9ec
    fi
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Dependencies:";
Andrew John Hughes e70d9ec
    echo -e "\tCHECKSUM: ${CHECKSUM}";
Andrew John Hughes e70d9ec
    echo -e "\tPGP: ${PGP}\n";
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Checking for IcedTea signing key ${ICEDTEA_SIGNING_KEY}...";
Andrew John Hughes e70d9ec
    if ! gpg --list-keys ${ICEDTEA_SIGNING_KEY}; then
Andrew John Hughes e70d9ec
	echo "IcedTea signing key ${ICEDTEA_SIGNING_KEY} not installed.";
Andrew John Hughes e70d9ec
	exit 6;
Andrew John Hughes e70d9ec
    fi
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Downloading IcedTea release tarball...";
Andrew John Hughes e70d9ec
    ${WGET} -v ${ICEDTEA_URL}/icedtea-${ICEDTEA_VERSION}.tar.xz
Andrew John Hughes e70d9ec
    echo "Downloading IcedTea tarball signature...";
Andrew John Hughes e70d9ec
    ${WGET} -v ${ICEDTEA_URL}/icedtea-${ICEDTEA_VERSION}.tar.xz.sig
Andrew John Hughes e70d9ec
    echo "Downloading IcedTea tarball checksums...";
Andrew John Hughes e70d9ec
    ${WGET} -v ${ICEDTEA_URL}/icedtea-${ICEDTEA_VERSION}.sha256
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Verifying checksums...";
Andrew John Hughes e70d9ec
    ${CHECKSUM} --check --ignore-missing icedtea-${ICEDTEA_VERSION}.sha256
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Checking signature...";
Andrew John Hughes e70d9ec
    ${PGP} --verify icedtea-${ICEDTEA_VERSION}.tar.xz.sig
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
    echo "Extracting files...";
Andrew John Hughes e70d9ec
    ${TAR} xJf icedtea-${ICEDTEA_VERSION}.tar.xz \
ff16d76
       icedtea-${ICEDTEA_VERSION}/tapset \
ff16d76
       icedtea-${ICEDTEA_VERSION}/jconsole.desktop.in
ff16d76
Andrew John Hughes e70d9ec
    rm -vf icedtea-${ICEDTEA_VERSION}.tar.xz
Andrew John Hughes e70d9ec
    rm -vf icedtea-${ICEDTEA_VERSION}.tar.xz.sig
Andrew John Hughes e70d9ec
    rm -vf icedtea-${ICEDTEA_VERSION}.sha256
Andrew John Hughes e70d9ec
fi
Andrew John Hughes e70d9ec
ff16d76
echo "Replacing desktop files...";
Andrew John Hughes e70d9ec
mv -v icedtea-${ICEDTEA_VERSION}/jconsole.desktop.in ${RPM_DIR}
ff16d76
ff16d76
echo "Creating new tapset tarball...";
ff16d76
mv -v icedtea-${ICEDTEA_VERSION} openjdk
Andrew John Hughes e70d9ec
${TAR} cJf ${RPM_DIR}/tapsets-icedtea-${ICEDTEA_VERSION}.tar.xz openjdk
ff16d76
ff16d76
rm -rvf openjdk
Andrew John Hughes e70d9ec
Andrew John Hughes e70d9ec
popd
Andrew John Hughes e70d9ec
rm -rf ${WORKDIR}