88 lines
2.2 KiB
Plaintext
88 lines
2.2 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# Create suse-xsl-stylesheet source tarball from SVN
|
||
|
#
|
||
|
# Copyright (C) 2011,2012 Frank Sundermeyer <fsundermeyer@opensuse.org>
|
||
|
#
|
||
|
# Author:
|
||
|
# Frank Sundermeyer <fsundermeyer@opensuse.org>
|
||
|
|
||
|
#set -x
|
||
|
|
||
|
NAME=suse-xsl-stylesheets
|
||
|
VERSION=
|
||
|
SPECFILE=${NAME}.spec
|
||
|
SRC_DIR=suse-xslt
|
||
|
NOVDOC_DIR=schema
|
||
|
SVNPATH=https://svn.code.sf.net/p/daps/svn/trunk/daps
|
||
|
TMPDIR=$(mktemp -q -d --tmpdir susexsl_XXXXXXXX)
|
||
|
EXCLUDES=${TMPDIR}/${NAME}/${SRC_DIR}/packaging/exclude-files_for_susexsl_package.txt
|
||
|
|
||
|
#----------
|
||
|
# Functions
|
||
|
#----------
|
||
|
|
||
|
# exit on error
|
||
|
#
|
||
|
function exit_on_error {
|
||
|
echo -e "$1"
|
||
|
#rm -rf $TMPDIR
|
||
|
exit 1
|
||
|
}
|
||
|
#-----
|
||
|
# MAIN
|
||
|
#-----
|
||
|
#
|
||
|
# This script needs to be called from the suse-xsl-stylesheet osc checkout
|
||
|
# directory, so lets check whethter we are in the correct directory
|
||
|
#
|
||
|
if [[ ! -s ${NAME}.spec && ! -d .osc ]]; then
|
||
|
echo "Looks like you are not in the ${NAME} checkout directory."
|
||
|
read -p "Continue anyway (y/n) [n]: " CONT
|
||
|
if [[ n = $CONT || N = $CONT ]]; then
|
||
|
exit_on_error "Aborted by user."
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
#
|
||
|
# Export daps from SVN
|
||
|
#
|
||
|
svn export $SVNPATH ${TMPDIR}/${NAME} || exit_on_error "SVN export failed"
|
||
|
|
||
|
#
|
||
|
# Get the version number
|
||
|
#
|
||
|
VERSION=$(egrep "^Version:\s*" ${TMPDIR}/${NAME}/${SRC_DIR}/packaging/$SPECFILE | sed 's/^Version:\s*//')
|
||
|
|
||
|
if [[ -z $VERSION ]]; then
|
||
|
exit_on_error "Couldn't get version number from spec-file."
|
||
|
fi
|
||
|
|
||
|
#
|
||
|
# Create the tarball
|
||
|
#
|
||
|
export BZIP2=--best
|
||
|
tar cvhf ${NAME}-${VERSION}.tar -C ${TMPDIR}/${NAME} \
|
||
|
--exclude-from=$EXCLUDES --transform=s:suse-xslt:suse-xsl-stylesheets: \
|
||
|
${SRC_DIR} || exit_on_error "Failed to create the tarball."
|
||
|
tar rvhf ${NAME}-${VERSION}.tar -C ${TMPDIR}/${NAME} \
|
||
|
--transform=s:${NOVDOC_DIR}:suse-xsl-stylesheets/${NOVDOC_DIR}: \
|
||
|
$NOVDOC_DIR || exit_on_error "Failed to add $NOVDOC_DIR to the tarball."
|
||
|
bzip2 -9f ${NAME}-${VERSION}.tar
|
||
|
echo "Successfully created ${NAME}-${VERSION}.tar.bz2"
|
||
|
|
||
|
#
|
||
|
# Copy the spec file if necessary
|
||
|
#
|
||
|
diff -q $SPECFILE ${TMPDIR}/${NAME}/${SRC_DIR}/packaging/$SPECFILE >/dev/null
|
||
|
if [[ 0 = $? ]]; then
|
||
|
echo "spec file is up-to-date"
|
||
|
else
|
||
|
cp ${TMPDIR}/${NAME}/${SRC_DIR}/packaging/$SPECFILE . || exit_on_error "Failed to copy the specfile."
|
||
|
echo "Successfully updated the spec file."
|
||
|
fi
|
||
|
|
||
|
rm -rf ${TMPDIR}
|
||
|
|
||
|
exit 0
|